[Tex/LaTex] Multi columns in latex

tables

I am having problems with tables in latex. Here is what I want:

Regressors                 Model 1                                  Model 2
                   Coefficient1  Lower1  Upper1           Coefficient2  Lower2 Upper2 
$beta_{concern_2}$        0.1903627  0.01208  0.89934           0.17054127  0.12093922 0.389928 

and here is my latex code

\begin{table} [h!]
\begin{center}
\begin{tabular}{lcrl}
\hline 
    \multicolumn{1}{l}{Regressors} & \multicolumn{3}{c}{Model 1 }\\ \hline 
    & Coefficient & Lower limit & Upper Limit  \\
     \multicolumn{3}{r}{Model 2 }\\ 
    & Coefficient & Lower limit & Upper Limit  \\
    $\beta_{concern_2}$     & 0.19036273    &0.01208    &   0.89934  & 0.17054127 & 0.12093922 & 0.389928 \\
    \hline
\end{tabular}
\caption{Regression Coefficients of model 1 and model 2 }
\label{beta}
\end{center}
\end{table}

This does not work as I want. Can someone please fix this?

Thanks

G√ľnal

Best Answer

Assuming you want your two models side by side, you need as many columns in your table as the maximum number of columns in the largest row. Then you use \multicolumn to span multiple columns. So since you have 7 columns in the last row, your \tabular command needs 7 columns.

Here's a version of your table using the booktabs package, which is highly recommended for all tables:

\documentclass{article}
\usepackage{booktabs}

\begin{document}
\begin{tabular}{lllllll}
\toprule 
    Regressors & \multicolumn{3}{c}{Model 1} & \multicolumn{3}{c}{Model 2}\\

    & Coefficient & Lower limit & Upper Limit
    & Coefficient & Lower limit & Upper Limit  \\
    \midrule
    $\beta_{concern_2}$     & 0.19036273    &0.01208    &   0.89934  & 0.17054127 & 0.12093922 & 0.389928 \\
    \bottomrule
\end{tabular}

output of code