1

I am creating a table with regression results. This is the result:

enter image description here

Aligning at the decimal point works fine. Two problems remain:

  • When having negative value, a space is inserted between the number and the stars.
  • The headers only show when using multicolumn. Now, they are not really aligned with anything. Using 'c' or 'r' in the multicolumn environment does not really solve the problem.

This is the code:

\documentclass[11pt]{article}


\usepackage{amsmath} 
\usepackage{longtable, booktabs}
\usepackage{siunitx}

\begin{document}

\begin{longtable}{@{}p{3cm}SS@{}} 
\centering
\kill

\toprule
 & \multicolumn{1}{l}{Target}    & \multicolumn{1}{l}{$R^2$}     \\*

\midrule
\endhead

\bottomrule
\endfoot

% body 
OIS\_1Y            & 1.67* & 0.55     \\
OIS\_2Y            & 1.61*** & 0.42   \\
OIS\_5Y            & -1.15*** & 0.25  \\
OIS\_10Y           & -0.09** & 0.09   \\
stoxx50euro        & -0.04*  & 0.06   \\
\end{longtable}

\end{document}

1 Answer 1

1

You can help siunitx a bit by specifying a suitable table-format for your columns, see section "4.12 Tabular material" of the siunitx documentation for more details.

\documentclass[11pt]{article}


\usepackage{amsmath} 
\usepackage{longtable, booktabs}
\usepackage{siunitx}

\begin{document}

\begin{longtable}{@{}p{3cm}S[table-format=-1.2,table-align-text-after=true,table-space-text-post={***}]S[table-format=1.2]@{}} 
\centering
\kill

\toprule
 & {Target}    & {$R^2$}     \\*

\midrule
\endhead

\bottomrule
\endfoot

% body 
OIS\_1Y            & 1.67* & 0.55     \\
OIS\_2Y            & 1.61*** & 0.42   \\
OIS\_5Y            & -1.15*** & 0.25  \\
OIS\_10Y           & -0.09** & 0.09   \\
stoxx50euro        & -0.04*  & 0.06   \\
\end{longtable}

\end{document}

enter image description here

1
  • Great! For the titles, just insterting {} around the header solves this problem
    – Chris tie
    Commented Oct 10, 2023 at 12:25

You must log in to answer this question.

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