Search code examples
latexmarkdownpandoc

Pandoc conversion to latex not complete


I have been writing a paper in Markdown and successfully converting to a pdf using pandoc. Now I need to output to a latex file. When I do pandoc does not output a full latex file.

I have recreated the problem in a smaller document.

---                                                                                       
title: Test Document                                                                      
author: Rusty                                                                             
date: 2022 Jul 26                                                                         
---                                                                                                                                                                                                                                             
                                                                                          
# Body #                                                                                  
                                                                                          
This is the body.                                                                         
                                                                                          

Using the command pandoc --read=markdown --write=latex --output=testdoc.pdf testdoc.md creates the following document which is perfect.

screenshot of pdf output

However, when I try to output to latex without converting to pdf a lot of the document is missing. I use a similar command pandoc --read=markdown --write=latex --output=testdoc.tex testdoc.md

This is the entire document.

\hypertarget{body}{%                                                                      
\section{Body}\label{body}}                                                               
                                                                                          
This is the body.                                                                         

How can I get the latex output to include everything and act as a full latex document?


Solution

  • You can add the --standalone option:

    pandoc --read=markdown --write=latex --output=testdoc.tex --standalone      test.md
    

    (but beware that this will just dump every package but the kitchen sink into your document - many of these package are unnecessary and cause a trillion "funny" problems)