Showing posts with label eps. Show all posts
Showing posts with label eps. Show all posts

Friday, 4 November 2011

Making single eps file from latex figure

Journals, being the cash-strapped money-printing machines that they are, like to have submissions written in LaTeX, but only in the simplest LaTeX possible.

I like to use LaTeX as much as possible when annotating figures produced by other programs, as then the fonts in my document match those in my figures. This makes it sensible to compose figures within the LateX figure environment. A simple example which collects some sub-figures then labels them would be:

\begin{figure}
\begin{picture}(86,175)(0,0)
  \put(0,140){\includegraphics[width=86mm]{figures-a}}%
  \put(80,144){a}
  \put(0,75){\includegraphics[width=86mm]{figures-b}}%
  \put(80,78){b}
  \put(0,108){\includegraphics[width=86mm]{figures-c}}%
  \put(80,111){c}
\end{picture}
\caption{A multi-figure figure}
\label{f-FigureLabel}
\end{figure}

For final submission, journals like to have single eps files for each figure, so we need a way to make a single eps file from this. The trick is to use the preview and standalone environments. Create a file for the figure (e.g. fig-01.tex) with contents:

\documentclass{standalone}
\usepackage[dvips]{graphicx}
\usepackage[T1]{fontenc}
\usepackage[active,tightpage]{preview}

\begin{document}%
\begin{preview}%
%
\resizebox{86mm}{!}{%
% put \picture{} here
}%
%
\end{preview}%
\end{document}

do not include the \caption or \label, just the code for the figure itself.

Now run:

latex fig-01.tex --output-format=dvi
dvips -E -I 3c -o fig-01.eps fig-01.dvi

to produce a single eps file with cropped boundaries. This can then be included in the main document's figure directly.