Math formatting "Pro Tips" edition: Using the cancel() and color() functions together! -"?"

Jul 26, 2015

Just some quick tips on how the cancel() and color() functions can be used together.

Explanation:

I came across a very cool variation of the syntax used to combine the cancel() and color() functions.

As I'm sure most of you know already, you can use the color() and cancel() functions together to write things like

• without the hashtags

cancel(color(red)(x^2 + 2x))

cancel(color(blue)("testing, testing...")

• with the hashtags

$\cancel{\textcolor{red}{{x}^{2} + 2 x}}$

cancel(color(blue)("testting, testing...")

Reversing the order in which the functions are being called will get you

• without the hashtags

color(red)(cancel(x^2 + 2x))

color(blue)(cancel("testing, testing..."))

• with the hashtags

$\textcolor{red}{\cancel{{x}^{2} + 2 x}}$

$\textcolor{b l u e}{\cancel{\text{testing, testing...}}}$

Now, to use color only for the strikeout line, you have to use the color() function once more for the text that's being used for the cancel() function.

More specifically, you need to call color(black)(text) within the cancel function to get this to happen. Here's how that would look like

• without the hashtags

color(red)(cancel(color(black)(x^2 + 2x)))

color(blue)(cancel(color(black)("testing, testing...")))

• with the hashtags

$\textcolor{red}{\cancel{\textcolor{b l a c k}{{x}^{2} + 2 x}}}$

$\textcolor{b l u e}{\cancel{\textcolor{b l a c k}{\text{testing, testing...}}}}$

Alternatively, you can use different sets of colors for the two functions to write things like

• without the hashtags

color(red)(cancel(color(green)("color mix 1")))

color(blue)(cancel(color(red)("color mix 2")))

• with the hashtags

$\textcolor{red}{\cancel{\textcolor{g r e e n}{\text{color mix 1}}}}$

$\textcolor{b l u e}{\cancel{\textcolor{red}{\text{color mix 2}}}}$

Dec 2, 2015

To put a red strikeout through xyz, I use "color(red)(cancel(color(black)(" before the xyz and ")))" after the xyz.

Explanation:

I can't claim credit for the method, because Stefan Z developed it.

The "color(red)cancel" inserts the red strikeout mark.

The "(color(black)" changes to black everything that follows, i.e. "(xyz)", and the closing parentheses are added to match the number of opening parentheses.

Without hashtags:

color(red)(cancel(color(black)(xyz)))

With hashtags:

$\textcolor{red}{\cancel{\textcolor{b l a c k}{x y z}}}$

You can use quotes in the argument to avoid italics.

Thus,

color(red)(cancel(color(black)("xyz")))

gives (with hashtags) $\textcolor{red}{\cancel{\textcolor{b l a c k}{\text{xyz}}}}$

You have to get the number of parentheses just right, or it doesn't work.