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.

1 comment:

  1. Hi, thanks for the tip! I tried this and the but the resulting eps files seem to be okay in GSView. They are not, however, visible when I'm trying to include them to a tex file. I can only see blanch space in the dvi file instead of a figure. Did you happen to face this kind of problems?

    ReplyDelete