The following is an excerpt from the chapter LaTeX Questions Answered in Pressbooks Guide: A reference for open textbook authors using Pressbooks by Arianna Cheveldave
If you’re working with conversion factors, or any other kind of math that involves showing that something has been removed or cancelled out, crossing things out is essential.
Luckily, it’s very easy to cross something out in a LaTeX expression. Simply use the \cancel{x}
command, where x is whatever you want to cross out. This looks like:
Let’s put this command to use in the conversion of 10 metres to millimetres.
First, determine the conversion factor. Since there are 1000 mm in 1 m, our conversion factor will be:
Next, multiply the conversion factor by the original measurement of 10 m. Following the rules of cancelling out in fractions, we end up with:
By crossing out the metres, it is easier to see that we’ll end up with millimetres.
While this example was very simple and easy to understand, the \cancel{}
command is especially useful when converting between many different units. To demonstrate, here is an example from chemistry:
While the \cancel{}
command is most useful when using numerals, it can also be used to cancel out words:
Cancelling Out Spaces
In a prior example, we had:
which is written as 10\cancel{\text{ m}}
. You’ll notice that the command is cancelling out the metre symbol as well as the space before it. But wouldn’t it be better to only cancel out the metre symbol?
Yes, it would be better — but this can be difficult.
Since LaTeX doesn’t recognize spaces written between its commands, the only way to insert a space is to use \text{ }
. If you have a numeral, then a unit of measurement, like in the case of 10 m, you need a space between the two.
The simplest way to write this in LaTeX is 10\text{ m}
, in which the space and the m are created using the same \text{}
command.
If you try to put the \cancel{}
command within the \text{}
command so that only the m is cancelled, this is what happens:[1]
10 \cancel{m}
The \text{}
command prints out exactly what you write in its curly brackets. Therefore, if you try to insert a \cancel{m}
command within a \text{}
command, you’ll just print out “\cancel{m}”.
If you really want to make sure that the space isn’t cancelled out, you can use two separate \text{}
commands to write the space and the m:
Compare this to the original way we wrote it:
You can see that the difference is minute and that using two separate \text{}
commands for the space and the m is cumbersome.
You can use two \text{}
commands if you prefer, but when you’re writing a ton of conversion factors (like in a chapter on conversion factors in a math or chemistry textbook), this extra work will quickly add up.
Generally, we recommend writing 10\cancel{\text{ m}}
, because it’s a little simpler, and it’s doubtful that anyone would be able to tell the difference.
Learn More:
- LaTeX Questions Answered: What Kind of Symbols Can I Write Using LaTeX?
- LaTeX Questions Answered: Should LaTeX Be Used For All Expressions?
- You can right-click this expression and go to Math Settings > Math Renderer > Plain Source and then back to Common HTML to switch between seeing the original LaTeX markup and the expression in display form. ↵
The featured image for this post (viewable in the BCcampus News section at the bottom of our homepage) is by Karolina Grabowska from Pexels