# Flexible rule length in titlesec

I'm trying to get a rule just after the label of a chapter. (i.e., between "chapter 1" and "This is the chapter 1 title").

So far, I've managed to do this:

\titleformat{\chapter}[display]%
{\normalfont\filcenter}%
{\scshape\Huge \chaptertitlename{} \thechapter{} \\[2.75pt] {\titlerule[1pt]} \vspace*{-1\baselineskip}}%
{15pt}%
{\LARGE\bfseries}


MWE:

\documentclass{report}

\usepackage{mathptmx} % For the drop cap
\usepackage[showframe]{geometry} %Just to show the frame
\usepackage{lettrine} %For the drop cap

%% Choose one option: titlesec or sectsty
\usepackage{titlesec}
\titleformat{\chapter}[display]%
{\normalfont\filcenter}%
{\scshape\Huge \chaptertitlename{} \thechapter{} \\[2.75pt] {\titlerule[1pt]} \vspace*{-1\baselineskip}}%
{15pt}%
{\LARGE\bfseries}

%\usepackage{sectsty}
%\chapternumberfont{\centering\sc\Huge\underline}
%\chaptertitlefont{\centering\LARGE}

\begin{document}

\chapter{Introduction}
\label{chap:Intro}

\lettrine[lines=3]{S}{ustained} bipedal locomotion is one of the main characteristics that separates the human being from other primates.  For millennia this has marked a difference not only in the way \textit{Homo Sapiens} moves, but also has played a fundamental part in the evolution and subsequent development of human beings.
\end{document}


but what I want it to look like is this:

I found a question somewhat related: Add small line in \section title, but it has a minor inconvenient: it has a fixed length. I want the rule to be set accordingly to the label width.

I'm also aware that I could achieve Fig.1 results by using the sectsty package (that's how I got the picture in the first place), but I want to be able to edit the chapter title of my bibliography so I can set in the same format as the rest of the chapter labels in the document... and I think that is only possible with titlesec (sectsty does not deal with local definitions, only global... I think)

There is also a possibility to use both packages (sectsty to set the global options and then just use titesec for the last bibliography part, but I'm not so sure about this one).

• Can't you use \underline{\chaptertitlename{} \thechapter{}}? (untested as you didn't show a complete example)- – Ulrike Fischer Nov 1 '13 at 12:53
• @UlrikeFischer I though of that, but the underline seems to be too close to the text. Is there any way to relocate it? – Mario S. E. Nov 1 '13 at 13:17
• Sure, you can use some \strut to move it down. Or check the ulem package. – Ulrike Fischer Nov 1 '13 at 13:33

You can try

\documentclass{report}

\usepackage{mathptmx} % For the drop cap
\usepackage[showframe]{geometry} %Just to show the frame
\usepackage{lettrine} %For the drop cap
\usepackage{booktabs}

%% Choose one option: titlesec or sectsty
\usepackage{titlesec}
\titleformat{\chapter}[display]%
{\normalfont\filcenter}%
{\begin{tabular}{c}\scshape\Huge \chaptertitlename{} \thechapter{} \\[1ex]\bottomrule[2pt]\end{tabular}}%
{15pt}%
{\LARGE\bfseries}

%\usepackage{sectsty}
%\chapternumberfont{\centering\sc\Huge\underline}
%\chaptertitlefont{\centering\LARGE}

\begin{document}

\chapter{Longer Introduction}
\label{chap:Intro}

\lettrine[lines=3]{S}{ustained} bipedal locomotion is one of the main characteristics that separates the human being from other primates.  For millennia this has marked a difference not only in the way \textit{Homo Sapiens} moves, but also has played a fundamental part in the evolution and subsequent development of human beings.
\end{document}


To change the distance of the line, change [1ex] to whatever you want. you can change the width of the line, I made it [2pt], which is probably too much. Notice that I \usepackage{booktabs}.

• Wow, this is an amazing approach! I didn't think of that! – Mario S. E. Nov 1 '13 at 13:30
• I originally thought of \underline{\rule[-1ex]{0pt}{1pt}...}, but it's difficult to change the rule width of \underline and the default one is just too thin... – yo' Nov 1 '13 at 13:33