[Tex/LaTex] How to \ref to subcaption numbers (a, b) when using memoirs subcaptions

captionscross-referencingmemoirsubcaptionsubfloats

How can I get references to subcaption numbers when using memoir? In this example:

\documentclass{memoir}

\newsubfloat{figure}
\begin{document}

\chapter{Lorem}
\section{ipsum}

\begin{figure}[b]
\begin{minipage}{0.49\textwidth}
    \centering
    \Large \textbf{Lorem}
    \subcaption{Lorem}
    \label{lorem}
\end{minipage}
\begin{minipage}{0.49\textwidth}
    \centering
    \Large \textbf{ipsum}
    \subcaption{Ipsum}
    \label{ipsum}
\end{minipage}
\caption{Lorem Ipsum}
\end{figure}

Lorem (figure:~\ref{lorem}) ipsum (figure:~\ref{ipsum}) dolor sit amet, consectetur adipiscing elit. Nullam ut nunc lacus, ac vestibulum orci. Nullam viverra dictum dolor, in molestie neque ullamcorper sed. Nullam felis velit, vestibulum ut convallis quis, luctus sit amet est. Etiam vel viverra magna. Phasellus euismod venenatis augue, quis rutrum sem pulvinar at. Donec pellentesque enim vitae ante tristique lacinia. Nulla auctor fermentum lorem, ut scelerisque nunc vehicula id. Phasellus sed facilisis erat. Nulla porttitor, metus eu bibendum molestie, elit dui lacinia dolor, nec iaculis sem tortor sit amet tortor. Vivamus a euismod arcu.

\end{document}

I would like to get references like "Lorem (figure: 1.1a) ipsum (figure: 1.1b)" instead it looks like this:

enter image description here

With the subcaption package which was used before I switched to memoir it seems this worked out of the box. How can I get this behavior with memoir?

Best Answer

Put the label within the subcaption command, as mentioned in ยง10.9 of the memoir manual. This will print parenthesis around the subreference, e.g. 1.1(a), but those cannot, at the moment, be removed (see comment by daleif).

\documentclass{memoir}
\newsubfloat{figure}
\begin{document}

\chapter{Lorem}
\section{ipsum}

\begin{figure}[h]
\begin{minipage}{0.49\textwidth}
    \centering
    \Large \textbf{Lorem}
    \subcaption{Lorem\label{lorem}}
\end{minipage}
\begin{minipage}{0.49\textwidth}
    \centering
    \Large \textbf{ipsum}
    \subcaption{Ipsum\label{ipsum}}
\end{minipage}
\caption{Lorem Ipsum}
\end{figure}

Lorem (figure:~\ref{lorem}) ipsum (figure:~\ref{ipsum}) dolor sit amet[...]
\end{document}

enter image description here

Related Question