8

I was experimenting with the answer I got to an earlier questions of mine: A better notation to denote arcs for an American high school textbook

I wrote a new command as

\documentclass{article}
\usepackage{graphicx}

\newcommand\arc[1]{%%
  \setbox9=\hbox{#1}%%
  \ooalign{%%
    \raisebox{\ht9}{%%
      \resizebox{\wd9}{\dimexpr1.75\height}{%%
        \rotatebox{90}{)}}}\cr#1}}

\begin{document}

\arc{ABC}

\arc{A}

\arc{AB}

\end{document}

which works fine. But, the problem comes up when I try defining things as follows:

\newcommand\arc[1]{%%
  \setbox9=\hbox{#1}%%
  \ooalign{%%
    \raisebox{\ht9}{%%
      \resizebox{\wd9}{\dimexpr1.75\height}{%%
        \rotatebox{-90}{(}}}\cr#1}}

I've tried various ways of avoiding this (such as wrapping up the rotated material in its own box) all to no avail.

Why is this second approach not working?

A.Ellett
  • 50,533

1 Answers1

9

If I do

\sbox0{\rotatebox{-90}{(}}\the\ht0

I see 0.0pt and this should explain the problem. Why? Let's look what happens when I type

(\rotatebox{-90}{(}\vrule height0.1pt depth 0.1pt width 4pt

(the \vrule just shows where the baseline is):

enter image description here

Here's a picture of the bounding box of the parenthesis:

enter image description here

(again, the rule shows the baseline).

If I do

\newcommand\arc[1]{{%%
  \sbox\arcbox{#1}%%
  \ooalign{%%
    \raisebox{\ht\arcbox}{%%
      \resizebox{\wd\arcbox}{\dimexpr1.75\height}{%%
        \rotatebox[origin=c]{-90}{(}}}\cr#1}}}

(notice the additional pair of braces, please) I get, from \arc{ABC},

enter image description here

Note also that I declared \newsavebox\arcbox; better avoiding random usage of scratch registers.

Always ensure that \ooalign is inside a group.


Explanation: when you do a rotation without specifying a center, the bottom left corner is used. So a box rotated -90 will always result in having height zero.

egreg
  • 1,121,712
  • 1
    @A.Ellett I've just added the reason – egreg Mar 23 '15 at 18:32
  • 1
    Aah, you know, I just realized something else: I keep forgetting that height isn't really what I naturally think of as the height. Height is just that which is above the baseline.... – A.Ellett Mar 24 '15 at 00:03