0

I am using pandoc to convert my .tex-file into a PDF, but my definitions are not being used. Example:

\documentclass[12pt,letterpaper]{article}

\usepackage[a4paper,margin=1in]{geometry}
\usepackage[doublespacing]{setspace}
\usepackage{booktabs}

\begin{document}

\section{Test}

We make a few claims, and many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many more.

\begin{table}[htbp]
\begin{center}
\begin{tabular}
{@{}lr@{}}
\toprule
key & value \\
\midrule 
a & 1 \\
b & 2 \\
\bottomrule
\end{tabular}
\caption{This table better look good.}
\end{center}
\end{table}

\end{document}

Compiling with pandoc -o out.pdf test.tex, this produces:

enter image description here

So the geometry and double spacing is ignored, and booktabs don't work.

Now, I can manually pass the geometry and the spacing to the call to pandoc, but why aren't the values from the file used? Also, what can I do get booktabs to work?

4
  • 1
    You mustn't use pandoc to convert tex to pdf, you have to run pdflatex (or xelatex or lualatex) instead.
    – DG'
    Nov 14, 2019 at 11:40
  • 1
    @DG' The reason I'm using pandoc is because I have a long .tex including bibliography file which I now need to compile using a given CSL file, and I haven't found another way to do it.
    – cheersmate
    Nov 14, 2019 at 13:37
  • Well, this is something else. You might want to write your own template file for pandoc, which contains the preamble of your long .tex file. If you run into problems doing that, you should ask a new question.
    – DG'
    Nov 14, 2019 at 14:04
  • @DG' a guide for this? Oct 12, 2021 at 18:28

1 Answer 1

2

You mustn't use pandoc to convert tex to pdf

Simply call pfdlatex test.tex to compile your .tex-file In order to get booktabs working, you have to load the package by adding \usepackage{booktabs} to the preamble of your file:

\documentclass[12pt]{article}

\usepackage[a4paper,margin=1in]{geometry}
\usepackage[doublespacing]{setspace}
\usepackage{booktabs}


\begin{document}

\section{Test}

We make a few claims, and many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many, many more.

\begin{table}[htbp]
\begin{center}
\begin{tabular}
{@{}lr@{}}
\toprule
key & value \\
\midrule
a & 1 \\
b & 2 \\
\bottomrule
\end{tabular}
\caption{This table better look good.}
\end{center}
\end{table}

\end{document}

enter image description here


Or, if you want to use pandoc, do write your text in markdown:

---
fontsize: 12pt
papersize: a4
linestretch: 2
geometry:
- 'margin=1in'
---

Test
====

We make a few claims, and many, many, many, many, many, many, many,
many, many, many, many, many, many, many, many, many, many, many, many,
many, many more.

  key     value
  ----- -------
  a           1
  b           2

  : This table better look good.

enter image description here


This is all very well documented on pandoc.org

4
  • Right, I need to include booktabs which I accidentally deleted for the minimal example above. But why doesn't it work with pandoc?
    – cheersmate
    Nov 14, 2019 at 13:39
  • Does it say in the docs for pandoc that may case will not work?
    – cheersmate
    Nov 14, 2019 at 13:39
  • Well, the docs explain how pandoc works, e.g. that the default pdf output is via pdflatex, that is, the source will be converted to a temporary latex file which will then be compiled with pdflatex. What is happening is this: tex → pandoc → tex → pdflatex → pdf. But if your input tex is valid, you can just do: tex → pdflatex → pdf. Of course there will be cases, where tex → pandoc → tex is useful.
    – DG'
    Nov 14, 2019 at 14:01
  • Ok, according to your other comment, your problem is such a case. Please consider asking a new, rephrased question
    – DG'
    Nov 14, 2019 at 14:19

You must log in to answer this question.

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