I saw a similar question few years ago here, however there is no effective answer.
The question is it possible to automatically export every figure and table in a specific document to separate files (with or without the figure/table caption). Following are a more specific list of requirements.
- Export figures created with tikz/pgfplots, to a separate pdf files (with and without the caption, and to be numbered as in the document)
- Export tables that uses tabular, tabularx, and longtable (with and without the caption)
- When extracted is there a way to remove/hide (and its caption) the figure/table from the document while preserving references to that figure/table.
I have created a sample document below which contains a figure and a table so contributers can use it in their answers.
Code:
\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{tabularx}
\title{example}
\author{John Doe}
\begin{document}
\maketitle
\begin{abstract}
\lipsum[1]
\end{abstract}
\section{a Section}
In Figure \ref{fig:one} \lipsum[1]
\begin{figure}[ht]
\centering
\begin{tikzpicture}
\node(a)[draw, rectangle, ultra thick] at (0,0) {Test};
\node(b)[draw, rectangle, ultra thick] at (2,2) {Test};
\draw[-latex](a)--(b);
\end{tikzpicture}
\caption{Sample caption for figure 1}
\label{fig:one}
\end{figure}
\section{another Section}
\begin{table}
\begin{tabularx}{\textwidth}{llX}
\hline
colA&colB&colC \\
\hline
test&test&test\\
\hline
\end{tabularx}
\caption{Table A}
\label{table:A}
\end{table}
\end{document}
\documentclass{standalome}[multi={figure}], although you would need to define a figure environment wrapper. – John Kormylo Feb 16 '18 at 15:45