0

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?

5
  • 1
    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.
    – Bernard
    Feb 11 '17 at 19:32
  • Where does \justifyheading come from?
    – Bernard
    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.
    – egreg
    Feb 11 '17 at 20:34
1

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}

enter image description here

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)

0

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

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.