3

Original thread. I want to make the long division represented with floating point, but i have strange results. The numbers are not aligned (with yellow). And some numbers are far away(red). enter image description here

\documentclass{article}
\usepackage[TABcline]{tabstackengine}
\TABstackMath
\renewcommand\stackalignment{l}
\newcommand\lminus{\llap{$-$}}
{\catcode`-=\active
\gdef -{\lminus}}
\newcommand\minusactive{\phantom{-}\catcode`-=\active}
\setstacktabbedgap{3pt}
\begin{document}
\begin{tabular}{ll@{\hspace{10ex}}c}

    $
    \minusactive
    \tabbedShortunderstack[r]{
        &7,&6&2&4&:4=1,815\\
        -&4&& &&&\\
        \TABcline{2,3}
        & &3&2&&&&\\
        &-&3&2&&&&\\
        \TABcline{3,4} 
        & & & &6& &&\\
        & & &-&4& &&\\
        \TABcline{5} 
        & & & & 2&0&\\
        & & & -& 2&0&\\
        \TABcline{5}
        & & & &0&
    }
    $

\end{tabular}
\end{document}
2
  • Just out of curiosity -- Why did you set the result of the division to 1815 rather 1906?
    – Mico
    Commented Dec 30, 2018 at 23:48
  • You are right. The number is 7,26 not 7,246... Again making mistake for fast MEW. Commented Dec 31, 2018 at 1:10

2 Answers 2

4

Like this?

\documentclass{article}
\usepackage[TABcline]{tabstackengine}
\TABstackMath
\renewcommand\stackalignment{l}
\newcommand\lminus{\llap{$-$}}
{\catcode`-=\active
\gdef -{\lminus}}
\newcommand\minusactive{\phantom{-}\catcode`-=\active}
\setstacktabbedgap{3pt}

\begin{document}

\begin{tabular}{ll@{\hspace{10ex}}c}
    $
    \minusactive
    \tabbedShortunderstack[r]{
        &7\rlap{,}&6&2&4&:4=1,815\\
        -&4&& &&&\\
        \TABcline{2,3}
        & &3&2&&&&\\
        &-&3&2&&&&\\
        \TABcline{3,4}
        & & & &6& &&\\
        & & &-&4& &&\\
        \TABcline{5}
        & & & & 2\rlap{$\; 0 $}&&\\
        & & & -& 2\rlap{$\; 0 $}&&\\
        \TABcline{5}
        & & & &0&
    }
    $
\end{tabular}

\end{document} 

enter image description here

4

If you don't need to show the thousands-separator symbol (here: ,), the layout becomes much easier, and the typographic problem can be solved using just an array environment.

\documentclass{article}
\usepackage{array} % for '\newcolumntype' macro
\newcolumntype{C}{>{{}}c<{{}}}
\usepackage{mathtools} % for '\mathllap' macro
\begin{document}
\[
\setlength\arraycolsep{0.5pt} % default: 5pt
\begin{array}[t]{@{} C @{} *{4}{c} CcC *{4}{c} @{}}
 &7&6&2&4 &:&4&=& 1&9&0&6\\
-&4      \\ \cline{2-2}
 &3&6    \\
-&3&6    \\ \cline{2-3}
 & &0&2  \\
 & &\mathllap{-}&0  \\ \cline{4-4}
 & & &2&4\\
 & &\mathllap{-}&2&4\\ \cline{4-5}
 & & & &0\rlap{.}    % "\rlap{.}" is optional
\\ \cline{5-5} % optional
\end{array}
\qquad
\begin{array}[t]{@{} C @{} *{4}{c} CcC *{4}{c} @{}}
 &7&2&6&0 &:&4&=& 1&8&1&5\\
-&4      \\ \cline{2-2}
 &3&2    \\
-&3&2    \\ \cline{2-3}
 & &0&6  \\
 & &\mathllap{-}&4  \\ \cline{4-4}
 & & &2&0\\
 & &\mathllap{-}&2&0\\ \cline{4-5}
 & & & &0\rlap{.}    % "\rlap{.}" is optional
\\ \cline{5-5} % optional
\end{array}
\]
\end{document}
1
  • 2
    The comma may have had the meaning of a decimal point, conventions vary.
    – Carsten S
    Commented Dec 31, 2018 at 10:54

You must log in to answer this question.

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