I am writing a simple document in markdown and will convert to pdf using pandoc
. I would like to insert colored shapes inline. For example, a red circle, or a blue square, or green triangle. What is the easiest way to do this?
If you know LaTeX, you can use raw TeX in your markdown, and use a package like TikZ. Something along the lines of:
---
title: My title
header-includes:
- \usepackage{tikz}
---
# my markdown title
\begin{tikzpicture}
\filldraw[color=red!60, fill=red!5, very thick](-1,0) circle (1.5);
\fill[blue!50] (2.5,0) ellipse (1.5 and 0.5);
\draw[ultra thick, ->] (6.5,0) arc (0:220:1);
\end{tikzpicture}
Alternatively, you may want to use a vector image editor like Inkscape. Then you can export the image to either SVG (in which case you need rsvg-convert
installed for pandoc to produce the PDF), or export to EPS or PDF (in which case it should just work).

See also Creating a PDF in the pandoc manual.