我知道这是一个老问题,但我还没有看到任何答案:本质上,如果您使用 markdown 和 pandoc 将文件转换为 pdf,请在页面顶部的 yaml 数据中,你可以包括这样的东西:
---
header-includes:
- \usepackage{pdfpages}
output: pdf_document
---
\includepdf{/path/to/pdf/document.pdf}
# Section
Blah blah
## Section
Blah blah
由于 pandoc 使用 Latex 转换您的所有文档,header-includes 部分调用 pdfpages 包。然后,当您包含 \includepdf{/path/to/pdf/document.pdf} 时,它将插入该文档中包含的任何内容。此外,您可以通过这种方式包含多个 pdf 文件。
作为一个有趣的奖励,这只是因为我经常使用降价,如果你想包含降价以外的文件,例如乳胶文件。我已经稍微修改了这个answer。假设你有一个markdown文件markdown1.md:
---
title: Something meaning full
author: Talking head
---
还有两个额外的乳胶文件 document1,看起来像这样:
\section{Section}
Profundity.
\subsection{Section}
Razor's edge.
另一个,document2.tex,看起来像这样:
\section{Section
Glah
\subsection{Section}
Balh Balh
假设您想将 document1.tex 和 document2.tex 包含到 markdown1.md 中,您只需对 markdown1.md 执行此操作
---
title: Something meaning full
author: Talking head
---
\input{/path/to/document1}
\input{/path/to/document2}
在它上面运行 pandoc,例如
在终端pandoc markdown1.md -o markdown1.pdf
您的最终文档将如下所示:
有意义的事情
会说话的头
部分
深度。
部分
剃刀的边缘。
部分
格拉赫
部分
呸呸呸