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.

Say I have a figure with two subfloats inserted using the subfig package. When I reference them with \ref{myLabel} I get this

Figure 3.5a and 3.5b.

But what I want is this:

Figure 3.5(a) and 3.5(b).

How can I add the parentheses?

share|improve this question
add comment

4 Answers

up vote 11 down vote accepted

For the subfig package see sections 2.2.2 and 3 of the documentation.

\documentclass{article}
\usepackage[subrefformat=parens,labelformat=parens]{subfig}

\begin{document}
See Figure~\subref*{sf1} for more information.
\begin{figure}
\centering
\subfloat[Subfig 1]{\label{sf1} Contents of the sub-figure}
\qquad
\subfloat[Subfig 2]{\label{sf2} Contents of the sub-figure}
\caption{A figure}
\label{fig}
\end{figure}
\end{document}

Subfigures with parentheses


(Original answer)
Assuming you're using the subfloat package, section 4 of its documentation indicates you can do something like:

\renewcommand*\thesubfloatfigure{\themainfigure(\alph{subfloatfigure})}

to put the sub-number in parentheses.

share|improve this answer
    
Unfortunately I'm using subfig. That's really my fault for leaving that unclear. –  user4600 Apr 20 '11 at 23:16
    
Edited for subfig. Not quite as straightforward, but easy enough. –  Mike Renfro Apr 21 '11 at 3:24
1  
I actually found this, which works for me well: \renewcommand\thesubfigure{(\alph{subfigure})} –  user4600 Apr 21 '11 at 3:56
    
This also works for \usepackage[subrefformat=parens,labelformat=parens]{subcaption}. –  bkarpuz Jul 15 '13 at 8:07
add comment
\documentclass{article}
\usepackage{subfig}

\begin{document}
See Figure~\ref{fig}\subref{sf1} for more information.
\begin{figure}
\centering
\subfloat[Subfig 1]{\label{sf1} Contents of the sub-figure}
\qquad
\subfloat[Subfig 2]{\label{sf2} Contents of the sub-figure}
\caption{A figure}
\label{fig}
\end{figure}
\end{document}
share|improve this answer
4  
It would be nice if you could say some words about your solution. We don't expect an epic story, but something like "I did ... to achieve ..." would be nice. Anyway, welcome to Tex.sX, and thanks for contributing! –  Tom Bombadil Oct 5 '11 at 23:02
    
@TomBombadil : I guess this is obvious as he uses '\ref' and '\subref' together. –  bkarpuz Apr 21 '13 at 16:05
add comment

If anyone came across this question and is using subcaption, here is a solution (borrowed from its excelent manual):

\documentclass{article}
\usepackage[labelformat=simple]{subcaption}
\renewcommand\thesubfigure{(\alph{subfigure})}

\begin{document}
Reference the sub-figure in full form: \ref{sf1}.
Referencing just the sub-figure parts: \subref{sf1} and \subref{sf2}.
\begin{figure}
  \begin{subfigure}{.48\textwidth}
    \centering
    Contents of the sub-figure
    \caption{Subfig 1}
    \label{sf1}
  \end{subfigure}
  \begin{subfigure}{.48\textwidth}
    \centering
    Contents of the sub-figure
    \caption{Subfig 2}
    \label{sf2}
  \end{subfigure}
  \caption{A figure}
  \label{fig}
\end{figure}
\end{document}

enter image description here

share|improve this answer
add comment

The [subrefformat=parens,labelformat=parens] options didn't work for me; the references still came out as, e.g., "1b". I had to use

\usepackage[caption=false,labelformat=simple]{subfig}
\renewcommand{\thesubfigure}{(\alph{subfigure})}

(I had to use caption=false because without it subfig makes the captions in my document class come out in the wrong style.) Does this seem all right to use? I did discover that under my way, you have to use \subref*, not \subref, if you want to auto-refer to something like "(a)" (with \subref you get "((a))").

Looking at the other answer again, I think I needed to do it this way because I had been using \ref for all my references to things like "Figure 1b". (I'd rather not change all my \ref's to \subref*'s if I can avoid it.)

share|improve this answer
add comment

Your Answer

 
discard

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