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?

4
  • 3
    Seems like a problem of the pdf viewer. Evince is doing fine, in Acrobat Reader (Linux version), the different edges are displayed at different zoom levels.
    – Caramdir
    Feb 22, 2011 at 20:49
  • @Caramdir Hi, the problem occurs at 100% zoom or less. With more than 100% they show all the lines.
    – Weslei
    Feb 22, 2011 at 21:11
  • 1
    @Caramdir: technically evince is doing wrong and acrobat is correct. The rasterization rules for PDF are counterintuitive.
    – Lev Bishop
    Feb 22, 2011 at 21:55

1 Answer 1

23

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

1
  • That is it!!! Thank you very much, it worked perfectly!
    – Weslei
    Feb 23, 2011 at 12:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .