我想仅将“平均差价($)”和“95% CI”列居中对齐。我目前拥有的代码如下:
\begin{frame}
\footnotesize
\centering
\frametitle{Bonferroni Simultaneous Confidence Intervals}
\setcounter{table}{3}
\renewcommand{\tablename}{Table 1} % Set the tablename to Panel, instead of Table
\renewcommand{\thetable}{\Alph{table}} % Setting the table number output to letters
\begin{table}
\caption{Bonferroni Simultaneous Confidence Intervals}
\resizebox{\linewidth}{!}{
\begin{tabular}{*{27}{l}}
\hline
Group 1 & Group 2 & {\thead{Mean Difference Price\\ Paid (\$)}} & 95\% C.I.\\
\hline
SEVERE STORMS&WILDFIRES&-70,917&(-160385,18550)\\
TROPICAL STORM LEE&WILDFIRES&-84,761&(-174238, 4717)\\
SEVERE STORMS&FLOODING&-33,371&(-57274, -9467)\\
TROPICAL STORM LEE&FLOODING&-47,214&(-71155, -23272)\\
TROPICAL STORM LEE&HURRICANE SANDY&-38,685&(-86791, 9421)\\
SEVERE STORMS&WINTER STORM&-36,750&(-72506, -994)\\
TROPICAL STORM LEE&WINTER STORM &-50593&(-86375, -14812)\\
SEVERE STORMS&HURRICANE IRENE&-17,456&(-35801, 888)\\
TROPICAL STORM LEE&HURRICANE IRENE&-31,300&(-49694, -12906)\\
\hline
\end{tabular}}
\end{table}
\end{frame}
我正在使用的软件包是(在 Overleaf 中)
\usepackage{graphicx} % Allows including images
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{float}
\usepackage{tabularx}
\usepackage{array}
\usepackage{wrapfig}
\usepackage{multirow}
\usepackage{tabu}
\usepackage{siunitx}
\usepackage{dcolumn,booktabs}
\newcolumntype{d}{D{.}{\cdot}{-1}}
\usepackage{makecell}
\usepackage{tabulary}
\renewcommand\theadfont{\footnotesize}
\renewcommand\theadgape{}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
此代码产生以下结果。我认为数字左对齐看起来很奇怪。任何帮助都将不胜感激。
答案1
最大的问题是第三列的标题过长,占用了大量宝贵的空间。
我建议在底部解释一下缩写。
\documentclass{beamer}
\usepackage{booktabs,siunitx}
\usetheme{Warsaw}
\sisetup{group-separator={,}}
\begin{document}
\begin{frame}
\frametitle{Bonferroni Simultaneous Confidence Intervals}
\centering
Panel 1: Bonferroni Simultaneous Confidence Intervals
\bigskip
\scriptsize
\addtolength{\tabcolsep}{-1.1pt}
\begin{tabular}{
@{\extracolsep{\fill}}
l
l
S[table-format=-5.0]
@{\hspace{2\tabcolsep}(}
S[table-format=-6.0]
@{,}
S[table-format=-5.0,group-four-digits]
@{)}
}
\toprule
Group 1 &
Group 2 &
\multicolumn{1}{c}{MDPP (\$)} &
\multicolumn{2}{c@{}}{95\% C.I.} \\
\midrule
SEVERE STORMS & WILDFIRES &-70917 & -160385 & 18550 \\
TROPICAL STORM LEE & WILDFIRES &-84761 & -174238 & 4717 \\
SEVERE STORMS & FLOODING &-33371 & -57274 & -9467 \\
TROPICAL STORM LEE & FLOODING &-47214 & -71155 & -23272 \\
TROPICAL STORM LEE & HURRICANE SANDY &-38685 & -86791 & 9421 \\
SEVERE STORMS & WINTER STORM &-36750 & -72506 & -994 \\
TROPICAL STORM LEE & WINTER STORM &-50593 & -86375 & -14812 \\
SEVERE STORMS & HURRICANE IRENE &-17456 & -35801 & 888 \\
TROPICAL STORM LEE & HURRICANE IRENE &-31300 & -49694 & -12906 \\
\midrule[\heavyrulewidth]
\multicolumn{5}{@{}l@{}}{MDPP: Mean Difference Price Paid}
\end{tabular}
\end{frame}
\end{document}
事实证明,如果您避免在前两列中使用全部大写字母并且\small
大小合适,则无需进行任何调整。
\documentclass{beamer}
\usepackage{booktabs,siunitx}
\usetheme{Warsaw}
\sisetup{group-separator={,}}
\begin{document}
\begin{frame}
\frametitle{Bonferroni Simultaneous Confidence Intervals}
\centering
Panel 1: Bonferroni Simultaneous Confidence Intervals
\bigskip
\small
\begin{tabular}{
@{\extracolsep{\fill}}
l
l
S[table-format=-5.0]
@{\hspace{2\tabcolsep}(}
S[table-format=-6.0]
@{,}
S[table-format=-5.0,group-four-digits]
@{)}
}
\toprule
Group 1 &
Group 2 &
\multicolumn{1}{c}{MDPP (\$)} &
\multicolumn{2}{c@{}}{95\% C.I.} \\
\midrule
Severe storms & Wildfires &-70917 & -160385 & 18550 \\
Tropical storm Lee & Wildfires &-84761 & -174238 & 4717 \\
Severe storms & Flooding &-33371 & -57274 & -9467 \\
Tropical storm Lee & Flooding &-47214 & -71155 & -23272 \\
Tropical storm Lee & Hurricane Sandy &-38685 & -86791 & 9421 \\
Severe storms & Winter storm &-36750 & -72506 & -994 \\
Tropical storm Lee & Winter storm &-50593 & -86375 & -14812 \\
Severe storms & Hurricane Irene &-17456 & -35801 & 888 \\
Tropical storm Lee & Hurricane Irene &-31300 & -49694 & -12906 \\
\midrule[\heavyrulewidth]
\multicolumn{5}{@{}l@{}}{MDPP: Mean Difference Price Paid}
\end{tabular}
\end{frame}
\end{document}