4

Among the several proposals for formatting long division in LaTeX, the one that has worked best for my purposes is the one for which the code appears below. It is necessary for me: to stop the process before it's over in order to comment on something happening at that point; to bring down one digit or more than one after each remainder (e.g. in this example, after the remainder 46 I bring down a 0 to the right of the remainder, but I could have brought down two 0s); and to insert labels or arrows or terse comments to the right of each line.

But I am wondering how to put a standard round right parenthesis in the standard place where that would appear, instead of the vertical solidus that you see here.

\begin{array}{rc@{}c@{}c@{}c@{}c@{}c@{}c@{}c@{}c@{}c@{}c@{}c@{}c@{}c@{}c@{}c@{}c@{}c@{}c@{}}
& & 0 & . & 7 & 1 & 6 & 2 \\ \cline{2-9}
\multicolumn{1}{r|}{74} & 5 & 3 & . & 0 & 0 & 0 & 0 & 0 \\
& 5 & 1 & & 8 \\ \cline{2-5}
& & 1 & & 2 & 0 \\
& & & & 7 & 4 \\  \cline{4-6}
& & & & 4 & 6 & 0 \\
& & & & 4 & 4 & 4 \\   \cline{5-7}
& & & & & 1 & 6 & 0 \\
& & & & & 1 & 4 & 8 \\  \cline{6-8}
& & & & & & 1 & 2 & 0
\end{array}
1
  • 4
    ...you can use \begin{array}{ r *{19}{c@{}} } for your column specification.
    – Werner
    Commented Oct 11, 2017 at 19:34

2 Answers 2

5

I use a \\ \cline{2-9}\\[-14.5pt] to get proper vertical spacing, and for the horizontal spacing, \multicolumn{1}{r}{74\rlap{\kern4.5pt)}}.

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}

\usepackage[margin=1in]{geometry}

\parindent=0pt
\pagenumbering{gobble}

\begin{document}

\[
\begin{array}{ r *{19}{c@{}} }
& & 0 & . & 7 & 1 & 6 & 2 \\ \cline{2-9}\\[-14.5pt]
\multicolumn{1}{r}{74\rlap{\kern4.5pt)}} & 5 & 3 & . & 0 & 0 & 0 & 0 & 0 \\
& 5 & 1 & & 8 \\ \cline{2-5}
& & 1 & & 2 & 0 \\
& & & & 7 & 4 \\  \cline{4-6}
& & & & 4 & 6 & 0 \\
& & & & 4 & 4 & 4 \\   \cline{5-7}
& & & & & 1 & 6 & 0 \\
& & & & & 1 & 4 & 8 \\  \cline{6-8}
& & & & & & 1 & 2 & 0
\end{array}
\]
\end{document}

enter image description here

3
  • Off-Topic: Steven, could you take a look on tex.stackexchange.com/questions/395756/…, seems to be an issue with stackengine, though I am not sure
    – user31729
    Commented Oct 12, 2017 at 7:11
  • @ChristianHupfer Thanks. I will have a look. Commented Oct 12, 2017 at 9:37
  • @ChristianHupfer A \protect was needed. Commented Oct 12, 2017 at 9:59
2

Some improvements:

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{xcolor}
\usepackage{array, booktabs}
\parindent=0pt
\pagestyle{empty}

\begin{document}

\[
\begin{array}{ rr@{} >{\color{red}}c@{}*{6}{c@{\mkern2mu}} }
 & 0 & . & 7 & 1 & 6 & 2 \\ \cmidrule[0.6pt](l{-0.385em}){2-8}\\[-16.9pt]
74\;\rlap{\Large)} &53 & . & 0 & 0 & 0 & 0 & 0 \\
 & 51 & & 8 \\ \cmidrule(l{1ex}){2-5}
 & 1 & & 2 & 0 \\
& & & 7 & 4 \\ \cmidrule{3-6}
& & & 4 & 6 & 0 \\
& & & 4 & 4 & 4 \\ \cmidrule{4-7}
& & & & 1 & 6 & 0 \\
& & & & 1 & 4 & 8 \\ \cmidrule{5-8}
& & & & & 1 & 2 & 0
\end{array}
\]

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .