Sie sind hier

Figure/Table Captions in the Margin?

Hi All..

I've been struggeling some time now trying to find out how to get the captions of my figures and tables next to the floats in the margin. I'd like the captions to be on the outer margin of the page, aligned either to the top or bottom of the float (adjustable would be nice, though).

Somehow the very few examples I've come across so far don't seem to work and I'd rather write .tex than .cls files ;-)

I hope that someone can help me on that one. (btw, I'm using the scrbook class with pdftex..)

thanks in advance,

KOMA script environment captionbeside provides a lot of the functionality that is needed to achive this. You just have to set its width to \linewidth+marginparsep+marginparwidth and occupy \linewidth with your figure or table. The rest \marginparsep+\marginparwidth is then used for a small horizontal skip and caption. The captionbeside environment is aligned horizontally using the starred version of its last optional parameter.

There are several draw backs in the code below:

1. As horizontal skip inserted between figure content and caption and \marginparsep seem to be equally large here (1em?) I ignored both in the code.

2. As I don't know how to provide multiple optional parameters I
didn't provide one to adjust figure alignment. Content is hardcoded to be centered, but can be aligned differently using a \parbox manually.

3. Caption alignment is hardcoded to be \raggedright on both even and odd pages. There is no option to control this behaviour currently. If you want to use \RaggedRight from the ragged2e package (to allow for hyphenation) or want a \raggedleft alignment on even pages you have to change the code.

Markus, as I think this environment is quite usefull, could the piece of code below be a starting point for a new KOMA script feature?

Stephan Hennig


%provide \margincap command
%save content in a box
%calculate total width used by figure and caption
%call captionbeside environment
%with or without optional argument
\raggedright #2}[o][\mcap@capbesidewidth][0pt]*%
\raggedright #2}[o][\mcap@capbesidewidth][0pt]*%
%write figure horizontally centered
%end environment

%set small captions without indentation,
%starting on second line
\marginpar{this is text in the margin}\par
\margincap{A first long figure caption
in the left or right margin.}{\rule{3cm}{4cm}}

\marginpar{this is text in the margin}\par
\margincap[short caption]{A second long figure caption
in the leftor right margin.}{\rule{2cm}{1cm}}


First of all, thank you very much for the above solution!

Now the only thing that's a little bit annoying is that the captions for tables are vertically placed in the middle of the table rather than on top/bottom as with the figure captions. Any ideas?

Bild von Markus Kohm

Default vertical alignment of tabular environment center to the baseline. You may change this with the optional argument of the tabular environment to top or bottom alignment. See any LaTeX introduction about this.

I used your script and it works great, thank you!
Therefore there's one more thing I can't do: placing the captions in the margin, but aligned on the top of the figure/table line. Can you explain me how to move them, despite the default behaviour that wants them vertical aligned in the middle of the side?

FFFF Caption

FFFF Caption

Great thanks in advance,

Bild von Markus Kohm

Have a look at mcaption package.

The mcaption package works very well, but what about the wrong references bug, as described in the manual? Is there a workaround to fix it?
Thank you.

Bild von Markus Kohm

Comments for "Figure/Table Captions in the Margin?" abonnieren