1

I'm using a lot of numbers in my thesis, and I'm use the cfr-lm package to make them old style instead of lining, so that they aren't so distracting- Otherwise it looks like I have random all caps words all over the place.

I'm using the siunitx package to typeset all the units in my thesis. However, the siunitx package is reading these numbers as if they should be in math mode, which is lining figures. This is great for when it is in a table with the S column type, as it makes all the numbers line up into columns, I want this. But it means that any number that is made using \SI is in diffrent formatting from those without units, which I don't want. I want those numbers to be oldstyle.

How do I tell siunitx to use one type of numbers for tables with the S column type, and one type of numbers for \SI (or everything that isn't that type of column in general?) I think I've tried all the combinations of detection options, but I might have missed one.

MWE showing the problem:

\documentclass{article}
%kpfonts is needed for something not relavent to the question
%Removing it changes the spacing in the detect-all=false siunitx line
\usepackage{kpfonts} 
\DeclareSymbolFontAlphabet{\mathrm}{operators}
\usepackage{cfr-lm}
\usepackage{siunitx}

\begin{document}
\sisetup{detect-all=false}
\textbackslash sisetup{detect-all=false}

\noindent 1234567890 Text \\
\(1234567890\) Math \\
\SI{1234567890}{\angstrom} siunitx

\begin{tabular}{Sl}
    1.234(5678) &   12345678901234567890\\
    1.111(1111) &   11111111111111111111  \\
\end{tabular}

\vspace{1 cm}
\sisetup{detect-all=true}
\textbackslash sisetup{detect-all=true}

\noindent 1234567890 Text \\
\(1234567890\) Math \\
\SI{1234567890}{\angstrom} siunitx

\begin{tabular}{Sl}
    1.234(5678) &   12345678901234567890\\
    1.111(1111) &   11111111111111111111  \\
\end{tabular}

\end{document}

Output: 1

(kpfonts and the command so it doesn't break siunitx left in as removing it changes the spacing in the number within the \SI command, so I'm wondering if it is related to the problem. Even if it isn't, I need the solution to be able to work with it in place.)

2

I think all you need to do is specify mode=text as the optional argument to \SI. E.g.,

\SI[mode=text]{1234567890}{\meter}

Same for the \num macro -- \num[mode=text]{12345} -- if it's used in text mode.


Addendum to address the OP's follow-up comments: If it's a burden to have to specify the optional argument [mode=text] of the \SI and \num directives explicitly, I suggest you load the letltxmacro package and issue the following instructions in the preamble.

\LetLtxMacro\origSI\SI
\renewcommand\SI[3][mode=text]{\origSI[#1]{#2}{#3}}
\LetLtxMacro\orignum\num
\renewcommand\num[2][mode=text]{\orignum[#1]{#2}}

That way, \SI and \num will set the option mode=text by default. If, for some reason, you do not wish to set this option and employ the original definitions of \SI and \num, you can do so either by running \origSI and \orignum or by explicitly specifying an empty first argument, e.g., \SI[]{...}{...} and \num[]{...}.


enter image description here

\documentclass{article}
\usepackage{kpfonts} % are you sure you need this?
\usepackage[T1]{fontenc}
\DeclareSymbolFontAlphabet{\mathrm}{operators}
\usepackage{cfr-lm}

\usepackage{siunitx}

\usepackage{letltxmacro}
%% redefine \SI and \num -- carefully
\LetLtxMacro\origSI\SI
\renewcommand\SI[3][mode=text]{\origSI[#1]{#2}{#3}}
\LetLtxMacro\orignum\num
\renewcommand\num[2][mode=text]{\orignum[#1]{#2}}

\begin{document}

\begin{tabular}{@{} l l @{}}
1234567890 & Text \\
\(1234567890\) & Math \\
\SI{1234567890}{\meter} & \verb+\SI+ \\
\num{1234567} & \verb+\num+ \\
\origSI{1234567890}{\meter} & \verb+\origSI+ \\
\orignum{1234567} & \verb+\orignum+ \\
\end{tabular}

\medskip
\begin{tabular}{@{} S[table-format=1.3] l @{}}
    \verb+S+ & \verb+l+\\
    \hline
    1.234 &   1234567890  \\
    1.111 &   1111111111  \\
\end{tabular}

\end{document}
5
  • In addition to setting the option mode=text, you may also want to set group-separator={,}.
    – Mico
    Dec 11 '20 at 21:28
  • Is there a way to set that globally? It is going to my things a lot harder to read if I have to type that every time. (Or add a new command with a wrapper)
    – Canageek
    Dec 12 '20 at 0:14
  • @Canageek - I'm not aware of a global option. But how hard is it to perform a global search and replace of \SI{ for \SI{mode=text]{?
    – Mico
    Dec 12 '20 at 0:36
  • 1
    Not hard, but that means that when I'm reading my text I've got something interrupting the flow, which makes editing a lot harder. I really try to keep my tex readable, and having a whole bunch of extra words in the middle of it is not in keeping with that.
    – Canageek
    Dec 12 '20 at 1:17
  • 1
    @Canageek - Please see the addendum I posted.
    – Mico
    Dec 12 '20 at 6:11

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.