\fontfamily{...}\selectfont 不适用于 XeLaTeX 引擎

\fontfamily{...}\selectfont 不适用于 XeLaTeX 引擎

以下 MWE 适用于 pdfLaTeX 引擎,但不适用于 XeLaXeX 引擎。\fontfamily{...}\selectfont使用 XeLaTeX 引擎时是否仅适用于某些字体系列?是否有合适的方法在一个文档中使用所有这些字体系列?

\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

西拉特克斯

答案1

您需要明确指定字体编码,因为默认情况下TU使用强制 LaTeX 经典字体选择系统使用 OpenType 字体的方法。

\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}

在此处输入图片描述

您可以来回切换,但建议仅在 XeTeX/LuaTeX 中使用 OpenType 字体。

\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}

在此处输入图片描述

答案2

上个世纪 8 个字母的文件系统需要短名称。使用 xelatex,您可以通过字体名称引用系统字体,例如

在此处输入图片描述

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Bitstream Vera Sans}
\begin{document}
\begin{enumerate}
 \item Hello World
\end{enumerate}
\end{document}

相关内容