6

I've found a nice \titlesec style for my chapter that I want to use for my thesis. Unfortunately the \chapter text doesn't align vertical with the \section text:

Not vertical aligned

(I've added the red line in paint to demonstrate the problem).

I know that it's very close and I could fiddle with the \hspace of the \chapter from the line \newcommand{\hsp}{\hspace{9pt} but i feel that it would never be 100% perfectly aligned. What would be an elegant way of doing it?

MWE look like this:

\documentclass[12pt,a4paper,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[left=4cm,right=2.5cm,top=2cm,bottom=2cm,bindingoffset=6mm]{geometry}


% Style for Chapterheadings
\usepackage{titlesec, blindtext, color}
\definecolor{gray75}{gray}{0.75}
\newcommand{\hsp}{\hspace{9pt}}
\titleformat{\chapter}[hang]{\Huge\bfseries}{\thechapter\hsp\textcolor{gray75}{|}\hsp}{0pt}{\Huge\bfseries}
%%%


\begin{document}

\chapter{Beschreibung des Geschäftsprozesses}
\section{Übersicht über das Arbeitsumfeld des Geschäftsprozesses}

\end{document}
7

You can box the numbers to a certain width.

\documentclass[12pt,a4paper,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[left=4cm,right=2.5cm,top=2cm,bottom=2cm,bindingoffset=6mm]{geometry}


% Style for Chapterheadings
\usepackage{titlesec, blindtext, color}

\definecolor{gray75}{gray}{0.75}

\titleformat{\chapter}[hang]
  {\Huge\bfseries\filright}
  {\makebox[40pt][s]{\thechapter\hfill\textcolor{gray75}{|}\hspace{9pt}}}
  {0pt}
  {\Huge\bfseries}
\titleformat{\section}[hang]
  {\Large\bfseries\filright}
  {\makebox[40pt][l]{\thesection}}
  {0pt}
  {\Large\bfseries}
%%%


\begin{document}

\chapter{Beschreibung des Geschäftsprozesses}
\section{Übersicht über das Arbeitsumfeld des Geschäftsprozesses}

\end{document}

enter image description here

I added \filright to avoid hyphenation in titles.

  • Thats awesome, thank you very much for your incredible fast help. – Christian Oct 12 '19 at 16:06
  • @Christian Pronto prontissimo son come il fulmine: sono il factotum della città. (from my profile). ;-) – egreg Oct 12 '19 at 16:26

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.