I use the caption
and subcaption
packages to set up my figures. Sometimes I don't want to display any (sub-) captions at all.
I tried \captionsetup[subfigure]{labelformat=empty}
with an empty caption (\caption{}
) which works, but the problem is, that the vertical space between the main-caption and the images is now too big, because the space for the sub-captions is still "reserved".
How do I fix this? I have a feeling it might be possible with the \DeclareCaption-Format
command of the caption
package, but I don't know how.
\documentclass{article}
\usepackage[list=false]{subcaption}
\usepackage{caption}
\usepackage[final]{graphicx}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.34\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{}
\end{subfigure}
\begin{subfigure}[b]{0.34\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{}
\end{subfigure}
\caption{With caption labels enabled.}
\end{figure}
\begin{figure}
\centering
\captionsetup[subfigure]{labelformat=empty}
\begin{subfigure}[b]{0.34\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{}
\end{subfigure}
\begin{subfigure}[b]{0.34\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{}
\end{subfigure}
\caption{With Subcaptions disabled. Spacing looks bad.}
\end{figure}
\end{document}
Best Answer
According to Zarko, you must delete the extraneous empty
caption{}
where you dont want to have neither caption nor space (ie on line 23 and 27). By this way your\captionsetup[subfigure]{labelformat=empty}
is not needed.The more elaborate suggestion of Bernard dont resolve the problem without removing the unwanted
caption{}
, as some extra space is still added.