%\filename{showboxdims.tex}
%\edited{last by stolfi on Tue Apr  7 15:35:50 1987}

\catcode`@=11 \endlinechar=-1

% A macro that makes a natural \hbox out of its argument, with
%   tick marks hanging around it to show the baseline, height,
%   width, and depth of the box.

  \font\ttfont = cmtt8 \relax

  \newbox\ltick \setbox\ltick\hbox to 0pt{\kern-5pt
    \vrule width 3pt height0.1pt depth 0.1pt\kern 2pt}
  \ht\ltick=0pt \dp\ltick=0pt

  \newbox\laxis \setbox\laxis\hbox to 0pt{\kern-12pt
    \vrule width 6pt height0.1pt depth 0.1pt\kern 6pt}
  \ht\laxis=0pt \dp\laxis=0pt

  \newbox\rtick \setbox\rtick\hbox to 0pt{\kern 2pt
    \vrule width 3pt height0.1pt depth 0.1pt\kern-5pt}
  \ht\rtick=0pt \dp\rtick=0pt

  \newbox\raxis \setbox\raxis\hbox to 0pt{\kern 6pt
    \vrule width 6pt height0.1pt depth 0.1pt\kern-12pt}
  \ht\raxis=0pt \dp\raxis=0pt

  \newbox\utick \setbox\utick\hbox to 0pt{\kern-0.1pt
    \vrule height 5pt width0.2pt depth -2pt}
  \ht\utick=0pt \dp\utick=0pt \wd\utick=0pt

  \newbox\dtick \setbox\dtick\hbox to 0pt{\kern-0.1pt
    \vrule height -2pt width0.2pt depth 5pt}
  \ht\dtick=0pt \dp\dtick=0pt \wd\dtick=0pt

  % Make character box with ticks and leave it in box 0

  \def\tickedbox#1{
      \setbox2\hbox{#1}
      \setbox4\vbox to 0pt{
        \kern-\ht2
        \copy\ltick
        \kern \ht2
        \copy\laxis
        \kern \dp2
        \copy\ltick
        \copy\dtick
        \kern-\dp2}
     \setbox6\vbox to 0pt{
       \copy\raxis
       \kern\dp2
       \copy\dtick
       \kern-\dp2}
     \setbox0\hbox{\box4\box2\box6}
   }

  \def\showboxdims#1{{
    \tickedbox{#1}
    $\vcenter{
      \hrule
      \hbox{\vrule
        \kern 15pt 
        \valign{\vfil##\vfil\cr
          \vbox{\kern 15pt \copy0 \kern15pt}\cr
          \noalign{\kern 15pt}
          \vbox{\ttfont\lineskip 2pt\baselineskip 10pt
            \hrule height0pt\kern 5pt
            \hbox{ht: \the\ht0}
            \hbox{dp: \the\dp0}
            \hbox{wd: \the\wd0}
            \kern 5pt \hrule height 0pt}\cr}
        \kern 5pt
        \vrule}\hrule}$
    }}

\catcode`@=12 \endlinechar=`\^^M

% END
