summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/beamer/beamerug-graphics.tex
blob: c040e5886079b0dc550737513de2c0c19a9797ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
% $Header: /cvsroot/latex-beamer/latex-beamer/doc/beamerug-graphics.tex,v 1.8 2004/11/01 16:18:44 tantau Exp $


% Copyright 2003, 2004 by Till Tantau <tantau@users.sourceforge.net>.
%
% This program can be redistributed and/or modified under the terms
% of the GNU Public License, version 2.

\section{Graphics}


\label{section-graphics}

In the following, the advantages and disadvantages of different
possible ways of creating graphics for \beamer\ presentations are
discussed. Much of the information presented in the following is not
really special to \beamer, but applies to any other document class as well.


\subsection{Including External Graphic Files Versus Inlines Graphics}

There are two principal ways of creating \TeX-documents that include
graphics: Either the graphic resides in an external file that is
\emph{included} or the graphic is \emph{inlined}, which means that
\TeX-file contains a bunch commands like ``draw a red line from
here to there.'' In the following, the advantages and disadvantages of
these two approaches are discussed.

You can use an external program, like |xfig| or the Gimp, to create a
graphic. These programs have an option to \emph{export} graphic files
in a format that can then be inserted into the presentation.

The main advantage is:
\begin{itemize}
\item
  You can use a powerful program to create a high-quality graphic.
\end{itemize}

The main disadvantages are:
\begin{itemize}
\item
  You  have to worry about many files. Typically there are at least
  two for each presentation, namely the program's graphic data file and the
  exported graphic file in a format that can be read by \TeX.
\item
  Changing the graphic using the program does not automatically change
  the graphic in the presentation. Rather, you must reexport the
  graphic and rerun \LaTeX.
\item
  It may be difficult to get the line width, fonts, and font sizes
  right.
\item
  Creating formulas as part of graphics is often difficult or
  impossible.
\end{itemize}

You can use all the standard \LaTeX\ commands for inserting graphics,
like |\includegraphics| (be sure to include the package
|graphics| or |graphicx|). Also, the |pgf| package offers commands for
including graphics. Either will work fine in most situations, so
choose whichever you like. Like |\pgfdeclareimage|,
|\includegraphics| also includes an image only once in a |.pdf| file,
even if it used several times (as a matter of fact, the |graphics|
package is even a bit smarter about this than |pgf|). However,
currently only |pgf| offers the ability to include images that are
partly transparent.

At the end of this section you will find notes on how to include
specific graphic formats like |.eps| or |.jpg|.

\lyxnote
You can use the usual ``Insert Graphic'' command to insert a graphic.

The commands |\includegraphics|, |\pgfuseimage|, and |\pgfimage| are
overlay-specification-aware in \beamer. If the overlay specification
does not apply, the command has no effect. This is useful for creating
a simple animation where each picture of the animation resides in a
different file:

\begin{verbatim}
\begin{frame}
  \includegraphics<1>[height=2cm]{step1.pdf}%
  \includegraphics<2>[height=2cm]{step2.pdf}%
  \includegraphics<3>[height=2cm]{step3.pdf}%
\end{frame}
\end{verbatim}


A different way of creating graphics is to insert
graphic drawing commands directly into your \LaTeX\ file. There are numerous
packages that help you do this. They have various degrees of
sophistication. Inlining graphics suffers from none of the
disadvantages mentioned above for including external graphic files,
but the main disadvantage is that it is often hard to use
these packages. In some sense, you ``program'' your graphics, which 
requires a bit of practice.

When choosing a graphic package, there are a few things to keep in
mind:
\begin{itemize}
\item
  Many packages produce poor quality graphics. This is especially true
  of the standard |picture| environment of \LaTeX.
\item
  Powerful packages that produce high-quality graphics often do not
  work together with |pdflatex|.
\item
  The most powerful and easiest-to-use package around, namely
  |pstricks|, does not work together with |pdflatex| and
  this is a fundamental problem. Due to the fundamental differences
  between \textsc{pdf} and PostScript, it is not possible to write a
  ``|pdflatex| back-end for |pstricks|.''
\end{itemize}

A solution to the above problem (though not necessarily the best) is
to use the \textsc{pgf} package. It produces high-quality graphics and
works together with |pdflatex|, but also with normal
|latex|. It is not as powerful as |pstricks| (as pointed
out above, this is because of rather fundamental reasons) and not as
easy to use, but it should be sufficient in most cases.

\lyxnote
Inlined graphics must currently by inserted in a large \TeX-mode
box. This is not very convenient.


\subsection{Including Graphic Files Ending \texttt{.eps} or \texttt{.ps}}

External graphic files ending with the extension |.eps| (Encapsulated
PostScript) or |.ps| (PostScript) can be included if you use |latex|
and |dvips|, but \emph{not} when using |pdflatex|. This is true
both for the normal |graphics| package and for |pgf|. When using
|pgf|, do \emph{not} add the extension |.eps|. When using
|graphics|, do add the extension.

If you have a |.eps| graphic and wish to use |pdflatex|, you can use
the program |ps2pdf| to convert the graphic to a |.pdf| file. Note,
however, that it is often a better idea to directly generate a |.pdf|
if the program that produced the |.eps| supports this.


\subsection{Including Graphic Files Ending \texttt{.pdf},
  \texttt{.jpg}, \texttt{.jpeg} or \texttt{.png}}

The four formats |.pdf|, |.jpg|, |.jpeg|, and |.png| can only be
included by |pdflatex|. As before, do not add these extension when
using |pgf|, but do add them when using |graphics|. If your graphic
file has any of these formats and you wish/must you |latex| and
|dvips|, you  have to convert your graphic to |.eps| first.


\subsection{Including Graphic Files Ending \texttt{.mps}}

A graphic file ending |.mps| (MetaPost PostScript) is a special kind
of Encapsulated PostScript file. Files in this format are produced by
the MetaPost program. As you know, \TeX\ is a program that converts
simple plain text into beautifully typeset documents. The MetaPost
program is similar, only it converts simple plain text into beautiful
graphics.

The MetaPost program converts a plain text file ending |.mp|
into an |.mps| file (although for some unfathomable reason the
extension is not added). The |.mp| file 
must contain text written in the MetaFont programming language. Since
|.mps| files are actually also |.eps| files, you can use the normal 
|\includegraphics| command to include them.

However, as a special bonus, you can \emph{also}
include such a file when using |pdflatex|. Normally, |pdflatex| cannot
handle |.eps| files, but the |.mps| files produced by MetaPost have
such a simple and special structure that this is possible. The |graphics|
package implements some filters to convert such PostScript output to
\pdf\ on-the-fly. For this to work, the file should end |.mps| instead
of |.eps|. The following command can be used to make the |graphics|
package just \emph{assume} the extension |.mps| for any file it knows
nothing about (like files ending with |.1|, which is what MetaPost
loves to produce): 
\begin{verbatim}
\DeclareGraphicsRule{*}{mps}{*}{}
\end{verbatim}

This special feature currently  only works with the |graphics|
package, not with |pgf|.



\subsection{Including Graphic Files Ending \texttt{.mmp}}

The format |.mmp| (Multi-MetaPost) is actually not format that can be
included directly in a \TeX-file. Rather, like a |.mp| file, it first
has to be converted using the MetaPost program. The crucial difference
between |.mp| and |.mmp| is that in the latter multiple graphics
can reside in a single |.mmp| file (actually, multiple graphics can
also reside in a |.mp| file, but by convention such a file is called
|.mmp|). When running MetaPost on a |.mmp| file, it will create not a
single encapsulated PostScript file, but several, ending |.0|, |.1|,
|.2|, and so on. The idea is that |.0| might contain a main graphics
and the following pictures contain overlay material that should be
incrementally added to this graphic. 

To include the series of resulting files, you can use the command
|\multiinclude| from the |mpmulti| or from the |xmpmulti| package. How
this program works is explained in Section~\ref{section-mpmulti}.





%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "beameruserguide"
%%% End: