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}
Stefan Müller
  • 6,901
  • 3
  • 29
  • 61
  • 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 07:56

3 Answers3

10

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

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}
Mico
  • 506,678
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

Heiko Oberdiek
  • 271,626