# Table borders are missing

\documentclass{article}
\usepackage{siunitx,booktabs}
\newsavebox{\toptabular}
\begin{document}
\begin{table}
\centering

\sbox{\toptabular}{%
\begin{tabular}{ @{} l r @{\hspace{3em}} l r @{} }
\toprule
\multicolumn{4}{@{}l}{\bfseries Probit Regression Results} \\
\midrule
Dep.\@ Variable &             Excess return sign   &   No.\@ Observations &       \num{254} \\
Model           &           Probit   &   Df Residuals       &       \num{248} \\
Methods         &              MLE   &   Df Model           &         \num{5} \\
Date            & Thu, 16 Apr 2020   &   Pseudo R-squ.      &    \num{0.1311} \\
Time            &         00:35:44   &   Log-Likelihood     &   \num{-149.65} \\
Converge        &             True   &   LL-Null            &   \num{-172.23} \\
Covariance Type &        nonrobust   &   LLR p-value        & \num{1.341e-08} \\
\bottomrule
\end{tabular}%
}
\usebox{\toptabular}

\bigskip

\begin{tabular*}{\wd\toptabular}{
@{\extracolsep{\fill}}
l
S[table-format=-2.4]
S[table-format=2.3]
S[table-format=-1.3]
S[table-format=1.3]
S[table-format=-2.3,table-align-text-pre=false,table-space-text-pre={[}]
S[table-format=-1.3,table-space-text-post={]}]% the minus also covers the second digit
@{}
}
\toprule
&   {Correlation Coefficient} & {Standard Error} &  {$z$} & {$P>|z|$} &  [0.025 &  0.975] \\
\midrule
const  &  -5.1870 &     1.270 & -4.083 &     0.000 &  -7.677 & -2.697  \\
Recession    &  -0.8608 &     0.394 & -2.183 &     0.029 &  -1.634 & -0.088  \\
Dividend to price &   0.3881 &     0.087 &  4.483 &     0.000 &   0.218 &  0.558  \\
Earning to price     &  11.3808 &     2.526 &  4.505 &     0.000 &   6.429 & 16.332  \\
Term spread    &  -1.3759 &     1.721 & -0.799 &     0.424 &  -4.750 &  1.998  \\
\bottomrule
\end{tabular*}

\end{table}
\end{document}


The code above for drawing but I draw another table and the results was that in the picture, but that happened when I used the package xltabular to draw a description table, how i can fix that.

– Mico
Aug 4 '20 at 3:25
• Off-topic: 3 of the 5 estimates you call "correlation coefficients" exceed 1 in absolute value. Is this really true? Are the estimates maybe regression coefficients rather than correlation coefficients?
– Mico
Aug 4 '20 at 3:28
• Yes, that's right I will adjust that, but i recompiled the code and it's still giving the same results. Aug 4 '20 at 3:50
• the table on bottom is wider-- but you are using width of the top table which is smaller Aug 4 '20 at 4:13

Some of the table headers in the second table are quite long; taken as a whole, the second table is just too wide to fit in the width of the first table.

I suggest you (a) shorten quite a few of the header cells and (b) use tabular* environments for both table, setting both widths to \textwidth. I would also reduce the number of digits shown for the regression coefficients (not correlation coefficients!) from 4 to 3. Finally, I'd left-align the contents of all four columns in the first table.

\documentclass{article}
\usepackage[tight-spacing]{siunitx}
\usepackage{booktabs}
\begin{document}

\begin{table}
\setlength\tabcolsep{0pt} % let LaTeX determine optimal intercolumn whitespace
\begin{tabular*}{\textwidth}{ @{\extracolsep{\fill}}
ll @{\hspace{3em}} ll }
\toprule
\multicolumn{4}{l}{\bfseries Probit Regression Results} \\
\midrule
Dep.\ Variable  & Excess return sign &   No.\ Observations  &       \num{254} \\
Model           &           Probit   &   Df Residuals       &       \num{248} \\
Method          &              MLE   &   Df Model           &         \num{5} \\
Date            & Thu, 16 Apr 2020   &   Pseudo R$^{2}$     &    \num{0.1311} \\
Time            &         00:35:44   &   Log-Likelihood     &   \num{-149.65} \\
Converge        &             True   &   LL-Null            &   \num{-172.23} \\
Covariance Type &        nonrobust   &   LLR $p$-value      & \num{1.341e-08} \\
\bottomrule
\end{tabular*}

\bigskip
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
l
S[table-format=-1.3,round-mode=places,round-precision=3]
S[table-format= 1.3]
S[table-format=-1.3]
S[table-format= 1.3]
S[table-format=-1.3]
S[table-format=-1.3]
@{}
}
\toprule
& {Coeff.} & {Std.\ Error} & {$z$} & {$P>|z|$} & {[0.025} & \multicolumn{1}{r}{0.975]} \\
\midrule
const             &  -5.1870 &     1.270 & -4.083 &     0.000 &  -7.677 & -2.697  \\
Recession         &  -0.8608 &     0.394 & -2.183 &     0.029 &  -1.634 & -0.088  \\
Dividend to price &   0.3881 &     0.087 &  4.483 &     0.000 &   0.218 &  0.558  \\
Earning to price  &  11.3808 &     2.526 &  4.505 &     0.000 &   6.429 & 16.332  \\
Term spread       &  -1.3759 &     1.721 & -0.799 &     0.424 &  -4.750 &  1.998  \\
\bottomrule
\end{tabular*}
\end{table}

\end{document}

• I tried your code, but it does not work, I think the problem is with the class document. But everything seems fine, however, after I added the package xltabular tables starting to look like this. Aug 4 '20 at 4:04
• @NizarHijazeen - Please clarify what you mean by "it does not work". E,g., if you use a document class other than article, you really need to say so explicitly in the body of your posting. I don't see how loading (or not loading) the xltabular package should affect the look of the tables generated by the code shown above.
– Mico
Aug 4 '20 at 4:10
• Please accept my apology, I forgot to put the document class, \documentclass[a4paper,11pt,leqno]{memoir} Aug 4 '20 at 4:12
• @NizarHijazeen - Changing \documentclass{article} to \documentclass[a4paper,11pt,leqno]{memoir} does not fundamentally affect the "look" of either table.
– Mico
Aug 4 '20 at 4:15

Almost the same as @Mico answer (1) ...

\documentclass{article}
\usepackage{booktabs, makecell}
\usepackage{siunitx}
\newsavebox{\toptabular}

\begin{document}
\begin{table}
\centering

\sbox{\toptabular}{%
\begin{tabular}{ @{} l r @{\hspace{3em}} l r @{} }
\toprule
\multicolumn{4}{@{}l}{\bfseries Probit Regression Results} \\
\midrule
Dep.\@ Variable &             Excess return sign   &   No.\@ Observations &       \num{254} \\
Model           &           Probit   &   Df Residuals       &       \num{248} \\
Methods         &              MLE   &   Df Model           &         \num{5} \\
Date            & Thu, 16 Apr 2020   &   Pseudo R-squ.      &    \num{0.1311} \\
Time            &         00:35:44   &   Log-Likelihood     &   \num{-149.65} \\
Converge        &             True   &   LL-Null            &   \num{-172.23} \\
Covariance Type &        nonrobust   &   LLR p-value        & \num{1.341e-08} \\
\bottomrule
\end{tabular}%
}
\usebox{\toptabular}

\bigskip
\setlength\tabcolsep{0pt}   % <--- new
\begin{tabular*}{\wd\toptabular}{
@{\extracolsep{\fill}}
l
S[table-format=-2.4]
S[table-format= 1.3]
S[table-format=-1.3]
S[table-format= 1.3]
S[table-format=-1.3,table-align-text-pre=false,table-space-text-pre={[}]
S[table-format= 2.3,table-space-text-post={]}]% the minus also covers the second digit
@{}
}
\toprule
&   {\makecell{Correlation\\ Coefficient}}   % <--- changed
&   {\makecell{Standard\\ Error}}       % <--- changed
&  {$z$} & {$P>|z|$} &  [0.025 &  0.975] \\
\midrule
const  &  -5.1870 &     1.270 & -4.083 &     0.000 &  -7.677 & -2.697  \\
Recession    &  -0.8608 &     0.394 & -2.183 &     0.029 &  -1.634 & -0.088  \\
Dividend to price &   0.3881 &     0.087 &  4.483 &     0.000 &   0.218 &  0.558  \\
Earning to price     &  11.3808 &     2.526 &  4.505 &     0.000 &   6.429 & 16.332  \\
Term spread    &  -1.3759 &     1.721 & -0.799 &     0.424 &  -4.750 &  1.998  \\
\bottomrule
\end{tabular*}

\end{table}
\end{document}


In comparison to your MWE I added before your second table \setlength\tabcolsep{0pt} and write column headers of the second and third column in two lines by use of the makecell command from the package of the same name. With this the second table width is shrink to the width of \toptabular.

• @Mico, thank you! I will make this change asap (I only focused to LaTeX aspect of table ;-). Aug 4 '20 at 4:16