XeTeX で titlesec と titleing を使用して章タイトルのフォントを変更するにはどうすればよいでしょうか?

XeTeX で titlesec と titleing を使用して章タイトルのフォントを変更するにはどうすればよいでしょうか?

XeTeX使用しようとしているドキュメントを編集しtitlesectitling一部の見出しに別のフォントを設定するために使用しています。

私は提案されたアプローチを使用しています同様の質問に返信するしかし、これまでのところ私の成功は本当に部分的です。

およびタイトルsectionsubsectionはフォントが希望どおりに変更されますが、chapterタイトルでは設定が無視されます。

これが私のコードの一部です

%%% to allow custom headings
\usepackage{titlesec}
% to change titles font family
\usepackage{titling}


%%% declare fonts and set some formats
% fontspec to use non-latex with xetex
\usepackage{xunicode}
\usepackage{fontspec}
\usepackage{xltxtra}

% font declaration and title settings
\newfontfamily\headingfont[]{Armata}
\titleformat{\chapter}{\LARGE\headingfont}
\titleformat*{\section}{\LARGE\headingfont}
\titleformat*{\subsection}{\Large\headingfont}
\renewcommand{\maketitlehooka}{\headingfont}

章の設定は、上記のリンクで提供されている解決策を模倣しながら試したものです。 は章のタイトルでは機能しない*ため、 を削除する必要があることeasy modeがわかりました。理由はまだわかりません。しかし、実際にはアスタリスクを削除するとエラーも解消されます... ただし、フォント フェイスの設定に関しては機能しないようです。

何か案は?

ありがとう :)

編集: 非常にばかげたエラーが見つかり、それが (部分的な) 解決策につながり、新しいエラーが表示されました。設定したところ\documentclass{book}、レンダラーは目的のフォントを配置しようとしましたが、titlesecエラーが発生します。

Titles must not be nested

LaTeX コードは次のとおりです。

\begin{document}


\chapter{First Chapter}

The title above does not show any font.

\section{First Section}

Works as desired.

\subsection{Subsection}

Hiya! This also shows up as expected.

\subsubsection{Subsubsection}

We have not declared a titleformat for this heading, and so it is shown with the default font.

\section{Second section}

Repeating the success

\end{document}

タイトルchapterは titlesec エラーをトリガーするものです。

答え1

この線

\titleformat{\chapter}{\LARGE\headingfont}

が犯人です。構文が間違っています。正しいのは

\titleformat{\chapter}[display]
  {\huge\headingfont}{\chaptertitlename\ \thechapter}{20pt}{\Huge}

それで、MWE です (Armata フォントがインストールされていないため、Arial ではなく Arial を使用しました)。

\documentclass{book}
%%% to allow custom headings
\usepackage{titlesec}
% to change titles font family
\usepackage{titling}


%%% declare fonts and set some formats
% fontspec to use non-latex with xetex
\usepackage{xunicode}
\usepackage{fontspec}
\usepackage{xltxtra}

% font declaration and title settings
\newfontfamily\headingfont[]{Arial}
\titleformat{\chapter}[display]
  {\huge\headingfont}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titleformat*{\section}{\LARGE\headingfont}
\titleformat*{\subsection}{\Large\headingfont}
\renewcommand{\maketitlehooka}{\headingfont}
\begin{document}


\chapter{First Chapter}

The title above does not show any font.

\section{First Section}

Works as desired.

\subsection{Subsection}

Hiya! This also shows up as expected.

\subsubsection{Subsubsection}

We have not declared a titleformat for this heading, and so it is shown with the default font.

\section{Second section}

Repeating the success

\end{document} 

次のような出力が得られる。

ここに画像の説明を入力してください

関連情報