複数のシステムフォントの使用

複数のシステムフォントの使用

ページのさまざまなセクションに、特定のフォント サイズの 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}

コードの出力

関連情報