Graphics
From TeX on Mac OS X wiki
Your helpful TeX on Mac wiki depends on you to support it by adding your valuable information!
This page covers the use of TeX and friends to produce graphics of various kinds, as well as the inclusion of arbitrary graphics files in TeX documents.
Contents |
Command Line Tools
GasTeX
Licence?
From the project page:
GasTeX is a set of LaTeX macros which allow to draw very easily graphs, automata, nets, diagrams, etc... under the picture environment of LaTeX. A picture with gastex basically consists of nodes and edges.
metapost
by John Hobby
Public domain
Tool for creating graphics in scalable postscript based on Metafont.
metapost is part of TeX Live.
GUI Tools
LaTeX Color Selector
Creates LaTeX colour definitions for colours chosen using the standard OS X interface.
Inkscape with TeXText plugin
Inkscape is open source (GPL)
TeXText is either open source or creative commons (source code is available; licence is unclear but source is hosted on a site which accepts only OSI and CC code)
The following steps allow for the insertion of editable LaTeX equations in Inkscape using TeXText on OS X Leopard 10.5.5:
- Download Inkscape and install it. Tested with Inkscape-0.46-2.LEOPARD.UNIVERSAL. You also might need to update X11.app by downloading and installing the latest Xquartz. Run Inkscape at least once to make sure it does work.
- Download TeXText. Tested with version 0.4.4.
- Install pstoedit-bin and pstoedit-shlibs from Fink (download the binary version; if you compile from source it takes several hours as it compiles every dependence). Not sure if both are needed. Tested with version 3.45-1.
- Install MacTeX. Tested with the MacTeX-2008 distribution.
- Comment/delete in textext.py the lines:
if 'plot-svg' not in out: raise RuntimeError("Pstoedit not compiled with plot-svg support")
Apparently the script does not detect that pstoedit does have plot-svg support. Indeed, when running the commandpstoedit -help | grep svg
in the Terminal we get
pstoedit: version 3.45 / DLL interface 108 (build Oct 10 2008 - release build - g++ 4.0.1 (Apple Inc. build 5484)) : Copyright (C) 1993 - 2007 Wolfgang Glunz plot-svg: .svg: svg via GNU libplot (/sw/lib/pstoedit-3.45/libp2edrvlplot.so)so we know it is installed!
- In textext.py replace
exec_command(['pdflatex', self.tmp('tex')] + latexOpts)
with
exec_command(['/usr/texbin/pdflatex', self.tmp('tex')] + latexOpts)
Even though the path to pdflatex is in the shell's $PATH environmental variable, textext.py needs the full path, as applications get their value of $PATH from ~/.MacOSX/environment.plist. Another solution is to make sure that ~/.MacOSX/environment.plist has /usr/texbin in PATH.
- Place textext.inx and textext.py inside the application bundle. This is done by right-clicking on Inkscape.app on the Finder and selecting Show Package contents and there going to
Contents/Resources/extensions/
When putting it in
~/.inkscape/extensions/
it does not work.
- Remove libpng12.0.dylib from
Contents/Resources/lib/
inside the Inkscape application bundle. The version included is not new enough for
pstoedit. I believe that its role will be taken by the libpng12.0.dylib installed by Fink in/sw/lib/
or already in the system in/usr/X11/lib/
If successful you will have a TeX Text item in the Effects menu in Inkscape, which you can use to insert/edit LaTeX into your open document.
These instructions were gleaned from the Inkscape forum.
IPE
GUI editor that allows easy embedding of LaTeX in the resulting PDF (default save format). The LaTeX can be edited later when the PDF is loaded into IPE. Cannot read generic PDF documents (but you may get lucky, I guess).
JasTeX
by Michel Duong, Gregory Kokanosky and Yannick Ozouf
Open source (GPL)
GUI for GasTeX.
An updated version by Pierre Moro is available on the GasTeX page.
Jpgfdraw
by Nicola Talbot.
Open source (GPL)
An interactive multiplatform 2D graphicse editor that output pgf code. Multiplatform (java). Output formats also include eps, png and svg.
jPicEdit
Open source (GPL)
Described on the project web site as a:
... multi-platform and interactive picture editor for LaTeX and PSTricks...
LaTeXDraw
Open source (GPL)
Written in Java. An interactive multiplatform 2D graphicse editor that can output eps and pstricks code. Latest version 2.0 stores files in svg format.
WARMFigToPDF
(Temporarily hosted by WSU. Email Joseph Slater for problems.)
by Francesco Costanzo and Gary L. Gray
Freeware with source
A system for labeling figures generated with Adobe Illustrator. WARMFigToPDF is an AppleScript that works with Illustrator, WARMreader, and xy-pic to automate the process of labeling figures in LaTeX. From the website:
- Label our figure with some reasonably complex mathematical expressions.
- Uses the same fonts as the document. Generally means Computer Modern, Lucida Bright, or Times.
- Works well with Adobe Illustrator (for example drawn from scratch or cleaned up and annotated Mathematica plots).
WARMreader/Xy-pic
by Ross Moore
Freeware
For Textures, OzTeX and possibly CMacTeX
I recently started using WARMreader with Xy-pic to label plots and diagrams. The reason I have done this is because of the endless string of problems with various versions of Adobe Illustrator and TeX fonts (who knows what Illustrator for OS X will do to this situation when it finally shows up). It is rather confusing at first, but it is quite nice once you get the hang of it. By itself, Xy-pic is a package for typesetting a variety of graphs and diagrams with TeX. Xy-pic works with most formats (including LaTeX, AMS-LaTeX, AMS-TeX, and plain TeX), in particular Xy-pic is provided as a LaTeX2e `supported package' (following the `CTAN LaTeX2e bundle' standard).WARMreader, along with Xy-pic, is a system for placing labels on included graphics in a way that does not require the user be concerned with explicit lengths or coordinates. The full system was developed specifically for use on Macintosh computers but, due to its modularity, can be used with other systems as well.The WARMreader package defines macros to read information from a file, indicating the location of specially marked points where labels may be desired. It also provides a link to the Xy-pic macros, which allow arbitrary labels to be attached at these points.
- Download Xy-pic 3.7 ( 8.6M)
- Download Xy-pic Reference Manual ( 2.7M)
- Download Xy-pic User's Guide ( 730k)
- Download WARMreader 1.2 ( 10k)
- Download the TUG article "Convenient Labelling of Graphics, The WARMreader Way." (1015k)
- Download the cheat-sheet guide to WARMreader ( 4k)
External Applications/Helpers
This section includes software which can be useful in the production of various sorts of graphics for use with TeX, including images, diagrams, graphs etc.
asymptote
Open source (LGPL)
Terminal command %asy and %xasy for built-in drawing tool. Asymptote 1.44 brought major new feature (creation of pdf with embedded prc 3d models).
See this thumbnail: .Requires Adobe Reader to see the model. Current version 1.66; enabled OpenGL renderer with antialiasing to MacOS (10.4 and 10.5) (Victor Ivrii 19:05, 25 December 2008 (UTC))
Now part of TeXLive and is updated regularly Victor Ivrii 11:39, 16 November 2009 (UTC)
gnuplot
Other/Proprietary licence
Plotting routine that can generate numerous high quality graphics format. (eps, pdf, metapost, etc.)
If \write18 enabled http://sourceforge.net/projects/pgf/ pgf with tikz] (very powerful graphics package for TeX and LaTeX) can use gnuplot for providing some data)
Example:
\usepackage{tikz}% in preamble \begin{tikzpicture} \draw[domain=0:2.5,scale=0.4, smooth] plot[parametric,id=parametric-example] function{-0.8*t*t*t+2.6,t*t+0.2*t*t*t*t} node[right]{$\mathcal Q$}; \end{tikzpicture}
To use as a standalone application in Aqua (standard Mac OS) environment you may need Aquaterm
ImageMagick
Open source (BSD)
A suite of image manipulation and conversion utilities with X11 and command line interfaces.
The MacTeX distribution installs the convert command line utility from ImageMagick in /usr/local/bin. To benefit from the full range of utilities provided by ImageMagick or to install the GUI (X11) interface, you need to use another installation method. If you install ImageMagick before MacTeX, you may wish to preserve your existing convert command by customising the MacTeX installation.
Note that ImageMagick may be installed using i-Installer which will include the GUI tools if X11 is available as well as the command line utilities.
MacPorts and Fink offer alternative installation methods, and precompiled binaries are available on macupdate and other Mac sites.
Ipe
by Otfried Cheong (version: 7.0.14, link: http://tclab.kaist.ac.kr/ipe/, licence: GPL with exception allowing distribution of binaries linked against CGAL, manual: http://ipe7.sourceforge.net/manual/manual.pdf)
An extensible drawing editor with embedded LaTeX support which can also be used to create complete presentations. Text and mathematics can be input as LaTeX source so that LaTeX markup can be easily included in drawings. Output is postscript or PDF.
Ipe is a serious replacement of the loved 'xfig' tool. If the core of your figure is produced, for example, by gnuplot into a PDF format to be incorporated in your LaTeX document, you can use the Ipe tool pdftoipe and edit this core figure with IPE in order to incorporate mathematics in texboxes anywhere. Ipe will display your figure as well as the formatted LaTeX mathematics (you can compile your local LaTeX texboxes from Ipe). Texboxes can then be moved, rotated, colored etc.
- An advantage over xfig is that instead of using the burden of 'special', 'export to both' with xfig, you can more precisely and rapidly adjust your maths to the figure.
- But instead of having a single LaTeX compilation which allows cross-references, you are using an independent on line compilation of the mathematics included in your figure.
Useful links:
Installation: Ipe 7.0.14 depends on cairo, fontconfig, freetype2, lua and some other more common libraries supplied by OS/X. You can compile the source yourself if you use fink for the less common libraries or use a MacPort port which already exists for the program as well as for the Ipe tools.
jfig
by Norman Hendrich
Dual licence (shareware for non-commercial use only)
The homepage describes jfig as a multi-platform
2D graphics and diagram editor based on the FIG file format.
written in Java with LaTeX support and a GUI based on xfig. A number of complementary programs are available on the download page.
Xfig
by Supoj Sutanthavibul, Brian V. Smith, Paul King et al.
Open source (details)
Xfig is an interactive drawing tool which runs under X Windows. In xfig, figures may be drawn using objects such as circles, boxes, lines, spline curves, text, etc.
Including graphics in your LaTeX-document
basics
Including graphics in a LaTeX-document is done with a command like this:
\includegraphics{image.jpg}
where image.jpg is a graphic-file of the JPEG-type. It is assumemed that you have loaded the graphics-package in your preamble. There are variants of this command, for example
\includegraphics[width=0.8\textwidth]{image.jpg}
- see for other options, for example, here or the documentation of the graphics-package. While this is very easy, one needs to be aware that not all file types are supported.
supported file types
These are the file types that are supported, depending on the typesetting-mode you are using. As a Mac-User, you are most likely a user of (pdf)latex with pdf-output.
| latex with dvi-output | latex with pdf-output |
|---|---|
| eps | pdf,jpg,png,mps |
See this article in the PracTeX Journal for more on this.
epstopf: including eps-graphics in a pdfLaTeX-document
The epstopf-package helps to overcome the limitations of latex and pdflatex when it comes to available graphic-formats. Its main purpose is to allow the inclusion of .eps-graphic in documents that are typeset in pdflatex (with a pdf as an output file). What the package does is that it calls an external script (with the same name: epstopdf) that converts a eps-graphic into a pdf such that pdflatex can use this. So, if you are using pdflatex, the following document would work:
\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\begin{document}
\includegraphics[width=0.8\textwidth]{image.eps}
\end{document}
It is essential for epstopdf to work that pdf(la)tex (with PDF output) is allowed to call external programs. Therefore a typical call to pdf(la)tex includes the option --shell-escape:
pdflatex --shell-escape --synctex=1
If you are using a recent version of epstopdf (at least 2009/07/16 v2.2), running the example above will result in a file image-epsf-converted-to.pdf in your working directory. See the documentation of epstopf for more details on the inner-workings of the package.
support for other image-formats
The epstopf-package offers also a very convenient way to add support for other graphic-types. For example, if you want to add support for .tif-files, you can add the following to your preamble (again, you need a recent version of epstopdf):
\usepackage{epstopdf}
\epstopdfDeclareGraphicsRule{.tif}{png}{.png}{%
convert #1 \OutputFile
}
\AppendGraphicsExtensions{.tif}
Whenever pdflatex finds a command
\includegraphics{image.tif}
it will try to convert it to an .png-file and use this. However, you need to have the command 'convert' to be available. It is availalable from ImageMagick, see Graphics_helpers#ImageMagick. If you are using the MacTeX-distribution, convert has been installed. ImageMagick can handle a lot of file types! So you can add support for almost any image-format by using epstopdf for a conversion to one of the #supported_file_types.
filenames and the list of known graphics-extensions
If pdflatex finds a command \includegraphics, it looks internally at íts list of supported file types. By default, this list is
.png,.pdf,.jpg,.mps,.jpeg,.PNG,.PDF,.JPG,.JPEG
This lists needs to altered if you add support for other file-types, hence the command \AppendGraphicsExtensions{.tif} in the example above that alters the internal list of supported file-types to
.png,.pdf,.jpg,.mps,.jpeg,.PNG,.PDF,.JPG,.JPEG,.tif
(There is also a command \PrependGraphicsExtensions that would put the new file type at the beginning of the list. Does the order make a difference? Consider you have several version of your a graphics-file in your working directory along with you .tex-document, for example
project.tex image.pdf image.png image.eps
If you include your image with a command
\includegraphics{image}
that is WITHOUT THE EXTENSION, the order of the internal list matters. If the list of supported file types is the default one, see above, it will be the image.png that is included in your final project.pdf. If you are using
\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\epstopdfsetup{prepend}
\begin{document}
\includegraphics[width=0.8\textwidth]{image}
\end{document}
the image.eps will be found first, converted to image-eps-converted-to.pdf (recent epstoopdf) or image.pdf may be overwritten by a newly converted one (older epstopdf), and this will be used. And so on - it can be rather complicated to determine which file is actually used depending on your configuration. Note that this is a problem if you a graphic file in an external program and then it turns out that you were working on a file that doesn't make into your final pdf!
If you include graphics WITH THE EXTENSION, like in
\includegraphics{image.tif}
it will always be this file that is used - either directly ift the file type is supported or after an appropriate conversion triggered by epstopdf.
