1

I think the question has not been posted already.

Here is my problem :

I wanted several subfigures within one. I used "subcaption" package at first, as it's the newest. But it appeared that it's not possible to reposition the subcaption next to the figure (instead of below it). For that, I had to use "floatrow" package, which is incompatible with "subcaption" package.

BUT, when I cross-reference the subfigure in the general figure caption, instead of 'blabla (a)', shows 'blabla 1(a)' (1 being the figure number). I don't want the figure number when I cross ref in the same fig !

Thanks a lot for any help !

\documentclass[10pt,a4paper]{report}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{floatrow}
\usepackage{subfig}
\usepackage[english]{babel} % for table, doesn't matter here
\usepackage{setspace}

\begin{document}

\begin{figure}[h]

  \sidesubfloat[]{\includegraphics[width=\linewidth,height = 5cm,keepaspectratio]{bigpicture1}\label{fig:sub_ref_1}}
  \\[10pt] 

  \sidesubfloat[]{\includegraphics[width=\linewidth,height = 5cm,keepaspectratio]{bigpicture2}\label{fig:sub_ref_2}}
\caption{I want to cross ref. Now I can only obtain that : \ref{fig:sub_ref_1}, and that : \ref{fig:sub_ref_2} }
\label{fig:fig_1_label}

 \end{figure}

 \end{document}

Compiled :

1

Solved !

It seems that there is a problem with my TeX distribution and/or OS. Let's see : what worked for me (MacOS 10.8.3, TeXshop 3.11)

\RequirePackage{lineno}
\documentclass[10pt,a4paper]{report}
\usepackage[demo]{graphicx}
\usepackage{floatrow}
% \usepackage{caption}
\usepackage{subfig}
\usepackage[english]{babel} % for table
\usepackage{setspace}


\begin{document}

\begin{figure}[h]

  \sidesubfloat[]{ \includegraphics[width=\linewidth,height = 5cm,keepaspectratio]{bigpicture1}\label{fig:sub_ref_1} }
  \\[10pt] 

  \sidesubfloat[]{ \includegraphics[width=\linewidth,height = 5cm,keepaspectratio]{bigpicture1}\label{fig:sub_ref_2} }

  \caption{I want to cross ref. Now I can only obtain that : \protect\subref{fig:sub_ref_1}, and that : \protect\subref{fig:sub_ref_2} }
  \label{fig:fig_1_label}

\end{figure}

\end{document}

So I had to

  • write \protect\subref{...} instead of \ref{..}
  • not write \usepackage{caption}

The solution is actually a derivative of another question : Referencing subfigures in main caption (with \subfloat and \subref)

:)

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.