How to place carried numbers in the French division algorithm with xlop?

Here is a solution with TiKz that uses the stylization of digits allowed by xlop with operandstyle, remainderstyle parameters. To do this, I have adapted my given solution to the following question: Drawing a circle around the numbers in xlop package

With xlop, when the style of a digit is applied by a macro, the last argument (the digit to be stylized) is provided by xlop itself to this macro.

Thus, the macro is declared with 2 arguments, but only the first one is provided to its call, xlop itself providing the last one.

I created two macros:

  1. The first macro called \chiffre creates a node with TiKz, it has two arguments: first is its name, the second the digit to stylize itself;

  2. The second macro called \retenue places the carried number at the bottom left of the digit (as I learned to do myself), its first argument is the name of the digit, its second argument is the carried number.

The code is as follows:

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

\newcommand{\chiffre}[2]{\tikz[remember picture] \node[inner sep=0pt](#1){#2};}
\newcommand{\retenue}[2]{\tikz[remember picture,overlay] 
                          \node[inner sep=0pt,
                                outer sep=2pt,
                                anchor=north east,
                                font=\tiny]at(#1){#2} ;}

\begin{document} 
\opidiv[dividendbridge,
        operandstyle.1.3=\chiffre{a},
        remainderstyle.1.1=\chiffre{b},
        remainderstyle.2.1=\chiffre{c}]{11945}{47}
\retenue{a}{1}
\retenue{b}{4}
\retenue{c}{3}
\end{document}

Output:

retenue division à la française

Translated with www.DeepL.com/Translator


I didn't find a solution with xlop, but, since nobody answered yet, this is a manual workaround with tikzmark:

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

\begin{document} 

\tikzmark{mydiv}\opidiv[dividendbridge, columnwidth=1.1em]{11945}{47}
\begin{tikzpicture}[overlay,remember picture]
    \node[font=\tiny, shift={(2.3em,8.75ex)}] at (pic cs:mydiv)
    {1};
    \node[draw=red, shift={(2.6em,9ex)}, circle, thick, text width=6pt] at (pic cs:mydiv)
    {};
\end{tikzpicture}
\end{document}

enter image description here

Tags:

Xlop