background image
to plot the points in the file "xxx.dat". But usually we would like to add some title etc. See
the examples of code and output which is found in section
3
.
After writing your gp-file we process it with the command
gnuplot xxx.gp
It will then run the commands in the file and if the terminal is set to fig as written above, it
will be saved as a fig-file.
2.3
Xfig
This step can luckily be done automatically. If we have created the file xxx.fig we just type, in
a terminal,
fig2dev -L pdftex xxx.fig xxx.pdf
fig2dev -L pdftex_t -p xxx.pdf xxx.fig xxx.pdf_t
The command on the first line produces the PDF file without any L
A
TEX commands, while the
second line produces the text. The filename after -p should be the name of the file we want
overlayed, including the relative path from your TEX document to the pdf-file. The xxx.pdf t
file contains a picture environment inserting the pdf image file and your text strings that will
be processed by X E TEX. If you need any special character like ¨u¨a¨o you’ll need to edit the file
manually since fig2dev can only handle ascii. fig2dev also has some other options, like setting
the font size with -s 10 for 10pt fonts, but please have a look in the manual.
If any changes (of design, not results, I hope!) is necessary, editing the file in Xfig is also
possible. Export as Combined PDF/Latex (both parts). However, if you save your files to a
different directory (usually a subdirectory) than your TEX document, the image won’t show up.
The reason for that is that the relative path is wrong, and X E TEX can’t find it unless you have
informed X E TEX of where to find it. It can be done in two ways:
1. Using the command
\graphicspath{{path1/}{pathN/}}. Then X E TEX will look for the
graphics file, ie. PDF-file, in these directories.
2. Setting the path in the pdf t-file. This requires less memory and is faster than the above
method, but if you move the files they must be regenerated or edited. But since the
pdf t-file is a text file you can edit it in any text editor to make X E TEX find the PDF!
It is actually possible to use both methods, like in this document!
2.4
X E TEX/pdfTEX
Importing into X E TEX/pdfTEX is now easy. Just do as you would do with any image, but
exchange
\includegraphics{file} with \input xxx.pdf t, like this:
\begin{figure}[h]
\begin{center}
%\resizebox{14cm}{!}{\input xxx.pdf_t} % For resizing!
\input xxx.pdf_t
\caption{A nice figure.}
\label{fig:xxx}
\end{center}
\end{figure}
It depends on graphic (or graphicx) package, so include one of those packages in the preamble,
as well as the color package if you’re doing colored plots.
2.5
Summarize
There are quite a few steps to go through. Luckily, I have made a script that will make it easier
to generate figures, once the gnuplot file is made. It is found in appendix
B
and free to use.
You will soon realize that a lot of files will be created. For each figure at least four files is
necessary – data-file(s), fig, pdf, pdf t. If it is just one figure in the document it won’t
be so messy, but with many plots it can be a good idea to keep them in separate directories.
However, as mentioned above, the pdf t-file must contain the path to the pdf-file or otherwise
use of command
\graphicspath is necessary. It is also covered a bit more in appendix
B
.
3