1

I would like to center align just the "Mean Difference Price Paid ($)" and "95% C.I." columns. The code I currently have is as follows:

\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}

The packages I am using are (in 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}}

This code produces the following. I think the numbers look strange left-aligned. Any help would be greatly appreciated.

enter image description here

  • (i) please extend your code snippet to complete small document with this snuppet as document body (ii) whay the table has defined 27 columns if you use only 4? (iii) don't use \resizebox, better is define smaller fonts (in case that table is to wide) or reduce column header width by its rephrasing or breaking in more lines (iv) consider to use S columns type from the siunitx package for the third column. – Zarko May 7 at 21:48
  • I was using the sample code here. I guess I didn't understand what the code was actually doing. I will edit my post. – Remy May 7 at 21:55
  • 1
    in giving link you have answer with very good advice: don't use large table in presentation :-), and please, merge both document fragments in to one complete document! – Zarko May 7 at 22:00
2

The biggest problem is the overlong header in the third column that eats a lot of valuable space.

I suggest an abbreviation explained at the bottom.

\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}

nnn

It turns out that no adjustment needs to be done if you avoid all uppercase in the first two columns and \small size fits.

\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}

enter image description here

  • Thanks, looks a lot better! Would it be possible for you to add leading parentheses in the confidence intervals? – Remy May 7 at 22:04
  • @Remy Sorry, posted the wrong image and left a wrong % inserted for an experiment. Please, have a look also at the second picture. – egreg May 7 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.