27

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?

3
  • 1
    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. Commented Aug 30, 2010 at 20:49
  • Have you tried the caption package? I think this package do whatever you want. Commented Aug 31, 2010 at 1:51
  • 2
    @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. Commented Aug 31, 2010 at 8:59

2 Answers 2

15

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.

11

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{adjustwidth*}{0pt}{-\marginparsep-\marginparwidth}
}{%
  \end{adjustwidth*}
}
\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}
2

You must log in to answer this question.

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