我有这个代码
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[margin=2.5cm]{geometry} % showframe
\usepackage{multirow}
\usepackage{multicol}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{bm}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{siunitx}
\usepackage[skip=0.33\baselineskip]{caption}
\captionsetup[table]{
font=bf,
size=normalsize,
justification=centerlast,
labelsep=newline
}
\renewcommand\thetable{\Roman{table}}
\begin{document}
\listoftables
\pagenumbering{roman}
\pagenumbering{arabic}
\setcounter{page}{1}
\vspace{10ex}
\def\arraystretch{1.5}
\begin{table}[h]
\centering
\setlength\tabcolsep{0pt}
\sisetup{table-format=2.2, group-separator={,}, group-minimum-digits=4}
\caption{\large{Header that includes math like this: $\bm{t(\alpha)}$}}
\label{table:fundsummary}
\parbox{\linewidth}{\small{This table presents some very interesting and very fancy data, which I expect will provide me with at least two Nobel prizes.}\vspace{2ex}}
\medskip\small\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
l
S[table-format=-2.2]
*{6}{S}
}
\toprule
\multicolumn{1}{c}{\multirow{2}{*}{Description}}&
\multicolumn{1}{c}{\multirow{2}{*}{Variable}}&
\multicolumn{5}{c}{Averages}\\\cmidrule{3-7}
\multicolumn{2}{c}{}&{Factor 1}&{Factor 2}&{Factor 3}&{Factor 4}&{Factor 5}\\\midrule
Section 1 &11.11 &22.22 &33.33 &44.44 &55.55 &66.66\\\midrule
Section 2\\
Section 2.2 &11.11 &22.22 &33.33 &44.44 &55.55 &66.66\\
Section 2.3 &11.11 &22.22 &33.33 &44.44 &55.55 &66.66\\
Section 2.4 &11.11 &22.22 &33.33 &44.44 &55.55 &66.66\\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
产生这个输出
我的表格标题是粗体,因此对于包含数学的表格,我使用\bm包。但是,我刚刚注意到数学符号在目录中也显示为粗体。有没有办法让数学符号在表头中保持粗体字体,然后在目录中将其设置为普通字体?
我读过了这问题,但解决方案似乎只适用于回忆录类。
提前致谢!
答案1
只需使用可选参数来\caption
包含应该显示在目录 (ToC) 中的文本即可。即,更改
\caption{\large{Header that includes math like this: $\bm{t(\alpha)}$}}
到
\captionsetup{font={large,bf}} % repeat 'bf' from an earlier '\captionsetup' call
\caption[Header that includes math like this: $t(\alpha)$]% % optional arg. for ToC
{Header that includes math like this: $\bm{t(\alpha)}$}
并重新编译两次。
请注意,由于您正在加载caption
包,因此最好通过指令更改标题的字体大小\captionsetup
。还请注意,这\large
是一个开关,即它不接受参数。
完整的 MWE (最小工作示例):
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[margin=2.5cm]{geometry}
\usepackage{booktabs}
\usepackage{bm}
\usepackage{mathtools}
\usepackage{siunitx}
\usepackage{caption}
\captionsetup[table]{font=bf,size=normalsize,
justification=centerlast,labelsep=newline}
\renewcommand\thetable{\Roman{table}}
\begin{document}
\pagenumbering{roman}
\listoftables
\clearpage
\pagenumbering{arabic}
\begin{table}[h]
\def\arraystretch{1.5}
\captionsetup{skip=0.33\baselineskip,font={large,bf}}
\setlength\tabcolsep{0pt}
\sisetup{table-format=2.2, group-separator={,},
group-minimum-digits=4}
\caption[Header that includes math like this: $t(\alpha)$]
{Header that includes math like this: $\bm{t(\alpha)}$}
\label{table:fundsummary}
\small
This table presents some very interesting and very fancy data,
which I expect will provide me with at least two Nobel prizes.
\medskip
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
l S[table-format=-2.2] *{5}{S} }
\toprule
Description & {Variable} & \multicolumn{5}{c}{Averages}\\
\cmidrule{3-7}
&&{Factor 1}&{Factor 2}&{Factor 3}&{Factor 4}&{Factor 5}\\
\midrule
Section 1 &-11.11 &22.22 &33.33 &44.44 &55.55 &66.66\\
\addlinespace
Section 2 \\
Section 2.2&-11.11 &22.22 &33.33 &44.44 &55.55 &66.66\\
Section 2.3&-11.11 &22.22 &33.33 &44.44 &55.55 &66.66\\
Section 2.4&-11.11 &22.22 &33.33 &44.44 &55.55 &66.66\\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
答案2
虽然我更喜欢 Mico 的答案,但也可以重新定义\bm
LOT。由于\bm
受到保护,它不会在 aux 或 lot 文件中展开。
顺便说一句,对于 MWE,您需要的是\caption
,而不是tabular
。
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[margin=2.5cm]{geometry} % showframe
\usepackage{multirow}
\usepackage{multicol}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{bm}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{siunitx}
\usepackage[skip=0.33\baselineskip]{caption}
\captionsetup[table]{
font=bf,
size=normalsize,
justification=centerlast,
labelsep=newline
}
\renewcommand\thetable{\Roman{table}}
\begin{document}
\bgroup
\def\bm{}
\listoftables
\egroup
\pagenumbering{roman}
\pagenumbering{arabic}
\setcounter{page}{1}
\vspace{10ex}
\def\arraystretch{1.5}
\begin{table}[h]
\centering
\setlength\tabcolsep{0pt}
\sisetup{table-format=2.2, group-separator={,}, group-minimum-digits=4}
\caption{\large{Header that includes math like this: $\bm{t(\alpha)}$}}
\label{table:fundsummary}
\parbox{\linewidth}{\small{This table presents some very interesting and very fancy data, which I expect will provide me with at least two Nobel prizes.}\vspace{2ex}}
\medskip\small\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
l
S[table-format=-2.2]
*{6}{S}
}
\toprule
\multicolumn{1}{c}{\multirow{2}{*}{Description}}&
\multicolumn{1}{c}{\multirow{2}{*}{Variable}}&
\multicolumn{5}{c}{Averages}\\\cmidrule{3-7}
\multicolumn{2}{c}{}&{Factor 1}&{Factor 2}&{Factor 3}&{Factor 4}&{Factor 5}\\\midrule
Section 1 &11.11 &22.22 &33.33 &44.44 &55.55 &66.66\\\midrule
Section 2\\
Section 2.2 &11.11 &22.22 &33.33 &44.44 &55.55 &66.66\\
Section 2.3 &11.11 &22.22 &33.33 &44.44 &55.55 &66.66\\
Section 2.4 &11.11 &22.22 &33.33 &44.44 &55.55 &66.66\\
\bottomrule
\end{tabular*}
\end{table}
\end{document}