# Palatino with text figures, not in math mode or headings

I'm working on a document which is fairly math-heavy, but also contains numbers outside of math mode. I want these numbers to be displayed as old-style/text figures. I also want a Palatino-type font (either mathpazo or tgpagella). Using tgpagella with textcomp gives me text figures, but then math mode is displayed in the regular Computer Modern font. Using mathpazo with the [osf] option gives me text figures everywhere---even in titles, headings, and math mode, where they don't belong. I can't seem to figure out how to mix text and lining figures with Palatino-like math fonts.

-
Are you sure that with the [osf] option of mathpazo, you get text figures in math mode? I agree with the fact that you get text figures in titles, but not in math mode. – Bruno Mar 13 '12 at 8:12
With \usepackage[osf]{mathpazo} you certainly get text figures in titles and headers, and certainly not in math mode. If you want lining figures in titles and headers, you should tell more about the document class you're using. – egreg Mar 13 '12 at 9:58

This is a XeLaTeX solution:

\documentclass{article}

% Load mathpazo as a math font
\usepackage{mathpazo}

% Load Pagella as a text font by specifying no-math to fontspec
\usepackage[no-math]{fontspec}
\setmainfont[Numbers=OldStyle]{TeX Gyre Pagella}

\begin{document}

Some numbers outside math mode: 1 2 3 4 5

Some numbers in math mode: $1 2 3 4 5$

\end{document}


It works the same for headers (use math-mode if you don't want old-style figures).

Edit: OSF are fine in headers and titles unless you write them in full capital letters (by contrast to roman, bold, italic and small-caps). Automatically putting lining figures there would require quite a bit more work (such as redefining the section headers) and I don't quite think it is worth it – especially since the result would not be typographically correct.

-