I've written this document (say it's an article) with a bunch of float - figures and tables. Some of them are just \includegraphics, so the figure essentially exists outside as well inside the document, and can be easily made into a PDF if it isn't one already. But some of them depend heavily on code elsewhere in the document - earlier and later.

I'd like to be able see each of the figures and tables as a separate PDF. This is obviously possible theoretically (after all, typesetting into the main document is not so different from typesetting into a separate one) - but can I achieve this practically without writing lots of deep voodoo code?

Note: I don't mind whether this is done ex-post-facto on the final PDF, or as part of the production of that PDF (i.e. the regular execution of pdflatex or xelatex), or as a separate process on the sources.

  • 1
    I don't understand your question exactly, but you could just include your figures/tables in a new document, so that you have now new pdf's which only contain the objects that you want (in this case figure/tables) … – current_user Aug 4 '18 at 23:12
  • @current_user: No, I couldn't just place them in a new document - if their content or layout depends on previous or later LaTeX code. – einpoklum Aug 4 '18 at 23:15
  • 1
    I mean, that you just leave your main code how it is and just typeset a completely new document with the figures/tables … – current_user Aug 4 '18 at 23:16
  • You can use endfloat to extract all the source code for the figures or tables into separate files (.fff and .ttt). You could then run those through standalone, although IIRC the figure and table environments are not yet defined. – John Kormylo Aug 5 '18 at 0:49
  • 1
    unless the floats contain page references (which would be compromised by this suggestion), you might try forcing each float onto a page of its own, using \pagestyle{empty} for those pages. then the pdf file could be "taken apart", saving each float page as a separate file, and cropping these as appropriate for re-use. – barbara beeton Aug 6 '18 at 14:46

Take a look at preview.sty. To extract one float per page:


If you want to specify which macros or environments are considered for previewing, try something like:


Eventually if you really need to split the PDF into single pages, use e.g. ghostscript:

gs -sDEVICE=pdfwrite -dSAFER -o outname.%d.pdf input.pdf

If you have an TeXLive (updated) distribution and Perl you can use the ltximg script is designed for situations like this:

$ ltximg --subenv --imgdir=myfigs --prefix=fig --margin 10 --extrenv=figure,table -- -o file-out file-in.tex

I recommend you to read the package documentation if you are a tikz or pstricks user.


You could use the subfiles package and put each graphic (at least the non-self-contained ones) into a subfile. Then you can compile each graphic on its own in a separate pdf file.

For more info on how to write the subfiles see this help page or the subfiles doc.

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.