fbox drawn incorrectly after \noindent

What's going on here that the first and last \fbox are not getting drawn correctly when immediately following \noindent?

\documentclass{article}
\usepackage{pst-node}
\pagestyle{empty}
\begin{document}

\noindent\fbox{A\rule{0.4pt}{3ex}}

\fbox{A\rule{0.4pt}{3ex}}

\noindent\fbox{A}

\fbox{A}

\noindent%
\begin{pspicture}(0,0)
\psset{linecolor=red,linewidth=0.4pt}
\rput(1.45em,6.5\baselineskip){\cnode{0.05}{A}}
\rput(2.9em,1.84\baselineskip){\cnode{0.05}{B}}

\end{pspicture}
\end{document}


It's barely noticeable: but now that I see it, it annoys me.

-
that is a problem with your viewer and the current magnification. –  Herbert Dec 6 '12 at 20:43
I don't think it's the viewer. The same misalignment shows up when I print the document. It also shows up when I e-mail the pdf to a different computer with a different operating system. –  A.Ellett Dec 6 '12 at 20:47
then give more informations! An image is not enough because I cannot see anything different when running the example. –  Herbert Dec 6 '12 at 20:49
I can't see it. Can you add info about OS, TeX distribution, compilation procedure and previewer/printer driver? –  egreg Dec 6 '12 at 20:50
I'm using Max OSX, pdfTeX Version 3.1415926-2.3-1.40.12 (TeX Live 2011), using Mac's preview. I first use latex, then dvips with the switch Pwww and then finally ps2pdf. –  A.Ellett Dec 6 '12 at 21:03

1 Answer

It is an rounding error of dvips:

543 575 a % moveto
Fa(A)p % draw A'
605 575 4 108 v % x y width height rule
515 443 123 4 v % x y width height rule % horizontal rule
515 602 4 161 v % x y width height rule % left vertical rule
633 602 V % x y (previous width) (previous height) rule % right vertical rule
515 604 123 4 v % x y width height rule % horizontal rule


The horizontal rules start at 515 with width 123 to 638. The rule thickness is 4, thus the right vertical rule should start at 634. but it is starting at 633.

You can use a higher resolution to get a more accurate result, e.g.

dvips -D8000


or better

dvips -Ppdf


that uses -D8000 and also includes the header alt-rule.pro:

%%BeginProcSet: alt-rule.pro 0 0
%!
% Patch by TVZ
% Makes dvips files draw rules with stroke rather than fill.
% Makes narrow rules more predictable at low resolutions
% after distilling to PDF.
% May have unknown consequences for very thick rules.
% Tested only with dvips 5.85(k).
[...]


Result with dvips -Ppdf:

-
Thank you. Now it works. –  A.Ellett Dec 7 '12 at 1:58
The dvi resolution should not exceed 2636 dpi (dvips -D2636`), if the PS contains material to be distilled into XObjects which are later used as appearances in PDF annotations. See: tex.stackexchange.com/a/127836. 2400 dpi is far enough to solve the rounding errors discussed here. –  AlexG Aug 20 '13 at 9:20