Reputation: 135
I'm running the following Pandoc 2.0.3 command on the Mac Terminal command line:
pandoc one.md "metadata.yaml" -o two.pdf
This should take the markdown file one.md
and output two.pdf
using the yaml file metadata.yaml
, a minimal version of which is:
---
header-includes:
- \usepackage{fancyhdr}
...
This Pandoc run produces a PDF as expected for the following version of one.md
:
# Report
However, it fails to produce a PDF for the following version of one.md
, which contains body text:
# Report
Lorem.
The resulting error message is:
Error producing PDF.
! LaTeX Error: Can be used only in preamble.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.65 header-includes: - \usepackage
I don't understand why including that one word creates a failure.
Upvotes: 2
Views: 470
Reputation: 22544
Your one.md
likely doesn't end with a newline. Pandoc concatenates all input files, adding a single newline between files. So the resulting input will be:
# Report
Lorem.
---
header-includes:
- \usepackage{fancyhdr}
...
As a result, the opening dashes of the YAML block are interpreted as underlines for Lorem.
, which is then read as a second-level header. This doesn't happen if the line above the ---
dashes is an ATX-style header.
Just add a newline to the end of one.md
and everything should work the way you expected.
Upvotes: 3