我正在 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
这样做,标题页的边距将与图书的所有其他页面不同。
标题页
其他页面
请注意我使用了几何包的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/