I found the solution to my problem, though I think that there may be a bug in the way siunitx interacts with mathspec. It turns out that both the detect-weight and detect-mode options are required to induce the correct behavior -- bold and aligned -- whereas the detect-weight option alone does not.
I discovered the same behavior with italics (don't forget to \robustify\it
), though the detect-shape option is required here, as opposed to detect-weight. The detect-all option also works, as one might expect, since this is merely a convenience option that sets detect-weight, detect-family, detect-shape, and detect-mode to true.
Below is a MWE and its output. The output shows the following:
- Proper font throughout, including digits in math mode
- Proper font weight and shape in the table
- Proper alignment of the numbers in the table
Note that I specified table-format=5.4
in order to ensure that proper alignment was not just coincident with a left or right aligned number.
I am not sure why the detect-mode option is required when using mathspec.
\documentclass{article}
\usepackage{etoolbox, siunitx, booktabs, mathspec}
\setallmainfonts(Digits,Latin,Greek)[Ligatures=TeX]{Helvetica}
\robustify\bfseries
\robustify\itshape
\begin{document}
\begin{table}
\begin{tabular}{S[table-format=5.4, detect-weight, detect-shape, detect-mode]}
\toprule
{Header 35}\\
\midrule
\bfseries 3.060\\
\itshape 100.59\\
0.64\\
0.52\\
\bottomrule
\end{tabular}
\end{table}
This is the number 2.
\[\int_{-\infty}^{\infty} 2 x^{2}_{i} dx \]
\end{document}
One could regard the percentage error as part of the unit and write:
\SI{145}{\milli\meter{} \pm{} 5\percent}
This will not break across lines, unless you use the option allow-number-unit-breaks
.
Best Answer
You can also set the number parsing off temporarily.