[Tex/LaTex] How to strikethrough a character in an equation

cancelmath-modeulem

I'm trying to create an equation where the letter "I" has a horizontal line through it. The only name I know for this action is "strikethrough" but I'm not sure if this would be correct when dealing with equations specifically; I don't want the line to be too long.

I've tried the ulem, soul, sout and cancel but none of these seem to work inside a \begin{equation}\end{equation} environment.

Best Answer

  1. Box the contents in an \mbox that you then use inside equation as a macro.

    enter image description here

    \documentclass{article}
    \usepackage{soul}% http://ctan.org/pkg/soul
    \newcommand{\stI}{\mbox{\st{$I$}}}
    \begin{document}
    \begin{equation}
      f(x)=\stI\times\stI
    \end{equation}
    \end{document}
    
  2. A slightly more verbatim boxing technique is to set everything inside a box using lrbox and then just use the box via \usebox:

    \documentclass{article}
    \usepackage{soul}% http://ctan.org/pkg/soul
    \newsavebox{\strikeoutI}
    \begin{lrbox}{\strikeoutI}\st{$I$}\end{lrbox}
    \newcommand{\stI}{\usebox{\strikeoutI}}
    \begin{document}
    \begin{equation}
      f(x)=\stI\times\stI
    \end{equation}
    \end{document}
    
  3. Use \ooalign to overlay symbols (an $I$ and a horizontal rule):

    \documentclass{article}
    \newcommand{\stI}{%
      \ooalign{\hidewidth $I$\hidewidth\cr\rule[.5ex]{1ex}{.4pt}}}
    \begin{document}
    \begin{equation}
      f(x)=\stI\times\stI
    \end{equation}
    \end{document}
    

    See \subseteq + \circ as a single symbol (“open subset”) for a short course in \ooalign.