2

I am using titlesec to change the font of chapter section etc. to Helvetica. I am struggling to do the same with part

This is the code I am using for chapter and section:

\titleformat{\chapter}
    {\normalfont\sffamily\huge\bfseries}
    {\thechapter. }{0em}{\setstretch{1}}
 \titleformat{\section}
    {\normalfont\sffamily\large\bfseries}
    {\thesection}{1em}{}

How do I set a \titleformat to mimic the standard look provded by the book class?

I only need to change the font to \normalfont\sffamily

Here is how it looks now:

enter image description here

0

2 Answers 2

3

You need the display format (Sec. 3 of the titlesec documentation). Looking into book.cls you see that the label "Part" is typeset in \huge, while the part's title comes in \Huge.

\documentclass{book}

\usepackage{newtxtext}
\usepackage{titlesec}

\titleformat{\part}[display]
    {\centering\normalfont\sffamily\huge\bfseries}
    {\partname~\Roman{part}}{2ex}{\Huge}

\begin{document}

\part{Blah}

\end{document}

enter image description here

1
  • thanks for guiding me through the solution. Now I know how to reverse engineer the book class Commented Aug 5, 2021 at 18:58
3

You can patch the relevant commands to use \sffamily:

\documentclass{book}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\@part}{\normalfont}{\normalfont\sffamily}{}{}
\xpatchcmd{\@spart}{\normalfont}{\normalfont\sffamily}{}{}
\makeatother

\begin{document}

\part{Title}

This is the following text

\part*{Title}

\end{document}
2
  • what is spart for? Was that supposed to be chapter? Commented Aug 3, 2021 at 15:36
  • @user1736049 It is \@spart, which is the internal command used when \part* is processed.
    – egreg
    Commented Aug 3, 2021 at 16:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .