# [pstricks] Strikeout macro

Thu Mar 19 02:18:01 CET 2009

David Arnold a écrit :
> Doesn't seem to work the way I need it to work:
>
> [...]
> \newlength{\numwid}
> \newlength{\numht}
>
> \newcommand{\strikeout}[1]{%
>       \settowidth{\numwid}{#1}
>       \settoheight{\numht}{#1}

It's better to say that we work inside math :
\settowidth{\numwid}{$#1$}
\settoheight{\numht}{$#1$}

>       \psline[linecolor=darkred](0,0)(\the\numwid,\the\numht)#1}
> [...]
> \frac{\strikeout{(x+1)}(x+2)}{\strikeout{(x+1)}}

It's a joke :-) When #1 is (x+1), actually you say :
\psline[...](0,0)(\the\numwid,\the\numht)(x+1)
(\usepackage{pstricks-add}), then there is an automatic \SpecialCoor,
then PostScript looks for a node 'x+1'... without error even when this
node doesn't exist! Funny isn't it?
\psline[...](0,0)(\the...)\relax #1
is a possibility. BTW it seems (to me) that the direct use of box is
simplier:

\newcommand*{\strikeout}[1]{%
\setbox0=\hbox{$#1$}%
\psline[linecolor=darkred](0,-\dp0)(\wd0,\ht0)\relax#1%
}

does the job... and you could use \mathpalette to improve the quality of
this macro.

Jean-Côme Charpentier