42

Please see the snippet below and tell me how can I achieve the same strike-out effect as in the main text. I am using the version of LaTeX from the latest Ubuntu repositories.

\documentclass{article}
\usepackage{ulem}
\begin{document}
The sout tag works perfect in the \sout{main text area} but not inside the equations.
$$
list = [1, \sout{2}, 3, \sout{4}, 5, \sout{6}, 7, \sout{8}, 9, \sout{10}]
$$
Any clue?
\end{document}

Here is LaTeX output

Aamir
  • 2,943
  • 5
  • 26
  • 28
  • 1
    You should not use `$$` in Latex. It is a plain Tex command. – Debilski Apr 18 '10 at 21:33
  • 2
    Furthe to what @Debilski said: there was a little discussion of this in http://stackoverflow.com/questions/2251417/latex-dollar-sign-vs. I don't regard using $$ as a crime, and I don't think $$ support is going away, but you're better off avoiding it. – Charles Stewart Apr 19 '10 at 11:06

4 Answers4

28

It looks like the \sout doesn't work inside a math env. You can try doing something like this, which works:

\documentclass{article}
\usepackage{ulem}
\begin{document}
The sout tag works perfect in the \sout{main text area} but not inside the equations.

$list = $[1, \sout{2}, 3, \sout{4}, 5, \sout{6}, 7, \sout{8}, 9, \sout{10}$]$

Any clue?
\end{document}
Macarse
  • 91,829
  • 44
  • 175
  • 230
28

If anyone's still interested, I just found out about the cancel package, which allows you to strike your text in math mode in a few different ways. It's not horizontal, though -- only diagonal, which in my case is much better.

Adam Stewart
  • 2,001
  • 1
  • 16
  • 16
Anthony Labarre
  • 2,745
  • 1
  • 28
  • 39
12

Pretty much any non-math-mode command can be used inside mathmode by putting it within a \text{} environment, e.g.:

\documentclass{article}
\usepackage{ulem}
\begin{document}
The sout tag works perfect in the \sout{main text area} but not inside the equations.

\[ list = [1, \text{\sout{2}}, 3, \text{\sout{4}}, 5, \text{\sout{6}}, 7, \text{\sout{8}}, 9, \text{\sout{10}}] \]
Any clue?
\end{document}

And if you'd like to be able to use strike-out without having ulem redefine how \emph{} works, use \usepackage[normalem]{ulem}.

Tonechas
  • 13,398
  • 16
  • 46
  • 80
Sara
  • 143
  • 1
  • 6
12

If you need to keep the strikeout in Math mode (e.g., to keep Math fonts) try:

\newcommand{\msout}[1]{\text{\sout{\ensuremath{#1}}}}

then

$\msout{\mathsf{stuckout}}$

you need amsmath and ulem.

(Solution from here.)

badroit
  • 1,316
  • 15
  • 28