16

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?

1
  • 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? Oct 23, 2010 at 19:26

5 Answers 5

15

Load the cancel package and use \cancel{word}. Most of the commands from the package work in both math and text modes.

1
  • 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.
    – Matt Reece
    Oct 23, 2010 at 22:20
12

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}
9

You might like to try the ulem package and use the command \sout{word} to strikeout a word.

2
  • 2
    I 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
  • 6
    Use \usepackage[normalem]{ulem} to avoid the problem mentioned by Geoffrey. Apr 25, 2011 at 11:29
9

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}    

enter image description here

0
2

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} 

enter image description here

2
  • Yes you need \tikz[baseline] and to add an optional argument Jun 14, 2012 at 19:23
  • @Altermundus I had it but I removed it. Don't remember why I did.
    – azetina
    Jun 14, 2012 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.