[texhax] \overline and \phantom

Lars Madsen daleif at imf.au.dk
Thu Aug 2 10:14:16 CEST 2012


Paul Stanley wrote, On 2012-08-01 15:57:
> [...]
>  > something like that, basically \phantom{...} takes up the same space as
>  > ... would
>  >
>  > there are two variants as well, \vphantom who give the same height and
>  > depth, but no width, and \hphantom, that provide width but no depth or
>  > height.
>  >
>  > Note that none of the phantoms print their argument
>  >
>  >
>  > At the other end there is \smash, which is like \hphantom, but it also
>  > prints its argument
> 
> Could you provide examples of where `\vphantom' and `\hphantom' could be 
> used?
> I can only picture two dimensions on the page, height and width, where 
> does the depth fit into this?
> Finally, where would smash be used?
> 
> Many thanks,
> Paul
> 

In a math construction we were using \overline to mark the closure of a 
set. As in \overline{X}, but would sometimes write \overline{X}^2, and 
because of the added height of the overline, the ^2 would disturb the 
spacing bewteen lines. Out solution, the following macro

\newcommand\closure[1]{\smash{\overline{#1}}\vphantom{#1}}

that is we typeset the overlines argument using smash to remove the 
height and depth of it, and then reintroduce the original height of the 
arg using \vphantom

\hphantom could be used within a large math expression where one would 
like to indent a broken formula to within a starting fence on the line 
before, something like

=\hphantom{ \sum_{i=1}^\infty \Bigl[ } ....

that is the sort of thing I use it for.

\smash is especially use when finishing manuscripts and I happen to find 
lines that are separated a bit too much.







-- 

/daleif


More information about the texhax mailing list