1

I can't find a way to fix this annoying corner case.

In this example, spreadtab gives the value for cell(foo)+cell(bar) correctly, but siunitx does not do its thing if \bfseries is being used in that cell, because to make the example compile with spreadtab, I'm forced to hide the calculation from siunitx (apparently).

The value shown, 20.687 should be 20.69 instead. and the number is misaligned. The decimal point is in the wrong place.

How can I placate both spreadtab or siunitx?

Aligning number with siunitx in spreadtab including calculated numbers appears to be the same question, but the sole answer does not describe a satisfactory solution.

Can anyone suggest a workaround, please?

\documentclass[12pt]{standalone}
\usepackage{siunitx}
\usepackage{spreadtab}

\RequirePackage{unicode-math} \setmainfont[Scale=0.93]{TeX Gyre Schola} \setmathfont[Scale=0.93]{TeX Gyre Schola Math}

\begin{document} \begin{spreadtab}{{tabular}{S[table-format=6.2, round-mode=places, round-precision=2, detect-weight=true]}} tag(foo) 10.343\ tag(bar) 10.344\ cell(foo)+cell(bar)\ \bfseries :={cell(foo)+cell(bar)}\ \end{spreadtab} \end{document}

Bernard
  • 271,350
Faheem Mitha
  • 7,778

1 Answers1

2

siunitx uses math to print the numbers, so you need a boldmath font. Either switch to text mode, or define a bold math version:

\documentclass[12pt]{standalone}
\usepackage{siunitx}
\usepackage{spreadtab}

\RequirePackage{unicode-math} \setmainfont[Scale=0.93]{TeX Gyre Schola} \setmathfont[Scale=0.93]{TeX Gyre Schola Math} \setmathfont{TeX Gyre Schola Math}[version=bold,FakeBold=2] \begin{document}

\begin{spreadtab}{{tabular}{S[table-format=6.2, round-mode=places, round-precision=2, detect-weight=true]}} tag(foo) 10.343\ tag(bar) 10.344\ cell(foo)+cell(bar)\ \bfseries :={cell(foo)+cell(bar)}\ \end{spreadtab} \end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • Your code apparently implem. ents "define a bold math version". I'm not sure what the other option, namely "switch to text mode", means. Can you elaborate? – Faheem Mitha Sep 07 '21 at 21:26
  • mode=text, see the siunitx documentation, – Ulrike Fischer Sep 07 '21 at 21:27
  • Also, does this problem correspond to the log file message "Package fontspec Info: Could not resolve font "TeXGyreScholaMath/B" (it probably doesn't exist)."? – Faheem Mitha Sep 07 '21 at 21:28
  • I tested your example on my system with TeX Live 2020, and it does not fix the issue. Perhaps something was fixed in the version of siunitx that you are using? That seems like the most likely possibility. The version of siunitx that is reported in the logs is "Package: siunitx 2020/02/25 v2.8b". What version are you using? The version of spreadtab I'm using is 0.5, but I don't think that has changed. I also tried on Overleaf with TeX Live 2020, and it shows the issue there too. – Faheem Mitha Sep 08 '21 at 09:54
  • I as you should expect from me have a current texlive 2021 and use the newest siunitx. – Ulrike Fischer Sep 08 '21 at 10:00
  • I confirmed that this works on an local installation of TeX Live 2021. I'm now wondering what changed between the corresponding versions of siunitx (assuming that siunitx was what changed) to make this work correctly. Would this be suitable for a separate question? – Faheem Mitha Sep 09 '21 at 09:34
  • I also confirmed that it bolds correctly with the mode=text option. The two bolds look quite different. I think I prefer the text one. Also, even if the bolding does not work, the column is correctly aligned in any case, by the TL2021 version. – Faheem Mitha Sep 09 '21 at 09:43