How to strike out inside LaTeX equations? [closed]
Asked Answered
L

4

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

Lipocaic answered 18/4, 2010 at 21:0 Comment(2)
You should not use $$ in Latex. It is a plain Tex command.Pigeontoed
Furthe to what @Pigeontoed said: there was a little discussion of this in https://mcmap.net/q/391666/-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.Sashasashay
O
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}
Oklahoma answered 18/4, 2010 at 21:16 Comment(3)
That does it elegantly. Thanks!Lipocaic
But package ulem changes \emph{} to underline.Irbm
from Sara's answer: "... to use strike-out without having ulem redefine how \emph{} works, use \usepackage[normalem]{ulem}". Thanks Sara!Clifton
O
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.

Osiris answered 9/11, 2010 at 15:16 Comment(1)
Thanks for mentioning this. The \cancelto command is exactly what I needed.Helbonnas
S
13

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.)

Staminody answered 23/8, 2011 at 2:30 Comment(0)
N
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}.

Nelan answered 19/4, 2011 at 14:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.