2

I'm using the cleveref package to reference floats (in this case subfigures) in the memoir class. Currently the output looks like this (sorry for the danish, I don't think it matters): subfigures in memoir using cleveref

Using the following input (not all packages included, ofc):

\documentclass[oneside,article,12pt,danish]{memoir}
\usepackage{graphicx}
\newsubfloat{figure}
\captiontitlefont{\slshape}
\subcaptionfont{\slshape}

\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}

\begin{document}

\begin{figure}[h!]
  \centering
  \subbottom[Subfigure 1 caption]{\rule{3cm}{1cm}\label{sub1}}
  \hspace{1cm}
  \subbottom[Subfigure 2 caption]{\rule{3cm}{1cm}\label{sub2}}
\caption{Figure text.}
\label{fig:secondfig}
\end{figure}

\cref{sub1,sub2}

\end{document}

I like the way the figure/subfigures are set up, but I would like the reference to say 5a or 5.a instead of 5(a) without changing the figure/subfigure captions. Is there a general way to do this in the entire document, so that it can be easilly be changed to a somewhat random notation?

  • This question has already been answered here: tex.stackexchange.com/questions/63069/… Enjoy! – FionaSmith May 12 '14 at 20:05
  • Thanks, but this is not the exact answer. I might be missing something obvious? The problem is that when I change the reference to e.g. "5a" the subfigure caption also changes to "a" (I still want the parentheses in the caption). I figured there might be a memoir specific way of doing this? – Thomas May 13 '14 at 8:06
  • I don't have too much time to think this through right now (might try tonight) but I had the opposite problem - My reference was saying 5a and I wanted it to say 5(a). Maybe compare what I had against yours and you might be able to work it out? tex.stackexchange.com/questions/75014/… – FionaSmith May 13 '14 at 13:09
  • I've read it but it didn't help me. I tried using the caption package and the \captionsetup[subfigure]{...} but no luck. I wasn't able to find any options in the documentation, and the ones used didn't work. FYI: It's not urgent. – Thomas May 13 '14 at 14:50
  • Well if I want distracting from my thesis when I get home tonight I will have a tinker. I'm not an expert on this sort of thing though - I just noticed nobody had replied to you and it was the sort of thing I'd fought with before! – FionaSmith May 13 '14 at 15:18
3

This solution avoids the need to load caption and thereby retains the facilities of memoir. At least, it seems so although my testing has been somewhat minimal. Uncomment/comment the appropriate line to achieve formatting with or without the dot, as the mood takes you.

\documentclass[oneside,article,12pt,danish]{memoir}
\newsubfloat{figure}
\captiontitlefont{\slshape}
\subcaptionfont{\slshape}

% \renewcommand{\thesubfigure}{\alph{subfigure}}% plain version
\renewcommand{\thesubfigure}{.\alph{subfigure}}% dotted version
\makeatletter
\renewcommand{\@thesubfigure}{(\alph{subfigure})%
    \if@tightsubcap\hskip\subfloatlabelskip\else\space\fi}
\makeatother

\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}

\begin{document}

\begin{figure}[h!]
  \centering
  \subbottom[Subfigure 1 caption]{\rule{3cm}{1cm}\label{sub1}}
  \hspace{1cm}
  \subbottom[Subfigure 2 caption]{\rule{3cm}{1cm}\label{sub2}}
\caption{Figure text.}
\label{fig:secondfig}
\end{figure}

\cref{sub1,sub2}

\end{document}

sub figures with variant referencing format in <code>memoir</code>

Were you to load xcolor then you could (perversely) have just the references to the sub-figure bits typeset in huge, blue lowercase without affecting the captions or other references:

\renewcommand{\thesubfigure}{\Huge\color{blue}.\alph{subfigure}}% dotted version

bizarre formatting

Obviously, this would be a terrible choice but it demonstrates that the format can be easily 'changed to a somewhat random notation' while retaining the format of sub-captions and the interface of memoir.

1

OK, here's a partial suggestion using subfig and caption. I've not used the memoir class before. If I use article, figures are labelled "1.a", when I switch to memoir I get "0.1.a". Some of your code doesn't compile for me. I've commented it out. I've changed the figure to look more like my own code (i.e. subfloat not subbottom) because I haven't used the latter before. I've incorporated the answer to the question I linked to before.

So, with the caveats above about the non-compiling code, my example here does what you want in terms of figure labelling (I think).

There's probably a better solution.

\documentclass[12pt]{memoir}
\usepackage{graphicx}



%%%%These do not work for me - is there a missing package?
%\newsubfloat{figure}
%\captiontitlefont{\slshape}
%\subcaptionfont{\slshape}
%%%%

\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}

\usepackage[font=sl,labelfont=up]{caption}
\usepackage[font=sl,labelfont=up]{subfig}

\renewcommand\thesubfigure{\alph{subfigure}} % default: "(\alph{subfigure})"
\makeatletter
\renewcommand{\p@subfigure}{\thefigure.} % default: "\thefigure" (without the ".")
\makeatother


\begin{document}


\begin{figure}
  \centering
  \subfloat[Subfigure 1 caption]{\rule{3cm}{1cm}\label{sub1}}
  \hspace{1cm}
  \subfloat[Subfigure 2 caption]{\rule{3cm}{1cm}\label{sub2}}
\caption{Figure text.}
\label{fig:secondfig}
\end{figure}

\cref{sub1,sub2}

\end{document}
  • Well, now there's another "problem" (it's small stuff, I know). The "Figure 0.1" (the numbering is easily changed, don't worry about that) and "(a)" is italic--or slanted, as I prefer. I don't know how to change this without changing the rest of the caption text. I've read/heard that memoir is made to be editable so I think there must be some way of doing this easily without using e.g. the subfigure package (keyword: think). That's why I use subbottom. When I uncomment the stuff you've commented I get errors too. That is, unless I use subbottom instead of subfloat. Weird. – Thomas May 13 '14 at 18:04
  • Thanks for your suggestion. I really appreciate the feedback! (I had no space left in the comment above for this.) And by the way, the things you commented in my document is used for making the sub-/captions slanted (globally). I think it's part of the (in memoir preloaded) ccaption package. Correct me if I'm wrong. – Thomas May 13 '14 at 18:07
  • Sorry I missed that, you can use \usepackage[font=sl,labelfont=up]{caption} will edit the answer. I agree I am sure that's what the lines I commented out look like they are doing - I don't know why it didn't work for me but I haven't used memoir before. I don't know why nobody else is answering your question - but I think it would help to have someone who has used memoir!! – FionaSmith May 13 '14 at 19:16
  • By the way, I can see why you don't want to use caption because it is clearly overwriting some memoir-specific stuff - that said, it seems to work! Generates the message: `Class memoir Warning: You are using the caption package with the memoir class. To prepare we will now reset all captioni ng macros and configurations to kernel defaults, and then let the caption package take over. Please remember to use the caption package interfaces in order to configure your captions.' – FionaSmith May 13 '14 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.