DCsunset / pandoc-include

A pandoc filter to allow file and header inclusion
MIT License
63 stars 14 forks source link

Including latex usepackege in include header reusult in error #16

Closed danieltomasz closed 3 years ago

danieltomasz commented 3 years ago

I have in my document

# Formatting Settings

documentclass: article
fontsize: 12pt
geometry: margin=1.0in
#geometry: "left=3cm,right=3cm,top=2cm,bottom=2cm"
header-includes:
  - \usepackage{times}
  - \usepackage[mathlines,displaymath]{lineno}
  - \linenumbers
urlcolor: blue

They work, when I include them into header.yaml and use include-header I got following error

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.55 \textbackslash
                    usepackage\{times\}
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on /tmp/tex2pdf.-98c2dc4c9fc43ed6/input.log.
danieltomasz commented 3 years ago

I managed to solve my problem by including tex file when running pandoc command line, but in general - how to include latex parameters in header is not solved

DCsunset commented 3 years ago

After some inspection, it seems that including latex headers wouldn't work because they are processed before the filter, which means only other metadata could be included.

Maybe I should emphasize it in the README. If you find some workarounds, feel free to comment here.

danieltomasz commented 3 years ago

I put latex header into separate file and run pandoc with `—include-in-header file.tex’ and it was my workaround

DCsunset commented 3 years ago

I found the actual reason today. It seems that reading directly from yaml would lose some information. So I use pandoc itself instead of yaml to read the headers to fix it.

It should work in v0.8.7 now.