[Tex/LaTex] Koma script captionbeside topbeside alignment question

captionsdebuggingkoma-scriptscrbook

Code based on the example of scrguien 3.12 (2013-12-19) page 122 gives bad result. Code:

\documentclass[captions=topbeside]{scrbook}
\usepackage[english]{babel}
\begin{document}
\begin{figure}
\begin{captionbeside}
    {A figure description which is neither above nor below, but top beside the figure}
\rule{6cm}{8cm}
\end{captionbeside}
\end{figure}
\end{document}

And the pdflatex result:

enter image description here

Part of compilation output:

> pdflatex topbeside01.tex
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
 restricted \write18 enabled.
entering extended mode
(./topbeside01.tex
LaTeX2e <2011/06/27>
Babel <3.9f> and hyphenation patterns for 78 languages loaded.
(/usr/local/texlive/2013/texmf-dist/tex/latex/koma-script/scrbook.cls
Document Class: scrbook 2013/12/19 v3.12 KOMA-Script document class (book)

Is this a bug or do I miss something?

Best Answer

It’s the documented behaviour, so you do not understand or misread the documentation. Read again (emphasis by me):

With setting topbeside the topmost base lines of the environment contents and caption will be aligned. […] In this context it should be known, that the base line of a pictures (sic!) is mostly at the bottom of the picture. This may be changed, e. g., using \raisebox.

And therefore this works as probably wanted (derived from another example in documentation):

\documentclass[captions=topbeside]{scrbook}
\usepackage[english]{babel}
\usepackage{graphicx}
\begin{document}
\chapter{An Example}
\begin{figure}
\begin{captionbeside}%
{A figure description which is neither above nor
below, but top beside the figure}%
\raisebox{%
\dimexpr\baselineskip-\totalheight\relax
}{%
\includegraphics[scale=0.5]{example-image}%
}%
\end{captionbeside}
\label{fig:maincls.captionbesidetop}
\end{figure}
\end{document}

screenshot of example output

Related Question