# Separation and width of caption with captionbeside

I'm trying to control the typesetting of a caption beside a figure when using the captionbeside environment of the KOMA Script packages. The \setcapwidth command doesn't work when using captionbeside. Figures are placed to the left of the page, with a caption to the right(top) side. Captions are supposed to be 4cm wide, and allowed to extend into the (4cm wide) margin. However they are stretched to the full \textwidth when the figure is small, for large figures it works reasonably well. I'm also clueless about the separation/margin between the figure and the caption, which I'd like to set exaclty to \marginparsep (0.4cm in my case). Example so far:

\documentclass[captions=topbeside]{scrartcl}

\begin{document}
% Works here
\begin{figure}
\setcapwidth{4cm}
\setcapindent{1em}
\rule{4cm}{6cm}
\caption{Long caption that is 4cm wide}
\end{figure}
% Not here
\begin{figure}
\setcapwidth{4cm}
\setcapindent{1em}
\begin{captionbeside}{Long caption supposed to be 4cm wide}[o]
\raisebox{\dimexpr\baselineskip-\totalheight\relax}{
\rule{4cm}{6cm}
}
\end{captionbeside}
\end{figure}

\end{document}


I also tried the sidecap package, possibly together with the caption package, but those also don't set the caption width.

EDIT: Another posibility:

\begin{figure}
\mbox{%
\raisebox{\dimexpr\baselineskip-\totalheight}{%
\rule{\textwidth}{4cm}%
}%
\hspace{0.4cm}%
\parbox{4.13cm}{\captionof{figure}{Caption that is 4cm wide}}
}
\end{figure}


## 1 Answer

Updated Answer!

Please try this new changed MWE:

\documentclass[captions=topbeside]{scrartcl} % topbeside

\usepackage{showframe}

\begin{document}

% Not here
\begin{figure}
\setcapindent{1em}
\begin{captionbeside}{Long caption supposed to be 4cm wide}[o][8cm]%[5cm]
\raisebox{\dimexpr\baselineskip-\totalheight\relax}{
\rule{4cm}{6cm}
}
\end{captionbeside}
\end{figure}

\begin{figure}
\setcapindent{1em}
\setlength{\columnsep}{1.4cm}  % <========================================
\begin{captionbeside}{Long caption supposed to be 4cm wide}[o][8cm]%[5cm]
\raisebox{\dimexpr\baselineskip-\totalheight\relax}{
\rule{4cm}{6cm}
}
\end{captionbeside}
\end{figure}

\begin{figure}
\setcapindent{1em}
\begin{captionbeside}{Long caption supposed to be 4cm wide}[o][8cm][5cm]
\raisebox{\dimexpr\baselineskip-\totalheight\relax}{
\rule{4cm}{6cm}
}
\end{captionbeside}
\end{figure}

\end{document}


With KOMA-Script the meaning of the environment captionbeside is: \begin{captionbeside}[Toc title]{Title}[Position][total length][offset from left]

See now line 11 in my MWE: \begin{captionbeside}{Long caption supposed to be 4cm wide}[o][8cm]%[5cm]

The given width here is the sum of your image width (4cm) and the caption width (4cm), resulting 8cm. o give the position of the caption: outside. offset is not used here. (You did not use the two latest options ...)

The second image shows the same with a changed space between image and caption. See line 20: \setlength{\columnsep}{1.4cm} You can change the \columnsep as shown (I took 1.4cm to make the change visible).

You can find the relevant code for example in line 4110 of scrartcl.cls (definition of \newenvironment*{captionbeside} in line 4103 ff).

The third image is the same as the first, but has an offset of 5cm. That means image and captions are moved 5 cm to the right (it always starts on the left side!).

You can find this information in the documentation of KOMA-Script, for example in my german book on page 153, chapter 3.20 "floatings for tables and figures". Sorry, I do not have the english book. You can also check texdoc KOMA-Script.

See the result:

• This is how I "solved" it for larger figures, where I need to do this to extend the caption into the margin. I was just hoping for a more "automated" solution where I don't have to explicitly enter the width of the figure (+4cm). But I guess I won't get around this. So the only thing missing is the separation between the figure and the caption. I can't find the length in any docs, so I guess I'll have to dive into the source. – Richard Sep 11 '15 at 8:53