13

I have the following code that generate a box with text content:

\documentclass{report}

\usepackage{color}
\usepackage{lipsum}
\newcommand\tipbox[1]{%
  \begin{center}%
    \fcolorbox{black}{white}{%
      \begin{minipage}[t]{\dimexpr\textwidth-2\fboxsep-2\fboxrule}%
        #1%
      \end{minipage}}%
  \end{center}}

\begin{document}
\lipsum[1]
\tipbox{\lipsum[1]}
\lipsum[1]
\tipbox{\lipsum[1]}
\end{document}

However, in the generated PDF, it does not show the lines properly at 100% zoom. See the screenshots taken from Foxit Reader (note missing left border):

Foxit Reader

and from TeXworks reader (note missing top border):

TeXworks pdf reader

If I increase the zoom to a larger number I can see all the lines. I haven't tried to print to see the results. Is this a PDF reader issue or a problem with my box? How to fix this?

Werner
  • 603,163
Weslei
  • 4,015
  • 8
  • 32
  • 37

1 Answers1

24

Change \usepackage{color} to \usepackage{xcolor} or for even better results (the lines meet properly in the corners of the box at all zoom levels) \usepackage[xcdraw]{xcolor}.

Background: this is a problem only with certain PDF viewers. Ironically, the PDF viewers that display the problem are the ones which are implementing the PDF spec correctly (see "Scan Conversion Rules" section 10.6.4). The other PDF viewers use an antialiasing type of algorithm that is strictly against the spec but is more forgiving of certain faulty assumptions that you might make when generating the PDF (for example the assumption that a line that is strictly to the left of a white rectangle will never be obscured by that rectangle).

Lev Bishop
  • 45,462