Thursday, February 21, 2008

Using tikz2pdf

When drawing graphs by trial and error, the script tikz2pdf by Hans Meine can be very useful.

I have the following in ~/.tikz2pdf.tex:

\documentclass{article}

\usepackage{tikz}
\usepackage{tkz-berge}

\usepackage[graphics,tightpage,active]{preview}
\PreviewEnvironment{tikzpicture}
\newlength{\imagewidth}
\newlength{\imagescale}

\begin{document}

\input{%s}

\end{document}

Then, I edit a file, say foo.tikz, with

\begin{tikzpicture}
\grHeawood[RA=1]
\end{tikzpicture}

and run

tikz2pdf -v foo.tikz

I can open then the generated tikz2pdf_temp.pdf with, say Sumatra,which is a viewer that, unlike Acrobat, does not complain if an opened file is modified. Next time I modify foo.tikz and save it, pdflatex is automatically run and I can press r in Sumatra to update the picture.