I'm using a tex template similar to https://github.com/davecap/markdown-latex-boilerplate/blob/master/template.tex

How can I get a frame around images which are passed from standard markdown code to the tex template?

Obviously this code handles the image sizes, but how can I add the graphics frames?

% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}



2 Answers 2


Without editing the template, you can use the YAML metadata block to pass options that would redefine \includegraphics so that it would always add a frame, similarly to what is done here.

Take, i.e., this picture as an example, and let's call it Screenshot_20200131_230154.png:

enter image description here

Then, the following markdown file test.md:

header-includes: |

![](Screenshot_20200131_230154.png){ width=150px height=150px }

would produce, when compiled with pandoc test.md -o test.pdf:

enter image description here


I didn't find how to make the yaml template work so I used @Clément's options as CLI parameters:

pandoc --pdf-engine xelatex \
    -V header-includes:'\usepackage[export]{adjustbox} \let\includegraphicsbak\includegraphics \renewcommand*{\includegraphics}[2][]{\includegraphicsbak[frame,#1]{#2}}'

You must log in to answer this question.

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