Search code examples
haskellpandoc

How to convert multi-file LaTeX documents using the pandoc API?


I'm curious how I can convert a multi-file document in LaTeX to some other format using the Haskell pandoc API. I see there is readLaTeX function, but this accepts a single Text value as a parameter instead of e.g. [Text]. What is the correct way to handle this more general situation?


Solution

  • As far as I can tell from the code, inclusion of other LaTeX documents with \input{...}, etc. is handled by searching for the documents using the TEXINPUTS environment variable as a colon-separated search path (or just checking the current directory, if TEXINPUTS isn't defined).

    Truth be told, that's not a great way of doing it. (To remain compatible with normal TeX stuff, it should be using the TeX kpathsea library to parse TEXINPUTS.)

    But, if you make sure TEXINPUTS is either blank or includes . as one of its colon-separated components, and ensure you switch to the directory where all the files are, if you pass the text of the main file in to readLaTeX, it should "just work".