I am wondering if there is any way to change the default style for sections. I would like to create a banner (across the page) with a dark-gray background and the section title in white. It would be great if I can also put two black bold lines on the top and bottom edge of the banner. I saw someone use TikZ to style the section but I am not familiar with that; is there any other package that can do that for me?

  • Are you referring to sections, as in \section (in an article) or did you mean chapters, as in \chapter (for a book). – Gonzalo Medina May 2 '13 at 17:14
  • Hi cmhughes, thanks for the link. I follow that code, it works. But if the title of the section is too long, the shaded box won't adjust automatically to fit the new height – user1285419 May 2 '13 at 18:19

Of course this could be done using TikZ, but there's not really need to use it here. Here's one possibility using the titlesec package:

\usepackage{lipsum}% just to generate text for the example



\section{Test Numbered Section}
\section*{Test Unnumbered Section}


enter image description here

  • Hi Gonzalo, it looks good. But how can I make the lines a bit thicker and remove the gaps between the lines and the box? Thanks again – user1285419 May 2 '13 at 18:46
  • @user1285419 please see my updated answer (the rule thickness can be controlled using the optional argument for \titlerule (I chose 3pt); the separation between the rules and the colored box depends on the length used in the \vskips). – Gonzalo Medina May 2 '13 at 19:38

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.