Graphics In Latex Article Index for
Graphics
Website Links For
Graphics
 

Information About

Graphics In Latex







INTRODUCTION


Inserting Graphics into a LaTeX document is easy once you know how to do it. The problem is that when you start out you have no clue of which software packages you should be using to make cool drawings because there are tons of different packages out there. I have tried out several ways but finally came back to using the PSTEX file type that I export from XFIG .


INSTALLING XFIG



Linux Based installation


I am using the Ubuntu (or Kubuntu) distribution which enables you to easily install packages using the Synaptic Package manager under Ubuntu (Gnome desktop) or Adept under Kubuntu (KDE Desktop). Open these download managers and look for the XFIG package, select it and apply changes. XFIG will automatically be downloaded and installed. How much easier could it be!


Windows based installation using Cygwin


This is not the easiest way to do things but it's pretty straight forwards anyway. Go to the official Cygwin website and download Cygwin-X. If you don't want to be bothers and you have a good internet connection and about 2 gigabyte of space on you computer just select all the packages when Cygwin asks you which packages you wan't to install. That's what I did at least. Of course it would be much smarter to only install the XFIG package that you are interrested in!

To run XFIG, you need to first start the "Start X - Server" (not much happens, don't worry) then launch "xterm". This will bring up a terminal. In this terminal type "xfig" (without the double quotes of course) and press return. XFIG should be up and running! Wasn't that hard was it?


CREATING A SAMPLE FIGURE WITH XFIG



EXPORTING THE .FIG FILE TO THE COMBINED PSTEX_T AND PSTEX FILES


Once your graphic is saved as an test.fig file you need to export it using the FILE>EXPORT drop down menu from the main XFIG window and then selecting the "Combined PS/Latex (both parts)" in the language drop down list. If you don't change any other settings, two files will be created in the same directory as you test.fig file once you click on EXPORT: a test.pstex_t and a test.pstex file if your initial fig file was called test.fig. You can of course change the directory so that your files are put in the right place and change some other settings. I try to not change to many things, keep life simple.


INCLUDING THE .PSTEX_T FILE INTO YOUR LATEX DOCUMENT


\begin{figure} {Link without Title}
\begin{center}
\input{./xfig/test.pstex_t}
\caption{This is the caption of my figure}
\label{fig:test}
\end{center}
\end{figure}


Placing the graphic where you want it in the document

I like to have my graphic inclusion done where I put my code and not have the graphic shifted somewhere else in my document, that's why I use the option in '''\begin{figure}[H '''. To have the taken into account, you need to include '''\usepackage{float}''' at the begining of you .tex file or not it won't work. You can also play around with other options like '''[htpb ''' etc.


Keeping yourself organized

I also like to keep order in my files so I usually put all my .fig, pstex_t and pstex in a separate folder located at the root of my working directory, (ie. ./xfig) that's why I specify the path when using the input command: \input{./xfig/test.pstex_t}. Similarly, you will also have to sepcify where these files are so that Latex find's them with the following command that also hase to be put at the beginning of your .tex file: '''\graphicspath'''


Compiling you document with .pstex_t and .pstex inclusions

Ok one last thing, since the .pstex file is a Postscript file you will need to compile from Latex into PS then into PDF because PdfLatex won't work directly. This is a small disadvantage that shouldn't bother you to much because latex editors like TeXnicCenter have a build in function that does this all alone.


SEE ALSO



EXTERNAL LINKS