在PDF输出中增加节号 [英] Increment section numbers in PDF output

查看:127
本文介绍了在PDF输出中增加节号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将rMarkdown(PDF输出)文件中的节标题增加1.而不是# First导致1 First,我想要2 First.

I'm trying to increment the section headers in my rMarkdown (PDF output) file by 1. Instead of # First resulting in 1 First, I'd like 2 First.

我找到了一种使用以下语法在html_output中定义偏移量的方法,但不适用于pdf_output.

I found a way to define the offset in html_output using the following syntax, but it doesn't work for 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文档:

However, this syntax does not work for PDF documents:

---
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文档.

According to PANDOC documentation, number-offset only exists for HTML documents.

-number-offset = NUM​​BER [,NUMBER,...] HTML输出中节标题的偏移(在其他输出格式中忽略).第一个数字被添加到 顶级标题的节号,第二个标题的节号 标头,等等.因此,例如,如果您想要第一个顶级 文档中标有"6"的标题,请指定--number-offset = 5. 如果您的文档以您想成为的2级标题开头 编号"1.5",请指定--number-offset = 1,4.默认情况下,偏移量为0. 表示--number-sections.

--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文档中的节标题?

How can I increment section headers in PDF documents?

谢谢!

推荐答案

默认情况下, pandoc通过首先生成LaTeX文件来进行PDF生成.

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

要告诉LaTeX以不同的数字开头,您可以在markdown文档中包含原始TeX,例如:

To tell LaTeX to start with a different number, you can include raw TeX in your markdown document, like:

\setcounter{section}{2}

# my title

这篇关于在PDF输出中增加节号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆