0

I'm using the memoir class. Let's say I have a figure like this.

\begin{figure}[htbp!]
    \centering
    \caption{Super-cool Figure}
    \label{fig:super_cool}
    \includegraphics[width = 0.7\textwidth]{super_cool.pdf}
    \legend{\small \emph{Notes:} Figure shows a super-cool image.}
\end{figure}

I'm using the \legend to provide notes to the figure. Generally, these notes are quite detailed, so that the \legend block becomes much wider than the figure. Is there a way to format the legend so that it is as wide as the figure (0.7\textwidth)?

3
  • Welcome to tex.sx. Commented Jul 9 at 13:50
  • Put it into a minipage. I probably would not do this, either include the text in the caption (which should be under figures), or, probably more preferably, place the explanation in the text. This is what you see in most published works.
    – daleif
    Commented Jul 9 at 15:19
  • @daleif this varies substantially across fields, in the field I'm working in adding legends to figures is very common, with the idea that figures should be as self-contained as possible.
    – simon97
    Commented Jul 11 at 8:25

1 Answer 1

0

I don't think that \legend is the right tool: it just uses the \caption mechanism, without adding a label.

\documentclass{memoir}
\usepackage{graphicx}

\NewDocumentCommand{\simonincludegraphics}{O{}mo}{%
  % #1 = options for \includegraphics, #2 = file name, #3 = notes
  \IfNoValueTF{#3}{%
    % just includegraphics
    \includegraphics[#1]{#2}
  }{% set the image in a box so its width is known
    \sbox{\simonimagebox}{\includegraphics[#1]{#2}}%
    \usebox{\simonimagebox}\par\smallskip
    \parbox[t]{\wd\simonimagebox}{\small\emph{Notes}: \ignorespaces #3}%
  }%
}
\newsavebox{\simonimagebox}

\begin{document}

\begin{figure}[htbp!]
\centering

\caption{Super-cool Figure}\label{fig:super_cool}

\simonincludegraphics[width = 0.7\textwidth]{example-image}[
  Figure shows a super-cool image but the legend goes on for 
  several lines. Here is some more text.
]

\end{figure}

\begin{figure}[htbp!]
\centering
\caption{Another super-cool Figure}\label{fig:super_cool_again}

\simonincludegraphics[width = 0.5\textwidth]{example-image}[
  Figure shows a super-cool image
]

\end{figure}
\end{document}

You can also use \simonincludegraphics[<options>]{filename} without the trailing optional argument and this is a drop-in replacement for \includegraphics. You may change your mind about adding or removing notes from below an image and it's handier if the syntax is uniform.

output

1
  • thanks, that's helpful!
    – simon97
    Commented Jul 11 at 8:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .