在 r 中自定义 rticles::elsevier_article 文档 class 的输出

Customizing the output of rticles::elsevier_article document class in r

我试图在 elsevier_article 中设置边距,但收效甚微。 This post 建议使用几何图形设置边距,但我收到以下错误:

! LaTeX Error: Option clash for package geometry.

我还尝试在序言中添加以下乳胶命令,但 none 确实更改了输出 PDF 中的边距:

header-includes:
  - \PassOptionsToPackage{left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}{geometry}
header-includes:
  - \PassOptionsToPackage{margin=2.5cm}{geometry}

我需要在页面的两边留出 2.5 厘米。下面是可以使用的东西。它只是可以从 Rstudio 访问的默认模板(我删除了一些不需要的东西):

---
title: Short Paper
author:
  - name: Alice Anonymous
    email: alice@example.com
    affiliation: Some Institute of Technology
    correspondingauthor: true
    footnote: 1
  - name: Bob Security
    email: bob@example.com
    affiliation: Another University
  - name: Cat Memes
    email: cat@example.com
    affiliation: Another University
    footnote: 2
  - name: Derek Zoolander
    email: derek@example.com
    affiliation: Some Institute of Technology
    footnote: 2
address:
  - code: Some Institute of Technology
    address: Department, Street, City, State, Zip
  - code: Another University
    address: Department, Street, City, State, Zip
footnote:
  - code: 1
    text: "This is the first author footnote."
  - code: 2
    text: "Another author footnote."
abstract: |
  This is the abstract.

  It consists of two paragraphs.
keywords: 
  - keyword1
  - keyword2
journal: "An awesome journal"
date: "`r Sys.Date()`"
classoption: preprint, 3p, authoryear
# bibliography: mybibfile.bib
linenumbers: false
numbersections: true
# Use a CSL with `citation_package = "default"`
# csl: https://www.zotero.org/styles/elsevier-harvard
# geometry: "left=3cm,right=3cm,top=2cm,bottom=2cm"
output: 
  rticles::elsevier_article:
    keep_tex: true
    citation_package: natbib
# geometry: margin=2.54cm
# header-includes:
#   - \PassOptionsToPackage{left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}{geometry}
#   - \PassOptionsToPackage{margin=2.5cm}{geometry}
---

Please make sure that your manuscript follows the guidelines in the 
Guide for Authors of the relevant journal. It is not necessary to 
typeset your manuscript in exactly the same way as an article, 
unless you are submitting to a camera-ready copy (CRC) journal.

For detailed instructions regarding the elsevier article class, see   <https://www.elsevier.com/authors/policies-and-guidelines/latex-instructions>

# References {-}

header-includes来不及使用\PassOptionsToPackage{...},这个宏需要在documentclass之前使用,这在rmarkdown中有点难做。

相反,您可以使用 \geometry{...} 在程序包加载后更改设置。

完整代码:

---
title: Short Paper
author:
  - name: Alice Anonymous
    email: alice@example.com
    affiliation: Some Institute of Technology
    correspondingauthor: true
    footnote: 1
  - name: Bob Security
    email: bob@example.com
    affiliation: Another University
  - name: Cat Memes
    email: cat@example.com
    affiliation: Another University
    footnote: 2
  - name: Derek Zoolander
    email: derek@example.com
    affiliation: Some Institute of Technology
    footnote: 2
address:
  - code: Some Institute of Technology
    address: Department, Street, City, State, Zip
  - code: Another University
    address: Department, Street, City, State, Zip
footnote:
  - code: 1
    text: "This is the first author footnote."
  - code: 2
    text: "Another author footnote."
abstract: |
  This is the abstract.

  It consists of two paragraphs.
keywords: 
  - keyword1
  - keyword2
journal: "An awesome journal"
date: "`r Sys.Date()`"
classoption: preprint, 3p, authoryear
# bibliography: mybibfile.bib
linenumbers: false
numbersections: true
# Use a CSL with `citation_package = "default"`
# csl: https://www.zotero.org/styles/elsevier-harvard
# geometry: "left=3cm,right=3cm,top=2cm,bottom=2cm"
output: 
  rticles::elsevier_article:
    keep_tex: true
    citation_package: natbib
# geometry: margin=2.54cm
header-includes:
  - \geometry{hmargin=2.5cm}
---

Please make sure that your manuscript follows the guidelines in the 
Guide for Authors of the relevant journal. It is not necessary to 
typeset your manuscript in exactly the same way as an article, 
unless you are submitting to a camera-ready copy (CRC) journal.

For detailed instructions regarding the elsevier article class, see   <https://www.elsevier.com/authors/policies-and-guidelines/latex-instructions>

# References {-}