5

I am having an interesting issue with spacing with siunitx, parenthesis, and exponents in a table I am using. Currently I am trying to make a regression table with standard errors reported below the estimates in parenthesis. I am also using siunitx to round all the numbers in the table to 2 decimal places. But when including an exponent for scientific notation, siunitx will add space before the closing parenthesis for all the numbers in the column.

It makes sense that this is likely the intended functionality of siunitx with parenthesis. Unfortunately, the result does not look very good. Is there away to format the output so that extra space is not added for all the parenthesis in the column.

Below is my attempt at a minimal working example. For reference I have combined answers from the following links to get this far:

Rounding of decimal numbers: Looking for an elegant way in latex table

siunitx and 'e' notation in Tables with S column

siunitx rounding in table with parentheses

\documentclass[12pt]{article}%

\usepackage{booktabs}

\usepackage[ group-separator={,} ]{siunitx}
\usepackage[referable]{threeparttablex}

\newcolumntype{L}{@{}l@{}} % a left column with no intercolumn space on either side
\newcommand{\mc}[1]{\multicolumn{1}{c}{#1}} % shorthand macro for column headings

\sisetup{
    output-exponent-marker = \text{e},
    exponent-product={},
    retain-explicit-plus,
    input-open-uncertainty  = ,
    input-close-uncertainty = ,
    table-align-text-pre    = false,
    round-mode=places,
    round-precision=2,
    table-space-text-pre    = (,
    table-space-text-post   = ),
}

\begin{document}

\begin{table}[ht]
    \small
    \caption {\textit{Example Demonstrating Spacing Problem with Parenthesis, Exponents, and Siunitx}}
    \centering
    \begin{threeparttable}
        \begin{tabular}{
                l
                S[table-format =-1.2e-1]
            }
            \toprule
            \multicolumn{2}{l}{Minimal Working Example}  \\
            \midrule
            \multicolumn{1}{l}{Variable Name} & \mc{Estimates} \\
            \midrule
            Parameter 1 & 0.48627106 \\
                        & (0.034917107) \\
            Parameter 2 & \\
                        & \\
            Parameter 3 & -1.6112648e-05 \\
                        & (0.039498207) \\
            Parameter 4 & 0.10223650 \\
                        & (0.040252205) 
        \end{tabular}
        \begin{tablenotes}
        \item Standard Errors are provided in parenthesis.
        \end{tablenotes}
    \end{threeparttable}

\end{table}

\end{document}

Compiled Code

  • Welcome to TeX.SX!, just add table-align-text-post = false. – Salim Bou Jan 16 '16 at 6:07
  • @salimbou, please consider to write your comment as answer. Maybe add some explanation. I observe, that similar question appears quit often, so an answer will be helpful. – Zarko Jan 16 '16 at 8:23
7

From siunutx manual

markers are often given in tables after the numerical content. It may be table-align-text-post desirable for these to close up to the numbers. Whether this takes place is controlled by the table-align-text-pre and ...-post option

You can remove space before the closing parenthesis with table-align-text-post = false.

Your code

\documentclass[12pt]{article}%

\usepackage{booktabs}

\usepackage[ group-separator={,} ]{siunitx}
\usepackage[referable]{threeparttablex}

\newcolumntype{L}{@{}l@{}} % a left column with no intercolumn space on either side
\newcommand{\mc}[1]{\multicolumn{1}{c}{#1}} % shorthand macro for column headings

\sisetup{
    output-exponent-marker = \text{e},
    exponent-product={},
    retain-explicit-plus,
    input-open-uncertainty  = ,
    input-close-uncertainty = ,
    table-align-text-pre    = false,
    table-align-text-post = false,
    round-mode=places,
    round-precision=2,
    table-space-text-pre    = (,
    table-space-text-post   = ),
}

\begin{document}

\begin{table}[ht]
    \small
    \caption {\textit{Example Demonstrating Spacing Problem with Parenthesis, Exponents, and Siunitx}}
    \centering
    \begin{threeparttable}
        \begin{tabular}{
                l
                S[table-format =-1.2e-1]
            }
            \toprule
            \multicolumn{2}{l}{Minimal Working Example}  \\
            \midrule
            \multicolumn{1}{l}{Variable Name} & \mc{Estimates} \\
            \midrule
            Parameter 1 & 0.48627106 \\
                        & (0.034917107) \\
            Parameter 2 & \\
                        & \\
            Parameter 3 & -1.6112648e-05 \\
                        & (0.039498207) \\
            Parameter 4 & 0.10223650 \\
                        & (0.040252205) 
        \end{tabular}
        \begin{tablenotes}
        \item Standard Errors are provided in parenthesis.
        \end{tablenotes}
    \end{threeparttable}

\end{table}

\end{document}

Output

enter image description here

  • Thank you so much. I didn't realize that this had a solution built into siunitx. – sticke4 Jan 16 '16 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.