Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat.
---
and obviously on oddside pages
---
Lorem ipsum dolor sit amet, xxxxxxxxxxxxxxxxxxx Fig 1: a nice
consectetur adipisicing elit, xxxxxxxxxxxxxxxxxxx picture
sed do eiusmod tempor incididunt xxxxxxxxxxxxxxxxxxx
ut abore et dolore magna aliqua. xxxxxxxxxxxxxxxxxxx
Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat.
---
Getting it to work on normal figures would be a great first step.
Any help appreciated.
- Peter
Maybe the package `sidecap' can help...
...Rolf
> I want to put the caption of figures (eps drawings) in the
> margin using twoside book. If somehow possible, it should
> also work with wrapfig.
Do check if sidecap works with wrapfig.
If not, it could be handled. Wrapfig does know what is the
"outside" margin so it knows which side to put the caption on.
--
Donald Arseneau as...@triumf.ca
> I want to put the caption of figures (eps drawings) in the
> margin using twoside book. If somehow possible, it should
> also work with wrapfig.
> [...]
> Getting it to work on normal figures would be a great first step.
Have a look at the captionbeside environment of the KOMA-Script classes,
especially the starred variant. With suitable parameters it is possible
to make it normal figure's captions appear in the margin. A small
wrapper style file providing a margincap environment that does exactly
that can be found here:
<URL:http://home.arcor.de/stephanhennig/Downloads/mcaption.sty>. There
is some documentation in the style. And as said, it depends on the use
of one of the KOMA-Script classes scrartcl, scrreprt or scrbook.
Since I don't know the wrapfig package I don't know if it is compatible
with captionbeside. But I don't see a reason why they should collide.
However, putting them together requires manual work, since you have to
tell captionbeside the width that is available for the figure + caption.
One more hint: captionbeside inserts a horizontal space of \columnsep
between figure and caption. (Mcaption.sty lets you adjust this.)
HTH,
Stephan Hennig
%Run LaTeX twice!
\documentclass{scrbook}
\usepackage{mcaption}
\usepackage[english]{babel}
\usepackage{blindtext}
%smaller captions
\addtokomafont{caption}{\footnotesize}
\begin{document}
\chapter{blubb}
\blindtext[3]
\begin{table}
\begin{margincap}
{A first long table caption in the left or right margin.}
\centering
\begin{tabular}[b]{cc}
category A & category B\\[1ex]
item 1 & item 2\\
item 3 & item 4\\
\end{tabular}
\end{margincap}
\end{table}
\blindtext[2]
\begin{table}
\begin{margincap}
{A second long caption in the left or right margin.}
\raggedright
\begin{tabular}[b]{@{}cc@{}}
category C & category D\\[1ex]
item 1 & item 2\\
item 3 & item 4\\
item 5 & item 6\\
\end{tabular}
\end{margincap}
\end{table}
\blindtext[3]
\begin{figure}[b]
\begin{margincap}[short caption]{more captions}
\raggedleft
\rule{4cm}{3cm}
\end{margincap}
\end{figure}
\end{document}
> Have a look at the captionbeside environment of the KOMA-Script classes,
> especially the starred variant.
The starred version is not necessary as wrapfigure changes \linewidth.
That makes things quite easy. In the example below the space between
figure and caption is again \columnsep. Changing that to, e. g.
\marginparsep, would need to track if you're on an even or odd page
similar to how it's done in mcaption.sty.
Regards,
Stephan Hennig
\documentclass{scrbook}
\usepackage{wrapfig}
\usepackage{calc}
\usepackage[english]{babel}
\usepackage{blindtext}
\AtBeginDocument{
\newlength{\mcwidth}% Available width for caption.
\setlength{\mcwidth}{\marginparwidth}
\addtolength{\mcwidth}{\marginparsep}
}
\setcapindent*{0em}% Change caption format.
\begin{document}
\chapter{blubb}
\begin{wrapfigure}[6]{r}[\mcwidth]{3cm+\mcwidth}
\begin{captionbeside}{A caption in the margin.}[o][\linewidth]
\rule{3cm}{2cm}
\end{captionbeside}
\end{wrapfigure}
\blindtext
\end{document}
\usepackage{ccaption}
\captionnamefont{\sffamily}
\captiontitlefont{\sffamily}
\AtBeginDocument{
\newlength{\mcwidth}% Available width for caption.
\setlength{\mcwidth}{\marginparwidth}
\addtolength{\mcwidth}{\marginparsep}
}
\setcapindent*{0em}% Change caption format.
\begin{document}
\chapter{blubb}
\begin{wrapfigure}{o}[\mcwidth]{5cm+\mcwidth}
\begin{captionbeside}{A wrapfigure caption in the margin.}[o][\linewidth]
\rule{5cm}{4cm}
\end{captionbeside}
\end{wrapfigure}
\blindtext
\blindtext
\begin{figure}[h]
\begin{margincap}{A figure caption in the margin.}
\centering
\rule{12cm}{4cm}
\end{margincap}
\end{figure}
\blindtext
\begin{wrapfigure}{o}[\mcwidth]{5cm+\mcwidth}
\begin{captionbeside}{A wrapfigure caption in the margin.}[o][\linewidth]
\rule{5cm}{4cm}
\end{captionbeside}
\end{wrapfigure}
\blindtext
\blindtext
\begin{figure}[h]
\begin{margincap}{A figure caption in the margin.}
\centering
\rule{12cm}{4cm}
\end{margincap}
\end{figure}
\blindtext
\end{document}
---
> The only thing that would still be nice is to have the caption begin
> at the top of the figure (currently they are aligned with the
> bottom)
captionbeside doesn't provide means to adjust that. Maybe some magic
\raisebox commands could help to fake the pictures height. But since the
height of the caption is not necessarily a multiple of \baselineskip,
that needed to measure the caption's real height, too. Sorry, no code,
I'm not a TeX programmer either. But I'll make an RFE to the KOMA-Script
developers to introduce an option to control the vertical caption alignment.
> So one can actually use figure and wrapfigure consistently together
> having the captions in the correct margins on a two-sided book.
Figure and wrapfigure captions are not correctly aligned horizontally in
your example. mcaption puts a horizontal space of \margincapsep, which
is \marginparsep by default, between between content and caption.
captionbeside puts a space of \columnsep. To get a consistent layout you
either have to reset \margincapsep to \columnsep which is then
inconsistent with margin notes.
Alternatively you could change captionbeside's spacing to \margincapsep.
You have to put suitable \hspace commands before (on even pages) or
after the content (on odd pages), see mcaption.sty. Another RFE will
address this lacking flexibility.
Or just set \columnsep to the value of \marginparsep.
> And it even works flawlessly with other fonts and ccaption allowing
> to format the captions as wanted.
If you only want to adjust the appearance of captions KOMA-Script
already provides commands for that. Additionally I'd suggest using
package ragged2e for margin captions.
Regards,
Stephan Hennig
BTW, I uploaded a new mcaption.sty version that removed the
\margincapjust macro since justification can be changed other ways, e.g.
by issuing \addtokomafont{caption}{\raggedright} or by other packages.
Moreover I cleaned up the handling of the optional argument according to
UK-TeX-FAQ Q283. The docs are also updated. No further functional changes.
\documentclass{scrbook}
\usepackage{mathpazo}
\usepackage{wrapfig}
\usepackage{mcaption}
\usepackage{ragged2e}
\usepackage{calc}
\usepackage[english]{babel}
\usepackage{blindtext}
% Change caption format the KOMA-Script way.
\addtokomafont{caption}{\sffamily\RaggedRight}
\addtokomafont{captionlabel}{\sffamily}
%Removed since this is already done by mcaption.sty.
%\setcapindent*{0em}
\AtBeginDocument{
\newlength{\mcwidth}% Available width for caption.
\setlength{\mcwidth}{\marginparwidth}
\addtolength{\mcwidth}{\marginparsep}
}
\begin{document}
\chapter{blubb}
\begin{wrapfigure}{o}[\mcwidth]{6cm+\mcwidth}
\begin{captionbeside}
{A long wrapfigure caption in the margin.}[o][\linewidth]
\rule{6cm}{4cm}
\end{captionbeside}
\end{wrapfigure}
\blindtext
\begin{figure}[h]
\begin{margincap}{Caption with wrong horizontal alignment.}
\centering
\rule{10cm}{3cm}
\end{margincap}
\end{figure}
\setlength{\margincapsep}{\columnsep}
\begin{figure}[h]
\begin{margincap}{Caption with correct horizontal alignment.}
\centering
\rule{10cm}{3cm}
>> So one can actually use figure and wrapfigure consistently together
>> having the captions in the correct margins on a two-sided book.
>
> Figure and wrapfigure captions are not correctly aligned horizontally
> in your example. mcaption puts a horizontal space of \margincapsep,
> which is \marginparsep by default, between between content and
> caption. captionbeside puts a space of \columnsep. To get a
> consistent layout you either have to reset \margincapsep to
> \columnsep which is then inconsistent with margin notes.
I just uploaded a new mcaption.sty version with better support for the
wrapfig package. You can now use the margincap environment inside a
wrapfigure environment and easily get a consistent look with normal
figures. Parameters to wrapfigure have to be "o" or "O" to place the
figure in the outside margin and you have to specify _no_ hang over
(since margincap automatically uses a width of \linewidth +
\marginparsep + \marginparwidth).
Regards,
Stephan Hennig
\documentclass{scrbook}
\usepackage{mathpazo}
\usepackage{wrapfig}
\usepackage{mcaption}% v1.5
\usepackage[english]{babel}
\usepackage{blindtext}
\addtokomafont{caption}{\raggedright}
\begin{document}
\chapter{blubb}
\begin{wrapfigure}{o}{5cm}
\begin{margincap}{A long wrapfigure caption in the margin.}
\rule{5cm}{3cm}
\end{margincap}
\end{wrapfigure}
\blindtext
\begin{figure}[h]
\begin{margincap}{Caption with correct horizontal alignment.}
\centering
\rule{10cm}{2cm}
> The only thing that would still be nice is to have the caption
> begin at the top of the figure (currently they are aligned with
> the bottom)
I uploaded mcaption.sty v1.6 which has support for top aligned captions.
To get those a KOMA-Script internal macro has to be changed. Just put
the following lines into your document preamble:
\makeatletter
\renewcommand*{\scap@valign}{t}
\makeatother
\setlength{\abovecaptionskip}{0pt}
And be sure to use mcaption.sty v1.6.
Regards,
Stephan Hennig
\documentclass{scrbook}
\usepackage{mathpazo}
\usepackage{wrapfig}% v1.6
\usepackage{mcaption}
\usepackage[english]{babel}
\usepackage{blindtext}
\addtokomafont{caption}{\footnotesize\raggedright}
\makeatletter
\renewcommand*{\scap@valign}{t}
\makeatother
\setlength{\abovecaptionskip}{0pt}
\begin{document}
\chapter{blubb}
\blindtext[2]
\begin{wrapfigure}{o}{5cm}
\begin{margincap}
{A long, top aligned wrapfigure caption in the margin.}
\rule{5cm}{3cm}
\end{margincap}
\end{wrapfigure}
\blindtext[1]
\begin{figure}[h]
\begin{margincap}{Caption with top alignment.}
\centering
\rule{10cm}{3cm}
> I uploaded mcaption.sty v1.6 which has support for top aligned captions.
mcaption.sty v1.61 works around a limitation of captionbeside and
enables true bottom alignment of captions. The docs are also updated.
Happy TeXing!
Stephan Hennig