[texhax] space between colorboxes in adjacent lines

José Romildo Malaquias j.romildo at gmail.com
Tue Apr 27 16:14:34 CEST 2010


I want to set the background color of a set of consecutive lines. I am
using the \colorbox command from the color LaTeX package. 

  \documentclass[a5paper]{article}
  \usepackage{color}

  \newcommand{\cbox}[2]{%
    \colorbox{#1}{\makebox[\linewidth][l]{#2}}}

  \begin{document}

  \noindent
  \cbox{yellow}{First~line}\newline
  \cbox{yellow}{Second line}\newline
  \cbox{yellow}{}\newline
  \cbox{yellow}{Fourth line}

  \end{document}

The result of running pdflatex with this document is attached.

The problem I want to solve is the small blank space between each
line. How can it be eliminated?

Typesetting the lines in a minipage (or similar) environment is not an
option, as the sequence of lines should not be restricted to a single
page.

Regards.

Romildo


More information about the texhax mailing list