Graphics, Figures & Tablessubfig | Two Labels, but only one Caption

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
freethebee
Posts: 6
Joined: Tue Sep 08, 2009 7:21 pm

subfig | Two Labels, but only one Caption

Post by freethebee »

Hi,

I was just messing with subfig to be able to refer to figures as figure (a) and figure (b), but I can't seem to find out how to prevent it from creating captions for the individual figures as well. What I would like is for example a main label and two sub-labels, but only one caption that spans the text width like,

Figure 1: (a) some stuff describing fig a, and (b) Some other text related to fig b.

Can subfig do this, or should I use something else or just forget about it?

I have a bit of a deadline, otherwise I would have spend some more time with the documentation :)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

subfig | Two Labels, but only one Caption

Post by Stefan Kottwitz »

Hi,
freethebee wrote:I have a bit of a deadline, otherwise I would have spend some more time with the documentation :)
in general, if you are in a hurry post some specific code to get a working fix.

Here, I guess, without consulting the documentation, a caption is required to get a label for referencing, since the caption command implicitly increments the subfigure counter. Regarding your deadline, I guess it would be easier to make a workaround and to manually add a reference to the automatic reference of the main label.

Stefan
LaTeX.org admin
Frits
Posts: 169
Joined: Wed Feb 02, 2011 6:02 pm

subfig | Two Labels, but only one Caption

Post by Frits »

This is done by using the subfig package, without assigning a caption between square brackets to the subfloat command:

Code: Select all

\documentclass[]{article}

\usepackage{subfig}
\usepackage{graphicx}

\begin{document}


\begin{figure}
\centering
\subfloat{\label{fig:fig1}\includegraphics[width=0.3\textwidth]{fig1}}
\subfloat{\label{fig:fig2}\includegraphics[width=0.3\textwidth]{fig2}}
\caption{(a) some stuff describing fig a, and (b) Some other text related to fig b.}
\label{fig:figures}
\end{figure}

Test: \ref{fig:fig2} or \ref{fig:figures}.

\end{document}
howtoTeX.com - Your LaTeX resource site (Tips, Tricks, Templates and more!)
Follow howtoTeX on twitter
freethebee
Posts: 6
Joined: Tue Sep 08, 2009 7:21 pm

subfig | Two Labels, but only one Caption

Post by freethebee »

I think I was a bit too quick posting. I quickly googled the syntax and used this

Code: Select all

\subfloat[\label{figa}]{\includegraphics[width=\figwidth]{figure}
Basically I generate an empty caption by putting the label in the optional parameter for the caption, so an empty caption with just (a) or (b) is created.

If I write like this,

Code: Select all

 \subfloat{\label{figa}}{\includegraphics[width=\figwidth]{figure}
it does not create subcaptions.
Thanks for the quick responses.

[edit]Added an s to response[/edit]
Post Reply