3

How can I get this chapter heading style? Mine is not looking good. The default LaTex one does not look like this. Do I have to change the .cls?

enter image description here

Right now I have this one but it does not look quite sharp:

I have found a simple solution. The\hrule is missing and also add \scshape to the chapter instead of \bfseries:

\documentclass{book}
\usepackage{sectsty}
\usepackage{lipsum}

\chapterfont{\centering}
%\sectionfont{\centering}
%\subsectionfont{\centering}

\begin{document}

    \chapter{Test Chapter}
    \section{Test Section}
    \lipsum[7]
    \subsection{Test Subsection}
\end{document}

enter image description here

5
  • No, don't change the class file, but it would help us to give a good answer if we knew which class you're using. Could you please include a complete minimal working example (MWE) that starts at \documentclass and ends at \end{document}?
    – Skillmon
    Nov 1, 2019 at 11:55
  • @Skillmon The whole Tex document is very large. I have uploaded what I am currently using
    – Stephen
    Nov 1, 2019 at 11:57
  • 1
    If you took a look at the link in my first comment, you'd see that there is an accepted answer that shows how you get a minimal example. Please follow the steps laid out there, creating a minimal example is quite important, as it will drastically enhance the answer quality and reduce the threshold to get people to answer your query.
    – Skillmon
    Nov 1, 2019 at 12:00
  • @Skillmon I added it before you had posted the last comment.
    – Stephen
    Nov 1, 2019 at 12:08
  • No, you didn't but that's not important. Your second example is a good starting point for anyone willing to answer!
    – Skillmon
    Nov 1, 2019 at 12:50

1 Answer 1

2

The following using titlesec comes close to your wished results.

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

\begin{document}

\tableofcontents
\listoffigures
\listoftables

\titleformat{\chapter}[display]
  {\Large}
  {\filcenter\textsc{\chaptertitlename} \thechapter}
  {2ex}
  {\bfseries\filcenter}
  [\vspace{5ex}\titlerule]

\chapter{Test Unnumbered Chapter}
\lipsum[1-2]
\chapter{Test Numbered Chapter}
\lipsum[1-2]

\end{document} 

enter image description here

6
  • It did work but there is a little problem. It is affecting the table of contents also along with the list of figures. I want those sections to remain the same, meaning, as default.
    – Stephen
    Nov 1, 2019 at 13:20
  • @Delan Then put the \titleformat macro after the ToC, LoF and LoT.
    – Skillmon
    Nov 1, 2019 at 13:59
  • I did everything at my disposal but it did not work. Could you please add it to your answer?
    – Stephen
    Nov 1, 2019 at 14:20
  • It did work!!! Thank you very much!!!
    – Stephen
    Nov 1, 2019 at 14:35
  • If the chaptertitlename is supposed to be grey or at least non-black (it's hard to tell on my browser), xcolor package's \color{black!40} command in the second parameter of the \titleformat command will do it. Vary the 40 between 1 and 100 to get different ratios of white mixed in with the black.
    – Cicada
    Nov 2, 2019 at 5:28

You must log in to answer this question.

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