[Tex/LaTex] siunitx: specifying custom command as input-symbol

siunitxsymbols

This is a follow up from siunitx uses math mode for symbols – workaround needed when using different fonts for math and text.

The problem has been solved thanks to David, however there is a problem remaining with tables that are generated by esttab for Stata. Esttab enters asterisks by a newly defined \sym command, i.e. \sym{*}. This is not necessary since I have redefined \sym to plain text, but esttab does not offer an option to omit the \sym command.

The problem is that siunitx does not recognise \sym as an input-symbol and the result are overfull hboxes, as the MWE below illustrates. My question is how to specify \sym{*}, \sym{**} and \sym{***} as input symbols for siunitx as I would like to avoid hacking the esttab plugin (btw, the problem is not pdfLaTeX or XeLaTeX specific).

\documentclass{scrartcl}
\usepackage{booktabs}
\usepackage[osf]{mathpazo}
\usepackage[euler-digits]{eulervm}
\overfullrule=5pt

% For Tables created by estout
\newcommand{\sym}[1]{#1} % for symbols in Table
\usepackage{siunitx}
\sisetup{ detect-mode, 
          group-digits            = false ,
          input-signs             = ,
          input-symbols           = ()[]-+* , % specifying \sym here does not work
          input-open-uncertainty  = ,
          input-close-uncertainty = ,
          table-align-text-post   = false 
        }

\def\xxx#1{%
  \bgroup\uccode`\~\expandafter`\string#1%
  \uppercase{\egroup\edef~{\noexpand\text\string#1}}%
  \mathcode\expandafter`\string#1"8000 }
\def\textsymbols{\xxx[\xxx]\xxx(\xxx)\xxx*}

\begin{document}

{\textsymbols
\begin{tabular*}{0.75\textwidth}{
    l @{\extracolsep\fill} *{2}{S[table-format=4.6]} @{}}
\toprule
\multicolumn{1}{@{}l}{\emph{Age}}  \\[0.5ex]
18--24 &   [-1360.228]*  &  -1371.941\sym{*}  \\
       &       (6.915)\sym{**} &    (-7.953)**      \\
\bottomrule
\end{tabular*}}
\end{document}

enter image description here

Best Answer

\newcommand{\sym}[1]{\rlap{$#1$}} % for symbols in Table

works for that example, as the symbols are always at the right edge of the column otherwise I'd need to look at the weekend to see what siuintx does with its symbol list.

Related Question