2

I'm not sure if this is too minimal. (In the real document the problem appears at the bibliography, table of contents and \chapter*)

\documentclass[a4paper, 11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[left=2cm,right=2cm,top=3cm,bottom=3cm]{geometry}

\usepackage{titlesec}
\titleformat{\chapter}[display]{\normalfont\bfseries}{}{0pt}{\LARGE\thechapter\quad}

\begin{document}
\chapter*{Not numbered}
\chapter{Numbered}
\end{document}

How do I get the \thechapter\quad to not apply for unnumbered chapters?

5
  • For numbered chapters, do you want the chapter number and chapter title on the same line or on different lines.? This is not clear from your code.
    – Bernard
    Commented May 16, 2015 at 16:24
  • @Bernard Same line
    – Coolwater
    Commented May 16, 2015 at 16:26
  • So my proposition was correct. Chapter title is left-aligned. Also, do you want unnumbered chapters to appear in the table of contents?
    – Bernard
    Commented May 16, 2015 at 16:28
  • @Bernard Yes. I currently use \addcontentsline{toc}{chapter}{Preface} locally, but is it possible automate that operation?
    – Coolwater
    Commented May 16, 2015 at 16:32
  • Yes. See my updated answer. You have to load titlesec with the explicit option. And hypothetically use titletoc to define a correct formatting of unnumbered chapters in the table of contents.
    – Bernard
    Commented May 16, 2015 at 17:22

1 Answer 1

4

As far as I understand what you want to do, you should use the blockstyle. Add something like this to your preamble:

\usepackage[explicit]{titlesec}
\titleformat{name=\chapter,numberless}[block]{\normalfont\LARGE\bfseries}{}{0pt}{\addcontentsline{toc}{chapter}{#1}#1}

Also, replace your present code for numbered chapters with

\titleformat{\chapter}[block]{\normalfont\LARGE\bfseries}{\thechapter}{1em}{#1}
0

You must log in to answer this question.

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