# How show rational simplification?

I need to show the path to simplify fractions, i.e., through their common divisors, so that show the first simplifications. For example: 18/6 I'd want to show some like this:

\frac{\cancel{18}^9}{\cancel{6}_3}


Taking 2 as a common divisor, I want that the 9 and the 3 appear above/below of 18 and 6 respectively. If I have more divisors they appear above/below of previous, for example, 50:

\cancel{50}^{\cancel{10}^{2}}


i.e., I want that 10 appears above of the cancelled 50, the 2 appear above of the cancelled 10 (if I divide for 5)

Is there some command or package that does that?

Thanks a lot!

• Welcome to TEX.SE! There is a package named cancel which does what you want! Commented Jan 12, 2022 at 19:43
• Please can you provide a minimal working example putting, if possible, an hand-drawing of that you want? Commented Jan 13, 2022 at 17:19
• Thanks Dan for your help. It's work fine. I modified a little the command using \cancel, because is more beauty, for example: \cancelmcd{24}{\cancelmcd{12}{\cancelmcd{6}{3}}} where \cancelmcd is a new command defined as: \newcommand{\cancelmcd}[2]{\substack{#2\\\text{\cancel{#1}}}} Sorry by my bad english Commented Jan 15, 2022 at 18:18

## 2 Answers

With a \substack and \sout from ulem you could do

\documentclass{article}
\usepackage{ulem}
\usepackage{amsmath}
\begin{document}
$\frac{\substack{9\\\text{\sout{18}}}}{\substack{\text{\sout{6}}\\3}}$
\end{document}


You can keep adding lines to the stack, so you can have multiple divisors if you want.

• I reviewed the modification above mentioned a bit because wasn't behaving quite as he expected, especially in the denominator. Searching in documents and manuals, I see the command overset and underset. I used like this: \overset{3}{\overset{\cancel{9}}{\cancel{27}}}, similarly for \underset. The new command was left this way: \newcommand[2]{\cancelnum}{\overset{#1}{\cancel{#2}}} \newcommand[2]{\cancelden}{\underset{#1}{\cancel{#2}}} when #1 is the new number and #2 is the canceled number. Commented Jan 26, 2022 at 3:18

As suggest @Imran in his comment - use of cancel package do this:

\documentclass[margin=3.141592]{standalone}
\usepackage{cancel}

\begin{document}
$\frac{\cancel{50}^{~5}}{\cancel{10}^{~1}} = 5$
\end{document}