Search code examples
pandoc

Pandoc: Error producing PDF. ! Undefined control sequence


I want to convert a table written with Markdown to PDF. Within the Table there is a Cell with \\walhalla\path as content. I use this command to generate the output:

pandoc testMD.md -o testMD.pdf

So about as simple as it gets. I keep getting an error that has something to do with the backslashes. I assume the backslashes are interpreted as escape characters and are causing trouble becouse of it but is there any way for me to tell pandoc to just leave the backslashes as they are?

Here is the full Errormessage:

Error producing PDF.
! Undefined control sequence.
l.185 \textbackslash walhalla\path

I tried to specify the pdf-engine but that did not really change anything.

Just changing the content of the cell is not an option either as this is supposed to run as a CI-Pipeline to accept valid Markdown and convert it to pdf


Solution

  • I had the same issue i think the problem here is that you are using the LateX engine. This interprets a \ as a command you can either escape the backslash like so: \backslash or \textbackslash.

    But you can also do what i did an switch engine because i had a very big document and didn't want to switch out any backslashes. I used groff and ghostscript which i setup like this:

    install pandoc with the engine

    sudo apt-get install pandoc groff ghostscript
    

    and then pass the PDF engine in the command

    pandoc --pdf-engine=pdfroff -s SourceFile.md -o OutputFile.pdf
    

    You can read more about the issue here
    Sorry for the late answer but hope this still helps :)