[Tex/LaTex] Libertine newtxmath and text (oldstyle) figures in headers

fontsheader-footerlibertineoldstylenumspdftex

This is closely related to the OP with title "lining figures in tables and math, old style figures in text", and to the answer provided therein.

The following (semi)MWE is to be run with pdfLaTeX:

\documentclass[12pt]{memoir}

\usepackage{etoolbox}% I tried with \AfterEndPreamble
\usepackage{textcomp}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}

\AfterEndPreamble{%
    \def\libertine@figurealign{}
    \libertineOsF
    \noindent% memoir indents at the very start 
}

\begin{document}
Text figures: 0123456789
\par\noindent
Math figures: $0123456789$
\end{document}

It leads to lining figures in math mode and text (oldstyle) figures in text mode, but only on the textblock and not so on the headers, where we still get lining figures, as can be seen in the numeral for the page number.

How can we get oldstyle figures on the headers, too?

Best Answer

This seems to work:

\documentclass[12pt]{memoir}

\usepackage[T1]{fontenc}
\usepackage[oldstyle]{libertine}

\makeatletter
\renewcommand*\libertine@figurestyle{LF}
\makeatother

\usepackage[libertine]{newtxmath}

\makeatletter
\renewcommand*\libertine@figurestyle{OsF}
\makeatother

\begin{document}


\section{foo 123 bar}

Text figures: 0123456789 \textbf{0123456789}
\par\noindent
Math figures: $0123456789$

\end{document}

enter image description here

Related Question