Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to duplicate an old document that has a small centered line above each \section. I have not been able to duplicate this when I set the formatting for the \section. (I'm using the titlesec package, among others.) This is an example of what I've tried:

\titleformat{\section}{\normalfont\Large\filcenter}{\rule{.5in}{.02in} \\ \thesection}{0em}{}

Is there a way to do this without putting the {\rule{.5in}{.02in} before each \section?

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

How about something like this?

share|improve this answer
That's pretty close, but the hrule is left justified, rather than centered. (I'll edit the question to make it clearer, my bad.) It's ignoring the \filcenter, and even trying \titleformat{\section}{\normalfont\Large\filcenter{\begin{center}\hrule width.5in\end{center}}}{\thesection}{0em}{} didn't shift it right. –  A. R. Diederich Jan 4 '11 at 21:16
@A. R.: Okay, I changed it. –  TH. Jan 4 '11 at 22:31
Genius! That did the trick. I modified it slightly as \titleformat{\section}{\normalfont\Large\centerline{\hss\rule{.5in}{.02in}\hss}‌​\filcenter}{\thesection}{1em}{} to center the rest of the text, and put \section in the command brackets. I've been pounding away through the titlesec docs trying to figure it out with the package, but that documentation is quite arcane. –  A. R. Diederich Jan 5 '11 at 0:15
How do you make the line to go as far as needed according to the text automatically? Is it possible? –  Mario S. E. Nov 1 '13 at 11:47
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.