[Tex/LaTex] chapter style latex horizontal line


I want a chapter style like this:

------chapter name-------------

      text text text text tex
      t text text text text t

I have come this far:







Text text text text


but I can not get it right. I want the horizontal line to be longer then the "normal" text and I want the line to be before and after the chapter name.

Best Answer

Her's an option using the explicit option for titlesec; the title is placed inside a varwidth environment of maximum width \textwidth; the left rule is drawn with a standard \rule command and the right rule uses \xrfill from the xhfill package. Long titles (spanning more than one line) are centered with respect to the rules:




\chapter{A short title}
\chapter{A long title spanning several lines just to see the format in this case}


An image of a short title:

enter image description here

An image of a long title:

enter image description here

Related Question