I want to have two subfigures, and then reference them like "as seen in Figure 2a,2b" -- so to combine them.
How can I do this? (or if you know a better way in lyx or latex)
I want to have two subfigures, and then reference them like "as seen in Figure 2a,2b" -- so to combine them.
How can I do this? (or if you know a better way in lyx or latex)
I slightly modified Gonzalo Medina's example in order to use the cleveref package which (among other things) automatically determines the format of a cross-reference according to its "type".
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{cleveref}
\AtBeginDocument{%
\renewcommand{\crefpairconjunction}{,}%% instead of " and\nobreakspace"
\renewcommand{\crefmiddleconjunction}{,}% instead of ", "
\renewcommand{\creflastconjunction}{,}% instead of " and\nobreakspace"
}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{.5\linewidth}
\centering
\includegraphics{name1}
\caption{A subfigure}
\label{fig:one-one}
\end{subfigure}%
\begin{subfigure}[b]{.5\linewidth}
\centering
\includegraphics{name1}
\caption{A subfigure}
\label{fig:one-two}
\end{subfigure}
\caption{A figure with two subfigures}
\label{fig:one}
\end{figure}
\dots\ as seen in \Cref{fig:one-one,fig:one-two} \dots
\end{document}
EDIT: Added redefinition of \crefpairconjunction & friends.

You can achieve what you want using the standard \ref command or \ref and \subref from the subcaption package (which should be preferred over the subfig package: subcaption vs. subfig). Here's a little example:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{.5\linewidth}
\centering
\includegraphics{name1}
\caption{A subfigure}
\label{fig:1a}
\end{subfigure}%
\begin{subfigure}[b]{.5\linewidth}
\centering
\includegraphics{name1}
\caption{A subfigure}
\label{fig:1b}
\end{subfigure}
\caption{A figure with two subfigures}
\label{fig:1}
\end{figure}
...as seen in Figures~\ref{fig:1a},\ref{fig:1b}...
...as seen in Figures~\ref{fig:1a},\ref{fig:1}\subref{fig:1b}...
\end{document}

EDIT: I added a link to the question whose answer explains why subcaption should be preferred over subfig.
You can use the subfig package, and then \label each subfigure, e.g.
\documentclass{article}
\usepackage{subfig}
\begin{document}
\begin{figure}
\centering
\subfloat[This is figA]{\label{fig:figA}\Large A}\hspace{3cm}
\subfloat[This is figB]{\label{fig:figB}\Large B}
\caption{Here goes the main caption}
\label{fig:figAB}
\end{figure}
Here are Figure~\ref{fig:figA} and Figure~\ref{fig:figB}, and a combination thereof:
Figure~\ref{fig:figA},\subref*{fig:figB}.
\end{document}
Replace \Large A and \Large B with your figures.
Here is the output:

I guess you can write a simple macro to wrap up the combined call to \ref and \subref.
\subref instead of \ref for referencing part B? I'll add an example.
– chl
May 26 '11 at 13:04
\Cref(e.g., remove the "and", or join "a,b")? Because it seems this what the OP was looking for, unless I misunderstood the question and his comment. – chl May 26 '11 at 16:17