# how to create good-looking figures for a latex document

## introduction

By "good-looking" I mean

• the font for any text in the figures is the same as the font for the text of the article
• labels are consistently aligned relative to the objects to which they refer
• lines that are meant to be smooth are in fact smooth
• any shading exactly fills the areas it is supposed to fill
• plots of specific functions are accurate, not hand-drawn rough approximations.

In other words, good-looking figures are unlike many of the figures that appear in most economics journals. (Theoretical Economics is, of course, an exception.)

Creating good-looking figures for a LaTeX document is not difficult, mainly due to the existence of PSTricks and TikZ. I have used only PSTricks (which was developed much earlier than TikZ), and that is the system I discuss on this page.

Here's an algorithm.

1. Create a PSTricks LaTeX file for the figure.
2. Produce an encapsulated pdf file from the LaTeX code.
3. Insert an \includegraphics command in your LaTeX document that refers to the pdf file.
The time it takes to perform the first step is relatively short if you use an editor that automatically and instantly displays the output as you write the code. The only such editor I know is BaKoMa TeX Word, which is not free. (But then neither is dinner at Guy Savoy.) If you use BaKoMa, configure it so that the output is on one screen and the code is on the other screen. (See my review. If you have only one screen, get another one.) BaKoMa also makes the second step very easy.

If you do not have BaKoMa and do not possess an extraordinary ability to visualize the output of PSTricks code, you'll need compile and view your file repeatedly to make it look the way you want it. In the absence of BaKoMa, you'll also probably have to execute step 2 in the following somewhat roundabout fashion.

1. Compile the TeX file and output it as Postscript (PS).
2. Convert the PS file to Encapsulated Postscript (EPS).
3. Convert the EPS file to pdf.
However, although this route is roundabout, once you have the programs set up the steps take little time. Tools to perform the steps are freely available.
1. Any text editor can create and edit a TeX file. TeXstudio is well-suited to TeX.
1. Any TeX system (e.g. MiKTeX) can compile a TeX file and output it as PS. Editors like the TeXnicCenter provide a menu-driven interface to MiKTeX.
2. Ghostview converts from PS to EPS.
3. eps2pdf converts from EPS to pdf.

Rather than creating your figure in a separate file, you can include the PSTricks code directly in the file for your article. However, if you do so you will not be able to use pdftex to process your article, which means you will not be able to take advantage of the magic of the hyperref package.

## details

1. Creating the PSTricks file is what takes the time. Here is the template of a suitable file.
\documentclass[11pt]{article}
\usepackage{pstricks}

\pagestyle{empty}
\begin{document}

\color{white}
%\color{black} % activate to see bounding box
\fboxsep=0pt
\fbox{%
\psset{unit=1mm}
\color{black} % for text
% this figure is 50mm by 50mm
\begin{pspicture}(0,0)(50,50)
<PSTricks code>
\end{pspicture}
}

\end{document}

The easiest way to learn how to write the PSTricks code is to find an example that is similar to the figure you want to create. Here's a simple example.
% axes
\psline(5,50)(5,5)(50,5)
% label on y-axis, with the top right at (4,50)
\rput[tr](4,50){\shortstack{$\uparrow$\\$y$}}
% label on x-axis, with the right of the baseline at (50,0)
\rput[Br](50,0){$x\rightarrow$}
% a curve
\pscurve(5,10)(20,40)(50,5)

If you substitute that for the string <PSTricks code> in the template and open the resulting file in BaKoMa TeX Word, you'll instantly see the following figure.

For the full range of capabilities of PSTricks, see the PSTricks manual or Chapter 4 of The LaTeX Graphics Companion (ISBN-13: 978-0-321-50892-8).

2. You now have to create an encapsulated pdf file. (That is, a pdf file with the dimensions of your figure, not the dimensions of a full page.)

In BaKoMa, this step is trivial: choose File -> Export -> Postscript (DVIPS) ... and then check the box labeled "Create EPSF" and click "Generate". In a few seconds, an encapsulated pdf file will be created.

If you're using another editor, you'll probably need to go through three steps.

1. Produce a Postscript file from your LaTeX code. In the TeXnicCenter, for example, choose LaTeX => PS in the drop-down menu at the top of the screen, then "build" the file (Ctrl-F7).
2. Open the Postscript file in Ghostview and choose File -> PS to EPS -> Yes. Give the file an eps extension.
3. Open the eps file in eps2pdf and click "Convert".
3. At the appropriate place in your article, include code along the following lines.
\begin{figure}[htb]
\hspace*{\fill}
\includegraphics{<filename>.pdf}
\hspace*{\fill}