# Right column misaligned in table

I have a simple table with four columns. Strangely, the last column, the right-most one, compiles as if it was "away" from the others. Why would this be? It is very annoying. Here is my code:

\documentclass[12pt]{article}
\usepackage{eurosym}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{amsmath}
\usepackage{caption}
\usepackage{xcolor}
\begin{document}

\begin{table}[h]

\caption{Title goes here}
\label{tab:regression2}
\centering
\resizebox{0.9\textwidth}{!}{
{
\def\sym#1{\ifmmode^{#1}\else$$^{#1}$$\fi}
\begin{tabular}{l*{4}{c}}
\hline\hline
&              Placement    &         Placement         &        Placement            &        Placement            \\
&\multicolumn{1}{c}{      \small{Model E}}&\multicolumn{1}{c}{\small{Model F}}&\multicolumn{1}{c}{\small{Model G}}&\multicolumn{1}{c}{\small{Model H }}\\
\hline

Treatment 1     &   -10.61\sym{**} &                  &   -3.811         &         0         \\
&  (0.048)         &                  &  (0.677)         &        ($\cdot$)          \\
[1em]

Sample Score    &                  &    1.332\sym{***}&    3.813\sym{*}  &        1.732\sym{***}          \\
&                  &  (0.237)         &  (0.061)         &        (0.007)            \\
[1em]
Treat.1 \textit{X} Sample Score&    7.005\sym{***}&    2.064\sym{**} &    3.245         &         2.064\sym{**}          \\
&  (0.002)         &  (0.046)         &  (0.283)         &        (0.046)          \\
[1em]
Male            &    5.031\sym{**} &    4.526\sym{*}  &    4.524\sym{*}  &          4.526\sym{*}         \\
&  (0.032)         &  (0.054)         &  (0.054)         &         (0.154)         \\

Constant        &    44.57\sym{***}&    16.17\sym{***}&    37.40\sym{***}&   46.17\sym{***}        \\
&  (0.000)         &  (0.000)         &  (0.000)         &      (0.000)        \\
\hline

\hline
N               &      282         &      282         &      282         &      282         \\
$R^2$              &   0.0648         &   0.0761         &   0.0767         &   0.0761         \\
\hline\hline
\multicolumn{5}{l}{\footnotesize NOTES: The dependent variable is placement (the reported belief that own performance in the quiz is }\\
\multicolumn{5}{l}{\footnotesize above the median). Models E-G are OLS regressions. Model H is a semi-structural estimation }\\
\multicolumn{5}{l}{\footnotesize imposing the model's  restriction that $Treatment 1 >0$.  }\\
\multicolumn{5}{l}{\footnotesize \textit{P}-values in parentheses. \sym{*} $$p<0.10$$, \sym{**} $$p<0.05$$, \sym{***} $$p<0.01$$.}\\
\end{tabular}
}
}
\end{table}
\end{document}


Thank you. I am using TexStudio to make this. I have tried to use the code from the answer here in this answer, but, although it improves, it is not perfect and TexStudio returns an error: illegal character, in the line of begin{tabular}).

• Welcome to TeX.SE! – Zarko Jul 29 '19 at 15:49
• Thank you! Hope to ask good questions (and someday know enough to answer some!) – Juan Pedro Jul 29 '19 at 17:33

I would redesign your table as follows:

• not use \resizebox
• for columns with numbers use S columns defined in the siunitx package; it enables aligning numbers at decimal points
• for "Note" below table use p{\linewidth} column type (your with l is source of your problem)
• instead \hlines is nicer to use rules from the package booktabs

Edit: as sugested @leandriis in his comment below:

• for the first row in table use \multicolumn{4}{c}{...}, since it is better to have common word "Placement" for all columns with numbers.
\documentclass[12pt]{article}
\usepackage{eurosym}
%\usepackage{graphicx}
%\usepackage{subcaption}
%\usepackage{amsmath}
\usepackage[skip=1ex]{caption}
%\usepackage{xcolor}
\usepackage{booktabs}
\usepackage{siunitx}
\def\sym#1{\ifmmode^{#1}\else$$^{#1}$$\fi}

\begin{document}
\begin{table}[h]
\caption{Title goes here}
\label{tab:regression2}
\centering
\begin{tabular}{l*{4}{S[input-symbols = {( )},
table-space-text-post ={$^{***}$},
table-align-text-post=false,
table-format=2.3]}}
\toprule
&  \multicolumn{4}{c}{Placement}                                                 \\
\cmidrule{2-5}
\\
&\small Model E &\small Model F         &\small Model G     &\small Model H     \\
\midrule
Treatment 1
& -10.61\sym{**}    &                   & -3.811            &  0                \\
&  (0.048)          &                   & (0.677)           & ($\cdot$)         \\
Sample Score
&                   &  1.332\sym{***}   &  3.813\sym{*}     &  1.732\sym{***}   \\
&                   & (0.237)           & (0.061)           &  (0.007)          \\
Treat.1 \textit{X} Sample Score
&   7.005\sym{***}  &  2.064\sym{**}    &  3.245            &  2.064\sym{**}    \\
&  (0.002)          &  (0.046)          &  (0.283)          & (0.046)           \\
Male
&   5.031\sym{**}   &   4.526\sym{*}    &   4.524\sym{*}    &  4.526\sym{*}     \\
&  (0.032)          &  (0.054)          &  (0.054)          & (0.154)           \\
Constant
&  44.57\sym{***}   & 16.17\sym{***}    &  37.40\sym{***}   & 46.17\sym{***}    \\
&  (0.000)          & (0.000)           &  (0.000)          & (0.000)           \\
\midrule
N   & {282}             & {282}             & {282}             & {282}             \\
$R^2$
&   0.0648          &   0.0761          &   0.0767          &  0.0761           \\
\midrule[\heavyrulewidth]
\multicolumn{5}{@{} p{\linewidth} @{}}{\footnotesize
NOTES: The dependent variable is placement (the reported belief that own performance in the quiz is above the median). Models E-G are OLS regressions. Model H is a semi-structural estimation
imposing the model's  restriction that $Treatment 1 >0$.

$P$-values in parentheses. \sym{*} $$p<0.10$$, \sym{**} $$p<0.05$$, \sym{***} $$p<0.01$$.}
\end{tabular}
\end{table}
\end{document}

• Maybe you could use a \multicolumn{4}{c} for "Placement Model" and a \cmidrule in the table header. – leandriis Jul 29 '19 at 15:55
• @leandriis, you are right. With this improvement table will become even nicer. done! thank you very much! – Zarko Jul 29 '19 at 16:02
• Thank you both. This definitely works. I have a colleague who uses Scientific Workplace, however, so I had to skip using the siunitx package (at least this time) because it does not work in SWP. Sadly, the notes are missing when using SWP, too. Any ideas on that? Using the code I posted, it works well (but with the misaligned column, of course). – Juan Pedro Jul 29 '19 at 17:32
• @JuanPedro, your problem with SWP is one more reason why is better use pure LaTeX :-). Concerning SWP I can't help you, I don't use it. About it I suggest you to ask a new question here or on SWP support, if it exist. Regarding your question, I belive, that answer solve what you asked for, so you can accept it :-) – Zarko Jul 29 '19 at 17:38
• Yes, I know. My colleague is the stubborn one, not me, so I am stuck. Thank you very much. I have accepted your answer. – Juan Pedro Jul 29 '19 at 19:25

Building upon Zarko's great answer, here is a slight variant that uses the threeparttable package in order to ensure that the table notes are automatically as wide as the table:

\documentclass[12pt]{article}
\usepackage[skip=1ex]{caption}
\usepackage{booktabs}
\usepackage{siunitx}
\def\sym#1{\ifmmode^{#1}\else$$^{#1}$$\fi}
\usepackage[flushleft]{threeparttable}
\begin{document}
\begin{table}[h]
\caption{Title goes here}
\label{tab:regression2}
\sisetup{input-symbols = {( )},
table-space-text-post ={$^{***}$},
table-align-text-post=false}
\centering
\begin{threeparttable}
\begin{tabular}{l*{2}{S[table-format=-2.3]S[table-format=2.3]}}
\toprule
&  \multicolumn{4}{c}{Placement Model}                                                 \\
\cmidrule{2-5}
&  {E} &  {F}         &  {G}     &  {H}     \\
\midrule
Treatment 1
& -10.61\sym{**}    &                   & -3.811            &  0                \\
&  (0.048)          &                   & (0.677)           & ($\cdot$)         \\
Sample Score
&                   &  1.332\sym{***}   &  3.813\sym{*}     &  1.732\sym{***}   \\
&                   & (0.237)           & (0.061)           &  (0.007)          \\
Treat.1 \textit{X} Sample Score
&   7.005\sym{***}  &  2.064\sym{**}    &  3.245            &  2.064\sym{**}    \\
&  (0.002)          &  (0.046)          &  (0.283)          & (0.046)           \\
Male
&   5.031\sym{**}   &   4.526\sym{*}    &   4.524\sym{*}    &  4.526\sym{*}     \\
&  (0.032)          &  (0.054)          &  (0.054)          & (0.154)           \\
Constant
&  44.57\sym{***}   & 16.17\sym{***}    &  37.40\sym{***}   & 46.17\sym{***}    \\
&  (0.000)          & (0.000)           &  (0.000)          & (0.000)           \\
\midrule
N   & {282}             & {282}             & {282}             & {282}             \\
$R^2$
&   0.0648          &   0.0761          &   0.0767          &  0.0761           \\
\midrule[\heavyrulewidth]

\end{tabular}
\begin{tablenotes}\setlength\labelsep{0pt}\footnotesize
\item{NOTES:} The dependent variable is placement (the reported belief that own performance in the quiz is above the median). Models E-G are OLS regressions. Model H is a semi-structural estimation
imposing the model's  restriction that $Treatment 1 >0$.

$P$-values in parentheses. \sym{*} $$p<0.10$$, \sym{**} $$p<0.05$$, \sym{***} $$p<0.01$$.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}


With the threeparttablex package you could also make use of the \note command. This might be especially useful if you later on decide that you would like the word "note" to be printed in a different style (italic, bold, not all uppercase,...).

To use this, replace \usepackage[flushleft]{threeparttable} from the above example with \usepackage[flushleft, para, referable]{threeparttablex} \renewcommand\TPTLnotesnamefontcommand{\MakeUppercase} and \item{NOTES:} with \note.

• Thank you very much. – Juan Pedro Jul 29 '19 at 19:28
• If you would use threeparttablex package with option referable, than you can use in tablenotes command \note like this: \begin{tablenotes}[flushleft, para] \footnotesize \note <note text> \end{tablenotes} :-) – Zarko Jul 29 '19 at 19:56
• @Zarko: Thank you for your great idea and for showing me yet another package that I did not know before. :) – leandriis Jul 29 '19 at 20:08