0

I'm writing a report that requires a particular style for titles as given by:

\titleformat{\chapter}{\fontsize{22pt}{0}}{}{0em}{\bf\LARGE\thechapter\\
~}

This shows up as intended below:

Introduction

However, for my 'References' and 'Glossary' sections, a number shows up in the heading despite them being unnumbered.

\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{\protect\numberline{}References}
\begin{thebibliography}{10}

References

Even a "test" chapter* has a number (also 7).

\chapter*{test}

test section

Does anyone know how I might go about rectifying this?

  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Adam Liter Mar 17 '15 at 23:37
4

Your problem comes from the placement of the chapter label as the last argument of \titleformat. Here is a correct placement. Note the style you have to use is \display instead of the default hang:

\documentclass[12pt, a4paper]{book}%

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{lipsum}
\usepackage{titlesec}%

\titleformat{\chapter}[display]{\fontsize{22pt}{28pt}\bfseries}{\LARGE\thechapter}{1.5ex}{}

\usepackage{hyperref}

\begin{document}

\tableofcontents

\chapter{Introduction}

\lipsum[1]

\chapter*{Test}

\lipsum[2-3]

 \cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{\protect\numberline{}References}
\begin{thebibliography}{10}
\end{thebibliography}

\end{document} 

enter image description here

enter image description here

enter image description here

0

I discovered that posting this in the document before the needed section helped solve my problem:

\titleformat
{\chapter}
{\fontsize{22pt}{0}}
{}
{0em}
{\bf\LARGE}
  • This is wrong syntax and will create problems for you later. \bf is a depreciated command its own problems. Use Bernhard's solution, which is the correct way doing this. – Sveinung Aug 30 at 14:42

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.