LaTeX forum ⇒ Graphics, Figures & TablesFigures in the margin

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

Figures in the margin

Postby scdpinto » Sat Jan 10, 2009 3:12 pm

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.

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Sat Jan 10, 2009 3:41 pm

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¹
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

scdpinto
Posts: 2
Joined: Thu Oct 30, 2008 4:09 pm

Postby scdpinto » Sat Jan 10, 2009 9:07 pm

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:

  1. \marginpar{
  2. \begin{figure}
  3. \includegraphics[width=\textwidth]{filename}
  4. \caption{Text of the caption}
  5. \end{figure}
  6. }


(This doesn't work)
You do the following:

  1. \marginpar{
  2. \includegraphics[width=\marginparwidth]{filename}
  3. \captionof{figure}{Text of the caption}
  4. }


The same should work for tables as well.
Thanks a lot for the help!


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 5 guests