更改 R Markdown PDF 中章节标题的大小

Change size of section titles in R Markdown PDF

有没有办法在 R Markdown 中更改标题文本的字体大小?

我知道如何给文章的章节编号;但是,就格式而言,编号为 1., 2., 3... 的部分的字体大小 太大 。作为一种变通方法,我一直在使用 lower-level headers ### Introduction,但它们的编号有误。

这是一个基本示例:

---
output: bookdown::pdf_document2
---

# This is too big

### This is the right size but are labelled as 1.0.1

你可以放置

\usepackage[medium]{titlesec} % or small

preamble.tex(或者你有特殊的 LaTeX 命令的地方)连同

subparagraph: yes

在 YAML headers 中(c.f。this question)。 要获得更详细的答案,我们将需要一个最小的工作示例。

一个解决方法是通过包含 css 文件来更改章节标题的字体大小。一个例子是:

h1 { font-size: 16px; }

h2 { font-size: 14px; }

h3 { font-size: 12px; }

h1{}中指定的字体大小将改变深度1的header(即# Section)的字体大小。 h2{}里面指定的字体大小会改变深度2的header的字体大小(即## Subsection)等等。