Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to cross out a letter. I found Draw a diagonal arrow across an expression in a formula to show that it vanishes but this works in mathmode only and mathmode changes the font. Is there a way to do the same without going to math mode? I need this for a slide where I want to have a really big font and wnat to `remove' the first letter of a word.

\documentclass{article}

\usepackage{cancel}

\begin{document}

$\xcancel{T}$

\end{document}
share|improve this question
    
Donald Arseneau said in the documentation that "Drawing slashes through math to indicate “cancellation” is poor design." So what is the rich design? :-) –  Who is crazy first Jul 18 at 7:56

3 Answers 3

Why should one worry when there is tikz? ;)

\documentclass{article}
\usepackage{tikz}
\newcommand{\tcancel}[2][thick]{%
\begin{tikzpicture}
\node[inner sep=1pt] (a){#2};
\draw[#1] (a.south west) -- (a.north east);
\draw[#1] (a.north west) -- (a.south east);
\end{tikzpicture}%
}
\begin{document}
\tcancel{T} 

\tcancel[red,line width=1pt]{T}
\end{document}

enter image description here

Thanks to Claudio Fiandrino`s idea that this can be improved further

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\newcommand{\tcancel}[2][black]{%
\begin{tikzpicture}
\node[draw=#1,cross out,inner sep=1pt] (a){#2};
\end{tikzpicture}%
}
\begin{document}
\tcancel{T}

\tcancel[red,thick]{T}
\end{document}

The baseline may be corrected by [baseline={(a.base)}]as in

\newcommand{\tcancel}[2][black]{%
\begin{tikzpicture}[baseline={(a.base)}]
\node[draw=#1,cross out,inner sep=0pt,outer sep=0pt] (a){#2};
\end{tikzpicture}%
}

Adjust inner and outer seps as you wish.

enter image description here

share|improve this answer
    
You can even improve it just using one node and the shape cross out (it requires shapes.misc library). –  Claudio Fiandrino Jul 18 at 6:57
    
@ClaudioFiandrino Thanks for the idea. I have updated the answer. –  Harish Kumar Jul 18 at 7:52
1  
@Mico To use it with other text, some polishing is needed. I have updated the answer. –  Harish Kumar Jul 18 at 9:53

You could achieve your objective by creating a macro named, say, \tcancel (short for text-mode cancel...) as a text-mode wrapper around \xcancel.

enter image description here

\documentclass{article}
\usepackage{cancel}
\usepackage{amsmath} % for \ensuremath and \text macros
\newcommand{\tcancel}[1]{\ensuremath{\xcancel{\text{#1}}}}
\begin{document}
$\xcancel{T}$ (letter is in math mode)

\tcancel{T} (letter is in text mode)
\end{document}
share|improve this answer

\mbox{} can be used to switch back to text mode from math:

\documentclass{article}

\usepackage{cancel}

\begin{document}

$\xcancel{\mbox{T}}$

\end{document}

Result

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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