# Background color of breakable box with thin blank lines

The purpose of the mybox environment in the following document is to typeset a box in a blue 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{article}
\usepackage[paperwidth=10cm,paperheight=35mm,margin=3mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{color}
\usepackage{lipsum}
\pagestyle{empty}

\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[68]
\end{mybox}

\end{document}


When looking with care (the following image shows the document opened in the evince pdf viewer), very thin white rules can be seen between the blue lines in the text formatted by the environment.

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 environments, and they cannot be nested.

EDIT:

As pointed by others, this seems to be an issue with the pdf viewer. I tried several viewers (on Linux) and found that some of them shows the thin white rules and others do not.

Good pdf viewers:

• qpdfview 0.4.9
• okular 0.18.3
• foxit reader 6.1.4.0217 (with wine)

• evince 3.10.3
• epdfviewer 0.1.8
• sumatra pdf 2.4 (with wine)
• pdf-xchange (with wine)
-
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