Como posso obter a rotulagem correta de subfiguras com subfig e floatrow?

Como posso obter a rotulagem correta de subfiguras com subfig e floatrow?

Estou usando subfige floatrowpara gerenciar subfiguras. Sem floatrow, tudo funciona bem, mas preciso floatrowalinhar facilmente as legendas, conforme subfigexplica o manual.

Adaptando o exemplo da página 37 do manual e comalguma ajuda de Gonzalo Medina, eu tenho este código:

\documentclass{article}
\usepackage{graphicx,subfig}
\usepackage[heightadjust=all,valign=c]{floatrow}
\usepackage{fr-subfig}

\begin{document}

  \thisfloatsetup{subfloatrowsep=none}
  \begin{figure}[!htbp]
    \captionsetup[subfigure]{justification=centering}
    \floatbox{figure}{%
      \caption{%
        Components of the system: Penguins (\ref{fig:a}), Jumpers (\ref{fig:b}), Thingies (\ref{fig:c}), Cabbages (\ref{fig:d}) and Nuclear Warheads (\ref{fig:e})%
      }\label{fig:x}%
    }{%
  \begin{subfloatrow}%
    \subfloat[Penguins were here and here and here]{%
      \label{fig:a}\includegraphics[height=.1\textheight]{example-image-a}}
    \qquad
    \subfloat[Penguin]{%
      \label{fig:b}\includegraphics[height=.15\textheight]{example-image-b}}
    \qquad
    \subfloat[Penguin]{%
      \label{fig:c}\includegraphics[height=.125\textheight]{example-image-a}}
  \end{subfloatrow}

  \begin{subfloatrow}
    \subfloat[Penguin]{%
      \label{fig:d}\includegraphics[height=.15\textheight]{example-image-b}}
    \qquad
    \subfloat[Penguins were here, there and everywhere!]{%
      \label{fig:e}\includegraphics[height=.2\textheight]{example-image-a}}
  \end{subfloatrow}}
\end{figure}
\ref{fig:x} \ref{fig:a} \ref{fig:c} \ref{fig:e}

\end{document}

subfiguras mal numeradas

Mas obviamente algo está errado com a numeração das legendas. Tudo isso deveria ser a figura 1, mas começa com 4 e depois aumenta mais 2. Tentei mover os rótulos para lugares diferentes, mas, embora o LaTeX me diga que as referências mudaram, ainda obtenho o mesmo resultado. Também tentei remover o .auxarquivo, etc. Mas, novamente, ainda recebo 4 para a figura e 6 para as subfiguras.

Qual é a maneira correta de fazer isso?

Responder1

Isso fornece a saída correta:

\documentclass{article}
\usepackage{graphicx,subfig}
\usepackage[heightadjust=all,valign=c]{floatrow}
\usepackage{fr-subfig}

\begin{document}

  \thisfloatsetup{subfloatrowsep=qquad}
  \begin{figure}[!htbp]
    \captionsetup[subfigure]{justification=centering}
      \ffigbox{%
  \begin{subfloatrow}[3]%
    \ffigbox[\FBwidth]{\caption{Penguins were here and here and here}\label{fig:a}}{%
      \includegraphics[height=.1\textheight]{example-image-a}}
    \ffigbox[\FBwidth]{\caption{Penguin}\label{fig:b}}{%
      \includegraphics[height=.15\textheight]{example-image-b}}
    \ffigbox[\FBwidth]{\caption{Penguin}\label{fig:c}}{%
      \includegraphics[height=.125\textheight]{example-image-a}}
  \end{subfloatrow}

  \begin{subfloatrow}
    \ffigbox[\FBwidth]{\caption{Penguin}\label{fig:d}}{%
      \includegraphics[height=.15\textheight]{example-image-b}}
    \ffigbox[\FBwidth]{\caption{Penguins were here, there and everywhere!}\label{fig:e}}{%
      \includegraphics[height=.2\textheight]{example-image-a}}
  \end{subfloatrow}%
      }{%
        \caption{Components of the system: Penguins (\ref{fig:a}), Jumpers (\ref{fig:b}), Thingies (\ref{fig:c}), Cabbages (\ref{fig:d}) and Nuclear Warheads (\ref{fig:e})\label{fig:x}}%
    }
\end{figure}
\ref{fig:x} \ref{fig:a} \ref{fig:c} \ref{fig:e}

\end{document}

insira a descrição da imagem aqui

O problema parece estar combinando floatrowcomandos com subfig's \subfloat(acho que usar comandos de ambos os pacotes faz com que os contadores andem de maneira errada (quando cada pacote assume o controle, ele pisa nos contadores)); uma vez feito tudo floatrowapenas com comandos, o problema desaparece; observe que isso também fará

  \thisfloatsetup{subfloatrowsep=qquad}

comportar-se como esperado, portanto, nenhum ajuste manual é necessário agora (adicionei um comentário sobre isso também emessa outra pergunta).

informação relacionada