I want to format my chapter headings so they look something like this:
------ 1 --------------------------------- % horizontal rule here
Here is the title for chapter 1
------------------------------------------ % horizontal another rule
I can use the titlesec
package to create most of this, but I can't get the first line I want, i.e. the chapter number surrounded by raised horizontal rules. I can almost get it right with \hrulefill using:
\hrulefill\thechapter \hrulefill\hrulefill
but the rule produced is at baseline height, and I cannot figure out how to raise the \hrulefill command. On the internet I stumbled on an alternative by using leaders:
\newcommand{\raisedrule}[2][0em]{\leavevmode\leaders\hbox{\rule[#1]{1pt}{#2}}\hfill\kern0pt}
but this also does not produce quite what I want. It successfully raises the line, but the result looks more like a series of concatenated small lines(of 1pt length, I guess), instead of a unified rule. I've tried to reduce the size of the individual units by setting it to something like \rule[#1]{0.1pt}
but that seems to significantly slow down the rendering of my PDF viewer (in one instance it even crashed it). I'm not sure why.
I've also tried the xhfill
package, but including two xrfill
commands next to each seems to introduce a small gap between them.
Any ideas on how to achieve this, either by modifying \hfillrule or introducing some other commands ?
Thanks.
MWE:
\documentclass[11pt,twoside]{book}
% I've tried two ways of defining the rule...
% I've tried this option:
\newcommand{\raisedrule}[2][0em]{\leavevmode\leaders\hbox{\rule[#1]{1pt}{#2}}\hfill\kern0pt}
\newcommand{\chaphrfill}{\raisedrule[10pt]{5pt}}
% And I've also tried this:
\usepackage{xhfill}
\newcommand{\chaphrfill}{\xrfill[10pt]{5pt}}
\usepackage[explicit]{titlesec}
\titleformat{\chapter}[display]
{\bfseries\scshape}
{%
\hspace*{0em}
{\chaphrfill~~\thechapter~~\chaphrfill\chaphrfill}
}
{0em}
{\Large\raggedright#1}
\begin{document}
\chapter{Chapter title....}
text .....
\end{document}