这个问题提供了使用来设置章节字体的代码titlesec
,但没有说明如何更改每个部分(标签和标题)的字体系列。
如何使用此代码更改以下示例中“章节优先”的字体系列(例如更改为 Tahoma)并使其居中?请仅注意章节标签(章节编号)
就像是
Chapter first
The theory of this work
答案1
尝试如下方法仅更改标签的字体:
\usepackage{fmtcount}
\usepackage{tahoma}
\titleformat{\chapter}[display]{\filcenter}{\fontfamily{tahoma}\selectfont\MakeUppercase\chaptername~\ordinalstring{chapter}}{6ex}{}
答案2
以下代码为波斯字体XB Zar
编译的Xelatex
技巧
\usepackage{titlesec}
\usepackage{xepersian}
\settextfont{XB Yagut}
%% Change font of chapter titles and make it center
\defpersianfont\chapterfont[Scale=0.95]{XB Zar}
\makeatletter
\def\@makechapterhead#1{%
\vspace*{40\p@}%
{\parindent \z@ \RTL\normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\Huge\filcenter\bfseries {\chapterfont \@chapapp}\space \thechapter
\par\nobreak
\vskip 15\p@
\fi
\fi
\interlinepenalty\@M
\huge \bfseries{\normalfont #1}\par\nobreak
\vskip 30\p@
}}
\def\@makeschapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \centering
\normalfont
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\makeatother
%%%%%%%%%%%%%%%%
%%%% Make Chapter number ordinal (for Persian)
\makeatletter
\bidi@patchcmd{\@makechapterhead}{\thechapter}{\tartibi{chapter}}{}{}
\bidi@patchcmd{\chaptermark}{\thechapter}{\tartibi{chapter}}{}{}
\makeatother
%%=========================