使用旁边的标题将图形和标题与文本宽度对齐

使用旁边的标题将图形和标题与文本宽度对齐

我正在尝试将我的图形与文本宽度内的 \captionbeside 对齐。图形和它旁边的标题应各占 0.5\textwidth,并且不应超出边距中的文本宽度。

如果问题理解上还有什么遗漏,请告诉我!

(我的代码改编自 Markus Kohm 的《KOMA-Script-Guide》):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}

答案1

如果您删除所有手动干预,您的标题和图像将自动放置在文本宽度内:

\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}

在此处输入图片描述

相关内容