Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text content before number in S column causes wrong font to be used #321

Open
lblblb opened this issue Nov 17, 2017 · 1 comment
Open

Text content before number in S column causes wrong font to be used #321

lblblb opened this issue Nov 17, 2017 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@lblblb
Copy link

lblblb commented Nov 17, 2017

The cause of this observation is that I want to use siunitx S columns to print monospaced (tabular) numbers if needed, but use proportional numbers by default. After hours of fiddling I now have a solution that works as well as possible, by using pre- and post-code for each column specifier. To get monospaced figures, I use \ttfamily for that column (and set it back to \sffamily as post-code if needed). My font setup is such that \ttfamily is the same font as \sffamily, but fontspec makes all characters monospaced. This solution is far more robust than using \addfontfeatures{Numbers=Monospaced} instead, where it worked only half the time.

Now this approach works well until I place something before the number:

\documentclass{article}

\usepackage{array,siunitx}

\sisetup{
	detect-all=true,
	mode=text,
	table-space-text-pre = \(-\)
}

\begin{document}

\begin{tabular}{%
>{\ttfamily}S[table-format=1.3]%
}
%
0,818 \\
-0,818 \\
\(-\)0,818 \\
A0,818 \\
0,818A \\
\end{tabular}

\end{document}

bug
I compiled with TeXLive 2017 lualatex.

  • The third row has the wrong font because I have a \(-\) in front of the number. I want to use math-mode minuses to get a more uniform look in my use case. It's also weird that only this row has the comma and the alignment is off.
  • The fourth row shows that the single letter is in the \ttfamily as specified, but the processed number after it is not.
  • The fifth row shows that something after the number doesn't cause the problems.

I tried the MWE with braces around the "foreign" content but it didn't make a difference in output.

Here is a real-use example of the issue, where the preceeding math-mode minus sign is causing a switch back to the surrounding "proportional" \sffamily:

realuse

@lblblb lblblb changed the title Text content besides number in S column causes wrong font to be used Text content before number in S column causes wrong font to be used Nov 17, 2017
@josephwright josephwright self-assigned this Nov 17, 2017
@josephwright josephwright added the enhancement New feature or request label Jun 22, 2018
@josephwright
Copy link
Owner

The underlying issue here is that there are two distinct things we might want to do with 'pre-cell' material. The first is to print something: that needs space and when we are reserving space, that means using a box. The other is to apply font/colour changes: this needs to happen outside of a box. The package checks whether there is any apparent width to pre-cell material before picking the route. The issue here is you need both aspects. The obvious way to handle that is to provide an explicit key which can insert font/colour changes (i.e. zero-width material). I'm putting that down for v3.1 - code-wise it's trivial, it's more how to describe the option that's an issue.

@josephwright josephwright added this to the v3.1 milestone Apr 19, 2021
@josephwright josephwright modified the milestones: v3.1, v3.2 Apr 22, 2022
@josephwright josephwright modified the milestones: v3.2, v3.3 Dec 16, 2022
@josephwright josephwright modified the milestones: v3.3, v3.4 Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants