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:


    \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}  
    \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}  

General summary statement / figure title:
With a small caption here describing the content of (A) through to (F).


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):


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








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

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.