Tuesday, March 31, 2009

Exporting diagrams from Latex

It's more common to import pictures/diagrams into Latex.

The Message Sequence Chart (msc) package in Latex is brilliant at drawing diagrams like protocols, UML message sequences. Unlike the algorithm package (alg2.sty), the MSC environment doesn't let you export its content to external files.

The reason you may want to export these graphs is to include them into your Beamer slides, the environment that scales up everything from the text to your drawing.

And as many, I prefer the diagrams in EPS format. So:

1. Draw your MSC in one page (using
or other
environment). Make sure the diagram is the only thing on the page. Suppose you named it "file.pdf"

2. pdfcrop file.pdf image.pdf

3. pdftops -eps image.pdf image.eps

All commands used in (2) and (3) come with standard Latex package. Executing these will give you the high quality image.eps file.