# Background color of breakable box: removing thin blank lines

The purpose of the mybox environment in the following document is to typeset a box in a yellow background. The box may be split by page breaks. The algorithm used is similar to the one found in the boites package:

• first the text is formatted in a vbox
• then each line of the vbox is extracted from the vbox and output in a colorbox.

The document:

\documentclass[a5paper]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{color}
\usepackage{lipsum}

\newbox\boxtail
\newbox\boxtemp

\newdimen\dimtemp

\def\boxsplit{%
% total height of original box
\dimtemp\ht\boxtail
% split original box in order to retrieve its first line
% fix the height of the first line
% restore original size
}

\newenvironment{mybox}{%
\ifhmode\par\fi
\setbox\boxtail\vbox\bgroup
}{%
\egroup
{%
\noindent
\fboxsep 0pt
\splittopskip 0pt
\baselineskip 0pt
\lineskiplimit 0pt
\lineskip 0pt
\vfuzz\maxdimen
\leavevmode
\loop
\ifvoid\boxtail
\else
\boxsplit
\hfil
\repeat
}%
}

\begin{document}

\begin{mybox}
\lipsum[134]
\end{mybox}

\end{document}


When looking with care, very thin white rules can be seen between the yellow lines in the text formatted by the environement.

Has anybody any clues on how to eliminate them?

I know there are packages like mdframed that already provides this functionality using a different algorithm. But they do not work with the beamer class or in multicolumn environemnts, and they cannot be nested.

-
Which pdf viewer do you use? I do not see any white lines. –  Yiannis Lazarides Apr 23 '12 at 2:07
@YiannisLazarides: evince, okular and zathura on Linux. With acroread I do not see the thin white lines. –  Romildo Apr 23 '12 at 2:10
It is a problem with the viewer and not the code. –  Yiannis Lazarides Apr 23 '12 at 5:05

This is most likely a feature of the viewer, however you can workaround it by inserting a small negative skip (the smallest fraction of a point that works on your screen) so that the coloured boxes overlap. Depending on your requirements that may be enough or you may want to compensate by increasing the height of the box so

    \colorbox{yellow}{\box\boxhead}%

     \vskip-0.1pt