使用多種系統字體

使用多種系統字體

我想為頁面的不同部分使用 3-4 種不同的特定係統字體(例如 Georgia、HelveticaNeui Light 和 Lucida Sans)以及特定的字體大小。我該怎麼做?

編輯:感謝您的回覆。我看到了fontspec我無法弄清楚如何定義字體系列,然後在特定部分引用它\setmainfont{}\setsansfont{}這是一個例子:

\documentclass[12pt]{article}

\usepackage{fontspec}

\begin{document}

\section{Georgia}%here define font

This text shows in Georgia.

\section{Lucida Sans}%

This text shows in Lucida Sans

\section{HelveticaNeue Light}%here define font

This text shows in Helvetica Neue Light

\end{document}

答案1

如果您只想將文字區塊設定為不同的字體,您可以使用對您的文件有意義的任何語義來簡單地為它們設定環境。主要要記住的是,您應該\newfontfamily為每種字體定義字體切換命令,而不是\fontspec直接使用該命令。例如:

% Compile with XeLaTeX or LuaLaTeX
\documentclass[12pt]{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}

\newfontfamily\calibrifont{Calibri}
\newfontfamily\cambriafont{Cambria}
\newfontfamily\georgiafont{Georgia}

\newenvironment{calibri}{\calibrifont}{\par}
\newenvironment{cambria}{\cambriafont}{\par}
\newenvironment{georgia}{\georgiafont}{\par}

\begin{document}
\begin{calibri}
This text is in Calibri
\end{calibri}
\begin{cambria}
This text is in Cambria
\end{cambria}
\begin{georgia}
This text is in Georgia
\end{georgia}
\end{document}

程式碼的輸出

相關內容