Knitr preamble error results in "pandoc document conversion failed with error 43"

9.8k views Asked by At

Rstudio Version 0.99.441; Windows 7 enterprise; knitr 1.10.5; MiKTex 0.4.5 r.1280 (2.9 64-bit)

I have a an error on my office computer when trying to knit PDF's in Rstudio, there are no problems knitting to HTML or word. The problem may be related to updates because knitting used to work fine and my home computer can knit to pdf without issue, however I took my computer home to update and the problem is still there.

My error message was as follows "pandoc.exe: Error producing PDF from TeX source Error: pandoc document conversion failed with error 43"

I created a new file using the template example in Rstudio attempted to knit, then inspected the TEX output. I traced the error to the last paragraph of the preamble.

\setlength{\droptitle}{-2em}
 \title{Untitled}
 \pretitle{\vspace{\droptitle}\centering\huge}
 \posttitle{\par}
 \author{user name}
 \preauthor{\centering\large\emph}
 \postauthor{\par}
 \predate{\centering\large\emph}
 \postdate{\par}
 \date{\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\setcounter{enumi}{14}
\itemsep1pt\parskip0pt\parsep0pt
\item
  juni 2015
\end{enumerate}}

by removing the last 7 lines to do with enumerate and the date then running the TEX code the document prints as a PDF. Why is this happening and what can I do about it so the document knits at first click from Rstudio?

4

There are 4 answers

4
Yihui Xie On BEST ANSWER

You should show the YAML frontmatter of the R Markdown document. Guessing from my experience, the error was caused by

---
date: "14. Juni 2015"
---

Any number followed by a period (e.g. 14.) will be treated as an item in a numbered list. You need to either remove or escape the period . (by \\.) in the date field. The same issue has been reported before.

0
DanAC On

This error can also be form having a curly quote or certain other characters. I spent ages on this pandoc error 43 before realising it was a block of text I had copied over form word.

e.g. Bob’s vs bob's

0
Edwin On

My screw-up that resulted in this error was forgetting to put dollar signs around some inline latex code. I did

\theta

Instead of

$\theta$
0
Witte On

Another way to create this error is from having 'æ', 'ø' or 'å' in the file name.