8

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}
  • 1
    Donald Arseneau said in the documentation that "Drawing slashes through math to indicate “cancellation” is poor design." So what is the rich design? :-) – kiss my armpit Jul 18 '14 at 7:56
9

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

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

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

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

\documentclass{article}

\usepackage{cancel}

\begin{document}

$\xcancel{\mbox{T}}$

\end{document}

Result

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.