Graphics, Figures & TablesFigures in the margin

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
scdpinto
Posts: 2
Joined: Thu Oct 30, 2008 4:09 pm

Figures in the margin

Post by scdpinto »

Hello,

I have what seemed to me a simple problem, but I haven't found any useful hints on all the web.

I would like to set a text with a wide outer margin, and place almost all my figures in this margin (including caption). Now I have no problems putting my pictures or any text in those margins, but a figure environment is a float. And so is a marginal note. There seems to be a constraint there.

What I do not want (and I have found tricks for these), are figures in the text block with their captions in the margin, "wrapped" figures, figures extending into the margin, or only graphics but no floating environment in the margin.

Any ideas will be highly appreciated.
Thanks a lot.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Figures in the margin

Post by localghost »

The solution is given with the caption package. It allows captions for figures or tables outside float environments. Search the manual for the \captionof command. A good example is given in epslatex (Section 22 - Marginal figures, p. 89f). In this context I recommend to use the marginnote package for a more flexible typesetting of marginals. For the case that you are running into trouble, build a minimal working example (MWE) and we will see what we can do.


Best regards and welcome to the board
Thorsten¹
scdpinto
Posts: 2
Joined: Thu Oct 30, 2008 4:09 pm

Figures in the margin

Post by scdpinto »

Thanks a lot for your very quick reply!

And it works, too. The \captionof (caption-outside-float) command is a feature of the newer versions of the caption package I was not aware of. If you only need the functionality of this command (as a memoir class user I don't need the rest, for instance), you can load the "lighter" package capt-of, which has no other features.

For the record (in case people are interested in doing the same thing), calling the package is as simple as \usepackage{capt-of} in your preamble. And to place a figure in the margin, instead of naively:

Code: Select all

\marginpar{
\begin{figure}
\includegraphics[width=\textwidth]{filename}
\caption{Text of the caption}
\end{figure}
}
(This doesn't work)
You do the following:

Code: Select all

\marginpar{
\includegraphics[width=\marginparwidth]{filename}
\captionof{figure}{Text of the caption}
}
The same should work for tables as well.
Thanks a lot for the help!
Post Reply