Esben Eickhardt
Esben Eickhardt

Reputation: 3852

pandoc: Undefined control sequence \colorbox

Problem

I have a file with a combination of Markdown and LaTex that I would like to convert into PDF. Pandoc seems to work in Ubuntu 20.04 but not in Debian 10.

My Installation

# Installing Pandoc and dependencies
apt-get install pandoc texlive-xetex texlive-latex-recommended

My Markdown

I have the following text in a file called test.md:

\centerline{\Large{\textbf{Test 1}}}

\colorbox{blue!25}{\Large{\textbf{Test 2}}}

**This is a test**

Convertion

# Conversion
pandoc -V geometry:margin=0.7in -s test.md -o output.pdf

In Ubuntu 20.04 a beautiful PDF i generated.
In Debian 10 (Docker) I get the following error:

! Undefined control sequence.
l.62 \colorbox

Am I missing some dependencies in Debian 10? Is there a way to see what Pandoc engine that is used by default? What am I doing wrong?

When running verbose mode it seems the installations are using different engines, however, when I specify the geometry driver such that they are the same, the problem remains.

# Debian 10
*geometry* driver: auto-detecting
*geometry* detected driver: xetex

# Ubuntu 20.04
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex

Update: Workaround

Reading several posts on similar problems, I first tried to add \usepackage{xcolor} to the start of the document, but that didn't work. Then I found out that you have to add a YAML-header and then it works. The original problem however still puzzles me.

# Adding this to the start of the document fixed the problem
---
header-includes:
  - \usepackage{xcolor}
output:
    pdf_document
---

Upvotes: 0

Views: 1346

Answers (1)

tarleb
tarleb

Reputation: 22609

Debian 10 (buster) ships with pandoc 2.2.1, while Ubuntu 20.04 (focal) comes with pandoc 2.5. It seems that you hit a bug which was fixed in the later version.

However, this is curious. The changelog mentions that a bug like this was fixed in version 2.6, which is newer than either of your versions. So I'm honestly a bit puzzled about the exact nature of the bug you triggered.

Upvotes: 1

Related Questions