# Preamble control to omit the figure caption of a figure file that contains a caption

I have a tex document made up of many tex files. Each figure I prepare is in it's own tex file. Specifically, this file would contain the figure environment, centering requests, the panel of subfloats and labels, and the figure caption.

I use tikz to overlay figure numbers and scalebars and other annotations because it makes for highly reproducible, well aligned annotations that are easily customized. Rather than repanel this figure with photoshoped labels and scale bars I'd like to export this paneled figure. Since saving a tikz figure is really quite complex (there are several questions on this site that I have never successfully implemented) I would settle for creating a new main tex document that create a pdf of only the specified figure using input of the same tex file the figure was assembled in.

This is all easily enough but I would like this second file to ignore the captions. Note, separating the figure calls and captions are not a convenient option.

Can I import the caption package, then redefine it to ignore it and gobble the white space between the figure and the now omitted caption so my pdf is as tightly cropped to the figure as possible?

A MWE of a sample figure tex file:

\begin{figure}
\begin{center}%

\subfloat{\includegraphics[keepaspectratio,width=0.3\textwidth]{example-image-a}}\hspace{3 mm}
\subfloat{\includegraphics[keepaspectratio,width=0.3\textwidth]{example-image-a}}\hspace{3 mm}
\subfloat{\includegraphics[keepaspectratio,width=0.3\textwidth]{example-image-a}}\hspace{3 mm}
\LineSep
\subfloat{\includegraphics[keepaspectratio,width=0.3\textwidth]{example-image-a}}\hspace{3 mm}
\subfloat{\includegraphics[keepaspectratio,width=0.3\textwidth]{example-image-a}}\hspace{3 mm}
\subfloat{\includegraphics[keepaspectratio,width=0.3\textwidth]{example-image-a}}\hspace{3 mm}

\caption[NO LIST OF FIGURES OR LEGEND EXPECTED]{%
\label{fig:Sample}
General summary statement / figure title:
With a small caption here describing the content of (A) through to (F).
}

\end{center}
\end{figure}


This file may be called from a main MWE document (in one version there would be the entire document assembly, and the other would contain a block of code to tell the document to skip the captions):

\documentclass{article}

\usepackage{xparse}         % can exclude expl3, xparse loads it
\usepackage{xpatch}         % can exclude etoolbox, xpatch loads it

\usepackage{graphicx}
\usepackage[format=hang,singlelinecheck=0,font={sf,small},labelfont=bf]{subfig}

%http://tex.stackexchange.com/questions/75014/is-it-possible-to-make-a-reference-to-a-subfigure-to-appear-figure-2a-with-cle
\captionsetup[subfigure]{subrefformat=simple,labelformat=simple,listofformat=subsimple}
\renewcommand\thesubfigure{\Alph{subfigure}}

\pagestyle{empty}

\DeclareDocumentCommand{\LineSep}{O{5mm}}{\par\vspace*{\dimexpr-\baselineskip+#1}}

\begin{document}

\input{FigureDoc.tex}

\end{document}

• – Werner Oct 31 '16 at 23:28
• So you want to just gobble the whatever is contained in \caption[.]{..} as well as the preceding white-space? – Werner Oct 31 '16 at 23:29

Since you're loading xparse (and possibly caption), add
\RenewDocumentCommand{\caption}{s o m}{}

to at the end of your preamble. This will gobble all arguments required by \caption (even if caption is loaded or not).
• I'd drop the use of the center environment as that adds additional space around your image (going against your attempt to have things "tightly cropped"). Rather use the \centering switch. – Werner Nov 1 '16 at 1:13