我正在尝试使用“captionsetup”格式化表格的标题,但无论我给它什么选项都没有效果,也没有返回任何错误消息。我想格式化它,使标签和标题在不同的行上,并向左对齐。
有什么帮助吗?
这是我的代码:
\documentclass{article}
\usepackage{caption}
\begin{document}
\begin{table}[h]
\captionsetup[table]{position=above,justification=raggedright}
\caption{\\Title of the table}
\begin{center}
\begin{tabular}{llp{2cm}p{2cm}}
...
\end{tabular}
\end{center}
\label{BoS}
\end{table}
\end{document}
答案1
正如 @egreg 和 @Johannes_B 在评论中所说,你可能想要labelsep=newline
和 singlelinecheck=false
如果没有后者,短标题将居中而不是左对齐。
顺便说一句:除非你想要这个设置,否则设置应该放在序言中仅适用于一张桌子。我还会使用 来\centering
代替“center”环境。该环境会插入额外的垂直空间。
\documentclass{article}
\usepackage{caption}
% the setup belongs into the preamble! you don't want to repeat the setup each
% time you insert a new table.
\captionsetup[table]{
position=above,
justification=raggedright,
labelsep=newline, % <<< label and text on different lines
singlelinecheck=false % <<< raggadright also when the caption is shorter
% than a single line
}
\begin{document}
\begin{table}
\centering
\caption{Title of the table}\label{tab:first}
This is my first table.
\end{table}
\begin{table}
\centering
\caption{Title of the table that is a bit longer. Indeed it is longer than
one line. We still need a little more.}\label{tab:second}
This is my second table.
\end{table}
\end{document}