I want to place a chapter title between two lines. The lines shall be on the left and the right side of the centered title like in this screenshot:
Note that the lines are slightly overhanging the text below. It would be nice if I could do the same. Obviously the length of the chapter titles is varies, so the solution needs to automatically adapt to the length.
By now I have the following:
\documentclass{memoir}
\usepackage{graphics}
\usepackage{fontspec}
\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1pt \hfill \kern \z@}
\def\@makechapterhead#1{%
\vspace*{60\p@}%
{\parindent \z@ \centering \reset@font
{\color{headings}
\scshape \large \@chapapp{} \thechapter
}
\par\nobreak
\interlinepenalty\@M
\Huge \itshape #1\par\nobreak
\thickhrulefill
\par\nobreak
\vskip 40\p@
}}
\usepackage{lipsum}
\setcounter{chapter}{12}
\begin{document}
\chapter{Implementation}
\lipsum
\end{document}
which gives me this:
Best Answer
Here is an idea:
I've placed the header (only the chapter title) inside a box of with
\linewidth
, which ensure no overfull\hbox
es. Then, inside that box, I place two\thickhrulefill
s beside the actual title, inside another box of width\linewidth+4em
. Since these boxes centre their content by default, it allows for a 2em overhang on either side.A slight raise of -1ex (or a drop) centres the heading with respect to the rules.