In my document I'm embedding figures using the following code:
\begin{figure}[!t]
\centering
\def\svgwidth{1.2\columnwidth}
\resizebox{\columnwidth}{!}{
\endlinechar=255\relax
\begin{picture}(1,0.63636365)
\put(0,0){\includegraphics[width=\unitlength]{figure.eps}}
\put(0.50454546,0.58636365){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{some text $ax^2+bx+c=0$.}}}
\end{picture}
}
\caption{Caption.}
\label{fig:figure}
\end{figure}
Where the image (figure.eps
) contains no text and all annotations are added on top of the image using \put
commands.
This method works very well (annotations can include any LaTeX macros, which is extremely useful) as long as I'm sticking to TeX. Now, however, I'd like to take the resulting figures (preferably in a vector format) and put them in some other tool.
Questions:
- Is there any way of outputting these
float
s into PDF files with no margins, captions and with page dimensions equal to the specifiedfloat
size? I imagine I'd have to somehow wrap eachfloat
in a.tex
file with a custom preamble. - Is it possible to automate this process so that if I want to dump all my N figures to PDFs I don't have to repeat the step (1) N times.
Best Answer
In general I recommend you to place all your complicated figures into separate files and use e.g. the
standalone
class to be able to compile them separatly and then\input
them easily in the main document with thestandalone
package.For your existing document you can use the
preview
package (which is used internally bystandalone
). It only compiles things wrapped in apreview
environment and every such environment as a page. With thetightpage
option you get tight pages as I requested.I would use code like the following to redefine
figure
to usepreview
environments and to disable (or include) the\caption
. The resulting PDF should have one picture per page. You can then use thepage=<number>
option of\includegraphics
to include it or split it into several PDFs using tools likepdftk allfigures.pdf burst output figure%02d.pdf
or Ghostscript.