In my document I'm embedding figures using the following code:

      \put(0.50454546,0.58636365){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{some text $ax^2+bx+c=0$.}}}

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.


  1. Is there any way of outputting these floats into PDF files with no margins, captions and with page dimensions equal to the specified float size? I imagine I'd have to somehow wrap each float in a .tex file with a custom preamble.
  2. 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.

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 the standalone package.

For your existing document you can use the preview package (which is used internally by standalone). It only compiles things wrapped in a preview environment and every such environment as a page. With the tightpage option you get tight pages as I requested.

I would use code like the following to redefine figure to use preview environments and to disable (or include) the \caption. The resulting PDF should have one picture per page. You can then use the page=<number> option of \includegraphics to include it or split it into several PDFs using tools like pdftk allfigures.pdf burst output figure%02d.pdf or Ghostscript.



        \renewcommand\caption[2][]{}% or
        %\def\@captype{figure}% If you want to include the caption


text text text text 

    \rule{5cm}{8cm}% dummy replacement
    \caption{some caption}

text text text text 

    \rule{8cm}{5cm}% dummy replacement
    \caption{some caption}

text text text text 

| improve this answer | |
  • thanks for the detailed answer. It works almost perfectly. "Almost" because there seems to be some problems with resizebox - it works fine up to width of ~12cm. Also, another, possibly related issue is that if I enable captions (as in your comment) all page widths are fixed to 4.79in (12.16cm). – Andrzej Sep 28 '11 at 13:01
  • @Andrzej: You need to comment out the new-line character which is taken as a space, i.e. write \resizebox{\columnwidth}{!}{% instead of \resizebox{\columnwidth}{!}{. This is a common mistake. Or use the adjustbox package with \begin{adjustbox}{width=\columnwidth} <content> \end{adjustbox} instead. – Martin Scharrer Sep 28 '11 at 14:15
  • @Andrzej: The \caption creates a new paragraph which is \linewidth wide. You could add a {minipage}{<your linewidth>} environment to change that, but I would not include the captions anyway. – Martin Scharrer Sep 28 '11 at 14:16
  • thanks, it works. I had to comment out all whitespaces (not just after resizebox) but that is not a problem. Thanks again, problem solved. – Andrzej Sep 28 '11 at 15:20

If you're OK with your procedures so far, I suppose you could set \pagestyle{empty} in the preamble, have only one float per page by inserting a \clearpage instruction after each float, and finally break up the resulting n-page pdf file into n separate pdf files. (Setting the pagestyle to empty will simplify cropping each page.)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.