Table of Contents

Latex Tips

Graphviz in PDFLatex

Ever wondered how to include graphiz diagrams in a pdflatex file without converting back to a raster image?

First use dot to generate a PostScript file:

dot -Tps -O example.gv

Convert to an Encapsulated PostScript:

ps2epsi example.gv.ps example.gv.eps

Use epstopdf (for ubuntu in texlive-extra-utils package) to create a pdf file:

epstopdf --outfile=example.pdf example.gv.eps

Combine them in an executable script (e.g. /usr/bin/dotpdf) like:

TIMESTAMP=`date +%s`
TMPDIR=/tmp/dot2pdf$TIMESTAMP
PSFILE=$TMPDIR/$1.ps
EPSFILE=$TMPDIR/$1.eps
PDFFILE=$1.pdf

mkdir $TMPDIR
dot -Tps -o$PSFILE $1
ps2epsi $PSFILE $EPSFILE
epstopdf --outfile=$PDFFILE $EPSFILE
rm $TMPDIR -r

This accepts the graphviz file <filename> and will result in an <filename>.pdf file. Don't forget to chmod +x /usr/bin/dotpdf .

Rotate table, or landscape

I use sidewaystable for simple table rotation, but it won't rotate the actual page when for example viewing in a pdf reader. Therefore, I now use landscape in certain situations.

\usepackage{pdflscape}
\begin{landscape}
\end{landscape}

But when I set the size of the resizebox, I get weird results. After some debugging I found the problem.

Width : \the\textwidth.
Height : \the\textheight.

Seems textheight is not set to textwidth of the portrait mode, while textwidth ís set to portrait textheight. Setting ptextheight:

\newdimen\ptextheight
\ptextheight\textheight
\begin{landscape}
Pheight : \the\ptextheight.
\begin{table}[h]
\resizebox{\ptextheight}{!} {
  blablabla tabular to be rotated
}
\end{table}