Fontspec: Palatino with small caps and old-style figures
You need a Palatino with proper OpenType support, alternatively you can use TeX Gyre Pagella (which is true Palatino by Zapf, and further opentypified by GUST) which is included in TeXlive.
\documentclass{article}
\usepackage{fontspec}
\setmainfont[Numbers=OldStyle]{TeX Gyre Pagella}
\begin{document}
Text 12345.
\end{document}
I like Khaled's approach better, but here's an answer to your more general problem. You can mix fonts with TeX-era encodings with unicode fonts if you specifically switch between font encodings:
\documentclass{article}
\usepackage{fontspec}
\newfontfamily\foo{Helvetica}
\usepackage[sc,osf]{mathpazo}
\usepackage[T1]{fontenc}
\begin{document}
Text 12345. {\fontencoding{EU1}\foo fontspec font}
\end{document}
Now that I write out this example, it strikes me that \newfontfamily
should include the line about switching font encodings. This has been simplified in this commit on Github.
This answer shouldn't take anything away from Khaled's or Will's insightful answers. Its purpose is just to pull their ideas together, to provide a soultion about \oldstylenums
that they'd omitted, to bring up the issue of math (since you had initially pulled in mathpazo
), and to introduce some font naming code to help you visualise your problem, especially when it comes to encodings. Here goes...
In fact, using \usepackage[osf]{mathpazo}, I get nice small caps and lowercase figures. But as soon as I \usepackage{fontspec}, old-style figures no longer work, even if I don’t select a font.
Firts, try adding (\fontname\the\font)
to your body text. If you do that, you'll quickly see that fontspec
has set your body text to Latin Modern (non-OSF) for you. Why, you might ask? Good question, go ask Will. In any event, you'll need to (re)load a compatible Palatino font. Per Khaled's answer, \setmainfont[Numbers=OldStyle]{TeX Gyre Pagella}
will do the trick. It's typeface is amazingly similar to ppl
. Everything will work now, except unfortunately this breaks \oldstylenums{...}
(because of the way mathpazo
has redefined \oldstylenums
, XeTeX throws a "Font shape `EU1/pplj/m/n' undefined" warning). This is the problem I was wrestling with when I started working on your problem.
You're very clear about the four points in your question. What's less clear is whether you also require that:
\oldstylenums{...}
must be available (and work)mathpazo
is absolutely needed for its nicer maths symbols than those from other Palatino families
The problem about using \oldstylenums
in your current configuration is that it reverts to printing Latin Modern (terrible match for Palatino). The second point is probably no big deal - mathpazo
math symbols are little different to those fontspec
gives you with TeX Gyre Pagella. Still, to my eye, the mathpazo
math symbols are definitely (albeit subtly) more refined.
The code below shows you the consequences and trade-offs that you get from various combinations. Try commenting out the \usepackage[sc,osf]{mathpazo}
line and, alternatively, my new definition for \oldstylenums
to see the effects of these. I've thrown in some font naming code and a \liningstylenums
command to help you with your choices.
\documentclass{article}
\usepackage[margin=0.5in]{geometry} % there are some pretty wide hboxes below
\usepackage{amsmath} % needed for the example below
\usepackage[sc,osf]{mathpazo} % comment this line in and out to see the
% differences in the displayed math
\usepackage{fontspec}
\setmainfont[Numbers=OldStyle]{TeX Gyre Pagella}
\newfontfamily\altfont[Numbers=OldStyle]{TeX Gyre Bonum}
\renewcommand*\oldstylenums[1]{{\fontencoding{T1}\fontfamily{pplj}\selectfont #1 (\fontname\the\font)}}
\newcommand*\liningstylenums[1]{{\fontencoding{T1}\fontfamily{pplx}\selectfont #1 (\fontname\the\font)}}
\newcommand\printstuff{
Plain text: abcdefghijk ABCDEFGHIJK (\fontname\the\font)\par
\textsc{Small caps: abcdefghijk ABCDEFGHIJK (\fontname\the\font)}\par
Plain figures: 0123456789 (\fontname\the\font)\par
Old style figures: \oldstylenums{0123456789}\par
Lining figures: \liningstylenums{0123456789}\par
\vspace{\baselineskip}
}
\begin{document}
Palatino...\par\printstuff
Here's some math:
\[\frac{1}{2\pi i}\int_\gamma f = \sum_{k=1}^m n(\gamma;a_k) \text{Res}(f;a_k).
\qquad (\fontname\the\font)\]\par
{\altfont Alternative font...\par\printstuff}
Palatino...\par\printstuff
\end{document}