1

Hopefully this is pretty simple for someone who's better at LaTeX than me. I've got a memoir class document I'm putting together, and I'm using sidecaptions, the usual memoir way:

\begin{figure}
  \begin{sidecaption}{Here's the caption.}
    \includegraphics{filename.jpg}
  \end{sidecaption}
 \end{figure}

This of course prints "Figure 1.1: Here's the caption" into the margin next to the figure. But I'd like it to always just say "Here's the caption." How can I do this with memoir's sidecaptions? I was using

\usepackage[
  labelformat=empty,
  justification=raggedright
]{caption}

but that doesn't allow me to have my captions flush against the figure as I'd like them to be (raggedleft on left-margin captions, raggedright on right-margin captions). If you can tell me how to use the caption package to achieve that, I'd be perfectly happy with that too.

(I've dug through the caption and sidecaption documentation in the manual, but can't seem to find what I'd need to change to get rid of the numbering, only ways to change its styling.)

Edit: I should have mentioned, this is a twoside document and I need the captions in the outer margin.

  • Digging around a bit more, I discovered \sidelegend, which does get rid of the numbering, but appears to have no equivalent to \sidecapmargin{outer} that would set these legends in the outer margin. It just puts them in the right margin whether it falls on a recto or a verso. – Chuck Jan 12 at 22:50
  • can you clarify whether you want caption package? I couldn't understand if you were just including to accomplish this task... or if you use it anyway. I ask, because there is a way to define the caption format using caption. – whatisit Jan 13 at 0:55
  • I had copied in some code from an older project that included an invocation of the caption package, so I was using it without really knowing why I was using it. Took it out today while trying to solve a different problem with the captions, and replaced it with memoir's sidecaption way of doing things. It solved that problem (being able to use RaggedLeft and RaggedRight in left and right margins respectively), which inclined me to want to use the memoir way. Nothing else I was doing depended on the caption package, so I don't think I want it. – Chuck Jan 13 at 2:42
2

What you're looking for is provided by the sidelegend environment:

enter image description here

\documentclass{memoir}

\usepackage{graphicx}

\sidecapmargin{right}

\begin{document}

\begin{figure}
  \begin{sidecaption}{Here's the caption.}
    \includegraphics[width=\linewidth]{example-image}
  \end{sidecaption}
  \begin{sidelegend}{Here's the legend.}
    \includegraphics[width=\linewidth]{example-image}
  \end{sidelegend}
\end{figure}

\end{document}

Legends are unnamed and unnumbered captions. There's also a sidenamedlegend environment which provides a named but unnumbered caption.


Within twoside mode, the following code seems to address the requirement of an outer legend:

enter image description here

\documentclass[twoside]{memoir}

\usepackage{lipsum}
\usepackage{graphicx}

\sidecapmargin{outer}

\makeatletter

\def\endsidelegend{%
  \m@mscapend@fbox
  \checkoddpage
  \ifoddpage
    \scapmargleftfalse
    \captionstyle{\raggedright}
  \else
    \scapmarglefttrue
    \captionstyle{\raggedleft}
  \fi
  \begin{lrbox}{\m@mscap@capbox}%
    \begin{minipage}[c]{\sidecapwidth}%
      %\sidecapstyle
      \legend{\m@mscap@forcap}
    \end{minipage}%
  \end{lrbox}%
  \m@mscapopboxes}

\makeatother

\begin{document}

\lipsum[1-4]

\clearpage

\begin{figure}
  \begin{sidecaption}{Here's the caption.}
    \includegraphics[width=\linewidth]{example-image}
  \end{sidecaption}
  \begin{sidelegend}{Here's the legend.}
    \includegraphics[width=\linewidth]{example-image}
  \end{sidelegend}
\end{figure}

\clearpage

\begin{figure}
  \begin{sidecaption}{Here's the caption.}
    \includegraphics[width=\linewidth]{example-image}
  \end{sidecaption}
  \begin{sidelegend}{Here's the legend.}
    \includegraphics[width=\linewidth]{example-image}
  \end{sidelegend}
\end{figure}

\end{document}
  • See my comment on the original question - sidelegend doesn't appear to have any option, at least none that I've found, to set the legends in the outer margin, only the right margin. Otherwise, yes, it's the perfect answer... but that's a big problem with my twoside layout. (I ran your MWE, except after the figure I put a \clearpage and duplicated the figure, just to make sure, and the legend was indeed on the right side.) – Chuck Jan 13 at 2:28
  • @Chuck: You can switch the \legend to the left by adding \scapmarglefttrue just before calling \begin{sidelegend}...\end{sidelegend}. – Werner Jan 13 at 3:50
  • I'd prefer not to have to do that before every sidelegend that falls on a verso. I have a lot of them, and occasionally my text reflows so I'd have to change a lot of them. – Chuck Jan 13 at 4:15
  • @Chuck: See the updated answer that adjusts \endsidelegend. – Werner Jan 13 at 5:01
  • Nice! This is indeed cleaner than my strategy. I ended up uncommenting the "\sidecapstyle" line to make the legends print in the same style the captions had been in. Then, find-replace sidecaption → sidelegend on a 220-page document, and nothing went wrong that I've noticed. Handily, memoir's macro \setsidecappos evidently works on these legends too. – Chuck Jan 14 at 18:51
0

Alright, I came up with something. Not sure if this is the best way, but I ended up with this:

\renewcommand{\figurename}{} % Set the "Figure" part to null
\renewcommand{\thefigure}{}  % Set the "1.1" part to null
\captiondelim{}              % Set the ": " part to null (memoir-specific)
  • This method will affect all figure captions, is that what you want? Or do you want it only for these sidecaption environments? – whatisit Jan 13 at 0:25
  • assuming you only want this for these sidecaptions you could patch the environment using etoolbox. Include \usepackage{etoolbox} and wrap your answer with \AtBeginEnvironment{sidecaption}{...}. – whatisit Jan 13 at 0:50
  • Yeah, I suppose that'd be why this isn't necessarily the best way... but in this case I do indeed not want captions on any of my figures. That etoolbox method looks good if I did want that, though - your comment and my answer may be the way to go for that use case, thanks! – Chuck Jan 13 at 2:34

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.