Pandoc LaTex PDF 标题和页脚

Pandoc LaTex PDF headed and footer

我正在使用 pandoc v 1.18 我想添加 header 以及页脚文本。

我想要完全控制意味着我想在左侧、中间和中间放置加热器文本,与页脚相同。

但我连一个地方都找不到。

我的 YAML 中有以下内容header 在我的降价文件中

---
header: This is fancy
footer: So is this
headertext: This is fancy
footertext: So is this
#abstract: This is a pandoc test . . .

documentclass: report
output:
  pdf_document:
    fontsize: 12pt
    mainfont: Roboto
    geometry: [top=2cm, bottom=1.5cm, left=1cm, right=1cm]
css : pandoc.css
linkcolor : cyan
toc : true
---

我也尝试过分别使用 headerheadertext,但效果不佳。

最简单的解决方案是添加自定义乳胶 header。在您的工作目录中创建 header.tex 并添加如下内容:

\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\rhead{Fancy on the right}
\lhead{Fancy on the left}
\cfoot{Fancy in the footer}

请参阅 fancyhdr manual 寻求帮助。

然后用pandoc myfile.md -o myfile.pdf -H header.tex编译。使用 Rmarkdown,可以在 YAML front matter 中设置:

---
output:
  pdf_document:
    includes:
      in-header: header.tex
---

为了能够像您希望的那样在 YAML 中使用变量设置 header,您将需要使用 rmarkdown latex template (see the pandoc manual section about templates) 但您可能会失去 fine-tune header 和页脚 fancyhdr