[Tex/LaTex] Chapter heading at the right-hand side

formattingsectioning

I want a specific chapter heading as in the picture below
(Chapter heading at the right-hand side, but section heading at the left-hand side)
Can you help me?

enter image description here

Best Answer

You can use the titlesec package and its \titleformat and \titlespacing commands.

\documentclass{book}
\usepackage[pass,showframe]{geometry}
\usepackage{titlesec}

\titleformat{\chapter}[display]
  {\filleft\Large}
  {\chaptername\ \thechapter}
  {5ex}
  {\bfseries\MakeUppercase}
\titlespacing*{\chapter}
  {0pt}
  {-15pt}
  {60pt}

\begin{document}
\mainmatter
\chapter{Introduction}
\section{Motivation}
Bla
\end{document}

The line \usepackage[pass,showframe]{geometry} has been added just for showing the result.

enter image description here


Here an approach to use the modification only for the mainmatter part.

\documentclass{book}
\usepackage[pass,showframe]{geometry}
\usepackage{titlesec}
\makeatletter
\let\ttl@save@mkchapOrig\@makechapterhead
\let\ttl@save@mkschapOrig\@makeschapterhead

\titleformat{\chapter}[display]
  {\filleft\Large}
  {\chaptername\ \thechapter}
  {5ex}
  {\bfseries\MakeUppercase}
\titlespacing*{\chapter}
  {0pt}
  {-15pt}
  {60pt}

\let\ttl@save@mkchapFormat\@makechapterhead
\let\ttl@save@mkschapFormat\@makeschapterhead

\g@addto@macro\frontmatter{%
   \let\@makechapterhead\ttl@save@mkchapOrig%
   \let\@makeschapterhead\ttl@save@mkschapOrig}

\g@addto@macro\mainmatter{%
   \let\@makechapterhead\ttl@save@mkchapFormat%
   \let\@makeschapterhead\ttl@save@mkschapFormat}

\g@addto@macro\backmatter{%
   \let\@makechapterhead\ttl@save@mkchapOrig%
   \let\@makeschapterhead\ttl@save@mkschapOrig}
\makeatother
\begin{document}
\frontmatter
\tableofcontents
\listoffigures
\mainmatter
\chapter{Introduction}
\section{Motivation}
Bla
\backmatter
\appendix
\chapter{appendix}
\end{document}