% Licence    : Released under the LaTeX Project Public License v1.3c
% or later, see http://www.latex-project.org/lppl.txtf
\newcommand\EquaBaseLaurent[5][]{%type ax=d ou b=cx
  \useKVdefault[ClesEquation]%
  \setKV[ClesEquation]{#1}%
  \ifx\bla#2\bla%on teste si le paramètre #2 est vide:
  % si oui, on est dans le cas b=cx. Eh bien on échange :)
  % Mais attention si les deux paramètres a et c sont vides...
  \EquaBaseLaurent[#1]{#4}{0}{0}{#3}
  \else
  % si non, on est dans le cas ax=d
  \xintifboolexpr{#2==0}{%
    \xintifboolexpr{#5==0}{%
      L'équation $0\useKV[ClesEquation]{ELettre}=0$ a une infinité de solutions.}{L'équation $0\useKV[ClesEquation]{Lettre}=\num{#5}$ n'a aucune solution.}%
  }{%\else
    \xintifboolexpr{#5==0}{L'équation $\num{#2}\useKV[ClesEquation]{Lettre}=0$ a une unique solution : $\useKV[ClesEquation]{Lettre}=0$.}{%\else
      \begin{align*}%
        \xintifboolexpr{#2==1}{\useKV[ClesEquation]{Lettre}}{\color{Cdecomp}\frac{\cancel{\color{black}\num{#2}}\color{black}\useKV[ClesEquation]{Lettre}}{\cancel{\num{#2}}}}&=\xintifboolexpr{#2==1}{\num{#5}}{\color{Cdecomp}\frac{\color{black}\num{#5}}{\num{#2}}}
        \xintifboolexpr{#2==1}{}{\\\useKV[ClesEquation]{Lettre}&=\frac{\num{#5}}{\num{#2}}}%\\
        %% decimal
        \ifboolKV[ClesEquation]{Decimal}{%
        \\\useKV[ClesEquation]{Lettre}&=\num{\fpeval{#5/#2}}%
                                        }{}%
%                                        %%%
        \ifboolKV[ClesEquation]{Entier}{%
        \SSimpliTest{#5}{#2}%
        \ifboolKV[ClesEquation]{Simplification}{%
        \ifthenelse{\boolean{Simplification}}{\\\useKV[ClesEquation]{Lettre}&=\SSimplifie{#5}{#2}}{}%\\
        }{}
        }{}
      \end{align*}
      \xdef\Coeffa{#2}%
      \xdef\Coeffb{#5}%
      \ifboolKV[ClesEquation]{Solution}{\EcrireSolutionEquation{#2}{#3}{#4}{#5}}{}%
    }
  }
  \fi
}

\newcommand\EquaDeuxLaurent[5][]{%type ax+b=d ou b=cx+d$
  \useKVdefault[ClesEquation]%
  \setKV[ClesEquation]{#1}%
  \ifx\bla#2\bla%On échange en faisant attention à ne pas boucler : c doit être non vide
  \EquaDeuxLaurent[#1]{#4}{#5}{#2}{#3}
  \else%cas ax+b=d
  \xintifboolexpr{#2==0}{%
    \xintifboolexpr{#3==#5}{%b=d
      L'équation $\num{#3}=\num{#5}$ a une infinité de solutions.}%
    {%b<>d
      L'équation $\num{#3}=\num{#5}$ n'a aucune solution.%
    }%
  }{%ELSE
    \xintifboolexpr{#3==0}{%ax+b=d
      \EquaBaseLaurent[#1]{#2}{0}{0}{#5}%
    }{%ax+b=d$ Ici
      \begin{align*}
        \xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#3>0}{+\num{#3}\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#3} {}}\stackText}{-\num{\fpeval{0-#3}}\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#3}} {}}\stackText}&=\num{#5}\xintifboolexpr{#3>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#3} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#3}} {}}\stackText}\\
        \xdef\Coeffa{#2}\xdef\Coeffb{\fpeval{#5-#3}}%\\
        \xintifboolexpr{\Coeffa==1}{\useKV[ClesEquation]{Lettre}}{\color{Cdecomp}\frac{\cancel{\color{black}\num{\Coeffa}}\color{black}\useKV[ClesEquation]{Lettre}}{\cancel{\num{\Coeffa}}}}&=\xintifboolexpr{\Coeffa==1}{\num{\Coeffb}}{\color{Cdecomp}\frac{\color{black}\num{\Coeffb}}{\num{\Coeffa}}}%\\
        \xintifboolexpr{\Coeffa==1}{}{\\}
        \xintifboolexpr{\Coeffa==1}{% 
        }{%\ifnum\cmtd>1
        \useKV[ClesEquation]{Lettre}&=\frac{\num{\Coeffb}}{\num{\Coeffa}}%\\
        %% decimal
        \ifboolKV[ClesEquation]{Decimal}{%
        \\\useKV[ClesEquation]{Lettre}&=\num{\fpeval{\Coeffb/\Coeffa}}%
                                        }{}%
                                        %%%
        \ifboolKV[ClesEquation]{Entier}{%
        \SSimpliTest{\Coeffb}{\Coeffa}%
        \ifboolKV[ClesEquation]{Simplification}{%
        \ifthenelse{\boolean{Simplification}}{\\\useKV[ClesEquation]{Lettre}&=\SSimplifie{\Coeffb}{\Coeffa}}{}%\\
        }{}
        }{}
        }
      \end{align*}
      \ifboolKV[ClesEquation]{Solution}{\EcrireSolutionEquation{#2}{#3}{#4}{#5}}{}%
    }
  }
}

\newcommand\EquaTroisLaurent[5][]{%ax+b=cx ou ax=cx+d
  \useKVdefault[ClesEquation]%
  \setKV[ClesEquation]{#1}%
  \ifx\bla#3\bla%on inverse en faisant attention à la boucle #3<->#5
    \ifx\bla#5\bla%
      %% paramètre oublié
    \else
      \EquaTroisLaurent[#1]{#4}{#5}{#2}{0}%
    \fi
  \else
  \xintifboolexpr{#2==0}{%b=cx
    \EquaBaseLaurent[#1]{#4}{0}{0}{#3}
  }{%
    \xintifboolexpr{#4==0}{%ax+b=0
      \EquaDeuxLaurent[#1]{#2}{#3}{0}{0}
    }{%ax+b=cx
      \xintifboolexpr{#2==#4}{%
        \xintifboolexpr{#3==0}{%ax=ax
          L'équation $\xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}$ a une infinité de solutions.}%
        {%ax+b=ax
          L'équation $\xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#3>0}{+\num{#3}}{-\num{\fpeval{0-#3}}}=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}$ n'a aucune solution.%
        }%
      }{%% Cas délicat
        \xintifboolexpr{#2>#4}{%ax+b=cx avec a>c
          \begin{align*}
            \xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#3==0}{}{\xintifboolexpr{#3>0}{+\num{#3}\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#3} {}}\stackText}{-\num{\fpeval{0-#3}}\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#3}} {}}\stackText}}&=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#3==0}{}{\xintifboolexpr{#3>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#3} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#3}} {}}\stackText}}\\
            \xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#4>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#4}\useKV[ClesEquation]{Lettre} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#4}}\useKV[ClesEquation]{Lettre} {}}\stackText}&=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#4>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#4}\useKV[ClesEquation]{Lettre} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#4}}\useKV[ClesEquation]{Lettre} {}}\stackText}\xintifboolexpr{#3==0}{}{\xintifboolexpr{#3>0}{-\num{#3}}{+\num{\fpeval{0-#3}}}}\\
            \xdef\Coeffa{\fpeval{#2-#4}}\xdef\Coeffb{\fpeval{0-#3}}%\\
            \xintifboolexpr{\Coeffa==1}{\useKV[ClesEquation]{Lettre}}{\color{Cdecomp}\frac{\cancel{\color{black}\num{\Coeffa}}\color{black}\useKV[ClesEquation]{Lettre}}{\cancel{\num{\Coeffa}}}}&=\xintifboolexpr{\Coeffa==1}{\num{\Coeffb}}{\color{Cdecomp}\frac{\color{black}\num{\Coeffb}}{\num{\Coeffa}}}%\\
            \xintifboolexpr{\Coeffa==1}{}{\\}
            \xintifboolexpr{\Coeffa==1}{% 
            }{%\ifnum\cmtd>1
            \useKV[ClesEquation]{Lettre}&=\frac{\num{\Coeffb}}{\num{\Coeffa}}%\\
            %% decimal
            \ifboolKV[ClesEquation]{Decimal}{%
            \\\useKV[ClesEquation]{Lettre}&=\num{\fpeval{\Coeffb/\Coeffa}}%
                                            }{}%
                                        %%%
            \ifboolKV[ClesEquation]{Entier}{%
            \SSimpliTest{\Coeffb}{\Coeffa}%
            \ifboolKV[ClesEquation]{Simplification}{%
            \ifthenelse{\boolean{Simplification}}{\\\useKV[ClesEquation]{Lettre}&=\SSimplifie{\Coeffb}{\Coeffa}}{}%\\
            }{}
            }{}
            }
          \end{align*}
          %\ifboolKV[ClesEquation]{Solution}{L'équation $\xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#3>0}{+\num{#3}}{-\num{\fpeval{0-#3}}}=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}$ a une unique solution : \opdiv*{\Coeffb}{\Coeffa}{solution}{resteequa}\opcmp{resteequa}{0}$\ifboolKV[ClesEquation]{LettreSol}{\useKV[ClesEquation]{Lettre}=}{}\displaystyle\ifopeq\opexport{solution}{\solution}\num{\solution}\else\ifboolKV[ClesEquation]{Entier}{\SSimplifie{\Coeffb}{\Coeffa}}{\frac{\num{\Coeffb}}{\num{\Coeffa}}}\fi$.}{}
        }{%ax+b=cx avec a<c              % Autre cas délicat
          \begin{align*}%
            \xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#4>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#4}\useKV[ClesEquation]{Lettre} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#4}}\useKV[ClesEquation]{Lettre} {}}\stackText}\xintifboolexpr{#3==0}{}{\xintifboolexpr{#3>0}{+\num{#3}}{-\num{\fpeval{0-#3}}}}&=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#4>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#4}\useKV[ClesEquation]{Lettre} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#4}}\useKV[ClesEquation]{Lettre} {}}\stackText}\\
            \xdef\Coeffa{\fpeval{#2-#4}}\xdef\Coeffb{\fpeval{0-#3}}%\\
            \xintifboolexpr{\Coeffa==1}{}{\num{\Coeffa}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#3==0}{}{\xintifboolexpr{#3>0}{+\num{#3}\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#3} {}}\stackText}{-\num{\fpeval{0-#3}}\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#3}} {}}\stackText}}&=0\xintifboolexpr{#3==0}{}{\xintifboolexpr{#3>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#3} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#3}} {}}\stackText}}\\
            \xintifboolexpr{\Coeffa==1}{\useKV[ClesEquation]{Lettre}}{\color{Cdecomp}\frac{\cancel{\color{black}\num{\Coeffa}}\color{black}\useKV[ClesEquation]{Lettre}}{\cancel{\num{\Coeffa}}}}&=\xintifboolexpr{\Coeffa==1}{\num{\Coeffb}}{\color{Cdecomp}\frac{\color{black}\num{\Coeffb}}{\num{\Coeffa}}}%\\
            \xintifboolexpr{\Coeffa==1}{}{\\}
            \xintifboolexpr{\Coeffa==1}{% 
            }{%\ifnum\cmtd>1
            \useKV[ClesEquation]{Lettre}&=\frac{\num{\Coeffb}}{\num{\Coeffa}}%\\
            %% decimal
            \ifboolKV[ClesEquation]{Decimal}{%
            \\\useKV[ClesEquation]{Lettre}&=\num{\fpeval{\Coeffb/\Coeffa}}%
                                        }{}%
                                        %%%
            \ifboolKV[ClesEquation]{Entier}{%
            \SSimpliTest{\Coeffb}{\Coeffa}%
            \ifboolKV[ClesEquation]{Simplification}{%
            \ifthenelse{\boolean{Simplification}}{\\\useKV[ClesEquation]{Lettre}&=\SSimplifie{\Coeffb}{\Coeffa}}{}%\\
            }{}
            }{}
            }
          \end{align*}
          %\ifboolKV[ClesEquation]{Solution}{L'équation $\xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#3>0}{+\num{#3}}{-\num{\fpeval{0-#3}}}=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}$ a une unique solution : \opdiv*{\Coeffb}{\Coeffa}{solution}{resteequa}\opcmp{resteequa}{0}$\ifboolKV[ClesEquation]{LettreSol}{\useKV[ClesEquation]{Lettre}=}{}\displaystyle\ifopeq\opexport{solution}{\solution}\num{\solution}\else\ifboolKV[ClesEquation]{Entier}{\SSimplifie{\Coeffb}{\Coeffa}}{\frac{\num{\Coeffb}}{\num{\Coeffa}}}\fi$.}{}%
        }%
        \ifboolKV[ClesEquation]{Solution}{\EcrireSolutionEquation{#2}{#3}{#4}{#5}}{}%
      }%
    }%
  }%
  \fi
}%

\newcommand\ResolEquationLaurent[5][]{%
  \useKVdefault[ClesEquation]%
  \setKV[ClesEquation]{#1}%
  \xintifboolexpr{#2==0}{%
    \xintifboolexpr{#4==0}{%
      \xintifboolexpr{#3==#5}{%b=d
        L'équation $\num{#3}=\num{#5}$ a une infinité de solutions.}%
      {%b<>d
        L'équation $\num{#3}=\num{#5}$ n'a aucune solution.%
      }%
    }%
    {%0x+b=cx+d
      \EquaDeuxLaurent[#1]{#4}{#5}{0}{#3}%
    }%
  }{%
    \xintifboolexpr{#4==0}{%ax+b=0x+d
      \EquaDeuxLaurent[#1]{#2}{#3}{0}{#5}%
    }
    {%ax+b=cx+d
      \xintifboolexpr{#3==0}{%
        \xintifboolexpr{#5==0}{%ax=cx
          \EquaTroisLaurent[#1]{#2}{0}{#4}{0}%
        }%
        {%ax=cx+d
          \EquaTroisLaurent[#1]{#4}{#5}{#2}{0}%
        }%
      }%
      {\xintifboolexpr{#5==0}{%ax+b=cx
          \EquaTroisLaurent[#1]{#2}{#3}{#4}{0}%
        }%
        {%ax+b=cx+d -- ici
          \xintifboolexpr{#2==#4}{%
            \xintifboolexpr{#3==#5}{%b=d
              L'équation $\xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#3>0}{+\num{#3}}{-\num{\fpeval{0-#3}}}=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#5>0}{+\num{#5}}{-\num{\fpeval{0-#5}}}$ a une infinité de solutions.}%
            {%b<>d
              L'équation $\xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#3>0}{+\num{#3}}{-\num{\fpeval{0-#3}}}=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#5>0}{+\num{#5}}{-\num{\fpeval{0-#5}}}$ n'a aucune solution.%
            }%
          }{%% Cas délicat
            \xintifboolexpr{#2>#4}{%ax+b=cx+d avec a>c
              \begin{align*}
                \xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#3>0}{+\num{#3}\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#3} {}}\stackText}{-\num{\fpeval{0-#3}}\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#3}} {}}\stackText}&=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#5>0}{+\num{#5}}{-\num{\fpeval{0-#5}}}\xintifboolexpr{#3>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#3} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#3}} {}}\stackText}\\
                \xdef\Coeffa{\fpeval{#2-#4}}\xdef\Coeffb{\fpeval{#5-#3}}%\\
                \xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#4>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#4}\useKV[ClesEquation]{Lettre} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#4}}\useKV[ClesEquation]{Lettre} {}}\stackText}&=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#4>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#4}\useKV[ClesEquation]{Lettre} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#4}}\useKV[ClesEquation]{Lettre} {}}\stackText}\xintifboolexpr{\Coeffb>0}{+\num{\Coeffb}}{-\num{\fpeval{0-\Coeffb}}}\\
                \xintifboolexpr{\Coeffa==1}{\useKV[ClesEquation]{Lettre}}{\color{Cdecomp}\frac{\cancel{\color{black}\num{\Coeffa}}\color{black}\useKV[ClesEquation]{Lettre}}{\cancel{\num{\Coeffa}}}}&=\xintifboolexpr{\Coeffa==1}{\num{\Coeffb}}{\color{Cdecomp}\frac{\color{black}\num{\Coeffb}}{\num{\Coeffa}}}%\\
                \xintifboolexpr{\Coeffa==1}{}{\\}
                \xintifboolexpr{\Coeffa==1}{% 
                }{%\ifnum\cmtd>1
                \useKV[ClesEquation]{Lettre}&=\frac{\num{\Coeffb}}{\num{\Coeffa}}%\\
                %% decimal
                \ifboolKV[ClesEquation]{Decimal}{%
                \\\useKV[ClesEquation]{Lettre}&=\num{\fpeval{\Coeffb/\Coeffa}}%
                                        }{}%
                                        %%%
                \ifboolKV[ClesEquation]{Entier}{%
                \SSimpliTest{\Coeffb}{\Coeffa}%
                \ifboolKV[ClesEquation]{Simplification}{%
                \ifthenelse{\boolean{Simplification}}{\\\useKV[ClesEquation]{Lettre}&=\SSimplifie{\Coeffb}{\Coeffa}}{}%\\
                }{}
                }{}
                }
              \end{align*}
              %\ifboolKV[ClesEquation]{Solution}{L'équation $\xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#3>0}{+\num{#3}}{-\num{\fpeval{0-#3}}}=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#5>0}{+\num{#5}}{-\num{\fpeval{0-#5}}}$ a une unique solution : \opdiv*{\Coeffb}{\Coeffa}{solution}{resteequa}\opcmp{resteequa}{0}$\ifboolKV[ClesEquation]{LettreSol}{\useKV[ClesEquation]{Lettre}=}{}\displaystyle\ifopeq\opexport{solution}{\solution}\num{\solution}\else\ifboolKV[ClesEquation]{Entier}{\SSimplifie{\Coeffb}{\Coeffa}}{\frac{\num{\Coeffb}}{\num{\Coeffa}}}\fi$.}{}
            }{%ax+b=cx+d avec a<c              % Autre cas délicat
              \begin{align*}%
                \xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#3>0}{+\num{#3}}{-\num{\fpeval{0-#3}}}\xintifboolexpr{#3>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#3} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#3}} {}}\stackText}%
                &=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#5>0}{+\num{#5}}{-\num{\fpeval{0-#5}}}\xintifboolexpr{#3>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#3} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#3}} {}}\stackText}
                \\
                \xdef\Coeffa{\fpeval{#2-#4}}\xdef\Coeffb{\fpeval{#5-#3}}%\\
                \xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#4>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#4}\useKV[ClesEquation]{Lettre} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#4}}\useKV[ClesEquation]{Lettre} {}}\stackText}&=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#4>0}{\stackMath\Longstack{$\tiny$\color{Cdecomp}-\num{#4}\useKV[ClesEquation]{Lettre} {}}\stackText}{\stackMath\Longstack{$\tiny$\color{Cdecomp}+\num{\fpeval{0-#4}}\useKV[ClesEquation]{Lettre} {}}\stackText}\xintifboolexpr{\Coeffb>0}{+\num{\Coeffb}}{-\num{\fpeval{0-\Coeffb}}}\\
                \xintifboolexpr{\Coeffa==1}{\useKV[ClesEquation]{Lettre}}{\color{Cdecomp}\frac{\cancel{\color{black}\num{\Coeffa}}\color{black}\useKV[ClesEquation]{Lettre}}{\cancel{\num{\Coeffa}}}}&=\xintifboolexpr{\Coeffa==1}{\num{\Coeffb}}{\color{Cdecomp}\frac{\color{black}\num{\Coeffb}}{\num{\Coeffa}}}%\\
                \xintifboolexpr{\Coeffa==1}{}{\\}
                \xintifboolexpr{\Coeffa==1}{% 
                }{%\ifnum\cmtd>1
                \useKV[ClesEquation]{Lettre}&=\frac{\num{\Coeffb}}{\num{\Coeffa}}%\\
                %% decimal
                \ifboolKV[ClesEquation]{Decimal}{%
                \\\useKV[ClesEquation]{Lettre}&=\num{\fpeval{\Coeffb/\Coeffa}}%
                                                }{}%
                                        %%%
                \ifboolKV[ClesEquation]{Entier}{%
                \SSimpliTest{\Coeffb}{\Coeffa}%
                \ifboolKV[ClesEquation]{Simplification}{%
                \ifthenelse{\boolean{Simplification}}{\\\useKV[ClesEquation]{Lettre}&=\SSimplifie{\Coeffb}{\Coeffa}}{}%\\
                }{}
                }{}
                }
              \end{align*}
              %\ifboolKV[ClesEquation]{Solution}{L'équation $\xintifboolexpr{#2==1}{}{\num{#2}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#3>0}{+\num{#3}}{-\num{\fpeval{0-#3}}}=\xintifboolexpr{#4==1}{}{\num{#4}}\useKV[ClesEquation]{Lettre}\xintifboolexpr{#5>0}{+\num{#5}}{-\num{\fpeval{0-#5}}}$ a une unique solution : \opdiv*{\Coeffb}{\Coeffa}{solution}{resteequa}\opcmp{resteequa}{0}$\ifboolKV[ClesEquation]{LettreSol}{\useKV[ClesEquation]{Lettre}=}{}\displaystyle\ifopeq\opexport{solution}{\solution}\num{\solution}\else\ifboolKV[ClesEquation]{Entier}{\SSimplifie{\Coeffb}{\Coeffa}}{\frac{\num{\Coeffb}}{\num{\Coeffa}}}\fi$.}{}%
            }%
            \ifboolKV[ClesEquation]{Solution}{\EcrireSolutionEquation{#2}{#3}{#4}{#5}}{}%
          }%
        }%
      }%
    }%
  }%
}%