typesetters / p5-App-pandoc-preprocess

Preprocess Pandoc before Processing Pandoc
8 stars 2 forks source link

Support PGF/TikZ images #6

Open nichtich opened 10 years ago

nichtich commented 10 years ago

See http://www.texample.net/tikz/examples/ for examples, e.g. http://www.texample.net/tikz/examples/cycle/

~~~ {.tikz}
\def \n {5}
\def \radius {3cm}
\def \margin {8} % margin in angles, depends on the radius
\foreach \s in {1,...,\n}
{
  \node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$\s$};
  \draw[->, >=latex] ({360/\n * (\s - 1)+\margin}:\radius) 
    arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
}
~~~

For LaTeX output the code could be embedded in \begin{tikzpicture}...\end{tikzpicture} and for other output it could be converted to PNG for inclusion as simple image.

mangecoeur commented 10 years ago

Even better would be if it was possible to include an external file (so you don't have to fill your text with latex literals) Something like

~~~{.tikz, file=diagram.tex}
Placeholder

It might be too complex to also handle image output, but maybe some kind of fallback could be provided. This would be especially interesting now since Matplot (the premier Python plotting package) supports tikz/pgf as an output format (which imho is, like, voodoo magic)