4

I am using .pdf_tex files to insert and label figures in LaTeX:

\begin{figure}
    \centering
    \graphicspath{{Graphics/FiltersCa/}}
    \input{Graphics/FiltersCa/COMB_filter_activeZ2b.pdf_tex
    }
    \caption{...
    }
    \label{fig:FiltersCa}
\end{figure}

Is it possible to export each figure as a separate PDF-file?

naphaneal
  • 2,614
Markus
  • 63

2 Answers2

7

The endfloat package will export all the figures (LaTeX source) to a .fff file.

\documentclass{article}
\usepackage{endfloat}
\usepackage{graphicx}

\makeatletter
\efloat@openpost{fff}
\efloat@iwrite{fff}{\string\textwidth=\the\textwidth}% pass \textwidth to fff file
\makeatother

\begin{document}

\begin{figure}
    \centering
    \includegraphics{example-image}
    \caption{Test caption}
\end{figure}

\end{document}

Standalone can create a PDF file containing one figure/page. Labels and counter values will be lost.

\documentclass[multi=figure]{standalone}
\usepackage{graphicx}

\makeatletter
\renewenvironment{figure}%
{\def\@captype{figure}%
\minipage{\textwidth}}%
{\endminipage}
\makeatother

\let\efloatseparator=\empty

\begin{document}
\input{test5.fff}
\end{document}

demo


This version loses the caption.

\documentclass[multi=figure]{standalone}
\usepackage{graphicx}

\renewenvironment{figure}{\ignorespaces}{\unskip}
\renewcommand{\caption}[2][]{\ignorespaces}
\let\efloatseparator=\empty

\begin{document}
\input{test5.fff}% previously created fff file
\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Almost perfect solution. Is there now a simple way to suppress the caption of each figure with one command at the beginning of the document. I would like to have the figures in the final PDF without caption and don't want to change everywhere caption to caption*.

    <\captionsetup{format=empty}> doesn't work for me :/

    – Markus Mar 26 '18 at 19:57
  • 1
    \renewcommand{\caption}[2][default]{\ignorespaces} should take care of it. If you are losing the caption, you don't need the minipage either. – John Kormylo Mar 26 '18 at 21:17
2

Quick update with my current work-around (figure-by-figure):

  • I open the original PDF-output with Inkscape (I recommend Poppler/Cairo import). You can select the page containing a specific figure.

  • Create an rectangle (F4) that outlines the region of the page, you would like to export (Figure with or without caption).

  • Press Shift and click on the imported PDF-page and the rectangle.

  • Right mouse click on the rectangle and choose Set Clip

  • Press Shift+Ctrl+D, click on Resize page to content... in the Custom size section and click Resize page to rawing or selection

  • In the File-menu, you can safe it as a PNG or PDF file. For PDF I would suggest to Convert text to path in order to maintain the original LaTeX font.

Best wishes, Markus

Markus
  • 63