TransWikia.com

How can I produce s separate PDFs for each one of my floats, when their code isn't self-contained

TeX - LaTeX Asked on September 27, 2021

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.

3 Answers

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.

Answered by Pablo González L on September 27, 2021

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.

Answered by schoekling on September 27, 2021

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

usepackage[active,tightpage,floats]{preview}

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

usepackage[active,tightpage]{preview}
PreviewMacro[{*[][]{}}]{includegraphics}

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

Answered by Andreas Matthias on September 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP