How can I draw the following scheme?
-
Probably a duplicate of tex.stackexchange.com/questions/476518/… or tex.stackexchange.com/questions/131125/…– albertMay 7, 2020 at 10:06
-
1Does this answer your question? Better way to display long division?– albertMay 7, 2020 at 10:07
-
@albert It is not duplicate post. \intlongdivision gives the entire division process. My question is regarding the greatest common divisor.– Vipul KakkarMay 7, 2020 at 10:22
-
2If it's not a duplicate, can you please provide a minimal working example (MWE) of what you have tried so far? Posting only an image is of little help– Alessandro CuttinMay 7, 2020 at 12:26
-
@AlessandroCuttin I tried \intlongdivision first and then I looked at polynom package and tried \polylonggcd.– Vipul KakkarMay 7, 2020 at 16:29
2 Answers
Something like this?
\documentclass{article}
\usepackage{array,booktabs}
\newcommand\ml[1]{\multicolumn{1}{l}{#1}}
\newcommand\lparen{\mkern1mu(\mkern1mu}
\newcommand\rparen{\mkern1mu)\mkern1mu}
\newcommand\pp{\phantom{\lparen}}
\begin{document}
\[
\setlength\arraycolsep{0pt}
\begin{array}{ *{11}{r} }
198 & \rparen & 360 & \lparen & \ml{1} \\
&& 198 & \pp \\
\cmidrule{3-4}
&& 162 & \rparen & 198 & \lparen & \ml{1} \\
&&&& 162 & \pp \\
\cmidrule{5-6}
&&&& 36 & \rparen & 162 & \lparen & \ml{4} \\
&&&&&& 144 & \pp \\
\cmidrule{7-8}
&&&&&& 18 & \rparen & 36 & \lparen & \ml{2} \\
&&&&&&&& 36 & \pp\\
\cmidrule{9-10}
&&&&&&&& \multicolumn{2}{c}{\times}
\end{array}
\]
\end{document}
This is typical example for doing macros recursive:
\def\divi #1)#2/#3=#4{#1)%
\vtop{\hbox{#2}\hbox{#3}\smallskip\hrule width1.5em\smallskip\hbox{#4}}}
\def\0{\phantom0}
\divi 198)360(1/190={%
\divi 162)198(1/162={%
\divi \036)162(4/144={%
\divi \018)36(2/36={%
$\0\times$}}}}
\bye