# strikethrough math formula in the math mode

Is there a way to do strikethrough math formula in the math mode?

\usepackage[normalem]{ulem}
\sout{ ...}


and

\usepackage{soul}
\st{...}


are useful but they can not be used in the math mode. So one needs to turn it to the \text mode then do it. Is there any better way out?

I also know this:

\usepackage[makeroom]{cancel}
\cancel{}
\cancelto{}


but they do not look like the strikethrough lines.

This will get you started. Note, this does not strike out each component individually; you have to do that yourself.

The \bgroup ... \egroup serves two purposes. First is preserves the contents of \box0. It also means you can use \mathsout as an exponent etc. without having to enclose it in braces.

\documentclass{article}
\usepackage{mathtools}

\newcommand{\mathsout}[1]% will draw line through middle of #1
{\bgroup\mathchoice
{\sbox0{$\displaystyle{#1}$}%
\usebox0\hspace{-\wd0}%
\rule[0.5\ht0-0.5\dp0-.5pt]{\wd0}{1pt}}%
{\sbox0{$\textstyle{#1}$}%
\usebox0\hspace{-\wd0}%
\rule[0.5\ht0-0.5\dp0-.5pt]{\wd0}{1pt}}%
{\sbox0{$\scriptstyle{#1}$}%
\usebox0\hspace{-\wd0}%
\rule[0.5\ht0-0.5\dp0-.5pt]{\wd0}{1pt}}%
{\sbox0{$\scriptscriptstyle{#1}$}%
\usebox0\hspace{-\wd0}%
\rule[0.5\ht0-0.5\dp0-.5pt]{\wd0}{1pt}}%
\egroup}

\begin{document}

$$x= \cos(\omega t) + \mathsout{sin(\omega t)} + \mathsout{e}^\mathsout{-t}$$

\end{document}