# Typesetting a single word with TeX Gyre Pagella at T5, using Palatino for everything else

I need to typeset a single Vietnamese word in my otherwise English document. My document is in Palatino, which doesn't support T5, so after I switch to T5, it uses a different font. So far, this is the same problem as described in this question. However, there the solution was to change the main font to TeX Gyre Pagella. I'd like to apply that solution locally, i.e. use TeX Gyre Pagella just for this one word.

\documentclass{memoir}
\usepackage[T1,T5]{fontenc}
\usepackage{fontspec}
\usepackage[defaultsups]{newpxtext}
\usepackage[english,vietnamese]{babel}
\newfontfamily\vnfont{TeX Gyre Pagella}

\begin{document}
Nguyen

\noindent

{\fontencoding{T5}\vnfont\selectfont{}Nguy\~\ecircumflex{}n}
\end{document}


However, this fails with:

LaTeX Error: Command \ecircumflex unavailable in encoding TU.

If instead I write \vnfont\fontencoding{T5}, then the latter overrides the former and I get the non-Palatino-looking font.

Since you are loading fontspec, I presume you are using either xelatex or lualatex. In such a case, don’t load fontenc and declare the font for vietnamese in the following way:

\documentclass{memoir}

\usepackage[english]{babel}

\babelfont[vietnamese]{rm}{TeX Gyre Pagella}

\begin{document}

Nguyen in English text.

\foreignlanguage{vietnamese}{Nguy\~{\^{e}}n}

% Better:
\foreignlanguage{vietnamese}{Nguyễn}

\end{document}

• Can you add a full self-contained example that also uses Palatino for the non-Vietnamese parts? If I take yours, and add \usepackage[defaultsups]{newpxtext}, the 'Nguyen in English text' line isn't typeset in Palatino. Jul 31, 2021 at 10:34
• @Cactus Sadly, newpxtext assumes pdftex and loads fontenc with T1 as default. Overcoming this problem would be more complicated than you own solution. Aug 1, 2021 at 10:45
• hmm, so what's the recommended way of loading Palatino into Xetex? Aug 1, 2021 at 10:59

I got it working by getting rid of the fontenc red herring (which I only put in there on suggestion of the VnTeX documentation), and using UTF-8 directly with my choice of \vnfont:

\documentclass{memoir}
\usepackage{fontspec}
\usepackage[defaultsups]{newpxtext}
\newfontfamily\vnfont{TeX Gyre Pagella}

\begin{document}
Nguyen, \vnfont Nguyễn, \normalfont and Nguyen.
\end{document}