# Margin Figures/Captions

I have two figure/caption related questions.

Firstly, in many textbooks, it is customary to put thin figures (along with their captions) entirely in the outer margin of the page. What is the most elegant way of doing this in LaTeX?

Secondly, for wider figures many books set the figure to be the width of the page (so spewing out into the outer margin) and then place the caption in the margin space below the figure. How can one achieve this effect in LaTeX?

-
This is one of those things where I think that you often find yourself trying to do this kind of complex layout, you may find that life would be easier with Context. – Charles Stewart Aug 30 '10 at 20:49
Have you tried the caption package? I think this package do whatever you want. – Vahid Damanafshan Aug 31 '10 at 1:51
@charles: I'm certainly not against such comments by any means whatsoever, but without an example from you demonstrating ConTeXt's superiority here, it's not a very compelling argument. @vahid: no, caption only styles the figure captions, not the figures themselves. – Will Robertson Aug 31 '10 at 8:59

You can use the the tufte-book class. It has margin figures, margin notes as well as full width environments. In general it has the general style you are looking for. It also has a fullwidth environment for larger figures - as you describe.

-

### Figures in margins

I haven't done this for years, but when I did I used the wrapfig package. Something like

\documentclass[twoside]{article}
\usepackage{wrapfig,calc,lipsum}
\newlength{\marginspace}
\setlength{\marginspace}{\marginparwidth+\marginparsep}
\setlength{\wrapoverhang}{\marginspace+\columnsep}
\begin{document}
\lipsum[1]
\begin{wrapfigure}{o}{\marginspace}
\centering
\rule{4em}{4em}
\caption{Black box.}
\label{fig:bb}
\end{wrapfigure}
\lipsum[2]
\end{document}


### Full-width figures

This one is easier. Using the changepage package,

\documentclass{article}
\usepackage{changepage,lipsum,calc}
\newenvironment{wide}{%
\strictpagecheck % just in case
}{%
}
\begin{document}
\lipsum
\begin{wide}
\lipsum
\end{wide}
\end{document}


Of course, you could also use a command instead of an environment if you prefer.

While the code above is fairly small (in the scheme of things) the floatrow package provides an interface around such elements (and much more).

Update: I don't personally use floatrow, so I don't know if it has its own methods for doing something like this, but here's an example of putting a margin caption beneath a wide figure:

\makeatletter
\newcommand\margincaption[1]{%
\par
\setbox\@tempboxa=\hbox{\parbox{\marginparwidth}{\caption{#1}}}
\@tempdima=\dimexpr\ht\@tempboxa+\dp\@tempboxa\relax
\par\null\hfill\usebox\@tempboxa\par
\vspace*{\dimexpr-\@tempdima-\baselineskip\relax}
}
\makeatother
...
\lipsum[1]
\begin{figure}[tp]
\begin{wide}
\rule{15cm}{1em}
\margincaption{A black long line with lots of explanation so it fills up some space.}
\end{wide}
\end{figure}
\lipsum[2]
\end{document}

-
The floatrow package seems to do most of what I need. However, I wonder how, with a wide/full width environment, the caption can be placed in the outer margin below the figure? – Freddie Witherden Aug 31 '10 at 9:17
I've asked myself the same question. See in text, margin, and text + margin width floats without using tufte class the answer I got using the sidenotes-package – ebo Apr 4 at 8:51