38

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,872
  • 5
  • 24
  • 28
  • You should not use `$$` in Latex. It is a plain Tex command. – Debilski Apr 18 '10 at 21:33
  • 1
    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

26

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
  • 87,001
  • 42
  • 169
  • 229
25

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
  • 1,389
  • 1
  • 13
  • 13
Anthony Labarre
  • 2,454
  • 1
  • 25
  • 37
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
  • 11,520
  • 14
  • 37
  • 68
Sara
  • 163
  • 1
  • 6
10

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,226
  • 12
  • 28