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 have equations with a lot of terms and I would like to be able to specify the reason of the cancelation of those terms using a color code (for example : red if the term is null, blue if it cancels out with another term, green if it can be considered as very small...).

How to define new commands to be able to cancel these terms with different colors using the cancel package?

share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

The color of the line used by cancel can be changed with

\renewcommand\CancelColor{<color command>}

You could include this in a new cancel-command where an optional argument defines the color.

output of below code

\documentclass{article}
\usepackage{cancel}
\usepackage{xcolor}
\newcommand\Ccancel[2][black]{\renewcommand\CancelColor{\color{#1}}\cancel{#2}}

\begin{document}
\[
\Ccancel{x+1} \qquad \Ccancel[blue]{x-1}
\]
\end{document}
share|improve this answer
add comment

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.