5

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?

6

How about something like this?

\titleformat\section{\normalfont\Large\centerline{\hss\rule{.5in}{.02in}\hss}}{\thesection}{1em}{}
  • 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

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.