3

I have a really big report that I have been writing in latex. The report has a number of figures that have been included using either \includegraphics or Tikz drawings. The files that i include are either PDF, PNG, eps or JPEG files.

I have got a request to send the report to someone as a word document with figures sent as separate pdf files. I have managed to convert the pdf-report to word. I have also found that by using something like the following latex code, I can create each jpg/png image´s pdf (one by one).

\documentclass{standalone}

\usepackage[utf8]{inputenc} % set input encoding (not needed with XeLaTeX)
\usepackage{graphicx}
\usepackage{epstopdf} %support for eps.
\DeclareGraphicsExtensions{.eps,.ps,.pdf,.png,.jpg}
\usepackage{float} % figure placing [H]
\usepackage[english]{babel}

\title{}
\author{}

\begin{document}
\pagenumbering{gobble}

\minipage{1.08\textwidth}
\begin{figure}
\includegraphics[width=1\textwidth]{figures/a_jpg_figure.jpg}
\end{figure}
\endminipage

\end{document}

However, this takes a very long time and I haven't got that much time. So i wonder whether there is a tool that can be used to "compile" the latex file much like pdflatex but instead output only the "standalone" figures in the resulting pdf file (s) without (much) editing of my original latex file.

I am using Texpad with macTex on a mac :)

4

You can use the preview package.

Loading it with the options active,graphics,tightpage will produce a .pdf file where each page is one image.

Example:

\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}

\usepackage[active,graphics,tightpage]{preview}

\begin{document}

\lipsum[1]
\begin{figure}
\includegraphics[width=.2\textwidth]{example-image-a}
\caption{A figure}
\end{figure}

\lipsum[1]
\begin{figure}
\includegraphics[width=.3\textwidth]{example-image-b}
\caption{B figure}
\end{figure}

\lipsum[1]
\begin{figure}
\includegraphics[width=.1\textwidth]{example-image-c}
\caption{C figure}
\end{figure}

\end{document} 

Output:

enter image description here

Then you can use a tool to extract each page as a separate file.

If you want to extract your tikzpictures also, add in the preamble

\PreviewEnvironment{tikzpicture}
  • is that an extra square bracket after \PreviewEnvironment? – jjunju Mar 19 '15 at 10:57
  • \PreviewEnvironment works when placed after begin{document} but not in the preamble. In addition twhen you have a figure environment with more than two-includes, each sub figure goes to its page. – jjunju Mar 19 '15 at 11:11
  • 1
    @jjunju \PreviewEnvironment works in the preamble if put after loading preview. In regards of multiple \includegraphics you can try substituting the graphics option with floats so the whole contents of the figure environment goes on the same page. – karlkoeller Mar 19 '15 at 11:40

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.