4

I am trying to align my figure with the \captionbeside within the textwidth. The figure and the caption next to it should be each 0.5\textwidth and should not go beyond the textwidth in the margin.

Please let me know if there is something missing to understand the question!

(The code I have is adapted from The KOMA-Script-Guide by Markus Kohm: http://texdoc.net/texmf-dist/doc/latex/koma-script/scrguien.pdf)

\documentclass[captions=centeredbeside]{scrbook}
\usepackage[demo]{graphicx}
\usepackage[left=2.5cm, right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry}

\begin{document}
\begin{figure}
\begin{captionbeside}{This is an example caption of a length comparable to my
caption length.This is an example caption comparable to my caption lenght. This is an examplecaption of a length comparable to my caption length.This is an example caption comparable to my caption length.}
[l][\linewidth][%
\dimexpr\marginparwidth+\marginparsep\relax
]*
\raisebox{%
\dimexpr\baselineskip-\totalheight\relax
}{% 
\includegraphics[width=0.5\textwidth]{figure1}
 }%
\end{captionbeside}
\label{fig:test}
\end{figure}
\end{document}
  • Welcome to TeX.Stackexchange! – user36296 Nov 13 '18 at 15:47
2

If you remove all the manual interventions, your caption and image will automatically be placed within the textwidth:

\documentclass[captions=centeredbeside]{scrbook}
\usepackage[demo]{graphicx}
\usepackage[left=2.5cm, right=2.5cm, top=2.5cm, bottom=2.5cm, showframe]{geometry}

\begin{document}
\begin{figure}
\begin{captionbeside}{This is an example caption of a length comparable to my caption length.This is an example caption comparable to my caption lenght. This is an examplecaption of a length comparable to my caption length.This is an example caption comparable to my caption length.}
[l]
\includegraphics[width=0.5\textwidth]{figure1}
\end{captionbeside}
\label{fig:test}
\end{figure}
\end{document}

enter image description here

  • I can't believe I didn't try that right in the beginning... Thank you so much! – Beatrix Keweloh Nov 13 '18 at 15:50
  • @BeatrixKeweloh You're welcome! – user36296 Nov 13 '18 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.