3

I have searched forums and tried multiple solutions, but to no avail. Basically I want some chapters heading and titles to be left-justified while others are centered. In the code snippet I provide (MWE), I use titletoc and titlesec packages to format chapter titles and headings and their appearance in the ToC. With this code the first chapter is left-justified (as I want), but the second one is full-justified where I would like to be centered. By centered I mean the alignment that would result from using

\titleformat{\chapter}[block]
  {\centering}
  {\chaptertitlename\ \thechapter: }{12pt}{\LARGE}

to define chapter format. How can I define chapters heading/title alignment on a per-chapter basis?

MWE:

\documentclass[12pt,letterpaper,titlepage]{report}

%%% Load packages %%%
\usepackage{titletoc}
\usepackage{titlesec}

%%% Modifications to default commands %%%

%% Add "Chapter #:" before numbered chapters in ToC
\titlecontents{chapter}% <section-type>
  [0pt]% <left>
  {\bfseries}% <above-code>
  {\chaptername\ \thecontentslabel:\quad}% <numbered-entry-format>
  {}% <numberless-entry-format>
  {\hfill\contentspage}% <filler-page-format>

%% Format the title for chapters
\titleformat{\chapter}[block]
  {\normalfont\LARGE\bfseries}
  {\chaptertitlename\ \thechapter: }{12pt}{\LARGE}

\begin{document}

%%% Table of contents %%%
\tableofcontents %

\chapter{Introduction}

\begin{center}
\chapter{Maturation-disturbance cycles: endogenous spatiotemporal complexity in meta-ecosystems}
\end{center}

\end{document}

1 Answer 1

1

You can have several \titleformat commands throughout your document. Define for instance:

\newcommand\titlesflushleft
  {\titleformat{\chapter}[block]%
    {\normalfont\LARGE\bfseries}%
    {\chaptertitlename\ \thechapter: }{12pt}{\LARGE}%
  }
\newcommand\titlescentered
  {\titleformat{\chapter}[block]%
    {\filcenter\normalfont\LARGE\bfseries}%
    {\chaptertitlename\ \thechapter: }{12pt}{\LARGE}%
  }

Then you can switch:

\begin{document}
\titlesflushleft
\tableofcontents
\chapter{Introduction}
\titlescentered
\chapter{Centered title}

enter image description here enter image description here

\documentclass[12pt,letterpaper,titlepage]{report}

%%% Load packages %%%
\usepackage{titletoc}
\usepackage{titlesec}

%%% Modifications to default commands %%%

%% Add "Chapter #:" before numbered chapters in ToC
\titlecontents{chapter}% <section-type>
  [0pt]% <left>
  {\bfseries}% <above-code>
  {\chaptername\ \thecontentslabel:\quad}% <numbered-entry-format>
  {}% <numberless-entry-format>
  {\hfill\contentspage}% <filler-page-format>

%% Format the title for chapters
\newcommand\titlesflushleft
  {\titleformat{\chapter}[block]%
    {\normalfont\LARGE\bfseries}%
    {\chaptertitlename\ \thechapter: }{12pt}{\LARGE}%
  }
\newcommand\titlescentered
  {\titleformat{\chapter}[block]%
    {\filcenter\normalfont\LARGE\bfseries}%
    {\chaptertitlename\ \thechapter: }{12pt}{\LARGE}%
  }

\begin{document}
\titlesflushleft

%%% Table of contents %%%
\tableofcontents %

\chapter{Introduction}

\titlescentered
\chapter{Maturation-disturbance cycles: endogenous spatiotemporal complexity in meta-ecosystems}

\end{document}
1
  • I thought it was possible to do something like that but couldn't quite figure it out. This works perfectly, many thanks!
    – 0SoGood
    Jan 13, 2017 at 15:30

You must log in to answer this question.

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