This is a rather specific question I have had for years now but I always just implemented a crummy manual solution.

I want my section headings to look like this. That being the section is in small caps (which has a rule on both sides)

                      -------------A CENTERED SECTION------------

The following causes this, with the after-rule not in the same line.

                      -------------A CENTERED SECTION


And this change produces the proper structure, but it is not centered.

 -------------A NOT CENTERED SECTION------------


Another curriosity is that the other shape options seem to break all the formatting content, even the color.

For reference, from titlesec.pdf

\titleformat{ 〈 command 〉 }[ 〈 shape 〉 ]{ 〈 format 〉 }{ 〈 label 〉 }{ 〈 sep 〉 }{ 〈 before-code 〉 }[ 〈 after-code 〉 ]


With two rules 2 inches long, your title must be really short to make everything fit on a line (or your paper sheet very wide)!

Anyway, here is a possibility with rules 1.5 in long, only \huge size, and the block style:


\titleformat{\section}[block]{\filcenter\color{SteelBlue}\centering\bfseries\scshape\huge}{\rule[0.5ex]{1.5in}{0.5pt}}{0.5em}{#1\enspace \rule[0.5ex]{1.5in}{0.5pt}}



 \section{A Test Section}



enter image description here

  • I am confused, why did you use {} instead of [] for the after-code? – Bob Aug 4 '18 at 17:55
  • I think I see what you did. Instead you used the label section in place of before-code and the before-code section in place of after-code. – Bob Aug 4 '18 at 18:54
  • @Bob: I didn't really use any after-code: I only used the 4th argument of \titleformat, anf the explicit optionsq lets me write the code for a small rule after the title. – Bernard Aug 4 '18 at 19:00

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.