[texhax] space between colorboxes in adjacent lines

Ulrike Fischer news3 at nililand.de
Tue Apr 27 17:27:20 CEST 2010


Am Tue, 27 Apr 2010 11:14:34 -0300 schrieb José Romildo Malaquias:

> 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.

There is no need to attach files. We all can compile documents too
;-) (and it didn't work anyway, I don't see an attachment).

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


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

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

  \begin{document}

  \noindent\lineskip=0pt
  \cbox{yellow}{First~line}\newline
  \cbox{yellow}{Second line}\newline
  \cbox{yellow}{\strut}\newline
  \cbox{yellow}{Fourth line}

  \end{document}
-- 
Ulrike Fischer 



More information about the texhax mailing list