我正在尝试在 Latex 中的表格中将下标置于上标正下方。我使用以下代码:
\begin{table}[htbp]
\centering
\begin{threeparttable}
\caption{To evaluate the statistical significance of variations in average measures across different countries, we computed p-values using a variety of statistical tests. The subscript numbers \textsubscript{1}, \textsubscript{2}, and \textsubscript{3} represent zones 1, 2, and 3, respectively. The superscript letters \textsuperscript{a}, \textsuperscript{b}, and \textsuperscript{c} denote the statistical tests ANOVA, T-test, and Welch's T-test, respectively. The Anderson-Darling test checks for data normality, while the ANOVA and T-tests are parametric tests for mean differences between groups. A p-value indicates the likelihood of observing the calculated mean value (or a more extreme value) if the null hypothesis is true; a low p-value (typically <0.05) suggests that the differences are statistically significant.}
\label{tab:NewPValues}
\begin{tabular}{@{}l S[table-format=1.3]S[table-format=1.3]S[table-format=1.3] | l S[table-format=1.3]S[table-format=1.3]S[table-format=1.3]@{}}
\toprule
\multicolumn{4}{c|}{\textbf{1928 - 1979}} & \multicolumn{4}{c}{\textbf{1995}} \\
\textbf{p\textsuperscript{a}\textsubscript{a-b-c}} & {\textbf{Country}} & {\textbf{p\textsuperscript{b}}} & {\textbf{p\textsuperscript{c}}} & \textbf{p\textsuperscript{a}\textsubscript{a-b-c}} & {\textbf{Country}} & {\textbf{p\textsuperscript{b}}} & {\textbf{p\textsuperscript{c}}} \\
\midrule
0.256 & {a - b} & 0.049 & 0.115 & 0.467 & {a - b} & 0.321 & 0.874 \\
& {b - c} & 0.198 & 0.572 & & {b - c} & 0.164 & 0.531 \\
& {a - c} & 0.087 & 0.293 & & {a - c} & 0.212 & 0.689 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item
\end{tablenotes}
\end{threeparttable}
\end{table}
`
如您所见,下标 abc 位于上标 a 的右侧。我希望下标位于上标下方,并从完全相同的水平位置开始。有人知道如何实现吗?
答案1
我建议你改变两个实例
\textbf{p\textsuperscript{a}\textsubscript{a-b-c}}
到
\textbf{p}\textsuperscript{\rlap{\kern0.5pt\textbf{a}}}\textsubscript{\textbf{a-b-c}}
另一个想法:假设p
表示“p 值”,我不明白为什么你使用粗体和文本模式而不是数学模式。例如,你为什么不放弃(边缘粗俗的样子)大胆的并写下$p^{a}_{\text{a-b-c}}$
?(\text
是包提供的宏amsmath
。)
\documentclass{article}
\begin{document}
\textbf{p}\textsuperscript{\rlap{\kern0.5pt\textbf{a}}}\textsubscript{\textbf{a-b-c}}
\end{document}
答案2
您需要类似\textsubsuperscript
定义的内容,类似于配套命令。无需猜测要备份多少。
我建议使用它\cmidrule
来更好地理解顶部标题所指的是哪些列,而不是垂直规则。
\documentclass{article}
\usepackage{threeparttable,booktabs,siunitx}
\makeatletter
\NewDocumentCommand{\textsubsuperscript}{mm}{%
{% start a group
\m@th % no \mathsurround
\ensuremath{% enter math mode
_{\mbox{\fontsize\sf@size\sf@size\selectfont #1}}% subscript
^{\mbox{\fontsize\sf@size\sf@size\selectfont #2}}% superscript
}% exit math mode
}% close the group
}
\makeatother
\begin{document}
\begin{table}[htbp]
\centering
\begin{threeparttable}
\caption{To evaluate the statistical significance of variations in
average measures across different countries, we computed p-values
using a variety of statistical tests. The subscript numbers
\textsubscript{1}, \textsubscript{2}, and \textsubscript{3} represent
zones 1, 2, and 3, respectively. The superscript letters
\textsuperscript{a}, \textsuperscript{b}, and \textsuperscript{c}
denote the statistical tests ANOVA, T-test, and Welch's T-test,
respectively. The Anderson-Darling test checks for data normality,
while the ANOVA and T-tests are parametric tests for mean differences
between groups. A p-value indicates the likelihood of observing the
calculated mean value (or a more extreme value) if the null hypothesis
is true; a low p-value (typically $<0.05$) suggests that the differences
are statistically significant.}
\label{tab:NewPValues}
\begin{tabular}{
@{}
l
S[table-format=1.3]
S[table-format=1.3]S[table-format=1.3]
l
S[table-format=1.3]S[table-format=1.3]
S[table-format=1.3]
@{}
}
\toprule
\multicolumn{4}{c}{\textbf{1928 -- 1979}} & \multicolumn{4}{c}{\textbf{1995}} \\
\cmidrule(r){1-4} \cmidrule(l){5-8}
\textbf{p\textsubsuperscript{a-b-c}{a}} &
{\textbf{Country}} &
{\textbf{p\textsuperscript{b}}} &
{\textbf{p\textsuperscript{c}}} &
\textbf{p\textsubsuperscript{a-b-c}{a}} &
{\textbf{Country}} &
{\textbf{p\textsuperscript{b}}} &
{\textbf{p\textsuperscript{c}}} \\
\midrule
0.256 & {a - b} & 0.049 & 0.115 & 0.467 & {a - b} & 0.321 & 0.874 \\
& {b - c} & 0.198 & 0.572 & & {b - c} & 0.164 & 0.531 \\
& {a - c} & 0.087 & 0.293 & & {a - c} & 0.212 & 0.689 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item Something here to see that there are notes
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}