我无法理解为什么在这 3 个子表中,只有最后一个子表的标题居中,而前两个子表的标题偏离了中心。这三个子表的代码以及它们的结构和标题几乎完全相同。
有人能给我发一个补救措施吗,但如果可能的话,不要要求我使用一些与不兼容的软件包subfig
。这是有问题的代码(我希望这可以作为 MWE):
\documentclass[11pt,twoside]{book}
\usepackage{caption}
\captionsetup{font=small, labelfont=bf, labelsep=period, width=.77\textwidth, justification=centerlast}
\usepackage{subfig}
\usepackage{mdwtab}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}
\begin{table}[htbp]
\caption{Useful ratios and respective dB's}
\centering
%
\subfloat[Power ratios vs. dB]{%
\vspace{0.5cm}
\begin{tabular}{|c|c|c|c|c|}
\hline
$P/P_{ref}$ & 1 & 2 & 4 & 10 \\
\hline
dB & 0 & 3 & 6 & 10 \\
\hline
\end{tabular}
\vspace{0.5cm}
} \\
%
\subfloat[Voltage ratios vs. dB]{%
\vspace{.5cm}
\begin{tabular}{|c|c|c|c|c|}
\hline
$V/V_{ref}$ & 1 & 2 & 4 & 10 \\
\hline
dB & 0 & 3 & 6 & 10 \\
\hline
\end{tabular}
\vspace{0.5cm}
} \\
%
\subfloat[dB vs. power- and voltage- ratios]{%
\vspace{0.5cm}
\begin{tabular}{|c|c|c|c|c|}
\hline
dB & 0 & 3 & 6 & 10 \\
\hline
$P/P_{ref}$ & 1 & 2 & 4 & 10 \\
\hline
$V/V_{ref}$ & 1 & $\sqrt{2}$ & $\sqrt{4}=2$ & $\sqrt{10}$ \\
\hline
\end{tabular}
}
\label{tab:db_conversions}
\end{table}
\end{document}
该代码的输出如下图所示:
答案1
通过以下方式删除您提供的宽度规格\captionsetup
:
\documentclass{book}
\usepackage{caption,amsmath}
\captionsetup{
font=small,
labelfont=bf,
labelsep=period,
justification=centerlast}
\usepackage{subfig}
\begin{document}
\begin{table}
\caption{Useful ratios and respective dB's}
\centering
\subfloat[Power ratios vs.\ dB]{%
\begin{tabular}{ *{5}{c} }
$P/P_{\text{ref}}$ & 1 & 2 & 4 & 10 \\
\hline
dB & 0 & 3 & 6 & 10
\end{tabular}
}
\subfloat[Voltage ratios vs.\ dB]{%
\begin{tabular}{ *{5}{c} }
$V/V_{\text{ref}}$ & 1 & 2 & 4 & 10 \\
\hline
dB & 0 & 3 & 6 & 10
\end{tabular}
}
\subfloat[dB vs.\ power- and voltage-ratios]{%
\begin{tabular}{ *{5}{c} }
dB & 0 & 3 & 6 & 10 \\
\hline
$P/P_{\text{ref}}$ & 1 & 2 & 4 & 10 \\
\hline
$V/V_{\text{ref}}$ & 1 & $\sqrt{2}$ & $\sqrt{4}=2$ & $\sqrt{10}$
\end{tabular}
}
\end{table}
\end{document}