1

This question provides a code to set chapter font using titlesec, but doesn't say how to change the font family of each part (label and title).

How to change the font family of the "Chapter first" in the following example (for example to Tahoma) using this code and make it center? please note only the chapter label (Chapter #)

something like

                 Chapter first
              The theory of this work
Ahmad
  • 1,013

2 Answers2

1

Try something like this to change the font only for the label:

\usepackage{fmtcount}
\usepackage{tahoma}
\titleformat{\chapter}[display]{\filcenter}{\fontfamily{tahoma}\selectfont\MakeUppercase\chaptername~\ordinalstring{chapter}}{6ex}{}
Bernard
  • 271,350
  • I tried to use XB Zar instead of tahoma, as it is a Persian font, and receive this error Package titlesec Error: Entered in horizontal mode. \tableofcontents – Ahmad Jun 22 '16 at 07:46
  • Is there a LaTeX package to use it? If not, you'll have to compile with XeLaTeX or LuaLaTeX and load fontspec. – Bernard Jun 22 '16 at 08:37
  • I found a solution posted in my answer, I needed the different font only for Chapter # – Ahmad Jun 22 '16 at 09:13
  • It should be simpler with titlesec. What's not clear to me, do you want to use this font only for the label, not for the title? – Bernard Jun 22 '16 at 09:20
  • Yes only for the label not title! – Ahmad Jun 22 '16 at 09:33
0

The following code for Persian font XB Zar compiled by Xelatex do the tricks

\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
%%=========================
Ahmad
  • 1,013