1

Guys anyone can figure out whatt's wrong here? I got this table from outreg2 stata and did some edit based on clemen's answer from this post. Thanks!

\documentclass[]{article}


\usepackage{amsfonts}
\usepackage{amsmath,array}
\usepackage[detect-all]{siunitx}
\usepackage[margin=1 in]{geometry}
\usepackage{booktabs, longtable}
\usepackage[english]{babel}

\setlength{\pdfpagewidth}{8.5in} \setlength{\pdfpageheight}{11in}
\begin{document}
\sisetup{
  input-symbols         = (),
  table-format          = -1.4,
  table-space-text-post = ***,
  table-align-text-post = false,
  group-digits          = false
}
\begin{tabular}{l *{8}{S}} \hline
 & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) \\
Variables & FullD & FullD & FullD & FullD & FullD & FullD & FullD & FullD \\ \hline
 &  &  &  &  &  &  &  &  \\
STI\_30 & 0.301*** & 0.179** & 0.152* & 0.159 & -0.000 & 0.107 & 0.097 & 0.115 \\
 & (0.087) & (0.085) & (0.085) & (0.097) & (0.003) & (0.084) & (0.094) & (0.105) \\
Produce\_Full\_SR &  & 0.349*** & 0.321*** & 0.303* & 0.318*** & 0.270*** & 0.244*** & 0.257*** \\
 &  & (0.071) & (0.074) & (0.170) & (0.074) & (0.074) & (0.078) & (0.090) \\
Has\_Sus\_Efforts &  &  & 0.078*** & 0.077*** & 0.245*** & 0.001 & 0.046** & 0.129*** \\
 &  &  & (0.020) & (0.020) & (0.094) & (0.013) & (0.019) & (0.041) \\
1o.STI\_30\#1o.Produce\_Full\_SR &  &  &  & 0.000 &  &  &  &  \\
 &  &  &  & (0.000) &  &  &  &  \\
1o.STI\_30\#1o.Has\_Sus\_Efforts &  &  &  &  & 0.000 &  &  &  \\
 &  &  &  &  & (0.000) &  &  &  \\
Water\_Efforts &  &  &  &  &  & 0.168*** &  &  \\
 &  &  &  &  &  & (0.039) &  &  \\
C\_or\_S &  &  &  &  &  &  & 0.202*** &  \\
 &  &  &  &  &  &  & (0.066) &  \\
C\_or\_S1 &  &  &  &  &  &  &  & 0.221** \\
 &  &  &  &  &  &  &  & (0.100) \\
Constant & 0.054*** & 0.029*** & -0.001 & -0.002 & 0.000 & -0.001 & 0.000 & 0.000 \\
 & (0.010) & (0.008) & (0.003) & (0.003) & (0.003) & (0.003) & (0.000) & (0.000) \\
 &  &  &  &  &  &  &  &  \\
Observations & 566 & 555 & 552 & 552 & 552 & 552 & 252 & 140 \\
Year FE & No & No & No & No & No & No & No & No \\
Nb of obs & 566 & 555 & 552 & 552 & 552 & 552 & 252 & 140 \\
 Adjusted R-squared & 0.0696 & 0.211 & 0.233 & 0.232 & 0.234 & 0.275 & 0.199 & 0.133 \\ \hline
\multicolumn{9}{c}{ Robust standard errors in parentheses} \\
\multicolumn{9}{c}{ *** p$<$0.01, ** p$<$0.05, * p$<$0.1} \\
\end{tabular}
\end{document}

Johnny

1 Answer 1

2

Cells in S-type columns which do not conform to the expected numeric format -- including cells such as (1), FullD, No, 552, and 0.0696 -- must be centered.

This is done most easily by encasing the cell contents in curly braces. E.g., instead of

Variables & FullD & FullD & FullD & FullD & FullD & FullD & FullD & FullD

you need to input

Variables & {FullD} & {FullD} & {FullD} & {FullD} & {FullD} & {FullD} & {FullD} & {FullD}

As the table is quite wide, it needs to be rendered in landscape format. One way to do this is to load the rotating package and employ its sidewaystable environment.

Finally, since you're loading the booktabs package, do make use of its \toprule, \midrule, \bottomrule, and \addlinespace directives instead of \hline.

enter image description here

\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry}
\setlength{\pdfpagewidth}{8.5in} 
\setlength{\pdfpageheight}{11in}
\usepackage[english]{babel}

\usepackage{amssymb,amsmath,array}
\usepackage{siunitx} % don't use 'detect-all' switch unless you know what you're doing
\usepackage{booktabs}
\usepackage{rotating} % for 'sidewaystable' env.

\begin{document}
\begin{sidewaystable}
\sisetup{
  input-symbols         = (),
  table-format          = -1.3,
  table-space-text-post = ***,
  table-align-text-post = false,
  group-digits          = false
}
\noindent
\begin{tabular}{@{}l *{8}{S} @{}} 
\toprule
          & {(1)} & {(2)} & {(3)} & {(4)} & {(5)} & {(6)} & {(7)} & {(8)} \\
Variables & {FullD} & {FullD} & {FullD} & {FullD} & {FullD} & {FullD} & {FullD} & {FullD} \\ 
\midrule
STI\_30   & 0.301*** & 0.179** & 0.152* & 0.159 & -0.000 & 0.107 & 0.097 & 0.115 \\
          & (0.087) & (0.085) & (0.085) & (0.097) & (0.003) & (0.084) & (0.094) & (0.105) \\
Produce\_Full\_SR &  & 0.349*** & 0.321*** & 0.303* & 0.318*** & 0.270*** & 0.244*** & 0.257*** \\
          &  & (0.071) & (0.074) & (0.170) & (0.074) & (0.074) & (0.078) & (0.090) \\
Has\_Sus\_Efforts &  &  & 0.078*** & 0.077*** & 0.245*** & 0.001 & 0.046** & 0.129*** \\
          &  &  & (0.020) & (0.020) & (0.094) & (0.013) & (0.019) & (0.041) \\
1o.STI\_30\#1o.Produce\_Full\_SR &  &  &  & 0.000 &  &  &  &  \\
          &  &  &  & (0.000) &  &  &  &  \\
1o.STI\_30\#1o.Has\_Sus\_Efforts &  &  &  &  & 0.000 &  &  &  \\
          &  &  &  &  & (0.000) &  &  &  \\
Water\_Efforts &  &  &  &  &  & 0.168*** &  &  \\
          &  &  &  &  &  & (0.039) &  &  \\
C\_or\_S  &  &  &  &  &  &  & 0.202*** &  \\
          &  &  &  &  &  &  & (0.066) &  \\
C\_or\_S1 &  &  &  &  &  &  &  & 0.221** \\
          &  &  &  &  &  &  &  & (0.100) \\
Constant  & 0.054*** & 0.029*** & -0.001 & -0.002 & 0.000 & -0.001 & 0.000 & 0.000 \\
          & (0.010) & (0.008) & (0.003) & (0.003) & (0.003) & (0.003) & (0.000) & (0.000) \\
\midrule
Observations & {566} & {555} & {552} & {552} & {552} & {552} & {252} & {140} \\
Year FE      & {No} & {No} & {No} & {No} & {No} & {No} & {No} & {No} \\
Nr.\ of obs  & {566} & {555} & {552} & {552} & {552} & {552} & {252} & {140} \\
Adj.\ R\textsuperscript{2} & {0.0696} & {0.211} & {0.233} & {0.232} & {0.234} & {0.275} & {0.199} & {0.133} \\ 
\bottomrule
\addlinespace
\multicolumn{9}{c}{Robust standard errors in parentheses} \\
\multicolumn{9}{c}{$^{***}\ p<0.01$; $^{**}\ p<0.05$, $^{*}\ p<0.1$} \\
\end{tabular}
\end{sidewaystable}
\end{document}
6
  • Nice thanks Mico! can i know what is the use of @{} in \begin{tabular}{@{}l *{8}{S} @{}}
    – Johnny
    Jan 3, 2019 at 11:54
  • And I have another qn: how do you get it p to be italicized at the last row??
    – Johnny
    Jan 3, 2019 at 12:00
  • @Johnny - Your code has *** p$<$0.01; I changed it to $^{***}\ p<0.01$. Put differently, I made p part of the "formula" p<0.01. This affects not only the shape of the letter "p" but also the spacing around the < symbol. The @{} particles in {@{} l *{8}{S} @{}} serve to suppress the whitespace padding that would otherwise be inserted to the left of the first column and to the right of the final column. This padding is not needed if one doesn't require vertical bars at the left-hand and right-hand edges of the tabular environment.
    – Mico
    Jan 3, 2019 at 12:53
  • Thanks Mico for the explanation! What are the (backslash and space) before the p's for btw?
    – Johnny
    Jan 4, 2019 at 7:17
  • btw do I need to add the braces (for my first qn in the post) manually? is there any keyboard shortcuts/ codes that can automate the adding of braces for non-numeric elements?
    – Johnny
    Jan 4, 2019 at 7:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .