1

For each chapter I am trying to put a double or triple horizontal rule that starts on the left and continues to the right-justified chapter heading like this:

================================================================= Chapter 10

I think I have a partial solution to creating the rule but when I put the code before \chaptertitlename \thechapter the word Chapter disappears and the chapter number shifts to the next line.

Here's what I've got:

\documentclass{book}
\usepackage[margin=1in]{geometry}
\usepackage{titlesec}

\titleformat{\chapter}[display]
{\normalfont\Huge\bfseries\raggedright\sffamily}{\raggedleft\chaptertitlename\ \thechapter}{20pt} 
{\Huge}

\newcommand{\chapterrule}{0.4pt}      % chapter rule thickness
\newcommand{\chapterrulesep}{5pt}     % space between the rules
\newcommand{\chapterruleoffset}{2pt}  % distance of the bottom rule from the baseline

\newcommand{\triplerule}[1]{%
\vbox{
\sbox0{ #1 }%
\dimen0=\textwidth
\advance\dimen0 by -\wd0
\noindent
\maketriplerule
\usebox{0}%
   }
}

\newcommand{\maketriplerule}{%
\vbox{
\hrule width \dimen0 height \chapterrule
\vskip\chapterrulesep
\hrule height \chapterrule
\vskip\chapterrulesep
\hrule height \dimen0 height \chapterrule
\vskip\chapterruleoffset
  }%
}

\begin{document}

\chapter[Test]{Test}

This is a test sentence.

\end{document}
0

Not sure this is exactly what you want, but I defined, adapted from a code by @DavidCarlisle, a \triplerulefill command: \documentclass{book} \usepackage[margin=1in]{geometry} \usepackage{titlesec}

\newcommand\triplerulefill{\leavevmode\leaders\vbox{\hrule width.1pt\kern 5pt\hrule width .1pt\kern 5pt\hrule\kern 3pt}\hfill\kern0pt }

\titleformat{\chapter}[display]
{\normalfont\Huge\bfseries\raggedright\sffamily}{ \triplerulefill\,\chaptertitlename\ \thechapter}{20pt}
{\Huge}

\begin{document}

\chapter[Test]{Test}

 This is a test sentence in a Test chapter.

\end{document}

enter image description here

| improve this answer | |
  • Thank you. That is very close. Are the lines black? Can they be vertically centered more with respect to the letter "C" (like up from the baseline)? – E2R0NS May 14 at 20:49
  • You mean just the lower part? – Bernard May 14 at 20:52
  • I figured out how to remove the linebreak. – E2R0NS May 14 at 20:53
  • No, I mean all three lines shifted up by the same amount so they are centered inline but still equidistant from each other. – E2R0NS May 14 at 20:53
  • They do look grey. Can I make them blacker? They also look thicker than a standard 0.4pt rule. – E2R0NS May 14 at 20:54
0

You have conflicting requirements: if you want 2pt from the baseline and a fixed space between the rules, you won't be able to center the middle rule with respect to the C.

The following solution typesets the rules at the stated distance from each other, and vertically centered with respect to C.

\documentclass{book}
\usepackage[margin=1in]{geometry}
\usepackage{titlesec}

\titleformat{\chapter}[display]
  {\normalfont\Huge\bfseries\sffamily}
  {\triplerule\chaptertitlename\ \thechapter}
  {20pt}
  {\Huge}

\newcommand{\triplerule}{%
  \leavevmode
  \sbox0{C}%
  \sbox0{\vbox to \ht0{%
    \vfill
    \hrule height \chapterrule depth \chapterrule width 4pt
    \vskip\chapterrulesep
    \hrule height \chapterrule depth \chapterrule
    \vskip\chapterrulesep
    \hrule height \chapterrule depth \chapterrule
    \vfill
  }}%
  \copy0\leaders\hbox{\kern-1pt\copy0\kern-1pt}\hfill\box0
  \enspace
}
\newcommand{\chapterrule}{0.3pt}      % chapter rule half thickness
\newcommand{\chapterrulesep}{5pt}     % space between the rules


\begin{document}

\chapter[Test]{Test}

This is a test sentence.

\end{document}

enter image description here

| improve this answer | |
  • Thanks. I see that now. My original code I think is adapted from you. Is it possible to bring the rules closer to the C (adjusting \ht0 perhaps)? Also, your rules seem bolder or darker. Are they they 0.6pt and if so, is that the cause? Finally, to adjust them up and down can I adjust the kern-1pt values? – E2R0NS May 14 at 22:21
  • @E2R0NS I set \enspace as the space between the rules and “Chapter”; you can use \hspace{<whatever>} (\enspace corresponds to 0.5em). I set the rules 0.6pt thick, yes: at 0.4pt they seemed too thin, but you can experiment by changing the value of \chapterrule which, in my implementation, is half the thickness. – egreg May 14 at 22:24
  • Thank you. Very helpful. – E2R0NS May 14 at 22: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.