边距标题的 captionsetup

边距标题的 captionsetup

我使用 caption 包来设置字幕的布局。但是对于使用 mcaption 包的边距字幕,\captionsetup似乎没有达到预期的效果。

\documentclass{scrbook}
\usepackage{graphicx}
\usepackage{caption}[2011/08/06]
\usepackage{mcaption}
\usepackage{float}
\usepackage{ragged2e}
\captionsetup{format=plain}
\captionsetup[margincap]{name=Fig.,
  indention=0pt,justification=RaggedRight}
\begin{document}

Pellentesque mollis nunc sed mauris tempor molestie. Aliquam adipiscing nisi

\begin{figure}[H]
\begin{margincap}
  \centering
  \includegraphics[width=0.4\textwidth]{images/TestBild}
  \caption[short caption text]{long caption text with some more 
   text and a bit more text and a little more text to fill space.}
  \label{fig:picmargincap}
\end{margincap}
\end{figure}

Pellentesque mollis nunc sed mauris tempor molestie. Aliquam adipiscing nisi
\end{document}

“Figure” 应缩​​写为 “Fig.” 但事实并非如此:

在此处输入图片描述

答案1

margincap不是一个浮动环境:

\begin{figure}
\captionsetup{name=Fig.,
  indention=0pt,justification=RaggedRight}
\begin{margincap}
  \centering
  \includegraphics[width=0.4\textwidth]{images/TestBild}
  \caption[short caption text]{long caption text with some more
   text and a bit more text and a little more text to fill space.}
  \label{fig:picmargincap}
\end{margincap}
\end{figure}

\usepackage{mcaption}
\usepackage{etoolbox}
\preto\margincap{\captionsetup{name=Fig.,%
  indention=0pt,justification=RaggedRight}}

您可以避免在环境中设置修改figure

按照 Axel Sommerfeldt 的建议,可以更好地定义一个新选项:

\usepackage{caption}
\usepackage{mcaption}
\usepackage{etoolbox}
\preto\margincap{\captionsetup{options=margincap}}

\captionsetup[margincap]{name=Fig.,%
  indention=0pt,justification=RaggedRight}}

答案2

mcaption'smargincap使用与传统环境相同的计数器figure,即figure。从包装文档(第 1 页,第2 使用):

标题文本和标签取自 环境内的命令\caption\label

因此,以下操作可产生所需的结果:

在此处输入图片描述

\documentclass{scrbook}
\usepackage[demo]{graphicx}
\usepackage{caption}[2011/08/06]
\usepackage{mcaption}
\usepackage{float}
\usepackage{ragged2e}
\captionsetup{format=plain}
\captionsetup[figure]{name=Fig.,
  indention=0pt,justification=RaggedRight}
\begin{document}

Pellentesque mollis nunc sed mauris tempor molestie. Aliquam adipiscing nisi

\begin{figure}[H]
\begin{margincap}
  \centering
  \includegraphics[width=0.4\textwidth]{images/TestBild}
  \caption[short caption text]{long caption text with some more 
   text and a bit more text and a little more text to fill space.}
  \label{fig:picmargincap}
\end{margincap}
\end{figure}

Pellentesque mollis nunc sed mauris tempor molestie. Aliquam adipiscing nisi
\end{document}

相关内容