我使用以下pandoc
命令从 mardown 文件编译 PDF:
pandoc infile.md metadata.yaml -o outfile.pdf
我的yaml
文件包含以下内容:
---
documentclass: extarticle
fontsize: 11pt
header-includes:
- \usepackage{fancyhdr}
- \usepackage{graphicx}
- \usepackage{hyperref}
- \pagestyle{fancy}
- \fancyfoot[CO,CE]{\href{https://creativecommons.org/licenses/by-nc-nd/4.0/deed.de}{\includegraphics[scale=0.7]{CC.png}}}
- \fancyfoot[LE,RO]{\thepage}
output: pdf_document
---
如何将 PDF 元数据添加到 PDF 文件?
我找到了tex
解决方案这里:
\usepackage[pdftex,
pdfauthor={Your Name},
pdftitle={The Title},
pdfsubject={The Subject},
pdfkeywords={Some Keywords},
pdfproducer={Latex with hyperref, or other system},
pdfcreator={pdflatex, or other tool}]{hyperref}
但无论我将其添加到我的yaml
文件中,我都会收到错误:
[WARNING] Could not parse YAML metadata at line 59 column 1: :4:0: Unexpected '\'
Error producing PDF.
! Undefined control sequence.
l.60 \includegraphics
答案1
将其添加到yaml
文件中几乎可以完美地工作:
---
title-meta:
- 'META Title'
author-meta:
- 'The Author'
date-meta:
- '1. Juni, 2020'
keywords:
- 'keyword1;keyword2;keyword3'
---
只是subject:
不起作用。
答案2
Pandoc (+ TeX) 解决方案
该包hyperref
默认加载在 Pandoc ( v 2.9.2.1
) LaTeX 模板中。您的代码再次调用它。相反,您应该设置它。MWE:
---
documentclass: extarticle
fontsize: 11pt
header-includes: |
\hypersetup{pdftex,
pdfauthor={Your Name},
pdftitle={The Title},
pdfsubject={The Subject},
pdfkeywords={Some Keywords},
pdfproducer={Latex with hyperref, or other system},
pdfcreator={pdflatex, or other tool}}
---
# Introduction
...
纯 Pandoc 解决方案
您使用的是最新的 Pandoc 吗?以下 MWE 运行良好:
---
documentclass: extarticle
fontsize: 11pt
title-meta: 'META Title'
author-meta: 'The Author'
date-meta: '1. Juni, 2020'
keywords:
- 'keyword1'
- 'keyword2'
- 'keyword3'
subject: My Favorite Subject
---
# Introduction
...