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 am trying to put a line over a paragraph in LaTeX. I tried this code:

\noindent\makebox[\linewidth]{\rule{\textwidth}{2pt}}
\noindent\colorbox{gray}{\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\textbf{Text}}}

But there is a small space between the line and the paragraph as shown in this image:

enter image description here

Do you know how I can remove this space between the paragraph and the text?

share|improve this question

migrated from stackoverflow.com Aug 22 '12 at 13:51

This question came from our site for professional and enthusiast programmers.

add comment

1 Answer 1

up vote 5 down vote accepted

Try

\noindent\makebox[\linewidth]{\rule{\textwidth}{2pt}}\par
\nointerlineskip
\noindent\colorbox{gray}{\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\textbf{Text}}}
share|improve this answer
    
Thanks. It works great. –  glcp Aug 22 '12 at 14:05
add comment

Your Answer

 
discard

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.