Libertine newtxmath and text (oldstyle) figures in headers

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


For the current newtxmath, don't use the osf option before \usepackage[libertine]{newtxmath} but add the following 4 lines immediately after:

\makeatletter
\def\libertine@figurestyle{OsF} %affects \libertine macro
\makeatother
\renewcommand*{\rmdefault}{LinuxLibertineT-OsF} % for normal text

It's in newtxdoc.pdf.


The package Libertine (as of the version published on february 11, 2014) provides the \useosf command, which, if used after loading the math font, sets old-style figures only for text (including headers).

\documentclass[12pt]{memoir}

\usepackage{textcomp}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}

\useosf

\begin{document}

\chapter{Chapter}

\section{Section}

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

enter image description here