Diagrams in Latex
By iant at Fri, Feb 22 2008 6:29am |
I've recently started using Latex and am enjoying it so far. I'm having slight issues with inserting graphics though, the way I'm doing it so far is to create a diagram using Omnigraffle, and then convert it to a png using graphic converter. When I then insert this into Latex and typeset into a pdf, the graphic looks out of place (most of my graphics are simple line drawings) as it is slightly blocky compared to the nicely rendered text that Latex creates.
What do other people recommend for creating graphics for use in Latex on the mac? I know I can use the picture environment but it looks quite time consuming.



For diagrams, OmniGraffle.
If you want to draw a diagram for your latex doc, use OmniGraffle. I found it is much better than MS Visio. Just save your diagram to a PDF file and include it to your latex.
I also use Adobe Illustrator to edit figures, which I usually generate in MATLAB. Export a figure in MATLAB to a AI file, and edit it in Adobe Illustrator, and then export it to a PDF file. You can modify any part of a graph, including the line type and thickness and add any texts on it.
Daehyok Shin
Diagrams in Latex, I use pdfs
I use omnigraffle but instead of exporting to jpeg or png, I export in PDF format.
R
I have been using R. It is a total pain to learn, but being able to script everything is great. Any time you need to change something, and lets face it, if you are writing a paper you will end up changing your graphs a number of times, all you have to do is change it in the script, and then run the script and all of your graphs reflect the change.
R + LaTeX
If you use R and LaTeX, you might like Sweave.
Diagrams in LaTex...
Your diagrams are probably blocky because they are in PNG format. If you don't have a high enough dpi, then you will see blocky-ness. If you use something scalable, like pdf or eps, then the diagram will scale with the zoom level of whatever viewer you use to look at the pdf produced by LaTex. Alternatively, if I use non-scalable images in my LaTex documents, then I create them (the images) with a resolution of 300 dpi. This seems to be good enough to view it at any reasonable zoom level, and it prints cleanly, but is not so big that it makes huge image files that bog down the viewer.
You can directly export to
You can directly export to PDF vector image from OmniGraffle; no GraphicConverter is required; this should yield excellent results, unless you added bitmap images (png,jpg,gif) in the diagram. I found it helpful to keep the width of the exported image constant to avoid different font sizes. Also, you can download and install the lmodern fonts in the Font Book to make them available for OmniGraffle, if you use these fonts in LaTeX.
Diagrams in LaTeX
For TeX, you've really got to stick to vector images to maintain a high quality of output. R produces great graphics especially with the lattice and grid packages, but to go low level the learning curve can be pretty steep (check out Murrell, P., "R Graphics", 2006). For an open source GUI option for vector graphic production you can't go past Inkscape. The leopard binaries of 0.46, available on the Inkscape website, work great, but avoid trying to save as anything other than SVG. I use rsvg-convert (available with macports in the librsvg package) to convert to PostScript or PDF. You can also convert from PDF/PostScript to SVG using pstoedit (also available on macports) and then edit graphics in Inkscape.
A great alternative to the picture environment and PStricks, for producing graphics within LaTeX or ConTeX is the pgf package the latest version of which, 2.00, has just become available.
Thanks guys, I never
Thanks guys, I never realised pdf export was an option with Omni Graffle, I'm now getting the results I was after. I'm loving using Latex!
PSTricks/Picture/PGF/TikZ
I'm surprised that in all of the comments here, this brief aside is the only mention of PSTricks, the picture environment, and the pgf/tikz stuff.
In my opinion, the *best* looking line drawings (and even grayscale, depending on the context) comes from these packages. You actually draw *within* latex using markup. The end result not only shares the same fonts and conventions in the rest of your document, but because drawings are rendered just-in-time, they don't suffer from conversion/raster problems that you see with other methods.
The general consensus is that the picture environment might be a good starting point, but it can be cumbersome to work with and has few advanced features. The PSTricks package is infinitely powerful (because its PostScript back-end allows for calculations), but it restricts you to building a DVI and then converting to PDF. The PDFTricks package gives you lots of what PSTricks does and can produce PDFs directly, but it has its own inconveniences. Finally, the PGF/TikZ package (very new) is very easy to use and does most of the cool things that PSTricks does. However, because PGF/TikZ does not depend on PostScript, it cannot use calculations, and so it still doesn't match the power of PSTricks.
Don't bother with the old picture environment. However, do see the PSTricks page at TUG for examples of what PSTricks can do. Then see the PGF/TikZ homepage to compare to what PGF/TikZ can do.
Note that there are also old-school methods (like the psfrag package) that let you build placeholders within your included graphic that can be filled in by latex on-the-fly. For example, you can have LaTeX populate all of the text on a MATLAB plot (note that plotting can also be done entirely within PSTricks packages--you can even read from a data file).
--
Ted Pavlic
http://www.tedpavlic.com/
http://phaseportrait.blogspot.com/
A non wysiwig diagram tool
If you want to create diagrams in PS or PDF from an command language, I like "asymptote". It has some 3D capability too.
Figure drawing
For my figures, which are usually pretty simplistic, I use jFig. It is a clone of xFig, written in java, that produces excellent results. It also gives you the capability to include tex in your figure and these can be included in your document fairly easily. The only downside is that, unlike xFig, jFig is not free and the author requests 25 euros for registration. I feel it is a small price to pay for the quality of the application, which integrates nicely with OS X and offers a variety of vector and raster-based export options.