6

I recently discovered the package xlop to typeset automatically elementary school calculations. Using this for division for example like this, gives the output below.

\documentclass{article}

\usepackage{xlop}

\begin{document}   

\opdiv[period=true,voperation=top,displayintermediary=all,decimalsepsymbol={,},shiftdecimalsep=none,maxdivstep=30]{54.60}{28}

\end{document}

Output of xlop

However I want the display style like this:

Desired Display Style

The part I marked manually is important, i.e. the ": 28 = 1,95" instead of the way xlop displays the divisor and the result. Additionally I want the vertical line and the right horizontal line in the xlop output to disappear.

I guess that there is no switch in xlop to to this so I checked the source code of xlop and wanted to modify a part of it (in my document between a makeatletter and makeatother pair).

I managed it to realize that the display thing is done in the macro \op@divdisplayone. Let me quote it here (I added comments at the lines which seems to be relevant):

\def\op@divdisplayone{%
  \begingroup
    \op@count@z=\z@\relax
    \op@count@i=\OP@a@w
    \loop
    \ifnum\@nameuse{OP@a@\the\op@count@i}=0
      \advance\op@count@i by-1
      \advance\op@count@z by1
    \repeat
    \op@count@i=\op@firstlength
    \advance\op@count@i by\op@count@z
    \xdef\op@firstlength{\the\op@count@i}%
    \setbox2=\vbox{%
      \op@count@i=\op@firstlength
      \advance\op@count@i by1
      \hbox{%
        \ifx\op@displayintermediary\op@string@none\else
% add 0.25
          \ifx\op@displayintermediary\op@string@None\else
% end add 0.25
            \kern\opcolumnwidth
            \advance\op@count@i by1
% add 0.25
          \fi
% end add 0.25
        \fi
        \ifop@dividendbridge
          \vrule width0pt depth0pt height\oplineheight
          \opvline(0,1){0.4}%
          \ophline(0,1){\op@firstlength}%
          \opvline(\op@firstlength,1){0.4}%
        \fi
        \op@display{operandstyle.1}{a}%
        \ifnum\op@shift=0\relax\else
          \op@count@v=\op@shift
          \advance\op@count@v by\OP@a@d
          \oplput(-\the\op@count@v,0){\op@strikedecimalsepsymbol}%
        \fi
      }%
      \op@count@z=\OP@q@w
      \op@count@ii=1\relax
      \ifx\op@displayintermediary\op@string@none
        \advance\op@count@i by-1\relax
% add 0.25
      \else\ifx\op@displayintermediary\op@string@None
        \advance\op@count@i by-1\relax
% end add 0.25
      \else
        \op@count@iv=\@nameuse{OP@q@\the\op@count@z}\relax
        \op@count@iii=\op@count@i
        \advance\op@count@iii by-\@nameuse{OP@T\the\op@count@iv @w}%
        \hbox{%
          \ifx\op@voperator\op@string@center
            \oplput(0,0.5){\op@subsymbol}%
          \else\ifx\op@voperator\op@string@top
            \oplput(0,1){\op@subsymbol}%
          \else
            \oplput(0,0){\op@subsymbol}%
          \fi\fi
          \ophline(1,-0.25){\op@firstlength}%
          \advance\op@count@ii by1
          \kern\op@count@iii\opcolumnwidth
          \op@display{intermediarystyle.1}%
                     {T\the\op@count@iv}%
        }%
% modif 0.25
      \fi\fi
% end modif 0.25
      {\global\setbox4=\hbox{}\setbox4=\box4}%
      \loop
        \advance\op@count@z by-1
        \advance\op@count@i by1\relax
      \ifnum\op@count@z>0\relax
        \op@count@iv=\@nameuse{OP@q@\the\op@count@z}\relax
        \ifnum\op@count@iv=0
          \ifx\op@displayintermediary\op@string@all
            \op@count@v=\op@count@i
            \advance\op@count@v by-\@nameuse{OP@R\the\op@count@ii @w}%
            \hbox{%
              \kern\op@count@v\opcolumnwidth
              \op@display{remainderstyle.\the\op@count@ii}%
                         {R\the\op@count@ii}%
            }%
            \op@count@iii=\op@count@i
            \advance\op@count@iii by-\@nameuse{OP@T\the\op@count@iv @w}%
            \hbox{%
              \kern\op@count@v\opcolumnwidth
              \ifx\op@voperator\op@string@center
                \oplput(-1,0.5){\op@subsymbol}%
              \else\ifx\op@voperator\op@string@top
                \oplput(-1,1){\op@subsymbol}%
              \else
                \oplput(-1,0){\op@subsymbol}%
              \fi\fi
              \ophline(0,-0.25){\@nameuse{OP@R\the\op@count@ii @w}}%
              \kern-\op@count@v\opcolumnwidth
              \kern\op@count@iii\opcolumnwidth
              \op@display{intermediarystyle.\the\op@count@ii}%
                         {T\the\op@count@iv}%
            }%
          \else
            \ifnum\@nameuse{OP@R\the\op@count@ii @w}=2
              \ifnum\@nameuse{OP@R\the\op@count@ii @2}=0
                \op@makebox{1}{0}{remainderstyle.\the\op@count@ii.1}{zero}%
                \setbox4=\hbox to\opcolumnwidth{\hss\box0\hss}%
              \fi
            \fi
          \fi
          \advance\op@count@ii by1\relax
        \else
          \op@count@v=\op@count@i
          \advance\op@count@v by-\@nameuse{OP@R\the\op@count@ii @w}%
          \ifvoid4\relax\else
            \advance\op@count@v by-1
          \fi
          \hbox{%
            \kern\op@count@v\opcolumnwidth\copy4
            \op@display{remainderstyle.\the\op@count@ii}%
                       {R\the\op@count@ii}%
          }%
          \advance\op@count@ii by1\relax
          \ifx\op@displayintermediary\op@string@none
% add 0.25
          \else\ifx\op@displayintermediary\op@string@None
% end add 0.25
          \else
            \op@count@iii=\op@count@i
            \advance\op@count@iii by-\@nameuse{OP@T\the\op@count@iv @w}%
            \hbox{%
              \kern\op@count@v\opcolumnwidth
              \ifx\op@voperator\op@string@center
                \oplput(-1,0.5){\op@subsymbol}%
              \else\ifx\op@voperator\op@string@top
                \oplput(-1,1){\op@subsymbol}%
              \else
                \oplput(-1,0){\op@subsymbol}%
              \fi\fi
              \advance\op@count@ii by-1
              \ifvoid4\relax
                \ophline(0,-0.25){\@nameuse{OP@R\the\op@count@ii @w}}%
              \else
                \ophline(0,-0.25){\@nameuse{OP@T\the\op@count@iv @w}}%
                \ophline(\@nameuse{OP@T\the\op@count@iv @w},-0.25){1}%
                {\setbox4=\box4}%
              \fi
              \advance\op@count@ii by1
              \kern-\op@count@v\opcolumnwidth
              \kern\op@count@iii\opcolumnwidth
              \op@display{intermediarystyle.\the\op@count@ii}%
                         {T\the\op@count@iv}%
            }%
% modif 0.25
          \fi\fi
% end modif 0.25
        \fi
      \repeat
      \advance\op@count@i by-1
      \op@count@iii=\op@count@i
      \advance\op@count@iii by-\@nameuse{OP@R\the\op@count@ii @w}%
      \hbox{%
        \kern\op@count@iii\opcolumnwidth
        \op@display{remainderstyle.\the\op@count@ii}%
                   {R\the\op@count@ii}%
      }%
    }%
    \setbox3=\vbox{%
      \op@count@v=\op@max{\OP@qq@w}{\OP@b@w}
      \hbox{\ophline(-0.5,-0.25){\the\op@count@v.5}%
            \op@display{operandstyle.2}{b} %%This seems to be the divisor
        \ifnum\op@shift=0\relax\else
          \op@count@v=\op@shift
          \advance\op@count@v by\OP@b@d
          \oplput(-\the\op@count@v,0){\op@strikedecimalsepsymbol}%
        \fi}
      \hbox{\op@display{resultstyle}{qq}} %%This seems to be the result
    }%
    \dimen0=\ht2
    \ifdim\dimen0>\ht3
      \ht3=\ht2
    \else
      \ht2=\ht3
    \fi
    \ifx\op@voperation\op@string@top
      \dimen0=\ht2
      \advance\dimen0 by-0.5\oplineheight
      \ht2=0.75\oplineheight
      \ht3=0.75\oplineheight
      \dp2=\dimen0
      \dp2=\dimen0
    \fi
    \setbox1=\hbox{%
      \box2
      \kern0.5\opcolumnwidth
      \kern-0.5\op@hrulewidth
      \ifx\voperation\op@string@top
        \vrule width\op@hrulewidth
      \else
        \vrule width\op@hrulewidth
      \fi
      \kern0.5\opcolumnwidth
      \kern-0.5\op@hrulewidth
      \box3
    }%
    \ifx\op@voperation\op@string@center
      \setbox1=\hbox{$\vcenter{\box1}$}%
    \fi
    \leavevmode\box1
  \endgroup
}
\def\op@div#1#2#3#4#5{%
  \begingroup
    \def\op@divmode{#1}%
    \op@copy{#2}{da}%
    \op@copy{#3}{db}%
    \op@count@iv=0
    \op@count@iii=\op@max{\OP@da@d}{\OP@db@d}\relax
    \op@powten{da}{\the\op@count@iii}%
    \op@powten{db}{\the\op@count@iii}%
% add 0.23
    \op@unzero{da}%
    \op@unzero{db}%
% end 0.23
    \ifnum\op@divmode=1
      \op@cmp{da}{maxinteger}%
      \ifopgt
        \op@warning{I can't deal period with such great dividend
                    (max = 2147483647).^^J
                    Use of maxdivstep instead period.}%
        \def\op@divmode{0}%
      \else \op@cmp{db}{maxdivperiod}%
      \ifopgt
        \op@warning{I can't deal period with such great divisor
                    (max = 214748363).^^J
                    Use of maxdivstep instead period.}%
        \def\op@divmode{0}%
      \else
        \op@unsplit{da}{@a}%
        \op@unsplit{db}{@b}%
        \op@divperiod{\Op@@a}{\Op@@b}{op@lengthperiod}%
        \ifnum\op@lengthperiod>\op@safedivstep
          \op@warning{Period of division is too big
                      (\op@lengthperiod\space > safedivstep).^^J
                      \space\space\space Division will stop
                      before reach it.}%
        \fi
      \fi\fi
    \fi
    \op@multable{db}%
    \op@copy{da}{R}%
    \op@cmp{da}{db}%
    \ifople
      \op@count@i=\OP@da@w
    \else
      \xdef\OP@R@d{0}%
      \xdef\OP@R@s{0}%
      \op@count@i=\@nameuse{OP@db@w}%
      \op@leftdividend{\the\op@count@i}%
      \op@cmp{R}{db}%
      \ifoplt
        \ifnum\OP@da@w>\op@count@i
          \advance\op@count@i by1
          \op@leftdividend{\the\op@count@i}%
        \fi
      \fi
    \fi
    \xdef\op@firstlength{\the\op@count@i}%
    \op@count@i=-\op@count@i
    \advance\op@count@i by\OP@da@w
    \op@copy{R}{R0}%
    \op@copy{zero}{dq}%
    \op@count@ii=0
    \op@againtrue
    \loop
    \ifop@again
      \op@tableextract{R}%
      \op@multen{dq}%
      \@namexdef{OP@dq@1}{\op@k}%
      \op@sub{R}{T\op@k}{dr}%
      \op@unzero{T\op@k}%
      \op@multen{dr}%
      \ifnum\op@count@i>0
        \@namexdef{OP@dr@1}{\@nameuse{OP@da@\the\op@count@i}}%
      \fi
      \advance\op@count@i by-1\relax
      \op@unzero{dr}%
      \ifnum\OP@dr@w=1
        \xdef\OP@dr@w{2}%
        \xdef\OP@dr@i{2}%
        \@namexdef{OP@dr@2}{0}%
      \fi
      \advance\op@count@ii by1\relax
      \op@copy{dr}{R\the\op@count@ii}%
      \op@copy{dr}{R}%
      \ifcase\op@divmode\relax
        \ifnum\op@count@ii<\op@maxdivstep\relax\else
          \op@againfalse
        \fi
        \ifnum\op@count@i<0\relax%
          \op@cmp{zero}{R}%
          \ifopeq
            \op@againfalse
          \fi
        \fi
      \or
        \ifnum\op@count@ii<\op@safedivstep\relax\else
          \op@againfalse
        \fi
        \ifnum\op@count@i<-\op@lengthperiod\relax
          \op@count@iv=\op@count@ii
          \advance\op@count@iv by-\op@lengthperiod
          \op@cmp{R\the\op@count@iv}{R\the\op@count@ii}%
          \ifopeq
            \op@againfalse
          \fi
        \fi
      \or
        \ifnum\op@count@i=-1
          \op@againfalse
        \fi
      \fi
    \repeat
    \op@copy{zero}{T0}%
    \advance\op@count@i by1\relax
    \ifnum\op@count@i<0
      \xdef\OP@dq@d{-\the\op@count@i}%
      \op@count@z=\OP@dq@w
      \advance\op@count@z by\op@count@i
      \xdef\OP@dq@i{\the\op@count@z}%
    \fi
    \op@unzero{dq}%
    \op@copy{dq}{#4}%
    \op@unzero{dr}%
    \op@copy{dr}{R}%
    \op@rshift{1}{dr}%
    \op@copy{dr}{R\the\op@count@ii}%
    \op@count@i=\op@count@iii
    \advance\op@count@i by1
    \advance\op@count@i by\OP@dq@d\relax
    \op@count@ii=\op@count@i
    \advance\op@count@ii by\OP@R@w
    \op@format{\the\op@count@ii}{0}{R}%
    \op@count@z=\OP@R@w
    \advance\op@count@z by-\op@count@i
    \xdef\OP@R@i{\the\op@count@z}%
    \xdef\OP@R@d{\the\op@count@i}%
    \op@unzero{R}%
    \op@copy{R}{#5}%
  \endgroup
}

However I am just a LaTeX user and don't know too much about TeX itself. However for me it seems to be a minor modification for someone who knows TeX, so I hope that someone can tell my how to achieve the desired display style.

  • 1
    I've updated my answer, with one option producing the desired alignment. – Gonzalo Medina Apr 22 '13 at 17:55
  • I advocate not using "x : y = z", which is misleading: if the result is not "exact" this is not an equality, unless you redefine the meaning of ":". I prefer to see division as a way of rewriting a number as a multiple of the divisor plus a remainder. – egreg Apr 22 '13 at 20:08
5

Here's another option, producing the desired alignment (with the same warning as in David's answer: "This may have broken some other constructs in the package, but..."). Since the code uses \tikzmark, two (or three) runs are needed for the code to stabilize:

\documentclass{article}
\usepackage{xlop}
\usepackage{tikz}

\newcommand\tikzmark[1]{%
  \tikz[remember picture,overlay] \node[inner xsep=0pt,outer sep=0pt,anchor=base,yshift=0.5ex] (#1) {};}

\makeatletter
\def\op@divdisplayone{%
  \begingroup
    \op@count@z=\z@\relax
    \op@count@i=\OP@a@w
    \loop
    \ifnum\@nameuse{OP@a@\the\op@count@i}=0
      \advance\op@count@i by-1
      \advance\op@count@z by1
    \repeat
    \op@count@i=\op@firstlength
    \advance\op@count@i by\op@count@z
    \xdef\op@firstlength{\the\op@count@i}%
    \setbox2=\vbox{%
      \op@count@i=\op@firstlength
      \advance\op@count@i by1
      \hbox{%
        \ifx\op@displayintermediary\op@string@none\else
% add 0.25
          \ifx\op@displayintermediary\op@string@None\else
% end add 0.25
            \kern\opcolumnwidth
            \advance\op@count@i by1
% add 0.25
          \fi
% end add 0.25
        \fi
        \ifop@dividendbridge
          \vrule width0pt depth0pt height\oplineheight
          \opvline(0,1){0.4}%
          \ophline(0,1){\op@firstlength}%
          \opvline(\op@firstlength,1){0.4}%
        \fi
        \op@display{operandstyle.1}{a}\tikzmark{a}%
        \ifnum\op@shift=0\relax\else
          \op@count@v=\op@shift
          \advance\op@count@v by\OP@a@d
          \oplput(-\the\op@count@v,0){\op@strikedecimalsepsymbol}%
        \fi
      }%
      \op@count@z=\OP@q@w
      \op@count@ii=1\relax
      \ifx\op@displayintermediary\op@string@none
        \advance\op@count@i by-1\relax
% add 0.25
      \else\ifx\op@displayintermediary\op@string@None
        \advance\op@count@i by-1\relax
% end add 0.25
      \else
        \op@count@iv=\@nameuse{OP@q@\the\op@count@z}\relax
        \op@count@iii=\op@count@i
        \advance\op@count@iii by-\@nameuse{OP@T\the\op@count@iv @w}%
        \hbox{%
          \ifx\op@voperator\op@string@center
            \oplput(0,0.5){\op@subsymbol}%
          \else\ifx\op@voperator\op@string@top
            \oplput(0,1){\op@subsymbol}%
          \else
            \oplput(0,0){\op@subsymbol}%
          \fi\fi
          \ophline(1,-0.25){\op@firstlength}%
          \advance\op@count@ii by1
          \kern\op@count@iii\opcolumnwidth
          \op@display{intermediarystyle.1}%
                     {T\the\op@count@iv}%
        }%
% modif 0.25
      \fi\fi
% end modif 0.25
      {\global\setbox4=\hbox{}\setbox4=\box4}%
      \loop
        \advance\op@count@z by-1
        \advance\op@count@i by1\relax
      \ifnum\op@count@z>0\relax
        \op@count@iv=\@nameuse{OP@q@\the\op@count@z}\relax
        \ifnum\op@count@iv=0
          \ifx\op@displayintermediary\op@string@all
            \op@count@v=\op@count@i
            \advance\op@count@v by-\@nameuse{OP@R\the\op@count@ii @w}%
            \hbox{%
              \kern\op@count@v\opcolumnwidth
              \op@display{remainderstyle.\the\op@count@ii}%
                         {R\the\op@count@ii}%
            }%
            \op@count@iii=\op@count@i
            \advance\op@count@iii by-\@nameuse{OP@T\the\op@count@iv @w}%
            \hbox{%
              \kern\op@count@v\opcolumnwidth
              \ifx\op@voperator\op@string@center
                \oplput(-1,0.5){\op@subsymbol}%
              \else\ifx\op@voperator\op@string@top
                \oplput(-1,1){\op@subsymbol}%
              \else
                \oplput(-1,0){\op@subsymbol}%
              \fi\fi
              \ophline(0,-0.25){\@nameuse{OP@R\the\op@count@ii @w}}%
              \kern-\op@count@v\opcolumnwidth
              \kern\op@count@iii\opcolumnwidth
              \op@display{intermediarystyle.\the\op@count@ii}%
                         {T\the\op@count@iv}%
            }%
          \else
            \ifnum\@nameuse{OP@R\the\op@count@ii @w}=2
              \ifnum\@nameuse{OP@R\the\op@count@ii @2}=0
                \op@makebox{1}{0}{remainderstyle.\the\op@count@ii.1}{zero}%
                \setbox4=\hbox to\opcolumnwidth{\hss\box0\hss}%
              \fi
            \fi
          \fi
          \advance\op@count@ii by1\relax
        \else
          \op@count@v=\op@count@i
          \advance\op@count@v by-\@nameuse{OP@R\the\op@count@ii @w}%
          \ifvoid4\relax\else
            \advance\op@count@v by-1
          \fi
          \hbox{%
            \kern\op@count@v\opcolumnwidth\copy4
            \op@display{remainderstyle.\the\op@count@ii}%
                       {R\the\op@count@ii}%
          }%
          \advance\op@count@ii by1\relax
          \ifx\op@displayintermediary\op@string@none
% add 0.25
          \else\ifx\op@displayintermediary\op@string@None
% end add 0.25
          \else
            \op@count@iii=\op@count@i
            \advance\op@count@iii by-\@nameuse{OP@T\the\op@count@iv @w}%
            \hbox{%
              \kern\op@count@v\opcolumnwidth
              \ifx\op@voperator\op@string@center
                \oplput(-1,0.5){\op@subsymbol}%
              \else\ifx\op@voperator\op@string@top
                \oplput(-1,1){\op@subsymbol}%
              \else
                \oplput(-1,0){\op@subsymbol}%
              \fi\fi
              \advance\op@count@ii by-1
              \ifvoid4\relax
                \ophline(0,-0.25){\@nameuse{OP@R\the\op@count@ii @w}}%
              \else
                \ophline(0,-0.25){\@nameuse{OP@T\the\op@count@iv @w}}%
                \ophline(\@nameuse{OP@T\the\op@count@iv @w},-0.25){1}%
                {\setbox4=\box4}%
              \fi
              \advance\op@count@ii by1
              \kern-\op@count@v\opcolumnwidth
              \kern\op@count@iii\opcolumnwidth
              \op@display{intermediarystyle.\the\op@count@ii}%
                         {T\the\op@count@iv}%
            }%
% modif 0.25
          \fi\fi
% end modif 0.25
        \fi
      \repeat
      \advance\op@count@i by-1
      \op@count@iii=\op@count@i
      \advance\op@count@iii by-\@nameuse{OP@R\the\op@count@ii @w}%
      \hbox{%
        \kern\op@count@iii\opcolumnwidth
        \op@display{remainderstyle.\the\op@count@ii}%
                   {R\the\op@count@ii}%
      }%
    }%
    \setbox3=\vbox{%
      \op@count@v=\op@max{\OP@qq@w}{\OP@b@w}
      \hbox{%\ophline(-0.5,-0.25){\the\op@count@v.5}%
            :\op@display{operandstyle.2}{b}=\op@display{resultstyle}{qq} %%This seems to be the divisor
        \ifnum\op@shift=0\relax\else
          \op@count@v=\op@shift
          \advance\op@count@v by\OP@b@d
          \oplput(-\the\op@count@v,0){\op@strikedecimalsepsymbol}%
        \fi}
      %\hbox{\op@display{resultstyle}{qq}} %%This seems to be the result
    }%
    \dimen0=\ht2
    \ifdim\dimen0>\ht3
      \ht3=\ht2
    \else
      \ht2=\ht3
    \fi
    \ifx\op@voperation\op@string@top
      \dimen0=\ht2
      \advance\dimen0 by-0.5\oplineheight
      \ht2=0.75\oplineheight
      \ht3=0.75\oplineheight
      \dp2=\dimen0
      \dp2=\dimen0
    \fi
    \setbox1=\hbox{%
      \box2
%      \kern0.5\opcolumnwidth
%      \kern-0.5\op@hrulewidth
%      \ifx\voperation\op@string@top
%        \vrule width\op@hrulewidth
%      \else
%        \vrule width\op@hrulewidth
%      \fi
%      \kern0.5\opcolumnwidth
%      \kern-0.5\op@hrulewidth
      \begin{tikzpicture}[remember picture,overlay]
         \node[anchor=west,inner xsep=0pt] at (a) {\box3};
      \end{tikzpicture}
    }%
    \ifx\op@voperation\op@string@center
      \setbox1=\hbox{$\vcenter{\box1}$}%
    \fi
    \leavevmode\box1
  \endgroup
}
\makeatother

\begin{document}   

\opdiv[period=true,voperation=top,displayintermediary=all,decimalsepsymbol={,},shiftdecimalsep=none,maxdivstep=30]{54.63}{28}

\opdiv[period=true,voperation=top,displayintermediary=all,decimalsepsymbol={,},shiftdecimalsep=none,maxdivstep=30]{54.60}{1}

\end{document}

enter image description here

| improve this answer | |
5

enter image description here

This may have broken some other constructs in the package but....

\documentclass{article}

\usepackage[]{xlop}

\makeatletter

\def\op@divdisplayone{%
  \begingroup
    \op@count@z=\z@\relax
    \op@count@i=\OP@a@w
    \loop
    \ifnum\@nameuse{OP@a@\the\op@count@i}=0
      \advance\op@count@i by-1
      \advance\op@count@z by1
    \repeat
    \op@count@i=\op@firstlength
    \advance\op@count@i by\op@count@z
    \xdef\op@firstlength{\the\op@count@i}%
    \setbox2=\vbox{%
      \op@count@i=\op@firstlength
      \advance\op@count@i by1
      \hbox{%
        \ifx\op@displayintermediary\op@string@none\else
% add 0.25
          \ifx\op@displayintermediary\op@string@None\else
% end add 0.25
            \kern\opcolumnwidth
            \advance\op@count@i by1
% add 0.25
          \fi
% end add 0.25
        \fi
        \ifop@dividendbridge
          \vrule width0pt depth0pt height\oplineheight 
          \opvline(0,1){0.4}%
          \ophline(0,1){\op@firstlength}%
          \opvline(\op@firstlength,1){0.4}%
        \fi
        \op@display{operandstyle.1}{a}%
        \ifnum\op@shift=0\relax\else
          \op@count@v=\op@shift
          \advance\op@count@v by\OP@a@d
          \oplput(-\the\op@count@v,0){\op@strikedecimalsepsymbol}%
        \fi
      }%
      \op@count@z=\OP@q@w
      \op@count@ii=1\relax
      \ifx\op@displayintermediary\op@string@none
        \advance\op@count@i by-1\relax
% add 0.25
      \else\ifx\op@displayintermediary\op@string@None
        \advance\op@count@i by-1\relax
% end add 0.25
      \else
        \op@count@iv=\@nameuse{OP@q@\the\op@count@z}\relax
        \op@count@iii=\op@count@i
        \advance\op@count@iii by-\@nameuse{OP@T\the\op@count@iv @w}%
        \hbox{%
          \ifx\op@voperator\op@string@center
            \oplput(0,0.5){\op@subsymbol}%
          \else\ifx\op@voperator\op@string@top
            \oplput(0,1){\op@subsymbol}%
          \else
            \oplput(0,0){\op@subsymbol}%
          \fi\fi
          \ophline(1,-0.25){\op@firstlength}%
          \advance\op@count@ii by1
          \kern\op@count@iii\opcolumnwidth
          \op@display{intermediarystyle.1}%
                     {T\the\op@count@iv}%
        }%
% modif 0.25
      \fi\fi
% end modif 0.25
      {\global\setbox4=\hbox{}\setbox4=\box4}%
      \loop
        \advance\op@count@z by-1
        \advance\op@count@i by1\relax
      \ifnum\op@count@z>0\relax
        \op@count@iv=\@nameuse{OP@q@\the\op@count@z}\relax
        \ifnum\op@count@iv=0
          \ifx\op@displayintermediary\op@string@all
            \op@count@v=\op@count@i
            \advance\op@count@v by-\@nameuse{OP@R\the\op@count@ii @w}%
            \hbox{%
              \kern\op@count@v\opcolumnwidth
              \op@display{remainderstyle.\the\op@count@ii}%
                         {R\the\op@count@ii}%
            }%
            \op@count@iii=\op@count@i
            \advance\op@count@iii by-\@nameuse{OP@T\the\op@count@iv @w}%
            \hbox{%
              \kern\op@count@v\opcolumnwidth
              \ifx\op@voperator\op@string@center
                \oplput(-1,0.5){\op@subsymbol}%
              \else\ifx\op@voperator\op@string@top
                \oplput(-1,1){\op@subsymbol}%
              \else
                \oplput(-1,0){\op@subsymbol}%
              \fi\fi
              \ophline(0,-0.25){\@nameuse{OP@R\the\op@count@ii @w}}%
              \kern-\op@count@v\opcolumnwidth
              \kern\op@count@iii\opcolumnwidth
              \op@display{intermediarystyle.\the\op@count@ii}%
                         {T\the\op@count@iv}%
            }%
          \else
            \ifnum\@nameuse{OP@R\the\op@count@ii @w}=2
              \ifnum\@nameuse{OP@R\the\op@count@ii @2}=0
                \op@makebox{1}{0}{remainderstyle.\the\op@count@ii.1}{zero}%
                \setbox4=\hbox to\opcolumnwidth{\hss\box0\hss}%
              \fi
            \fi
          \fi
          \advance\op@count@ii by1\relax
        \else
          \op@count@v=\op@count@i
          \advance\op@count@v by-\@nameuse{OP@R\the\op@count@ii @w}%
          \ifvoid4\relax\else
            \advance\op@count@v by-1
          \fi
          \hbox{%
            \kern\op@count@v\opcolumnwidth\copy4
            \op@display{remainderstyle.\the\op@count@ii}%
                       {R\the\op@count@ii}%
          }%
          \advance\op@count@ii by1\relax
          \ifx\op@displayintermediary\op@string@none
% add 0.25
          \else\ifx\op@displayintermediary\op@string@None
% end add 0.25
          \else
            \op@count@iii=\op@count@i
            \advance\op@count@iii by-\@nameuse{OP@T\the\op@count@iv @w}%
            \hbox{%
              \kern\op@count@v\opcolumnwidth
              \ifx\op@voperator\op@string@center
                \oplput(-1,0.5){\op@subsymbol}%
              \else\ifx\op@voperator\op@string@top
                \oplput(-1,1){\op@subsymbol}%
              \else
                \oplput(-1,0){\op@subsymbol}%
              \fi\fi
              \advance\op@count@ii by-1
              \ifvoid4\relax
                \ophline(0,-0.25){\@nameuse{OP@R\the\op@count@ii @w}}%
              \else
                \ophline(0,-0.25){\@nameuse{OP@T\the\op@count@iv @w}}%
                \ophline(\@nameuse{OP@T\the\op@count@iv @w},-0.25){1}%
                {\setbox4=\box4}%
              \fi
              \advance\op@count@ii by1
              \kern-\op@count@v\opcolumnwidth
              \kern\op@count@iii\opcolumnwidth
              \op@display{intermediarystyle.\the\op@count@ii}%
                         {T\the\op@count@iv}%
            }%
% modif 0.25
          \fi\fi
% end modif 0.25
        \fi
      \repeat
      \advance\op@count@i by-1
      \op@count@iii=\op@count@i
      \advance\op@count@iii by-\@nameuse{OP@R\the\op@count@ii @w}%
      \hbox{%
        \kern\op@count@iii\opcolumnwidth
        \op@display{remainderstyle.\the\op@count@ii}%
                   {R\the\op@count@ii}%
      }%
    }%
    \setbox3=\vbox{%
      \op@count@v=\op@max{\OP@qq@w}{\OP@b@w}
      \hbox{%\ophline(-0.5,-0.25){\the\op@count@v.5}%
            \op@display{operandstyle.2}{b}%
        \ifnum\op@shift=0\relax\else
          \op@count@v=\op@shift
          \advance\op@count@v by\OP@b@d
          \oplput(-\the\op@count@v,0){\op@strikedecimalsepsymbol}%
        \fi}
      %\hbox{XXX\op@display{resultstyle}{qq}}
    }%
    \dimen0=\ht2
    \ifdim\dimen0>\ht3
      \ht3=\ht2
    \else
      \ht2=\ht3
    \fi
    \ifx\op@voperation\op@string@top
      \dimen0=\ht2
      \advance\dimen0 by-0.5\oplineheight
      \ht2=0.75\oplineheight
      \ht3=0.75\oplineheight
      \dp2=\dimen0
      \dp2=\dimen0
    \fi
    \setbox1=\hbox{%
      \box2
      \kern0.5\opcolumnwidth
      \kern-0.5\op@hrulewidth
      \ifx\voperation\op@string@top
        KKK\vrule width\op@hrulewidth
      \else
        : %\vrule width\op@hrulewidth :@:
      \fi
      \kern0.5\opcolumnwidth
      \kern-0.5\op@hrulewidth
      \box3
      = \hbox{\op@display{resultstyle}{qq}}
    }%
    \ifx\op@voperation\op@string@center
      \setbox1=\hbox{$\vcenter{\box1}$}%
    \fi
    \leavevmode\box1
  \endgroup
}
\makeatother



\begin{document}   

\opdiv
[period=true,voperation=top,displayintermediary=all,decimalsepsymbol={,},shiftdecimalsep=none,maxdivstep=30]
{54.60}{28}

\end{document}
| improve this answer | |
  • Wow, thanks! Is it possible to adjust the spacing such that it would appear in usual math-mode like in $54,6 : 28 = 1,95$? – Anna Apr 22 '13 at 15:23
  • @Anna hey I was quite pleased I managed to find my way round there at all, I hadn't seem the package before:-) Clearly it would be possible but probably harder than I want especially as there is a comment: ` In this package version, the division is the ``french'' one, which is more or less used as it in some other countries. The \package{xlop} package v. 0.3 will allow ''english'' division (and many more features).` so it may be worth simply asking the author if this feature is on the planned list.... – David Carlisle Apr 22 '13 at 15:31
  • @Anna The problem is I just added the : where previously there was a vertical rule, so it is spaced as if for the rule, to do more would require restructuring a lot more of the code. – David Carlisle Apr 22 '13 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.