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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to use \cancel from the cancel package to strike out some colored text but it is apparent that the diagonal line is drawn first so it doesn't do a very good job of canceling. enter image description here

Minimal example.


I can obviously use the \llap, but that is suboptimal. Is there a better way?

share|improve this question
Probably the best answer is going to be 'take the code and alter it to reverse the order'! – Joseph Wright Apr 15 '11 at 19:54
or use TikZ instead! – Martin Scharrer Apr 15 '11 at 21:01
@Joseph: You're probably right about that. Maybe I'll take a look when I get some spare time. – TH. Apr 15 '11 at 22:51
I think your solution with \llap is the easiest way so far. I had a look at the docs, a hack is not easy. Suggestion cancel the word "suboptimal" in you question:) Certainly TikZ is not the answer for this. – Yiannis Lazarides Apr 16 '11 at 17:13
@Yiannis: That's herasy! TikZ is the answer to everything. Indeed, when computed according to the Magrathean system, the numerical value of TikZ is 42. – Loop Space Apr 16 '11 at 17:57

Using Tikz :

        \node[inner sep=0pt,outer sep=0pt] (tocancel) {#1};
        \draw[red] (tocancel.south west) -- (tocancel.north east);

This is a \cancel{test}

Another possibility with Tikz is to use the strike out shape:


Strike \tikz[baseline] \node [strike out,draw=red,anchor=text] {me}; out!

Using pstricks, in the pstricks-add package :

%in preamble

%in document
%example taken from pstricks-add documentation
\psCancel[linecolor=red]{Tikz :-)}

Edit 1 : I just realized that the \psCancel macro draws the mark before the text to cancel, same as for the cancel package. If you want the mark above the text, I guess you should use Tikz.

Edit 2 : Incorporated suggestions about baseline into the Tikz code

share|improve this answer
You should add the baseline=(tocancel.base) option to \tikz to make sure that the baseline doesn't change. Try a \cancel{Ag} or \cancel{test\strut} to see the difference. Also you need % after the first { and the closing } of \tikz to avoid spurious spaces. – Martin Scharrer Apr 16 '11 at 17:49
@Martin : thanks for the suggestion – Frédéric Apr 16 '11 at 18:04

Your Answer


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.