I would like to write a word with a slash through it, using LaTeX (in text, not in math mode). That is, I want a line from the lower-left corner of the word through the upper-right. Is there a nice way to do this?
-
What exactly do you mean by "lower-left" corner? Should the line start at the baseline, in the lower left corner of the bounding box of the word, or somewhere else?– Jan HlavacekOct 23, 2010 at 19:26
5 Answers
Load the cancel
package and use \cancel{word}
. Most of the commands from the package work in both math and text modes.
-
Thanks! It's not quite perfect; it would be nice if the line were thicker if the word is in a larger font, which doesn't seem to be the case. But it might suffice. Oct 23, 2010 at 22:20
Following frabjous' advice, I seem to have discovered a bug in the cancel
package: Cancelling at the start of a paragraph only works if you add \leavevmode
.
\documentclass{article}
\usepackage{cancel}
\begin{document}
Some text.
% \cancel{Some text.}% Doesn't work
\leavevmode\cancel{Some text.}% Works
\end{document}
You might like to try the ulem
package and use the command \sout{word}
to strikeout a word.
-
2I agree that
ulem
can be very useful but do watch out - it hijacks\emph
, typesetting emphasised text in underline. The fix is very simple, after loading, issue\normalem
to restore\emph
back to its original meaning. Oct 25, 2010 at 6:15 -
6Use
\usepackage[normalem]{ulem}
to avoid the problem mentioned by Geoffrey. Apr 25, 2011 at 11:29
Another possibility with tikz.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\newcommand*\cancel[2][thin]{\tikz[baseline] \node [strike out,draw,anchor=text,inner sep=0pt,text=black,#1]{#2};}
\begin{document}
First \cancel{word} canceled, second \cancel[thick,draw=red]{attempt}
\end{document}
You can use the strike out
from the shapes.misc
library in TikZ. See the sample code below:
\documentclass[letterpaper]{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\newcommand{\strikeout}[1]{%
\tikz[baseline, inner sep=0.5pt] \node [strike out,draw=OrangeRed,anchor=text]{#1};}
\begin{document}
Sample text \strikeout{strike} out.
\end{document}