How do you change the typeface used for the part environment to an Opentype font?

(In the MWE below, I've used a TrueType font, but the method should be the same).

It appears the standard titlesec method for chapter and section headings doesn't work.

Engine is LuaLaTeX.


\documentclass[11pt, a4paper]{book}



    \part{Hello world.}
    \chapter{Hello again, world.}

The \part command can't be changed using the “easy” mode. When you compile your code you get this error:

! Package titlesec Error: Not allowed in `easy' settings.

See the titlesec package documentation for explanation.
Type  H <return>  for immediate help.

l.7 \titleformat*{\part}{\partfont}

? h % < I typed h<return> here
The sectiong command you are trying to redefine
is not handled by the starred variant (eg, \part)

You'll have to use the general form of the \titleformat macro (i.e. without the *) and replicate the \part command from book class. Use this \titleformat:

  {\filcenter\huge\bfseries} % Format of the section header
  {\partname\nobreakspace\thepart} % Format of the “Part X” text
  {0pt} % Horizontal space (none, we want vertical)
  {\\\vspace{20pt}\Huge} % Commands before the title part (vertical space of 20 pt and increase in font size

The \chapter command allows you to use \titleformat*, so your code works.

Now you just have to add in your custom font. I used TeX Gyre Termes for I don't have Verdana.ttf:

\documentclass[11pt, a4paper]{book}

\newfontfamily\partfont{Tex Gyre Termes}

{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}

\newfontfamily\chapterfont{Tex Gyre Termes}

    \part{Hello world.}
    \chapter{Hello again, world.}

Part heading:

enter image description here

Chapter heading:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.