Processing math: 0%
\newcommand{\n}{\hat{n}}\newcommand{\thetai}{\theta_\mathrm{i}}\newcommand{\thetao}{\theta_\mathrm{o}}\newcommand{\d}[1]{\mathrm{d}#1}\newcommand{\w}{\hat{\omega}}\newcommand{\wi}{\w_\mathrm{i}}\newcommand{\wo}{\w_\mathrm{o}}\newcommand{\wh}{\w_\mathrm{h}}\newcommand{\Li}{L_\mathrm{i}}\newcommand{\Lo}{L_\mathrm{o}}\newcommand{\Le}{L_\mathrm{e}}\newcommand{\Lr}{L_\mathrm{r}}\newcommand{\Lt}{L_\mathrm{t}}\newcommand{\O}{\mathrm{O}}\newcommand{\degrees}{{^{\large\circ}}}\newcommand{\T}{\mathsf{T}}\newcommand{\mathset}[1]{\mathbb{#1}}\newcommand{\Real}{\mathset{R}}\newcommand{\Integer}{\mathset{Z}}\newcommand{\Boolean}{\mathset{B}}\newcommand{\Complex}{\mathset{C}}\newcommand{\un}[1]{\,\mathrm{#1}}

   

Separating figures from a LaTeX document

-

Some academic journals, like PLoS One, require that you submit a final document as a single self-contained LaTeX file. All figures need to be submitted as separate image files, with any figures having multiple panels merged into a single image.

If you have a complex LaTeX source with a lot of \includes and figures, this is a pain to do by hand. It is possible to do this automatically.

   

Merging the file into one .tex file

Assume your paper is called paper.tex and currently has many \include or \input elements (e.g. \include{intro.tex}, \include{theory.tex}, ...)

First:

latex paper.tex
bibtex paper.tex

to generate paper.bbl.

To make sure the bibliography is included in the source, change your source of paper.tex to replace \bibliography{...} with \input{paper.bbl}.

Then use latexpand to include all \input{} and \include{} files, as well as the bibliography into one file.

latexpand paper.tex > paper_merged.tex

   

Separating the figures

The following is based on this StackOverflow answer by John Kormylo.

We can use the endfloat package to split out all floats into a separate file. In the preamble of paper_merged.tex, just after \documentclass, add:

\usepackage{endfloat}
\usepackage{graphicx}

\makeatletter
\efloat@openpost{fff}
\efloat@iwrite{fff}{\string\textwidth=\the\textwidth}
\makeatother

Run pdflatex paper_merged and you will get a new file paper_merged.fff that has all the code for floating figures in it.

   

The figure document

Create a new, blank document figures_separated.tex with the following contents:

\documentclass[multi=figure]{standalone}
\usepackage{graphicx}
\usepackage{amsmath} % packages I used in figures
\usepackage{subfig}

%% Include all custom macros used in figures here

\renewenvironment{figure}{\ignorespaces}{\unskip}
\renewcommand{\caption}[2][]{\ignorespaces}
\newcommand{\Figure}[1]{\ignorespaces}
\let\efloatseparator=\empty
\newcommand{\titlecaption}[2]{}
\begin{document}
\input{paper_merged.fff}
\end{document}

If you've used any custom macros or packages inside your floats, you'll need to include the relevant packages and add any of your own macros from paper_merged.tex into the preamble of separated_figures.tex.

Then:

pdflatex separated_figures.tex

to produce separated_figures.pdf which has each figure as a separate page.

   

Making TIFFs

PLoS One recommends all figures to be submitted as TIFF (unfortunately EPS is the only vector format PLoS support and it is not recommended...). imagemagick can convert this multi-page PDF to individual TIFF files in one go — if you configure it correctly!

magick convert -density 700 -scene 1 -background white -alpha remove \ 
       -alpha off  separated_figures.pdf  "output_figures/fig%d.tiff"

You should now have one TIFF file per figure, named output_images/fig1.tiff etc. You may need to adjust density if the images are too high or too low resolution — density 700 looked about right for my configuration.

That's it, you're done!

John H Williamson

GitHub / @jhnhw

formatted by Markdeep 1.18