将 yaml 元数据(标头包含)与 Pandoc 相结合
如果我有这些文件:
text.md:
---
header-includes:
- \usepackage{pgf-pie}
---
\begin{tikzpicture}
\pie{50/, 50/}
\end{tikzpicture}
settings.yaml:
variables:
header-includes:
- \pagecolor{black}
并且我使用 pandoc 使用以下命令编译它们:
pandoc text.md -d settings -o text.pdf
...默认文件中的 header-includes
值 settings.yaml< /code> 会覆盖
text.md
中的元数据块,从而导致编译失败。
有没有办法让 pandoc 组合两个 header-includes
列表?
If I have these files:
text.md:
---
header-includes:
- \usepackage{pgf-pie}
---
\begin{tikzpicture}
\pie{50/, 50/}
\end{tikzpicture}
settings.yaml:
variables:
header-includes:
- \pagecolor{black}
and I compile them with pandoc with the command:
pandoc text.md -d settings -o text.pdf
...the header-includes
value in the defaults file settings.yaml
will overwrite the metadata block in text.md
, thus failing to compile.
Is there a way to get pandoc to combine the two header-includes
lists instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
组合这些
header-includes
列表是不可能的。这样做有两个原因:第一,默认文件中的值始终优先。此外,如果名称既用作变量又在元数据中使用,则将使用该变量。
有关本主题的其他信息和讨论,请参阅这些 pandoc GitHub 问题:
可能的解决方法是使用“新样式”自定义 writer,因为它们提供对元数据和变量的写访问权限:
但是请注意,这当前需要开发版本,因此您' d 需要使用每晚构建。您还需要显式指定模板和 PDF 引擎,例如
--template=default.latex --pdf-engine=xelatex
。Combining these
header-includes
lists is not possible.There are two reasons to this: One, the values from the defaults file always take precedence. In addition, if a name is used both as as a variable and in the metadata, then the variable will be used.
For additional info and discussions of this topic, see these pandoc GitHub issues:
A possible workaround would be to use a "new style" custom writer, as these provide write access to both metadata and variables:
Note, however, that this currently requires the development version, so you'd need to use a nightly build. You'll also need to explicitly specify the template and PDF engine, e.g.,
--template=default.latex --pdf-engine=xelatex
.