Images in LaTeX

Graphics in LaTeX documents (PDF/PS)

Learning to get decent images in PDF/PS/DVI documents produced from LaTeX seems to be like running a treadmill. Here's what I've found so far, gleaned by experimentation and all over the net.

No doubt this isn't all the best advice, so let me know what is wrong here, and what is better as I'd love to know, and I'll improve these notes.

Best to use Encapsulated Postscript (EPS) but ensure the images are vector format, not raster (bitmap) if at all possible (should be for diagrams).

Issues arise over fonts (see below). Need to ensure scaleable fonts only are used and/or ensure embedded in PDF. Otherwise text will become blocky when document is re-sized.

EPS Diagrams from OpenOffice Draw/Impress

See http://www.iml.ece.mcgill.ca/~stephan/ooeps.

e.g.

  1. Create in OpenOffice Draw.
  2. Export as PDF (to get fonts embedded properly - EPS export does not do this).

    pdffonts {file.pdf} should confirm all fonts are embedded.

  3. Convert to EPS:

    pdftops -eps {file.pdf} generates file.eps

  4. Correct boundingbox (crop):

    Obtain ps2eps Perl script from http://www.tm.uka.de/~bless/ps2eps. This includes bbox binary which you may need to move to somewhere in the PATH.

    cat file.eps | ps2eps > file1.eps

Issues

Transparency in filling seems to cause problems. Use solid colours. May also need to have diagram near top of page when exporting (?).

EPS Diagrams from dia (use for Petri nets) and automata

Can export as "Encapsulated Postscript (using Pango fonts)" or "Encapsulated Postscript (using PostScript Latin-1 fonts)" fonts. In dia 0.96-1, Pango fonts don't scale quite as well (Dell 4700, Ubuntu 9.04). PS latin fonts do, but come out slightly wrong size/position. (Also may look completely wrong in DVI/PS?)

dia 0.96-1 has problems when changing grid scale (non-dynamic grid) - defaults to 0.00. Even though works fine on school server.

Upgrade to pre-compiled dia 0.97-1 Debian package, which seems to handle fonts slightly better (maybe just related to other libraries or method of compilation). PS latin fonts look slightly better than Pango, but difference not so marked. Looks like placement issue may be fixed.

As the PS fonts don't appear to include Greek characters (pasted from Ubuntu character mapper), so export fails for them (can this be fixed?), seems best to use the Pango fonts.

EPS Diagrams from PIPE (Petri Nets)

Problem: horizontals on screen are not necessarily horizontal once printed. Better to use dia. Can export as PS and use ps2eps to convert to EPS as for OpenOffice.

Diagrams from WoPeD (Petri Nets)

WoPeD saves as .pnml but not export to EPS (PNG etc. only). I have some perl scripts to convert PNML to DOT.

Diagrams from Graphviz Dot (Use for Petri Nets or Automata)

Great for automatic layout. Difficult to get start arrow for start state on automaton. Arcs will be straight where possible. If different or more control wanted, dia may be better. But lots is possible using dot and I have only scratched the surface.

dot -Teps file.dot -o file.eps

Diagrams from VAS (Visual Automata Simulator)

VAS cannot export but can be used for design. Saves to its own XML-based format. Can then use Perl scripts to read and convert to DOT.

IEEE testflow

Useful test suite and detailed instructions test for getting LaTeX configuration just right. Discusses issues re creating PDFs.

Ghostscript command for correct embedding of all fonts (incl type 13/14, if required):

gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPAPERSIZE=letter -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile=testflow.pdf testflow.ps

Fonts

Postscript 14 fonts, required to be available without embedding: