我怎样才能强制使标题始终具有相同的边距?

我怎样才能强制使标题始终具有相同的边距?

我希望所有标题的左右边距都相同。如何实现?

图片

在此处输入图片描述

平均能量损失

\documentclass[
12pt,
a4paper
]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}


\usepackage[
labelfont=sf,
hypcap=false,
format=hang,
margin={2cm,2cm},
%also not working for forcing all captions:
%minmargin={2cm,2cm},
%maxmargin={2cm,2cm},
%justification=raggedright,
%width=0.9\columnwidth,
]{caption}

\begin{document}
\begin{table}
\centering
AAA
\caption{Test.}
\end{table}
\begin{center}
BBB
\captionof{table}{Some more words 12. Some more words 12. Some more words 12. Some more words 12. Some more words 12. Some more words 12.}
\end{center}
\end{document}

答案1

尽可能地使用类的内置功能总是更好的,而不是加载额外的包。

在这种情况下,您只需要\setcapmargin{2cm}\setkomafont{captionlabel}{\sffamily}

\documentclass[12pt]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

%% built-in KOMA caption specifications
\setcapmargin{2cm}
\setkomafont{captionlabel}{\sffamily}

\begin{document}
\begin{center}
AAA
\captionof{table}{Test.}
\end{center}
\begin{center}
BBB
\captionof{table}{Some more words 12. Some more words 12. Some more words 12. Some more words 12. Some more words 12. Some more words 12.}
\end{center}
\end{document}

在此处输入图片描述

相关内容