我正在使用带有 sidenotes 包的 koma 脚本。
我可以重新定义\sidecaption
以获得语法吗\ caption [Text in list of figures] {Text next to the figure}
最小示例:
\documentclass{scrbook}
\usepackage{graphicx}
\usepackage{sidenotes}
\begin{document}
\listoffigures
\begin{figure}[htb]
\sidecaption[][-2\baselineskip]{Text next to image 1}%Missing lof description
\includegraphics[width=\textwidth]{example-image-a}
\end{figure}
\begin{figure}[htb]
\caption[Text in listoffigures]{Text next to image 2}
\includegraphics[width=\textwidth]{example-image-a}
\end{figure}
\end{document}
答案1
中的可选参数的选择\sidecaption
不是最好的。语法的更好选择可能是
\sidecaption[<list entry>]{<caption>}[<offset>]
但软件包的作者却不这么认为。
\begin{figure}[htb]
\sidecaption[Text next to image 1][-2\baselineskip]{Text next to image 1}
\includegraphics[width=\textwidth]{example-image-a}
\end{figure}
您可能希望使用具有更好的语法的其他命令。
\documentclass{scrbook}
\usepackage{graphicx}
\usepackage{sidenotes}
\NewDocumentCommand{\SideCaption}{sO{#3}mo}{%
\IfBooleanTF{#1}
{% \sidecaption*
\IfNoValueTF{#4}{\sidecaption*{#3}}{\sidecaption*[#4]{#3}}%
}
{% \sidecaption
\IfNoValueTF{#4}{\sidecaption[#2]{#3}}{\sidecaption[#2][#4]{#3}}%
}%
}
\begin{document}
\listoffigures
\begin{figure}[htb]
\SideCaption{Text next to image 1}[-2\baselineskip]
\includegraphics[width=\textwidth]{example-image-a}
\end{figure}
\begin{figure}[htb]
\SideCaption[Lof text]{Text next to image 2}[-2\baselineskip]
\includegraphics[width=\textwidth]{example-image-a}
\end{figure}
\begin{figure}[htb]
\caption[Text in listoffigures]{Text next to image 3}
\includegraphics[width=\textwidth]{example-image-a}
\end{figure}
\end{document}