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

Jonno Bourne picture Jonno Bourne · Jun 17, 2015 · Viewed 8.6k times · Source

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?

Answer

Yihui Xie picture Yihui Xie · Jun 17, 2015

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.