1

I want my numbers in inline math mode (with \( and \)) to be old-style to match the rest of the text. However, math in display mode should be in the regular lining figures. I've tried using the etoolbox package but alas, that didn't work. MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\useosf
\usepackage{etoolbox}
\AtBeginEnvironment{math}{\def\libertine@figurestyle{OsF}}
%\AtBeginEnvironment{displaymath}{\useosf}


\begin{document}

This is some text with 45 numbers included becuase 123 I like numbers. I also like to \(5+4=9\) include math in my texts.
\begin{math}
77 \times 11 \neq 5
\end{math}
Some more text here.

\[5+4\neq 10 \]

\end{document}

Update

The following commands are useful, but do not work for math or displaymath environments. However, they do work for the tabular environment.

  • proportional oldstyle figures: \fontfamily{LinuxLibertineT-OsF}\selectfont
  • proportional lining figures: \fontfamily{LinuxLibertineT-LF}\selectfont
  • tabular oldstyle figures: \fontfamily{LinuxLibertineT-TOsF}\selectfont
  • tabular lining figures: \fontfamily{LinuxLibertineT-TLF}\selectfont

E.g.:

\AtBeginEnvironment{tabular}{\fontfamily{LinuxLibertineT-TOsF}\selectfont}
Tommiie
  • 526
  • 1
    is it the current display or textstyle that is the criterion, or is it the outer environment that starts the math? so for example if you have \begin{array}... in the display \[ what digits would you want (entries in array are set in textstyle) – David Carlisle May 04 '18 at 12:20
  • I don't completely understand your question. In inline math mode (with ( and ) ) I want the proportional old-style figures so it blends in with the text more. In "real" math mode, be it arrays or other equations, I want the lining figures. – Tommiie May 04 '18 at 12:28
  • 2
    to make it more explicit what would you want for \[5+4 = \mbox{$5+4$} \] the second 5+4 is set in inline math nested in display math and that is very common, apart from explicit nesting as there, matrices, arrays, fractions all use textstyle. I would guess you want both 5+4 set using lining digits but that complicates the testing as you can't simply make start of inline math use old-style as it is depending on the outer context.... – David Carlisle May 04 '18 at 12:31
  • I didn't consider that as I didn't know that's very common. It's for a book with only a handful of equations really, most are inline. And indeed, I think I would want both using lining digits in that situation. – Tommiie May 04 '18 at 12:40
  • 1
    Did you see the posting Numbers outside Math environment? In my view, the distinction should be between math-y versus non-mathy contexts. Numbers that are not parts of an equation -- such as page numbers, years, day within a month, and numbers that occur in simple denumerations such as "47 Ronin" or "31 Flavors [of Ice Cream]" -- can be displayed using old-style digits. In constrast, in a mathy context (`$e^{i\pi}-1=0$^) numbers should always employ lining numerals, whether or not the numbers occur in an inline math context. – Mico May 04 '18 at 14:29
  • 1
    Interesting read. So that would mean that a text which heavily refers to page numbers and also heavily uses inline-math would have a mix of old-style and lining numbers. To me that looks ugly. But then again, nobody cares about how I think about typography because I don't know anything about it. – Tommiie May 04 '18 at 14:39
  • Note also @egreg's comment: "in a text with very little math, I'd probably typeset also "proper numbers" (in tables, for instance) as lowercase (old style), if the main font uses them" and as it currently stands, I have 2 equations in 150 pages of text so I would prefer to have them in old-style figures as well. – Tommiie May 04 '18 at 14:42
  • @Tom - Do also keep in mind that old-style numerals come in two "flavors": fixed-width and proportionately-widths. For numbers in a tabular setting, it would be a good idea to use fixed-width oldstyle numerals even if proportionately-spaced numerals are used in the body of the document. – Mico May 04 '18 at 15:04
  • @Tom -- A quick suggestion: Take a look a the user guide of the siunitx package: It uses oldstyle numerals in non-math contexts and lining numerals in math-y ("equation") contexts. To me, there's nothing ugly in that document about employing a mix of oldstyle and lining numerals in running text. – Mico May 04 '18 at 15:06
  • 1
    i was going to suggest a look at knuth's article, but i see that it's mentioned in the answer mentioned by @Mico,. the problem with old-style digits in math is that they could conceivably be mistaken for, or in, sub- or superscripts because many of then hang below the baseline, and the positioning would not be consistent. – barbara beeton May 05 '18 at 20:35
  • I was using old-style numbers in text, including when I used the SIunitx package. This feels more natural to me. Also I do not use any complex math in the running text, only simple additions and multiplications, e.g. $5 \times 7$ or $3 + n$. For anything more complex than that, I use the displaymath environments. Although I will reconsider using lining figures for everything math-related in-text, including all SI units, is there a technical solution to my question? – Tommiie May 10 '18 at 11:46

0 Answers0