latex - 如何在四开 pdf 书籍的标题页上使用不同的页边距?

标签 latex r-markdown rstudio quarto

我正在 RStudio 中使用 Quarto 创建 PDF 书籍。我使用几何包来指定其中的边距。特别是,我希望扉页上的页边距与其他页面不同。标题页边距应为

geometry:
      - top=25.4mm
      - left=25.4mm
      - right=25.4mm
      - bottom=25.4mm

但我希望所有其他页面上有不同的左边距。所有其他页面的边距应为

geometry:
      - top=25.4mm
      - left=38.1mm
      - right=25.4mm
      - bottom=25.4mm

我该怎么做?

最佳答案

使用template partials ,您可以为标题页指定不同的几何图形,并且在标题页之后,您可以恢复其他页面的几何图形。

为此,您需要创建一个 before-body.tex 文件作为部分 latex 模板,并在该文件内,按照建议指定标题页的新边距 here .

before-body.tex

$if(has-frontmatter)$
\frontmatter
$endif$

%------------------------------------------------
% Declaring new geometry for the title page only.
\newgeometry{margin=25.4mm}
%------------------------------------------------

$if(title)$
$if(beamer)$
\frame{\titlepage}
$else$
\maketitle
$endif$

%-----------------------------------------------
% Ending the declared geometry for the title page
% and restore the geometry for other pages
\restoregeometry
%-----------------------------------------------

$if(abstract)$
\begin{abstract}
$abstract$
\end{abstract}
$endif$
$endif$

然后要添加此模板,请使用 _quarto.yml 中的 template-partials 选项

_quarto.yml

project:
  type: book

book:
  title: "Different Margins for Title Page"
  author: "Shafee"
  date: "7/31/2022"
  chapters:
    - index.qmd
    - intro.qmd
    - summary.qmd
    - references.qmd

bibliography: references.bib

format:
  pdf:
    documentclass: scrreprt
    include-in-header: 
      text: \usepackage[showframe, top=25.4mm, left=38.1mm, right=25.4mm, bottom=25.4mm]{geometry}
    template-partials:
      - before-body.tex
    

这样做,标题页的边距将与图书的所有其他页面不同。


标题页

Title page

其他页面

Other page


请注意我使用了几何包的showframe选项只是为了显示边距发生了变化。当您完成边距测试后,请删除该选项。

include-in-header: 
      text: \usepackage[top=25.4mm, left=38.1mm, right=25.4mm, bottom=25.4mm]{geometry}

关于latex - 如何在四开 pdf 书籍的标题页上使用不同的页边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73182820/

相关文章:

r - 将 PDF 中未嵌入的字体替换为同系列其他字体的最佳方法是什么?

r - 是否有 R 脚本可以使用 Excel 电子表格中的内容编写 rmd 文件?

r - knit/Sweave 中使用 R 变量作为条件的 If-Else 语句(第 2 部分)

emacs - 在 emacs 窗口中居中文本

latex - 如何更改 latex 中逐项列出的项目之间的空间?

Rmarkdown - 嵌入句子中

r - 在Rmd文件中使用knit2pdf

html - GitHub网站在RStudio中发布“编织”生成的HTML文件

r - 行首的 "+"符号是什么意思?

java - 在 Mac 上为 Java 1.7 编译 rJava