4

I used \LaTeX to get the LaTeX logo in my .tex file. However, converting it to pdf with:

pandoc file.tex -o file.pdf

produces a file that doesn't have the correctly formatted LaTeX logo. However, pdflatex works just fine.

How do I resolve this?

EDIT: Minimal example:

\documentclass{article}
\begin{document}
\LaTeX{} is a program for typesetting documents.
\end{document}
6
  • Pandoc uses by default the pdflatex engine for conversion. If I take the one-liner from above: \LaTeX is a program for typesetting and save it as logo.md and process it pandoc logo.md -o logo.pdf the result is as expected (a correctly displayed logo). If you "just" have a complete .tex file, I would rather use the pdflatex command directly. Mar 17, 2016 at 8:26
  • @blue_tiger300 Yes, you're right. I have a complete .tex file, and the pdflatex command directly works. (I'm left wondering why, though).
    – naiveai
    Mar 17, 2016 at 8:34
  • Pandoc sets the option -s automatically and uses its internal template to generate the pdf. My guess is that there is clash between your full .tex document and the template. But then again it is just a guess. Maybe you want to open a ticket on the pandoc github site?! Mar 17, 2016 at 9:07
  • 1
    What are you trying to achieve with pandoc file.tex -o file.pdf? Why are you running pandoc on a latex file?
    – DG'
    Mar 17, 2016 at 10:14
  • I normally use Pandoc to convert pretty much anything. I am learning LaTeX and was trying to integrate it with the tools I use.
    – naiveai
    Mar 17, 2016 at 11:13

1 Answer 1

7
  1. Don't use pandoc to run LaTeX files. Pandoc is a document converter not a LaTeX compiler.

  2. Pandoc just behaves as it's supposed to. Pandoc has two parts, a reader and a writer. The reader transforms the input to an abstract syntax tree (AST) that represents the document structure and the writer transforms the AST back into the desired output format.

    So, what happend to \LaTeX in your document? The reader translated it to LaTeX and stored it in the AST. The latex writer consequently saw only the string LaTeX (and not \LaTeX) and therefore wrote only LaTeX.

    In other words, pandoc converted your LaTeX document into another LaTeX document containing only those elements, which can be represented in pandoc's AST.

  3. Pandoc's markdown reader on the other hand can pass LaTeX code through to the writer. So a markdown file containing:

    \LaTeX\ is a program for typesetting documents.
    

    can be converted to PDF (via latex) with:

    pandoc file.md -o file.pdf
    

    and the logo will be preserved:

    enter image description here

2
  • The problem with markdown is that you can't use a custom preamble and/or packages (to my knowledge). Guess I'll use pdflatex then.
    – naiveai
    Mar 17, 2016 at 15:08
  • 1
    You can edit the template and/or use header includes, cf. tex.stackexchange.com/questions/296990/…
    – DG'
    Mar 17, 2016 at 17:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .