Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have two pictures that I want to place as subparts using the floatrow package. The following example works if I add subcaptions to the parts, but does not if I leave them out.

I do not want any subcaptions for these parts. Am I doing something wrong or is this a bug?

Here is a minimal working example:

\documentclass{article}

\usepackage[demo]{graphicx}
\usepackage{caption,subcaption}
\usepackage{floatrow}

\begin{document}

    \begin{figure}
      \ffigbox{%
        \begin{subfloatrow}[2]%
          \ffigbox{%
            \includegraphics[width=3cm,height=3cm]{fig1}%
          }{
            %\subcaption{} %% does not work without
          }%
          \ffigbox{%
            \includegraphics[width=3cm,height=3cm]{fig2}%
          }{
            %\subcaption{} %% does not work without
          }%
        \end{subfloatrow}% 
      }{
        \caption{A caption}
      }
    \end{figure}

\end{document}
share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

You can use the \phantomcaption command to actually skip the caption of the subfigures.

\documentclass{article}

\usepackage[demo]{graphicx}
\usepackage{subcaption}


\begin{document}

\begin{figure}

\begin{subfigure}{0.5\textwidth}\centering
\includegraphics[width=3cm,height=3cm]{fig1}%
\phantomcaption
\label{fig:subfiga}
\end{subfigure}

\begin{subfigure}{0.5\textwidth}\centering
\includegraphics[width=3cm,height=3cm]{fig1}%
\phantomcaption
\label{fig:subfigb}
\end{subfigure}

\caption{A caption}
\label{fig:thefig}
\end{figure}

\end{document}

enter image description here

share|improve this answer
    
Unfortunately, the \phantomcaption commant does not work in combination with the floatrow package. –  Björn Steffen Jul 30 '12 at 15:15
    
@BjörnSteffen Do you need to use it? I've not used it in my answer anyway. –  percusse Jul 30 '12 at 15:18
    
Yes I could disable floatrow for the current figure and just use your solution. Maybe its an odd behavior (or bug) of the floatrow package that it always requires a caption?! –  Björn Steffen Jul 30 '12 at 15:24
    
@BjörnSteffen Or slowly getting outdated though it's a very nice package. I don't know if it is still actively supported. –  percusse Jul 30 '12 at 15:30
add comment

You can use the starred version of \subcaption with an empty argument; you will also need to correct the vertical spacing removing the default caption skip (-10pt):

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption,subcaption}
\usepackage{floatrow}

\begin{document}

\begin{figure}
\floatsetup[subfigure]{captionskip=-10pt}%
\ffigbox{%
  \begin{subfloatrow}[2]%
    \ffigbox{\includegraphics[width=3cm,height=3cm]{fig1}}{\subcaption*{}}%
    \ffigbox{\includegraphics[width=3cm,height=3cm]{fig2}}{\subcaption*{}}%
  \end{subfloatrow}% 
}{\caption{A test caption}}
\end{figure}

\end{document}

enter image description here

share|improve this answer
    
I hoped there is a cleaner way than using \vskip-1.5\baselineskip. But it seems that the floatrow package does not support float parts without captions inside (sub)floatrow. –  Björn Steffen Jul 30 '12 at 15:28
    
@BjörnSteffen apparently not; I've updated my answer with a cleaner approach (although some correction is still applied). –  Gonzalo Medina Jul 30 '12 at 23:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.