# titlesec: How to get current chapter number when using [hang]

I'm using the titlesec package so my chapter heading looks like:

1. METHODOLOGY

According to this package documentation, I must use [hang] to get the chapter number and title in the same line. However, I cannot get the number to appear (only the chapter label is displayed).

This is my code:


\documentclass{book}
\usepackage{lipsum}
\usepackage{titlesec}

\titleformat{\chapter}[hang]{\normalfont\bfseries\huge\uppercase}{\thechapter. }{15pt}{}

\begin{document}

\chapter{Methodology}
\lipsum[2]

\chapter{Results}

\lipsum[2]

\end{document}



Do you see anything wrong with it?

• Welcome to TeX.SE. Please provide a compilable document, not such fragments only!
– user31729
Feb 11 '17 at 19:10
• You also can use the [block] style. This is not exactly the same if the chapter title spreads over several lines. That said, \thechapter in your code yields the chapter number. Feb 11 '17 at 19:32
• Where does \justifyheading come from? Feb 11 '17 at 19:43
• Because I'm using the following command to right-aligned: \newcommand*{\justifyheading}{\raggedleft}
– heb
Feb 11 '17 at 19:44
• \uppercase is always wrong; in that position it's very wrong. Feb 11 '17 at 20:34

There is nothing wrong, apart from \uppercase that should never be used.

\documentclass{book}
\usepackage{lipsum}
\usepackage{titlesec}

\titleformat{\chapter}[hang]
{\normalfont\bfseries\huge\raggedright}
{\thechapter. }
{15pt}
{\MakeUppercase}

\begin{document}

\chapter{Methodology}
\lipsum[2]

\chapter{Results}

\lipsum[2]

\end{document}


If you don't get the chapter number, you probably have an outdated version of titlesec, see titlesec: loss of section numbering with the new update (2016/03/15)

@Bernard gave me the answer: by changing [hang] to [block], \thechapter worked!