2

I have the following MWE:

\documentclass[twoside]{book}

\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,headheight=28pt,bindingoffset=6mm]{geometry}
\usepackage[pagestyles]{titlesec}
\usepackage{lipsum}
\usepackage{fancyhdr}

\titleformat{\chapter}[display]
  {\normalfont\bfseries}{}{10pt}{\Huge}
\newpagestyle{mystyle}{
  \sethead[][][\chaptertitle]{\thesection~\sectiontitle}{}{\thepage}}

\begin{document}

\pagestyle{mystyle}
\chapter{A chapter}
\lipsum[1-40]

\end{document}

This successfully removes the word 'chapter' from the chapter titles. However I want to include the chapter count number as well. Something like '1. Introduction'. How do I do this using titlesec?

1
  • Do you want chapter number and chapter title on separate lines?
    – Bernard
    Jun 30, 2017 at 12:52

2 Answers 2

3

You shouldn't use the display style if you want the chapter label on the same line as the chapter title. Use the default hang style, or blockif you want to centre it. Note twoside isn't necessary: it's the default in the book class. Also don't load fancyhdr if you want to use titlesec with the pagestyles option, which loads titleps, and it may conflict with fancyhdr.

Here is a code:

\documentclass{book}

\usepackage[a4paper, width=150mm, vmargin=25mm, headheight=28pt, bindingoffset=6mm]{geometry}
\usepackage[pagestyles]{titlesec}
\usepackage{lipsum}

\titleformat{\chapter}%
  {\normalfont\bfseries\Huge}{\thechapter.}{10pt}{}
\newpagestyle{mystyle}{
  \sethead[][\thechapter.\enspace\chaptertitle][]{}{\thesection~\sectiontitle}{}
\setfoot{}{\thepage}{}}

\begin{document}

\pagestyle{mystyle}
\chapter{A Chapter}
\lipsum[1-5]
\section{A First Section}
\lipsum[6-20]

\end{document} 

enter image description here

6
  • Thanks. I want all the page numbers centered at the bottom. Also I want the custom heading to be centered, on both odd and even pages.
    – user131526
    Jun 30, 2017 at 13:53
  • I've updated my answer. Is it like you want?
    – Bernard
    Jun 30, 2017 at 14:07
  • thanks! I am trying to achieve the same result using fancyhdr, which i find easier to tweak and more intuitive. Stay tuned for my next question!
    – user131526
    Jun 30, 2017 at 14:18
  • You find the \leftmark/rightmark:\markboth system more intuitive that \sectiontitleand \chaptertitle?!!!
    – Bernard
    Jun 30, 2017 at 14:21
  • ok. Maybe not, these are all equally confusing!
    – user131526
    Jun 30, 2017 at 16:32
1

Include \thechapter.\quad as part of your title setting:

enter image description here

\documentclass{book}

\usepackage{titlesec}

\titleformat{\chapter}[display]
  {\normalfont\bfseries}{}{10pt}{\Huge\thechapter.\quad}

\begin{document}

\chapter{A chapter}

\end{document}
6
  • You should be able to do the same for your header.
    – Werner
    Jun 30, 2017 at 12:42
  • Thanks! How would you change the heading \sethead[][][\chaptertitle]{\thesection~\sectiontitle}{}{\thepage}} to include that? I can't get it to work for the heading!
    – user131526
    Jun 30, 2017 at 12:47
  • @PintoDoido: Use \thechapter~\chaptertitle in the header setting.
    – Werner
    Jun 30, 2017 at 12:50
  • @Werner: For your code, the default [hand] style is enough. [display] is to be used when chapter label and chapter title are on separate lines.
    – Bernard
    Jun 30, 2017 at 12:52
  • it's working now! \sethead[][][\thechapter.\quad\chaptertitle]{\sectiontitle}{}{\thepage}
    – user131526
    Jun 30, 2017 at 13:30

You must log in to answer this question.

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