[Tex/LaTex] How to get \titleformat to display chapter count number

chaptersformattingtitlesec

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?

Best Answer

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