2

I have a table with significance stars built via the command ^{***} (i.e. math mode). I recently found out that \sym{***} could also be used. I don't know which is better, would be nice if someone can explain. The main goal however is to make the simple table of the MWE below compile without errors.

\documentclass[11pt]{article}
\usepackage[a4paper]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern, textcomp}
\usepackage{csquotes}
\usepackage{ragged2e}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{caption}
\usepackage{booktabs}

\begin{document}

\sisetup{group-separator = {,}, 
    input-decimal-markers = {.},
    input-symbols = ()}

\begin{table}[ht]
    \centering
    \begin{tabular}{
            l*{3}{S[table-align-text-post = false]}
            }

            \hline
            XYZ & -100.00^{***} & -80.15^{**} & -20.15^{*} \\
            \hline
    \end{tabular}%
\end{table}
\end{document}

It always says 'Missing $ inserted'. Not sure what to do here. Thanks for any hints.

  • Did you try with XYZ & -100.00*** & -80.15** & -20.15* \\ ? – leandriis Sep 3 '19 at 19:44
  • @leandriis just now, that also doesn't work. Now it says 'Misplaced \noalign. \end – ghx Sep 3 '19 at 19:55
  • What are those $... $ doing in those cells? S columns are already math mode – daleif Sep 3 '19 at 20:40
  • @ghx: Did you make sure to end your line with a \\ ? It is missing in your code. – leandriis Sep 3 '19 at 20:51
  • @leandriis thanks, I added the linebreak `\\`. daleif Removed, thank you. Unfortunately it still does not work. Now it says 'Missing $ inserted' – ghx Sep 3 '19 at 21:03
4

In the following code, I have used the \sym command (\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}) in order to get superscript stars in S type columns. I have also used appropriate table-format settings for the three S type columns to get less horizontal white space between them. To reserve some space for the stars, I have used the table-space-text-post option:

enter image description here

\documentclass[11pt]{article}
\usepackage[a4paper]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern, textcomp}
\usepackage{csquotes}
\usepackage{ragged2e}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{caption}
\usepackage{booktabs}

\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}

\begin{document}

\sisetup{group-separator = {,}, 
    input-decimal-markers = {.},
    input-symbols = ()}

\begin{table}[ht]
\sisetup{table-align-text-post = false, table-space-text-post=\sym{***}}
    \centering
    \begin{tabular}{
            lS[table-format=-3.2]*{2}{S[table-format=-2.2]}
            }

            \hline
            XYZ & -100.00\sym{***} & -80.15\sym{**} & -20.15\sym{*} \\
            \hline
    \end{tabular}%
\end{table}
\end{document}

Other alternatives to typeset the stars include the use of $^{*}$ or the \stars{**} command from here

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.