9

The following MWE works fine with pdfLaTeX engine but does not with XeLaXeX engine. Does \fontfamily{...}\selectfont work only with some font family when using XeLaTeX engine? Is there an appropriate way to use all of these font family in one document?

\documentclass{article}
\begin{document}
\begin{enumerate}
    \fontfamily{pag}\selectfont \item Avant Garde
    \fontfamily{fvs}\selectfont \item Bitstream Vera Sans
    \fontfamily{pbk}\selectfont \item Bookman
    \fontfamily{bch}\selectfont \item Charter
    \fontfamily{ccr}\selectfont \item Computer Concrete
    \fontfamily{cmr}\selectfont \item Computer Modern
    \fontfamily{pcr}\selectfont \item Courier
    \fontfamily{phv}\selectfont \item Helvetica
    \fontfamily{fi4}\selectfont \item Inconsolata
    \fontfamily{lmr}\selectfont \item Latin Modern
    \fontfamily{lmss}\selectfont\item  Latin Modern Sans
    \fontfamily{lmtt}\selectfont\item  Latin Modern Typewriter
    \fontfamily{pnc}\selectfont \item New Century Schoolbook
    \fontfamily{ppl}\selectfont \item Palatino
    \fontfamily{ptm}\selectfont \item Times
    \fontfamily{uncl}\selectfont\item  Uncial
    \fontfamily{put}\selectfont \item Utopia
    \fontfamily{pzc}\selectfont \item Zapf Chancery
\end{enumerate}
\end{document}

PDFLaTeX

XeLaTeX

2 Answers 2

13

You need to specify explicitly the font encoding, because by default TU is used which is a way to coerce LaTeX classic font selection system into working with OpenType fonts.

\documentclass{article}
\begin{document}
\begin{enumerate}\fontencoding{T1}
    \fontfamily{pag}\selectfont \item Avant Garde
    \fontfamily{fvs}\selectfont \item Bitstream Vera Sans
    \fontfamily{pbk}\selectfont \item Bookman
    \fontfamily{bch}\selectfont \item Charter
    \fontfamily{ccr}\selectfont \item Computer Concrete
    \fontfamily{cmr}\selectfont \item Computer Modern
    \fontfamily{pcr}\selectfont \item Courier
    \fontfamily{phv}\selectfont \item Helvetica
    \fontfamily{fi4}\selectfont \item Inconsolata
    \fontfamily{lmr}\selectfont \item Latin Modern
    \fontfamily{lmss}\selectfont\item  Latin Modern Sans
    \fontfamily{lmtt}\selectfont\item  Latin Modern Typewriter
    \fontfamily{pnc}\selectfont \item New Century Schoolbook
    \fontfamily{ppl}\selectfont \item Palatino
    \fontfamily{ptm}\selectfont \item Times
    \fontfamily{uncl}\selectfont\item  Uncial
    \fontfamily{put}\selectfont \item Utopia
    \fontfamily{pzc}\selectfont \item Zapf Chancery
\end{enumerate}
\end{document}

enter image description here

You can switch back and forth, although it is advisable to use only OpenType fonts with XeTeX/LuaTeX.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\begin{document}
Now using Times New Roman.

\fontencoding{T1}\fontfamily{cmr}\selectfont
Now using Computer Modern classic 8bit font files.

\normalfont
Now using again Times New Roman.

\fontencoding{T1}\fontfamily{pzc}\selectfont
Now using Zapf Chancery classic 8bit font files.

\normalfont
Now using again Times New Roman.

\fontencoding{T1}\fontfamily{pnc}\selectfont
Now using New Century Schoolbook classic 8bit font files.

\normalfont
Now using again Times New Roman.
\end{document}

enter image description here

7
  • 1
    But using T1 encoding with xelatex is naturally not recommended. One should better use fontspec and search for suitable open type replacements. Commented Apr 13, 2018 at 7:00
  • @UlrikeFischer the usage is scoped here to enumerate environment
    – user4686
    Commented Apr 13, 2018 at 7:28
  • 1
    But only in the example. The OP probably plan to use these fonts in a full document and then switching to T1-encoding is not the right thing to do. Commented Apr 13, 2018 at 7:33
  • The OP will have been warned ! ;-)
    – user4686
    Commented Apr 13, 2018 at 7:57
  • @UlrikeFischer: Yes, I plan to them in a full document but I tried to minimize it for posting question only.
    – Say OL
    Commented Apr 13, 2018 at 9:19
3

The short names are required for 8 letter file systems last century. Using xelatex you can refer to your system fonts via their font names, so for example

enter image description here

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Bitstream Vera Sans}
\begin{document}
\begin{enumerate}
 \item Hello World
\end{enumerate}
\end{document}
2
  • 1
    Helpful! Changing font encoding from time to time assist me to use those 8-bit fonts. Anyway, I am still doubtful if it it harmful to use fontspec package and T1 encoding.
    – Say OL
    Commented Apr 13, 2018 at 14:10
  • 2
    @SayOL in xelatex as currently built it on;y has hyphenation patterns for TU encoding so if you use T1 encoding hyphenation is likely to be wrong, if you just use it for a small section to access a font then that is probably OK, although there are very few fonts that are only available in classic 8bit tex font encodings and not available as unicode based fonts Commented Apr 13, 2018 at 15:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .