0

I used the stargazer module in R to do the following table (and I've adapted it some). I wish to have the standard error of that one really long IV interaction term (the 0.300) in the same line as the second line of the text in the left column so there is no gap in the table as there is currently.

Also, on a related note, the stargazer package has this strange notation to create its table, which I have replaced by a specific column width. I am referring to this, which I have added as a comment: {@{\extracolsep{5pt}}lD{.}{.}{-3} }

What does it mean?

As far as my search goes, I have come across this: How to align two column in a table but they do not cover how to do this in the middle of a table.

\begin{tabular}{p{7cm}p{2cm}} %{@{\extracolsep{5pt}}lD{.}{.}{-3} } 
\\[-1.8ex]\hline 
\hline \\[-5ex] 
 & \multicolumn{1}{c}{\textit{Dependent variable:}} \\ 
\cline{2-2} 
\\[-4.5ex] & \multicolumn{1}{c}{Some DV} \\ 
\hline \\[-5ex] 
 Some IV & \multicolumn{1}{c}{0.1} \\ 
  & \multicolumn{1}{c}{(0.1)} \\ 
  Some really long IV for an interaction with*another really long IV & \multicolumn{1}{c}{$50^{***}$} \\ 
  & \multicolumn{1}{c}{(0.300)} \\ 
  Constant & \multicolumn{1}{c}{$50^{***}$} \\ 
  & \multicolumn{1}{c}{(10.3)} \\ 
 \hline \\[-5ex] 
Observations & \multicolumn{1}{c}{1000} \\ 
R$^{2}$ & \multicolumn{1}{c}{0.121} \\
\hline 
\hline \\[-1.8ex] 
\textit{Note:}  & \multicolumn{1}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular}

enter image description here

2 Answers 2

0

To simply move (0.300) to the same line as with*... you could use the makecell package as shown in the following example.

\documentclass{article}
\usepackage{makecell}
\begin{document}

\begin{tabular}{p{7cm}c}
\\
\hline 
\hline
 & \textit{Dependent variable:} \\ 
\cline{2-2} 
 & Some DV \\ 
\hline
 Some IV & 0.1 \\ 
  & (0.1) \\ 
  Some really long IV for an interaction with*another really long IV &  \makecell[t]{$50^{***}$ \\(0.300)} \\ 
  Constant & $50^{***}$ \\ 
  & (10.3)\\ 
 \hline
Observations & 1000 \\ 
R$^{2}$ & 0.121 \\
\hline 
\hline
\textit{Note:}  & \multicolumn{1}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular}

\end{document}

enter image description here

Please note, that I have removed all the unneccesary \multicolumn{1} commands (as well as [-5ex]...) and changed the column specifier of the second column.

To make the distances of the horizontal lines to the text in you table more visually appealing, you might also consider using the booktabs package and its rules as shown in the following example. Please note, that I have additionally changed the Note row so that the second column is not unneccesary wide.

\documentclass{article}
\usepackage{makecell}
\usepackage{booktabs}

\begin{document}

\begin{tabular}{p{7cm}c}
\toprule
 & \textit{Dependent variable:} \\ 
\cmidrule{2-2} 
 & Some DV \\ 
\midrule
 Some IV & 0.1 \\ 
  & (0.1) \\ 
  Some really long IV for an interaction with*another really long IV &  \makecell[t]{$50^{***}$ \\(0.300)} \\ 
  Constant & $50^{***}$ \\ 
  & (10.3)\\ 
\midrule
Observations & 1000 \\ 
R$^{2}$ & 0.121 \\
\bottomrule
\multicolumn{2}{l}{\textit{Note:} \hfill  $^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01}
\end{tabular}

\end{document}

enter image description here

Lastly, you might also consider having the value and its error in the same line. In my opinion this would make it clearer to which entry in the left column they belong. As a side effect, you will save some vertical space.

1
  • Thank you so much. I also appreciate the advice on how to make the table look more appealing.
    – Tea Tree
    Jan 28, 2018 at 22:45
0

Some improvements and simplifications: I grouped the first six rows after the head row by pairs, with a systematic use of makecell, adding some vertical spacing between the groups and trimming the \cmidrule. Also I used the threeparttable package for the notes:

\documentclass{article}
\usepackage{makecell}
\usepackage{booktabs}
\usepackage{threeparttable, xspace}

\begin{document}

\begin{threeparttable}
\begin{tabular}{lc}
\toprule
 & \textit{Dependent variable:} \\
\cmidrule(lr){2-2}
 & Some DV \\
\midrule
 Some IV & \makecell[t]{0.1\\(0.1)} \\
 \addlinespace
  \makecell[l]{Some really long IV for an interaction \\ with\tnote{*}\, another really long IV} & \makecell{50\tnote{***} \\(0.300)} \\
\addlinespace
  Constant & \makecell[t]{50\tnote{***}\\ (10.3)} \\
\midrule
Observations & 1000 \\
R$^{2}$ & 0.121 \\
\bottomrule
\end{tabular}
\begin{tablenotes}[para]
\textit{Note: }
  \item[*] $p < 0.1$;
\item[** ] $p < 0.05$;
\item[***] $p < 0.01$.
\end{tablenotes}
\end{threeparttable}

\end{document} 

enter image description here

1
  • Thanks for the details on how to make the table look prettier. Henceforth this shall be the template I'll use for my tables!
    – Tea Tree
    Jan 28, 2018 at 22:46

You must log in to answer this question.

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