gpt4 book ai didi

latex - 增加 PDF 输出中的节号

转载 作者:行者123 更新时间:2023-12-01 11:29:51 25 4
gpt4 key购买 nike

我正在尝试将 rMarkdown(PDF 输出)文件中的部分标题增加 1。而不是 # First导致 1 First , 我要 2 First.
我找到了一种使用以下语法在 html_output 中定义偏移量的方法,但它不适用于 pdf_output。

---
title: "Untitled"
author: "author"
date: "date"
output:
html_document:
toc: true
pandoc_args: [
"--number-sections",
"--number-offset=1"
]
---
# First Header
# First SubHeader

这导致
2   First Header
2.1 First Subheader

但是,此语法不适用于 PDF 文档:
---
title: "Untitled"
author: "author"
date: "date"
output:
pdf_document:
toc: true
pandoc_args: [
"--number-sections",
"--number-offset=1"
]
---

# First Header
## First Subheader

这导致
1   First Header
1.1 First Subheader

节标题不加 1。

根据 PANDOC 文档, number-offset只存在于 HTML 文档中。

--number-offset=NUMBER[,NUMBER,…] Offset for section headings in HTML output (ignored in other output formats). The first number is added to the section number for top-level headers, the second for second-level headers, and so on. So, for example, if you want the first top-level header in your document to be numbered “6”, specify --number-offset=5. If your document starts with a level-2 header which you want to be numbered “1.5”, specify --number-offset=1,4. Offsets are 0 by default. Implies --number-sections.



如何增加 PDF 文档中的部分标题?

谢谢!

最佳答案

默认情况下,pandoc does PDF generation首先生成一个 LaTeX 文件...

$ echo '# first' | pandoc -t latex
\section{first}\label{first}

要告诉 LaTeX 以不同的数字开头,您可以在 Markdown 文档中包含原始 TeX,例如:
\setcounter{section}{2}

# my title

关于latex - 增加 PDF 输出中的节号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33395773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com