Graphics, Figures & Tablesa \subref question

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
yongmayer
Posts: 1
Joined: Wed Mar 17, 2010 9:47 pm

a \subref question

Post by yongmayer »

Hi all,

I need to refer to subfigures as Figures 1a and b, but when I used \subref{}, it only gave me Figures 1a and (b). How can I get rid of the parentheses around b?

BTW, I used following lines to remove parentheses in 1(a) with \ref{}, however I don't know how to set similar commands for \subref{}.

Code: Select all

\usepackage{subfigure}
\makeatletter
\renewcommand{\thesubfigure}{\alph{subfigure}}
\renewcommand{\@thesubfigure}{(\alph{subfigure})\hskip\subfiglabelskip}
\renewcommand{\@@thesubfigure}{(\alph{subfigure})}
\makeatother
Thanks,
yongmayer

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

a \subref question

Post by gmedina »

Hi,

subfigure is an obsolete package and shouldn't be used anymore; in its stead you can use the subfig or the subcaption package. The former, offers you a starred version of the \subref command that solves your problem; take a look at the following example:

Code: Select all

\documentclass{article}
\usepackage{subfig}

\begin{document}

\begin{figure}[!ht]
  \centering
  \subfloat{\rule{3cm}{2cm}\label{fig:sub1}}%
  \qquad
  \subfloat{\rule{3cm}{2cm}\label{fig:sub2}}
  \caption{Two subfigures.}%
  \label{fig:test}%
\end{figure}

Figures \ref{fig:sub1} and \ref{fig:sub2}...
Subfigures \subref{fig:sub1} and \subref{fig:sub2}

Figures \ref{fig:sub1} and \ref{fig:sub2}...
Subfigures \subref*{fig:sub1} and \subref*{fig:sub2}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply