4

I would like to have a "not asterisk" symbol. I try to do such a feature with the cancel package.

My current favourite is:

A^{\xcancel{\ast}}

But the cancel sign goes down very far. I would like to restrict it to the superscript (but maybe let it go out just a little bit). Any suggestion to achieve that?

Xu Wang
  • 1,239

2 Answers2

6

Here is a method using \ooalign.

\documentclass{article}

\newcommand{\strike}[1]{%
  \mathchoice
  {{\ooalign{$#1$\cr\hidewidth$\times$\hidewidth}}}
  {{\ooalign{$#1$\cr\hidewidth$\times$\hidewidth}}}
  {{\ooalign{$\scriptstyle#1$\cr\hidewidth$\scriptstyle\times$\hidewidth}}}
  {{\ooalign{$\scriptscriptstyle#1$\cr\hidewidth$\scriptscriptstyle\times$\hidewidth}}}%
}


\begin{document}
  $A^{\strike{\ast}}\strike{\ast}$
\end{document}

enter image description here

For a nice tutorial on \ooalign, read egreg's answer to this question.

1

Here, I use a \stackinset, with math style preservation from the scalerel package.

\documentclass{article}
\usepackage{stackengine,scalerel,verbatimbox}
\def\Times{\addvbuffer[-1pt]{$\times$}}
\newcommand\strike[1]{%
  {\ThisStyle{\stackinset{c}{}{c}{}{$\SavedStyle#1$}{$\SavedStyle\times$}}}}
\begin{document}
\[A^\strike{\ast} \quad\strike{\ast} \quad
\scriptstyle\strike{\ast} \quad\scriptscriptstyle\strike{\ast}\]
\end{document}

enter image description here

And at the cost of a little more complexity, it can be made to scale to its argument:

\documentclass{article}
\usepackage{stackengine,scalerel,verbatimbox}
\def\Times{\addvbuffer[-1pt]{$\times$}}
\newcommand\strike[1]{%
  {\ThisStyle{\stackinset{c}{}{c}{}{$\SavedStyle\scalerel*{\Times}{#1}$}{$\SavedStyle#1$}}}}
\begin{document}
\[\strike{A}\quad A^\strike{\ast} \quad\strike{\ast} \quad
\scriptstyle\strike{\ast} \quad\scriptscriptstyle\strike{\ast}\]
\[\strike{\int_0^B x\,dx}\]
\end{document}

enter image description here

...or throw in a little color with

\newcommand\strike[1]{{\ThisStyle{%
  \stackinset{c}{}{c}{}{\color{red}$\SavedStyle\scalerel*{\Times}{#1}$}{$\SavedStyle#1$}}}}

enter image description here