[Previous] [Up] [Next]
Go backward to Keyboard shortcuts
Go up to Top
Go forward to Preparing slides with Ipe

Ipe and LaTeX

Ipe files (i.e. those with a file extension of .ipe) are Encapsulated Postscript files, and can be used in any situation where such a file can be used--they can be sent to the printer directly, they can be previewed with ghostview or any other Postscript previewer, or they can be included by a package such as showcase. You could also include an Ipe file into a LaTeX document using the epsf.sty package. However, if you do any of this, the text information in your Ipe file will be lost--the text in your Ipe file is not stored as Postscript.

  The proper way to include an Ipe file picture.ipe into your LaTeX document is as follows: (The syntax given here is for LaTeX2e. If you are still using LaTeX 2.09, you will need to replace \documentclass by \documentstyle.)

  \documentclass{article}
  \def\Ipe#1{\def\IPEfile{#1}\input{#1}}
  \begin{document}
  ...
  \begin{figure}[h]
    \begin{center}
      \Ipe{picture.ipe}
    \end{center}
    \caption{This is your Ipe figure}
    \label{fig:picture}
  \end{figure}
  ...
  \end{document}
Note that the Ipe file is simply \input into the LaTeX document. In fact, an Ipe file is not only a Postscript file, it is at the same time a legal LaTeX file! (How this is done).

The picture will be included at its natural size. This is the most elementary way of including an Ipe drawing in a LaTeX document, and it is also the recommended one. You do not need any special style files, only the simple definition of the \Ipe macro, somewhere in your preamble. (This is necessary because the Ipe drawing has to know its own name, and TeX doesn't supply this information.)

The Ipe drawing itself is a single LaTeX picture-environment, and can be used whereever such an environment is used. There is no need to enclose it in a center environment, and in fact you can make a little drawing and use it just like a letter or as your End Of Proof symbol.

Note that the expression "natural size" above can be taken literally. The size of the drawing, as it appears on the printed document, is the same as the size on your screen--you can measure the size of a drawing directly on the glass surface in front of you. If you need to change the size of the drawing, the recommended procedure is to load it into Ipe, and to scale it from there. This way, you can change the text fonts properly at the same time.

  Sometimes, however, it will be necessary to include an Ipe drawing at a size different from its natural size. This can easily be done using the commands in the LaTeX package ipe.sty that comes with Ipe. Note that using this package has the disadvantage that whenever you send Ipe drawings to your friends or colleagues, you must not forget to send the ipe.sty file as well, since it is not part of the standard LaTeX distribution. (The ipe.sty file can be found in your system's TeX macro directory, often called /usr/local/lib/tex/inputs (/net/lib/tex/inputs/latex2e on Utrecht systems). Ask your system manager or TeX guru for details.)

  Here is an example that scales an Ipe drawing to 60% of its natural size. (For LaTeX 2.09, replace the first two lines by \documentstyle[ipe]{article}.)

\documentclass{article}
\usepackage{ipe}  
\begin{document}
...
\begin{figure}[h]
  \begin{center}
    \IpeScale{60}
    \Ipe{picture.ipe}
  \end{center}
  \caption{This is your Ipe figure}
  \label{fig:picture}
\end{figure}
...
\end{document}
Note three changes with respect to the previous example: first, we need to include the ipe package. This makes the definition of \Ipe superfluous, it is already in the package.

Finally, the macro \IpeScale is called to scale the following picture to 60% of its natural size. If you want to scale only a single picture, place this line inside the center environment, so it will have no influence elsewhere. If you want to scale all pictures in your file, put the \IpeScale line in the preamble.

  Instead of specifying a percentage, you can also specify the exact width that the picture should have in your document, as in

\IpeFit{5cm}
  You could also specify the width in terms of LaTeX parameters, such as \textwidth. Then scaling will depend on the document class and options used when processing the LaTeX document:
\IpeFit{\textwidth}
  These two macros are actually just two special cases of a much more general concept, based on the \IPEsize macro. This macro is called by the IPE file when it is processed by LaTeX, with the actual picture size as parameters. The macro is then responsible to set \IPEscale, \IPEwidth and \unitlength. The latter determines the interpretation of coordinates in LaTeX's picture environment, and therefore the positioning of text objects. The value of \IPEscale is passed to dvips to scale the Postscript data.

Using this concept, you could implement any kind of scaling behavior, like scaling to match a given height of the picture. Look at the definitions in ipe.sty, and, if that is not sufficient, ask your local guru to help you. In an extreme emergency, you could mail me for help.

  There is another topic which needs to be discussed. Text objects cannot be scaled or stretched within an Ipe picture. Therefore, every text item has some legal font size installed on your system. However, when you scale the whole picture with \IpeScale or \IpeFit, this nice property is spoiled. After scaling a picture to 73% of its original size, say, a letter in 12pt font should be in a strange 8.76pt font, which is very unlikely to be installed on your LaTeX system.

  There are two solutions to this problem. The first one is simple: Just don't scale text! This can be achieved by adding the following command to your LaTeX document.

\IpeNoScaleFont
(As before, you can either do this locally for one picture, or globally for the whole file, or any combination of these). This is not as stupid a solution as it might seem. Sometimes you scale several pictures in the same document by slightly different factors between, say, 85% and 115%, to achieve a pleasing global impression. Then it would actually look bad if the same 10pt font was scaled differently in different pictures.

However, if you scale by a factor not close to 100%, this is not desirable. The standard behavior of ipe.sty is therefore the following: (You can revert to this standard behavior using \IpeScaleFont) The fontsize specified in the text object is multiplied by the scale factor, and then the nearest size in the list

5, 6, 7, 8, 9, 10, 11, 12, 14.4, 17.28, 20.74, and 24.88
is used. (These are the sizes usually installed on LaTeX systems).

  If you need a behavior different from the above, you will have to redefine the \IPEcolfs macro. In fact, every Ipe text object is passed to LaTeX as follows.

\IPEcolfs{color}{size}\rm
(The \rm gets replaced by \it or \bf if these fonts are used). It is fully up to the macro \IPEcolfs to set up the desired fonts. Look in ipe.sty for the default definition which obeys the commands \IpeScaleFont and \IpeNoScaleFont.

  Note that the standard definition of \IPEcolfs is based on NFSS, LaTeX's new font selection scheme. If you are using an old version of LaTeX, this macro will not work, and all text in the figure will be set in the size active outside the picture environment. You can still use size declarations in the text objects, of course. If you encounter this situation, it is strongly suggested that you upgrade to a newer version of LaTeX.

See the next chapter for a description of the document class mipe.cls that redefines \IPEcolfs such that font sizes larger than 25pt can be used.

  The previous discussion has assumed that you use the dvips program to convert your DVI-files to Postscript: By default, both the .ipe-files and the ipe package generate \specials that can be interpreted by dvips (and by recent releases of the xdvi previewer, by the way).

However, if you are using LaTeX2e, there is an easy way to create portable files that will work with other converters: Simply include the LaTeX2e package graphicx before using the ipe package. The ipe package will then automatically use the \includegraphics command defined by the graphicx package. By giving the proper option to the graphicx package, you can generate a DVI-file suitable for the converter of you choice.

The same works for Ipe's text color handling: Use the LaTeX2e color package to create portable color \specials, or use ipe's nocolor option to turn off text color altogether.

As an illustration, let's show how to use an Ipe file with OzTeX:

\documentclass{article}
\usepackage[oztex]{graphicx}
\usepackage[nocolor]{ipe}
\begin{document}
...
Or with emtex:
\documentclass{article}
\usepackage[emtex]{graphicx}
\usepackage[emtex]{color}
\usepackage{ipe}
\begin{document}
...

[Previous] [Up] [Next]