2

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}
  • 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 4 '18 at 12:20
  • 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 4 '18 at 12:31
  • 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 4 '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 4 '18 at 14:39
  • 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 5 '18 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.