[Tex/LaTex] Positioning of \hrule and \vrule

positioningrulestex-core

I try to construct a symbol from 4 rules, one horizontal and three vertical ones.
\showoutput gives me the correct dimensions for all of them (see below). However, the horizontal one somehow erratically moves slightly to the left or right in the PostScript and PDF. Given four dimensions \@omwd (desired width), \@omht (desired height), \@omhtn (desired height of part above horizontal line), \@omhtp (desired height of part below horizontal line), where \@omht = \@omhtp + \@omhtn; I am using this code:

\documentclass{article}

\title{Testing}
\author{Michael Nüsken}

\begin{document}

\showoutput\fboxsep=0pt

\makeatletter
\newdimen\@omwd 
\newdimen\@omht
\newdimen\@omhtn
\newdimen\@omhtp
\newdimen\@roundlinewidth
\@omwd=3.72299pt
\@omht=7.05666pt
\@omhtn=5.57127pt
\@omhtp=1.48538pt
\@roundlinewidth=0.438pt
%
\def\Y{%
  \vbox to\@omht{\hsize=\@omwd%
    \hbox to\@omwd{%
      \hfil
      \vrule\@width\@roundlinewidth\@height\@omhtn\@depth\z@
      \hfil
    }%
    \kern-.5\@roundlinewidth% overlap vertical and horizontal lines
    \hrule\@width\@omwd\@height\@roundlinewidth\@depth0\@roundlinewidth
    \kern-.5\@roundlinewidth% overlap vertical and horizontal lines
    \hbox to\@omwd{%
      \vrule\@width\@roundlinewidth\@height\@omhtp\@depth\z@
      \hfil
      \vrule\@width\@roundlinewidth\@height\@omhtp\@depth\z@
    }%
  }%
}
\makeatother

Y\Y

\begin{itemize}
\item Y\Y
\end{itemize}

\end{document}

Also I observe that even \fbox does not have rules matching properly in its corners.

For example I obtain:

....\vbox(7.05666+0.0)x3.72299
.....\hbox(5.57127+0.0)x3.72299, glue set 1.6425fil
......\glue 0.0 plus 1.0fil
......\rule(5.57127+0.0)x0.438
......\glue 0.0 plus 1.0fil
.....\kern -0.219
.....\rule(0.438+0.0)x3.72299
.....\kern -0.219
.....\hbox(1.48538+0.0)x3.72299, glue set 2.84698fil
......\rule(1.48538+0.0)x0.438
......\glue 0.0 plus 1.0fil
......\rule(1.48538+0.0)x0.438

But \rule(0.438+0.0)x3.72299 appears to be shifted left or right slightly.
However, this does not happen in all positions on a page!???

Is that a bug in TeX? How to fix or bypass that?
Please don't tell me it's a rounding problem…

Best Answer

I'm not getting “erratic” behavior. However, there's a better way for drawing the symbol so that it has the same height as a Y; I set the width to .5em in the current font and the proportion between the two parts as 1:3

\documentclass{article}
\usepackage{amsmath}
\usepackage{pict2e,picture}

\newcommand\drawY{%
  \begingroup
  \dimen0=.5em
  \dimen2=\fontcharht\font`Y
  \dimen4=.25\dimen2
  \begin{picture}(\dimen0,\dimen2)
  \roundcap
  \put(0,0){\line(0,1){\dimen4}}
  \put(\dimen0,0){\line(0,1){\dimen4}}
  \put(0,\dimen4){\line(1,0){\dimen0}}
  \put(.5\dimen0,\dimen4){\line(0,1){\dimexpr\dimen2-\dimen4}}
  \end{picture}%
  \endgroup
}
\newcommand{\Y}{\text{\drawY}}

\begin{document}

{\fboxsep=0pt \fbox{\Y}}

$Y\Y_{Y\Y}$

\end{document}

enter image description here