2

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.

2 Answers 2

6

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}
3
  • 1
    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.
    – Cactus
    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?
    – Cactus
    Aug 1, 2021 at 10:59
2

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.