Plots/Graphs, Pictures/Images & Diagrams in LaTeX Documents
LaTeX has several mechanisms for incorporating graphical plots,
line drawings and images into a document.
Plots & Graphs
- To incorporate graphics files in LaTeX, you
must have the
graphicx package (which comes with MiKTeX).
Inclusion of graphics in LaTeX is quite easy: simply add to the preamble at the start of
your LaTeX file the following:
\usepackage{graphicx}
Then wherever you wish to include a graphics file (say, 3dplot.pdf)
in your LaTeX document, you simply use:
\includegraphics[width=100mm]{3dplot.pdf}
The width, in this case, is set to 100mm. The height is scaled accordingly to
keep the correct aspect ratio.
- You should use
.pdf format for plots and graphics (a vector format),
rather than .jpg (a raster format), which does not scale well for line drawings.
- If you have any Encapsulated PostScript (
.eps) files, you have to convert them
into PDF format for pdflatex. This typically occurs with MATLAB.
In MATLAB you can generate an eps file for the current figure by typing
print -deps myplot.eps
For colour figures, use
print -depsc myplot.eps
Then use epstopdf myplot.eps in a Windows command shell (Start-Run-cmd) to generate myplot.pdf.
For example:
eps2pdf 3dplot
This will take 3dplot.eps and convert it to 3dplot.pdf.
- It is also possible to add LaTeX fonts to MATLAB graphics.
To do that, you need to add special LaTeX strings to the MATLAB plotting commands,
then export an EPS file as above, then convert it to PDF.
To insert these special strings into MATLAB plots, look in the help
documentation (online or at MathWorks Help and search for
Adding Text Annotations to Graphs.
Pictures & Images
- As noted above, to incorporate graphics files in LaTeX, you
must have the
graphicx package (which comes with MiKTeX)
and then use the \includegraphics[width=100mm]{3dplot.pdf}
command each time you wish to insert a graphic.
You can also use JPEG files:
\includegraphics[width=100mm]{mypic.jpg}
- You must use either
.jpg or .pdf formats.
If you have an application that generates other file formats, then you must convert
the file into pdf or jpg.
- For converting many different image file formats,
IrfanView is highly recommended.
- If you have any Encapsulated PostScript (
.eps) files, you have to convert them
into PDF format for pdflatex. See the example under the previous heading for instructions.
Diagrams
- The pstricks package
(alternate site)
allows you to create complex diagrams & drawings in LaTeX documents. It uses a LaTeX
syntax for defining the diagram and the PostScript language for
rendering the diagram.
It is very powerful but can take some time to create a diagram.
- The PGF package
(alternate site) provides
macros for picture drawing in LaTeX, and generates PDF output directly.
The advantage of this approach is that it allows you to embed LaTeX text, fonts, equations, or any LaTeX
typesetting commands into the diagram.
- A free drawing package for Windows is Paint.Net.
You can save in formats suitable for LaTeX or web documents.
For images and drawings, it is quite useful. It has no knowledge of LaTeX
as such, so you cannot embed LaTeX fonts in your diagrams.
- LaTeXPiX is an application
for Windows which allows you to draw PGF format graphics. It is less tedious
than manually entering object placement commands directly for PGF. You can embed all LaTeX
fonts and many drawing objects; as such, it is quite suitable for high-quality
line diagrams.
- If you wish to purchase a commercial drawing package,
SmartDraw
may be worth a look.
Back