我有许多Markdown文件,我正在使用Pandoc将其转换为PDF - 包括使用LaTeX选项折叠一些头文件。
如果我在一个步骤中创建PDF(MD→PDF),这就可以了,但是,我需要在中间LaTeX文件上执行一些额外的步骤,所以我尝试将Pandoc过程分成两个步骤(MD→TEX→PDF) - 这会产生"未定义的控制序列"错误。
我将一步 Pandoc 生成的.tex
文件与两步版本进行了比较,它们是相同的 - 包括产生错误的 LaTeX 软件包的相关usepackage
命令。
我在Windows上运行,并将Pandoc更新到2.7.3,并在今天早上更新了我所有的MiKTeX软件包。
产生此错误的最小测试文件:
test.md
:
% Title
% Author
% Date
Body text
标题.tex
setmainfont{Times New Roman}fontsize{11pt}{11pt}selectfont
sectionfont{
setmainfont{Arial}
fontsize{32pt}{32pt}
selectfont
}
当我使用单步命令时,PDF 可以正确生成,没有问题:
> pandoc test.md options.yaml -o test.pdf -f markdown+smart+tex_math_dollars -s -V block-headings -H fontoptions.tex -B title.tex -B title_logo.tex -B header.tex --pdf-engine=lualatex
lualatex: warning: running with administrator privileges
lualatex: warning: running with administrator privileges
lualatex: warning: running with administrator privileges
分两步运行时:
> pandoc test.md options.yaml -o test.tex -f markdown+smart+tex_math_dollars -s -V block-headings -H fontoptions.tex -B title.tex -B title_logo.tex -B header.tex
> pandoc test.tex -o test.pdf -f latex --pdf-engine=lualatex
lualatex: warning: running with administrator privileges
lualatex: warning: running with administrator privileges
lualatex: warning: running with administrator privileges
Error producing PDF.
! Undefined control sequence.
l.81 sectionfont
第二步应该是:
> lualatex test.tex
通过使用 pandoc 从 LaTeX 转到 PDF,您可能会丢失信息(因为 pandoc 不能代表所有 TeX,更重要的是,pandoc 将使用自己的模板)。