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}
\[what digits would you want (entries inarrayare set in textstyle) – David Carlisle May 04 '18 at 12:20\[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:31siunitxpackage: 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