1

I need this table to be aligned properly with decimal points of the coefficient value. The minus signs are also not good here. I think this can be attained through dcolumn but I could not get it apparently because there are two decimal points: one for the coefficient value and the other for the SE value. Any help please!

\documentclass[12pt]{article}
\usepackage{stackengine}
\begin{document}
\begin{table}
\caption{Regression results I}
\begin{center}
\stackunder{
\begin{tabular}{llll} \hline
 & (1) & (2) & (3) \\
 & Low Value-added & High value-added & Total \\ \hline
RTA         & 0.718 (0.265)***  & -0.487 (0.544)    & 0.648 (0.286)** \\
RTA(t-3)    & 0.430 (0.208)**   & 0.419 (0.265)     & 0.425 (0.219)* \\
RTA(t-6)    & 0.047 (0.067)     & 0.540 (0.262)**   & 0.013 (0.070) \\
RTA(t-9)    & -0.074 (0.180)    & 0.353 (0.156)**   & -0.123 (0.186) \\
RTA(t-12)   & 0.553 (0.195)***  & 0.602 (0.328)*    & 0.494 (0.182)*** \\
GATT/WTO    & 0.277 (0.358)     & -0.527 (0.402)    & 0.085 (0.373) \\
Constant    & 8.081 (0.358)***  & 6.980 (0.763)***  & 8.606 (0.379)*** \\ 
Country/Time FE & Yes           & Yes               &Yes \\\hline
N           & 4,872             & 4,872             & 4,872 \\
R-squared   & 0.927             & 0.955             & 0.955 \\ \hline
\end{tabular}
}{\parbox{6in}{
\footnotesize Note: Robust standard errors clustered over importers are given in parentheses. Significance levels are denoted as *** p$<$0.01, ** p$<$0.05, * p$<$0.1. Time and country fixed effects are not reported for the sake of brevity.}
}
\end{center}
\end{table}
\end{document}

1 Answer 1

1

With the help of siunitx and separated columns for the values and their standard errors. I also used tabular* and a smaller font size to make sure the table fits into the textwidth and booktabs for horizontal lines with improved spacing around them:

enter image description here

\documentclass[12pt]{article}

\usepackage{siunitx}
\usepackage{booktabs}

\begin{document}
\begin{table}
\caption{Regression results I}
%\setlength{\tabcolsep}{0pt} 
\small
\begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}*{3}{S[table-format=-1.3]@{\,}l}}
\toprule
                & \multicolumn{2}{c}{(1)}             & \multicolumn{2}{c}{(2)}              & \multicolumn{2}{c}{(3)}   \\
                & \multicolumn{2}{c}{Low Value-added} & \multicolumn{2}{c}{High value-added} & \multicolumn{2}{c}{Total} \\ 
\midrule
RTA             & 0.718  &(0.265)***                  & -0.487 &(0.544)                      & 0.648  &(0.286)**         \\
RTA(t-3)        & 0.430  &(0.208)**                   & 0.419  &(0.265)                      & 0.425  &(0.219)*          \\
RTA(t-6)        & 0.047  &(0.067)                     & 0.540  &(0.262)**                    & 0.013  &(0.070)           \\
RTA(t-9)        & -0.074 &(0.180)                     & 0.353  &(0.156)**                    & -0.123 & (0.186)          \\
RTA(t-12)       & 0.553  &(0.195)***                  & 0.602  &(0.328)*                     & 0.494  &(0.182)***        \\
GATT/WTO        & 0.277  &(0.358)                     & -0.527 &(0.402)                      & 0.085  &(0.373)           \\
Constant        & 8.081  &(0.358)***                  & 6.980  &(0.763)***                   & 8.606  &(0.379)***        \\ 
Country/Time FE & \multicolumn{2}{c}{Yes}             & \multicolumn{2}{c}{Yes}              & \multicolumn{2}{c}{Yes}   \\
\midrule
N               & \multicolumn{2}{c}{4,872}           & \multicolumn{2}{c}{4,872}            & \multicolumn{2}{c}{4,872} \\
R-squared       & \multicolumn{2}{c}{0.927}           & \multicolumn{2}{c}{0.955}            & \multicolumn{2}{c}{0.955} \\ 
\bottomrule
\multicolumn{7}{@{}p{\textwidth}@{}}{\footnotesize Note: Robust standard errors clustered over importers are given in parentheses. Significance levels are denoted as *** p$<$0.01, ** p$<$0.05, * p$<$0.1. Time and country fixed effects are not reported for the sake of brevity.}
\end{tabular*}

\end{table}
\end{document}

Update:

In the comments, the OP stated their use of \usepackage[margin=1in]{geometry} which makes the table fit into the textwidth without the need to decrease the font size. I have now added two different examples. In the first one, I slightly stretched the table to make it exactly as wide as the textwidth, while in the second example, the table is as wide as it naturally is, while the table notes below are as wide as the natural width of the table.

enter image description here

\documentclass[12pt]{article}

\usepackage{siunitx}
\usepackage{booktabs}

\usepackage{threeparttable} % only used for the second example

\usepackage[margin=1in]{geometry}

\begin{document}
\begin{table}
\caption{Regression results I --  as wide as the textwidth}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}l *{3}{S[table-format=-1.3]@{}l}}
\toprule
                & \multicolumn{2}{c}{(1)}             & \multicolumn{2}{c}{(2)}              & \multicolumn{2}{c}{(3)}   \\
                & \multicolumn{2}{c}{Low Value-added} & \multicolumn{2}{c}{High value-added} & \multicolumn{2}{c}{Total} \\ 
\midrule
RTA             & 0.718  &(0.265)***                  & -0.487 &(0.544)                      & 0.648  &(0.286)**         \\
RTA(t--3)       & 0.430  &(0.208)**                   & 0.419  &(0.265)                      & 0.425  &(0.219)*          \\
RTA(t--6)       & 0.047  &(0.067)                     & 0.540  &(0.262)**                    & 0.013  &(0.070)           \\
RTA(t--9)       & -0.074 &(0.180)                     & 0.353  &(0.156)**                    & -0.123 & (0.186)          \\
RTA(t--12)      & 0.553  &(0.195)***                  & 0.602  &(0.328)*                     & 0.494  &(0.182)***        \\
GATT/WTO        & 0.277  &(0.358)                     & -0.527 &(0.402)                      & 0.085  &(0.373)           \\
Constant        & 8.081  &(0.358)***                  & 6.980  &(0.763)***                   & 8.606  &(0.379)***        \\ 
Country/Time FE & \multicolumn{2}{c}{Yes}             & \multicolumn{2}{c}{Yes}              & \multicolumn{2}{c}{Yes}   \\
\midrule
N               & \multicolumn{2}{c}{4,872}           & \multicolumn{2}{c}{4,872}            & \multicolumn{2}{c}{4,872} \\
R-squared       & \multicolumn{2}{c}{0.927}           & \multicolumn{2}{c}{0.955}            & \multicolumn{2}{c}{0.955} \\ 
\midrule
\end{tabular*}
\footnotesize Note: Robust standard errors clustered over importers are given in parentheses. Significance levels are denoted as *** p$<$0.01, ** p$<$0.05, * p$<$0.1. Time and country fixed effects are not reported for the sake of brevity.

\end{table}




\begin{table}
\centering
\begin{threeparttable}
\caption{Regression results I --  as wide as the table naturally is}
\begin{tabular}{l *{3}{S[table-format=-1.3]@{\enspace}l}}
\toprule
                & \multicolumn{2}{c}{(1)}             & \multicolumn{2}{c}{(2)}              & \multicolumn{2}{c}{(3)}   \\
                & \multicolumn{2}{c}{Low Value-added} & \multicolumn{2}{c}{High value-added} & \multicolumn{2}{c}{Total} \\ 
\midrule
RTA             & 0.718  &(0.265)***                  & -0.487 &(0.544)                      & 0.648  &(0.286)**         \\
RTA(t--3)       & 0.430  &(0.208)**                   & 0.419  &(0.265)                      & 0.425  &(0.219)*          \\
RTA(t--6)       & 0.047  &(0.067)                     & 0.540  &(0.262)**                    & 0.013  &(0.070)           \\
RTA(t--9)       & -0.074 &(0.180)                     & 0.353  &(0.156)**                    & -0.123 & (0.186)          \\
RTA(t--12)      & 0.553  &(0.195)***                  & 0.602  &(0.328)*                     & 0.494  &(0.182)***        \\
GATT/WTO        & 0.277  &(0.358)                     & -0.527 &(0.402)                      & 0.085  &(0.373)           \\
Constant        & 8.081  &(0.358)***                  & 6.980  &(0.763)***                   & 8.606  &(0.379)***        \\ 
Country/Time FE & \multicolumn{2}{c}{Yes}             & \multicolumn{2}{c}{Yes}              & \multicolumn{2}{c}{Yes}   \\
\midrule
N               & \multicolumn{2}{c}{4,872}           & \multicolumn{2}{c}{4,872}            & \multicolumn{2}{c}{4,872} \\
R-squared       & \multicolumn{2}{c}{0.927}           & \multicolumn{2}{c}{0.955}            & \multicolumn{2}{c}{0.955} \\ 
\bottomrule
\end{tabular}
\begin{tablenotes}[flushleft]
\setlength\labelsep{0pt}
\footnotesize 
\item Note: Robust standard errors clustered over importers are given in parentheses. Significance levels are denoted as *** p$<$0.01, ** p$<$0.05, * p$<$0.1. Time and country fixed effects are not reported for the sake of brevity.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}

In both tables, I used S type columns from the siunitx package to make sure the values are aligned with respect to their decimal separator. For this, I used S[table-format=-1.3]. - since there are negitive numbers, 1 since there is a maximum of one integer digit and 3 since there is a maximum of 3 decimal places. For the alignment of the standard errors, I used an l type column, one could however, also use an S type column with appropriate options for this task. Since all three blocks of columns can use the same table-format options, I used *{3}{...} to repeat the contents of the second set of braces three times.

To make sure, the first table is as wide as the textwidth, I used tabular* instead of tabular and added @{\etracolsep{\fill}}. This makes sure that the additional width is distributed evenly between all spaces between adjacent columns. To now reduce the distance between columns that contain a value and columns that contain the corresponding standard error, I added @{} between the column specifiers. To display the table notes below the table, I just placed them between \end{tabular} and \end{table}. (The \multicolum command in my original solution caused the shifted columns you mentioned in your comment. Sorry for that.)

In the second example, I used a regular tabular environment to make sure the table keeps its natural width. In order to slightly decrease the distance bewteen value and error columns, I used @{\enspace}. If you want a smaller/larger horizontal space, you might want to take a look at What commands are there for horizontal spacing? for some other commands, you can use instead of \enspace. In order to make sure the table notes now are just as wide as the table instead of as wide as the textwidth (as in the first example), I here used the threeparttable package ans its tablenotes environment that ensures just that. Using [flushleft] \setlength\labelsep{0pt} \footnotesize I additionally, adjusted font size and alignment of the text.

8
  • Thank for the quick reply. It works well. Just a little improvement: Any other way, instead of enclosing them is $...$, to make the minus sign in variables names such as RTA(t-3) look better? Oct 31, 2020 at 22:32
  • You could use -- as in RTA(t--6).
    – leandriis
    Nov 1, 2020 at 10:08
  • Thanks @leandriis . I could not understand this line except for the part of format: \begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}*{3}{S[table-format=-1.3]@{\,}l}} Could you please explain a little. Can we control the space between coefficient and SE values as well? One space between them would make it much better readable, I think. Nov 1, 2020 at 10:22
  • Secondly, the tables work well as a separate document. However, the part between \\midruleand \bottomrule of (only the) last column moves to left which look very clumsy. I just identified that happens because of another package in my main document \usepackage[margin=1in]{geometry}. Any way out for this? Nov 1, 2020 at 10:23
  • 1
    @AmosMachado: I have updated my answer accordingly to include two possible ways to typeset your table in a document with 1in margins. The first exmple makes sure that the table is as wide as the textwidth, while the second example uses a different approach and a table that is as wide as its natural width. I also added some explanations on the used code. If there are any questions left, feel free to ask. Regarding the margin size: I don't think there really are settings for a "typical research article".
    – leandriis
    Nov 1, 2020 at 11:21

You must log in to answer this question.

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