Q: Why is Pandoc not converting a .tex to .pdf but will convert the .md fine? I have a number of Markdown files which I am converting to PDF using Pandoc - including folding in some header files with LaTeX options.
This works if I create the PDF in a single step (MD → PDF), however, I need to perform some additional steps on the intermediate LaTeX file so I am trying to split the Pandoc process into two steps (MD → TEX → PDF) - which produces an "Undefined Control Sequence" error.
I have compared the .tex file produced by one-step-Pandoc with the two-step version and they are identical - including the relevant \usepackage commands for the LaTeX packages that produce the error.
I am running on Windows, and have updated Pandoc to 2.7.3 and updated all my MiKTeX packages this morning.
Minimal test files that produce this error:
test.md:
% Title
% Author
% Date

Body text

title.tex
\setmainfont{Times New Roman}\fontsize{11pt}{11pt}\selectfont
\sectionfont{
    \setmainfont{Arial}
    \fontsize{32pt}{32pt}
    \selectfont
}

When I use a single step command, the PDF produces correctly without issue:
> 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

When run in two steps:
> 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


A: The second step should simply be:
> lualatex test.tex

By using pandoc to go from LaTeX to PDF you potentially lose information (because pandoc cannot represent all of TeX and more importantly, pandoc will use it's own template.)
