和-V toc-title:"Custom text"

和-V toc-title:"Custom text"

我正在從 Markdown 文件創建 PDF,並希望自訂輸出。具體來說,我想更改生成的 PDF 中的目錄標題。

目前,它是“內容”:

目錄範例

我怎樣才能更改該標題?


我在 Arch Linux 5.1.2 上呼叫 Pandoc 2.7.2,如下所示:

pandoc --pdf-engine=xelatex --toc test.md -o doc.pdf

為了完整起見,這是test.md

# First Heading
Some text

# Second Heading
More text

# Third Heading
Even more text

答案1

-V toc-title:"Custom text"

查看 的模板/usr/share/pandoc/data/templates/default.latex,有這部分:

$if(toc)$
$if(toc-title)$
\renewcommand*\contentsname{$toc-title$}
$endif$

這表示我們可以toc-title向 Pandoc 傳遞一個參數:

pandoc --pdf-engine=xelatex --toc test.md -V toc-title:"Custom text" -o doc.pdf

事實上,目錄標題已經改變:

toc_with_custom_text

有關修改模板的更多信息,請參閱這個答案文件


若要將摘要標題從「摘要」變更為其他內容,您可以插入

header-includes:
  \renewcommand{\abstractname}{Different abstract title}

在文件的元資料區塊。這是描述的這裡

相關內容