I have a Markdown file that I want to compile to LaTeX. I want to put \usepackage{tikz} in the header. Here's what I tried:

$ cat test.md | pandoc -s -f markdown -t latex -H \usepackage{tikz} > test.tex
File usepackage{tikz} not found in resource path

Then I removed the -H flag and made a YAML header for my Markdown.

title: My title
author: My name
  - '`\usepackage{tikz}`{=latex}'

It yields

File tikz not found in resource path.

I'm using Tectonic so I don't have TikZ installed locally. I just want to add a string of text to my header, so I guess I must be on the wrong path if pandoc expects to find software in some path.

How do I make pandoc add a package to my header?

  • 1
    I know only a little about Tectonic; but as far as I know, it downloads packages from CTAN? And after compilation, it removes them? Anyway, your error message is saying that it is looking for file "tikz"; but at least you have to look for file "tikz.sty"; which contains (hopefully all) definitions. This looks like tectonic specific issue. About headers, I am not entirely sure what you mean while converting to latex with pandoc; but among other things you can modify default latex template (that might be the most straightforward way), save it and call in it template variable. Commented Aug 31, 2020 at 7:09
  • Last line should be <space><space>-<space>\usepackage{tikz} and nothing more.
    – Fran
    Commented Aug 31, 2020 at 8:10

2 Answers 2


The comment of Fran did the trick.

Instead of:

  - '`\usepackage{tikz}`{=latex}'

I had to use

  - \usepackage{tikz}

and make sure that pandoc is called without -H \usepackage{tikz}.


I use the following:

> pandoc --standalone \
  -H packages.tex \
  -f markdown \
  -t latex -o book.pdf \

Note the -H packages.tex. That file includes all the packages I want in the header, e.g.:


You must log in to answer this question.

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