我创建了下表。标题基本上包括标签、标题(位于\caption{}
)和我描述表格的标题(位于\caption*{}
)。格式与《金融杂志》中使用的格式类似。
问题是,如果标题较长,如下图所示,表格和标题就不再居中。
为了创建上述表格,我使用了以下代码。使用 caption 包。
\documentclass[11pt, a4paper]{article}
\usepackage{caption}
\usepackage{tabularx}
\captionsetup[table]{labelsep = newline, labelfont = bf}
\begin{document}
\begin{table}[!htbp] \centering
\caption{\bf \Large This is the main title.}
\caption*{This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table.}
\label{table:rnmSummary}
\begin{center}
\begin{tabular}{ l | c || r }
\hline
1 & 2 & 3 \\ \hline
4 & 5 & 6 \\ \hline
7 & 8 & 9 \\
\hline
\end{tabular}
\end{center}
\end{table}
\end{document}
答案1
你可以使用
\captionsetup{justification=centering,singlelinecheck=off}
在组内(以保持局部效果)。完整的示例:
\documentclass[11pt, a4paper]{article}
\usepackage{caption}
\usepackage{tabularx}
\captionsetup[table]{labelsep = newline, labelfont = bf}
\begin{document}
\begin{table}[!htbp] \centering
{\captionsetup{justification=centering,singlelinecheck=off}
\caption{\bfseries\Large This is the main title and some more words so it spans more than one line.}}
\caption*{This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table. This is a second caption describing the table.}
\label{table:rnmSummary}
\begin{center}
\begin{tabular}{ l | c || r }
\hline
1 & 2 & 3 \\ \hline
4 & 5 & 6 \\ \hline
7 & 8 & 9 \\
\hline
\end{tabular}
\end{center}
\end{table}
\end{document}
结果:
当然,如果要多次使用,请定义一个命令来简化代码。在序言中:
\newcommand\MyCaption[2][]{%
\begingroup
\captionsetup{justification=centering,singlelinecheck=off,font=bf,textfont=Large}
\caption[#1]{This is the main title and some more words so it spans more than one line.}
\endgroup%
}
然后,在你的文档中,
\MyCaption{This is the main title and some more words so it spans more than one line.}