TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The proposed effect

How can I achieve this effect? I have tried the following code:

\parbox[c]{3.5cm}{\color{NavyBlue}{\rule{90px}{7px}}} \parbox[c]{6cm}{\section*{Section Title}}

But the rule is not center aligned with the title because \section command contain some extra space below the text.

And I had tried a alternative:

\parbox[c]{3.5cm}{\color{NavyBlue}{\rule{90px}{7px}}} \parbox[c]{6cm}{\Large{Section Title}}

Although this time the rule is center aligned, but if I add text below the title, the line space would be too small.

Can anyone help me with this?

share|improve this question
Should the rule hang in the margin? – Gonzalo Medina Nov 25 '12 at 15:29
up vote 5 down vote accepted

Seems that there was a related question yesterday How can I make a bold horizontal rule under each section title? Following that example, I seem to be able to create the effect that you desire:




\section{Test Section}

Random stuff


enter image description here

I'd never heard of the titlesec package before. Looks like it has some very nice tools for modifying the look and feel of sections.

share|improve this answer
Don't use px for the units. It hasn't a fixed value and changes in the preamble might modify it. And I don't think that the \parbox is really needed (use the optional arguments to `\rule). – egreg Nov 25 '12 at 15:22
@egreg. Thanks. I was just following lhhNJU's example as closely as possible. I used the parbox to force vertical centering with the section title. I know you can write \rule[1ex]{10em}{0.5ex} but is there a way to tell rule to center with text on the same line? – A.Ellett Nov 25 '12 at 15:31
Just play with the "raise" argument; possibly something like 0.4ex – egreg Nov 25 '12 at 15:33
I just noticed I used a non-fixed value length again. @egreg. Are you suggesting that I doing sometihng like \rule[3pt]{2in}{3pt}? – A.Ellett Nov 25 '12 at 15:35
ex is good, as it depends on the current font, which is really what you want. – egreg Nov 25 '12 at 15:36

Here's a variation in which the rule hangs in the margin:

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



\section{Section Title}


enter image description here

share|improve this answer
Thank you for your help. But what I intend is to put the rule in the text region. – lhhNJU Nov 26 '12 at 1:59
@lhhNJU OK, but you should consider what would happen if a section title spans more than one line. – Gonzalo Medina Nov 26 '12 at 2:01
I see. Thank you for your reminder. – lhhNJU Nov 26 '12 at 2:22

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.