% Author     : Christophe Poulain
% licence    : Released under the LaTeX Project Public License v1.3c
% or later, see http://www.latex-project.org/lppl.txtf
\NeedsTeXFormat{LaTeX2e}%
\def\filedate{2026/05/25}%
\let\PfCfiledate\filedate%
\def\fileversion{1.00-b}%
\let\PfCfileversion\fileversion%
\ProvidesPackage{ProfCollege}[\filedate\space v\fileversion\space Utiliser LaTeX au college]%

\RequirePackage{verbatim}%

\RequirePackage{mathtools}%

\newif\if@shellescape \@shellescapetrue%
\newif\if@amssymb \@amssymbtrue%
\newif\if@full \@fulltrue

\newif\ifPfCPfMScratchDys
\PfCPfMScratchDysfalse
%
\newif\ifPfCDeuxColonnes
\if@twocolumn
  \PfCDeuxColonnestrue
\fi
%
\newif\if@Euro \@Eurotrue
\newif\if@CFA \@CFAfalse
\newif\if@CFP \@CFPfalse
\newif\if@CHF \@CHFfalse
\newif\if@US \@USfalse
\newif\if@UK \@UKfalse

\DeclareOption{CFA}{\@Eurofalse\@CFAtrue}%
\DeclareOption{CFP}{\@Eurofalse\@CFPtrue}%
\DeclareOption{CHF}{\@Eurofalse\@CHFtrue}%
\DeclareOption{UK}{\@Eurofalse\@UKtrue}%
\DeclareOption{US}{\@Eurofalse\@UStrue}%
%
\DeclareOption{nonshellescape}{\@shellescapefalse}%
\DeclareOption{nonamssymb}{\@amssymbfalse}%
\DeclareOption{nonfull}{\@fullfalse}%
\ProcessOptions\relax%

\if@amssymb%
  \RequirePackage{amssymb}%
\fi%
\RequirePackage{shellesc}
% mathématiques
\RequirePackage{siunitx}%
\sisetup{%
  locale=FR,mode = match,
  propagate-math-font = true,%
  reset-math-version = false, reset-text-family = false,%
  reset-text-series = false, reset-text-shape = false,%
  text-family-to-math = true, text-series-to-math = true,%
  output-decimal-marker={,},%
  group-minimum-digits=4,%
  quantity-product={~}%
}%
\DeclareSIUnit{\kmh}{\km\per\hour}%
\newcommand\speed[1]{\SI{#1}{\kmh}}%
\newcommand\Speed[1]{\SI[per-mode=symbol]{#1}{\kmh}}%

\DeclareSIUnit{\are}{a}%
\DeclareSIUnit{\annee}{an}%
\DeclareSIUnit{\mois}{mois}%
\DeclareSIUnit{\jour}{j}%
\DeclareSIUnit{\quintal}{q}%
\DeclareSIUnit{\octet}{o}%
\DeclareSIUnit{\fahrenheit}{\text{\textdegree}F}%
\DeclareSIUnit{\EuRo}{€}%
\DeclareSIUnit{\Dollar}{\$}%
\DeclareSIUnit{\LivreSterling}{£}%
\DeclareSIUnit{\PfCCFA}{F.C.F.A.}%
\DeclareSIUnit{\PfCCFP}{F.C.F.P.}%
\DeclareSIUnit{\PfCCHF}{CHF}%

%
\if@CFA%
  \DeclareSIUnit{\DeviseDefaut}{F.C.F.A.}%
\fi%
\if@CFP%
  \DeclareSIUnit{\DeviseDefaut}{F.C.F.P.}%
\fi%
\if@CHF%
  \DeclareSIUnit{\DeviseDefaut}{CHF}%
\fi%
\if@Euro%
  \DeclareSIUnit{\DeviseDefaut}{€}%
\fi%
\if@US%
  \DeclareSIUnit{\DeviseDefaut}{\Dollar}%
\fi%
\if@UK%
  \DeclareSIUnit{\DeviseDefaut}{\LivreSterling}%
\fi%

\RequirePackage[table,svgnames]{xcolor}%Gestion des couleurs

\definecolor{PfCdblue}{HTML}{4477AA}%
\definecolor{PfCdcyan}{HTML}{66CCEE}%
\definecolor{PfCdgreen}{HTML}{228833}%
\definecolor{PfCdyellow}{HTML}{CCBB44}%
\definecolor{PfCdred}{HTML}{EE6677}%
\definecolor{PfCdpurple}{HTML}{AA3377}%
\definecolor{PfCdgray}{HTML}{BBBBBB}%

\RequirePackage{xstring}%Gestion de chaines de caractères
\RequirePackage{simplekv}%Gestion de paramètres sous forme de clés
\def\ifempty#1{\csname @\ifcat\relax\detokenize{#1}\relax first\else second\fi oftwo\endcsname}
\RequirePackage{ifthen}%
\RequirePackage{modulus}%Pour certains calculs arithmétiques.
\RequirePackage{xinttools}%Pour la création dynamique d'un tableau

\RequirePackage{iftex}%

\ifluatex
  \RequirePackage{luacas}%
  \RequirePackage{luamplib}%
  \mplibtextextlabel{enable}%à partir de la v2.25 de mplibcode
  \everymplib{input PfCSvgnames; input PfCConstantes; input PfCGeometrie; input PfCAfficheur; beginfig(1);}%
  \everyendmplib{endfig;}%
\fi

\RequirePackage{xintexpr}%
\RequirePackage{listofitems}%
\RequirePackage{datatool}%
\RequirePackage{readarray}%
\RequirePackage{multirow}%
\RequirePackage{multido}%
\RequirePackage{xlop}%

\RequirePackage{tcolorbox}%
\tcbuselibrary{breakable,external,fitting,hooks,magazine,poster,raster,skins,theorems,listings,listingsutf8}

\RequirePackage{tikz}%
% https://tex.stackexchange.com/questions/349259/curved-arrow-describing-a-step-in-a-equation-derivation
%https://tex.stackexchange.com/questions/58656/best-way-to-draw-a-chevron-diagram-using-tikz
\usetikzlibrary{calc,shapes,arrows,tikzmark,chains,positioning,shapes.symbols,babel,fit,backgrounds}%

%\RequirePackage{suffix}%pour la commande étoilée

\RequirePackage{multicol}%

\RequirePackage{hhline}%

\RequirePackage{stackengine}%
\RequirePackage[thicklines]{cancel}%

\RequirePackage{fontawesome5}%
\RequirePackage{pifont}%Pour la commande \Autonomie
\RequirePackage{nicematrix}%
\NiceMatrixOptions{allow-duplicate-names}%

\let\myoldmulticolumn\multicolumn%
\AtBeginEnvironment{tabular}{\let\multicolumn\myoldmulticolumn}%

%\RequirePackage{multirow}%
\RequirePackage{longtable}

\RequirePackage{fmtcount}%
\FCloadlang{french}%

% https://stackoverflow.com/questions/3391103/how-to-make-the-grayed-round-box-using-tiks
% \RequirePackage{environ}%

\RequirePackage{stringstrings}

%%%%% Quelques besoins particuliers

\def\bla{}%JCC :) Pour les tests sur arguments vides

% Pb ProfCollege<->Chinois soulev\'e par Denis
% Solution by egreg :)
\newcommand\getstrut[1]{%
  \the\expandafter#1\expanded{\strutbox}%
}%

% Colorer uniquement la barre de soulignement
% https://tex.stackexchange.com/questions/9466/color-underline-a-formula/153884
\def\mathunderline#1#2{\color{#1}\underline{{\color{black}#2}}\color{black}}%

% Ecrire des lignes d'équations
\def\Eqalign#1{\null\,\vcenter{\openup\jot\m@th\ialign{%
      \strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil%
      &&\quad\strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$%
      \hfil\crcr #1\crcr}}\,}%

%%% 
% Commandes "utiles"
%%%
\NewDocumentCommand\NumMA{m}{%
  \xintifboolexpr{#1<0}{%
    (\num{#1})%
  }{%
    \num{#1}%
  }%
}%

\NewDocumentCommand\NumS{m}{%
  \xintifboolexpr{#1==0}{}{\xintifboolexpr{#1>0}{+\num{#1}}{\num{#1}}}%
}%

\newcounter{Marque}
\newcounter{PfCTrash}
\newcounter{PfCTrasha}

\NewDocumentCommand\AffichageTab{O{x}mmm}{%
  \ifnum#2=0\relax%
    \ifnum#3=0\relax%
      \ifnum#4=0\relax%
      \else%
        #4%
      \fi%
    \else%
      \ifnum#3=1\relax%
      \else%
        #3*#1%
      \fi%
      \ifnum#4=0\relax%
      \else%
        \ifnum#4<0\relax%
          #4%
        \else%
          +#4%
        \fi%
      \fi%
    \fi%
  \else%
    \ifnum#2=1\else#2*\fi#1*#1%
    \ifnum#3=0\relax%
      \ifnum#4=0\relax%
      \else%
        \ifnum#4<0%
          #4%
        \else%
          +#4%
        \fi%
      \fi%
    \else%
      \ifnum#3<0%
        \ifnum#3=-1\relax
          -%
        \else
          #3*#1%
        \fi%
      \else%
        +\ifnum#3=1\relax%
        \else%
          #3*%
        \fi%
        #1%
      \fi%
      \ifnum#4=0\relax%
      \else%
        \ifnum#4<0%
          #4%
        \else%
          +#4%
        \fi%
      \fi%
    \fi%
  \fi%
}%
%encadrer avec des "sommets arrondis"
%\newsavebox{\logobox}%

\newcommand\Logo[2]{%
\setbox1=\hbox{\includegraphics[scale=#2]{#1}}%
\begin{tikzpicture}%
\clip[rounded corners=5mm] (0,0) rectangle (\wd1,\ht1);%
\node[xshift=0.5\wd1, yshift=0.5\ht1, inner xsep=0pt, inner ysep=0pt] (box) {%
\includegraphics[scale=#2]{#1}%
};%
\end{tikzpicture}%
}%

\newcommand\LogoTW[2]{%
\setbox1=\hbox{\includegraphics[scale=#2]{#1}}%
\begin{tikzpicture}%
  \clip (0,0) circle (4mm);%
  \draw (0,0) circle (4mm);%
  \node[xshift=0mm, yshift=0mm, inner xsep=0pt, inner ysep=0pt] (0,0) {%
    \includegraphics[scale=#2]{#1}%
  };%
\end{tikzpicture}%
}%


%\makeatletter
\newlength{\LongBoitePoint}

\def\Suspensionfill{%
  \leavevmode%
  \cleaders\hb@xt@\LongBoitePoint{.}\hfill%
  \kern\z@%
}

\NewDocumentCommand\PointsSuspension{O{1}m}{%
  \setbox2=\hbox{.}%
  \setlength{\LongBoitePoint}{\wd2}%
  \ifx\bla#2\bla%
    \Suspensionfill%
  \else%
    \setbox1=\hbox{#2}%
    \StrLen{#2}[\LongueurPoints]%
    \ifmmode%
      \mathinner{%
        \xintFor* ##2 in {\xintSeq{1}{\fpeval{ceil(#1*\LongueurPoints)}}}\do{%
          .%
        }%
      }%
    \else%
      \xintFor* ##2 in {\xintSeq{1}{\fpeval{round(#1*\wd1/\wd2)}}}\do{%
        .%
      }%
    \fi%
  \fi%
}%

\NewDocumentCommand\Dotfill{}{%
\leavevmode%
\cleaders\hb@xt@.44em{\hss\xleaders\hrule width0.33em\hss}\hfill%
\kern\z@}%

\NewDocumentCommand\PfCdotover{}{\leavevmode\cleaders\hb@xt@ .22em{\hss $\cdot$\hss}\hfill\kern\z@}%
%\makeatother%

\NewDocumentCommand\pointilles{o}{%
  \IfNoValueTF{#1}{\Dotfill}{\makebox[#1]{\Dotfill}}%
}%

\NewDocumentCommand\PfCNbLignesRestantes{}{%
  \edef\measurepage{\dimexpr\pagegoal-\pagetotal\relax}%
  \xintifboolexpr{\fpeval{\the\measurepage}>\fpeval{\the\textheight}}{%
    \edef\measurepage{\dimexpr\textheight\relax}%
  }{}%
  \xdef\PfCResteLignes{\fpeval{trunc((\the\measurepage)/(\baselineskip),0)}}%
}%

\NewDocumentCommand\PfCLignesFinales{}{%
  \PfCNbLignesRestantes%
  \xintFor* ##1 in {\xintSeq {1}{\PfCResteLignes}}\do{%
    \pointilles\par%
  }%
}%

\NewDocumentCommand\Lignespointilles{m}{%
  \ifx\bla#1\bla%
    \par\PfCLignesFinales%
  \else%
    \xintifboolexpr{\fpeval{#1}>1}{%
      \xintFor* ##1 in {\xintSeq {1}{#1}}\do{%
        \pointilles\par%
      }%
    }{}%
  \fi
}%

\newlength{\PfCLongueurBarreHor}
\setKVdefault[PfCLigneCompleter]{Ecart=20pt,Couleurs=false,Couleur={}}%
\defKV[PfCLigneCompleter]{Couleur=\ifempty{#1}{}{\setKV[PfCLigneCompleter]{Couleurs}}}%

\NewDocumentCommand\ListeACompleter{som}{%
  \useKVdefault[PfCLigneCompleter]%
  \setKV[PfCLigneCompleter]{#2}%
  \ifboolKV[PfCLigneCompleter]{Couleurs}{\colorlet{PfCLC}{\useKV[PfCLigneCompleter]{Couleur}}}{}%
  \setlength{\PfCLongueurBarreHor}{\useKV[PfCLigneCompleter]{Ecart}}%
  \setsepchar{,}\reademptyitems%
  \readlist*\ListeTiti{#3}%
  \foreachitem\compteur\in\ListeTiti{%
    \itemtomacro\ListeTiti[\compteurcnt]\PfCCaractere%
    \StrChar{\PfCCaractere}{1}[\RetiensElmt]%
    \IfStrEq{\RetiensElmt}{!}{%
      \IfBooleanTF{#1}{%
        \ifboolKV[PfCLigneCompleter]{Couleurs}{\colorlet{saved}{.}\color{PfCLC}}{}\StrGobbleLeft{\PfCCaractere}{1}\ifboolKV[PfCLigneCompleter]{Couleurs}{\color{saved}}{}%
      }{%
        \hbox to \PfCLongueurBarreHor{\hrulefill}%
      }
    }{%
      \ListeTiti[\compteurcnt]%
    }%
    \ifnum\compteurcnt=\ListeTitilen\relax%
      .%
    \else%
      ,
    \fi%
  }%
}%

%https://tex.stackexchange.com/questions/128991/frac-or-inference-rule-with-dotted-line
\newcommand\PfCfrac[2]{%
\ooalign{$\genfrac{}{}{0pt}{0}{#1}{#2}$\cr\PfCdotover\cr}%
}%

\NewDocumentCommand\MultiCol{O{}+m+m}{%
  \setsepchar[*]{/}%
  \readlist*\ListeNombreCol{#2}%
  \setsepchar[*]{§}%
  \readlist*\ListeContenuCol{#3}%
  \xintFor* ##1 in {\xintSeq{1}{\ListeNombreCollen}}\do{%
    \itemtomacro\ListeContenuCol[##1]\PfMTexte
    \begin{minipage}[#1]{\ListeNombreCol[##1]\linewidth}%
      \PfMTexte
    \end{minipage}%
    \xintifboolexpr{##1<\ListeNombreCollen}{\hfill\vrule width \columnseprule\hfill}{}%
  }%
}%

\newcount\PfCrappeljour%

\newcommand\Demain{%
  \PfCrappeljour=\day\relax%
  \advance\day by 1\relax%
  \ifnum\month=1\relax%
  \ifnum\day>31\relax%
  \day=\numexpr1\relax%
  \advance\month by 1\relax%
  \today\relax%
  \advance\month by -1\relax%
  \else%
  \today\relax%
  \fi%
  \fi%
  \ifnum\month=2\relax%
  \ifnum\day>28\relax%
  \day=\numexpr1\relax%
  \advance\month by 1\relax%
  \today\relax%
  \advance\month by -1\relax%
  \else%
  \today\relax%
  \fi%
  \fi%
  \ifnum\month=3\relax%
  \ifnum\day>31\relax%
  \day=\numexpr1\relax%
  \advance\month by 1\relax%
  \today\relax%
  \advance\month by -1\relax%
  \else%
  \today\relax%
  \fi%
  \fi%
  \ifnum\month=4\relax%
  \ifnum\day>30\relax%
  \day=\numexpr1\relax%
  \advance\month by 1\relax%
  \today\relax%
  \advance\month by -1\relax%
  \else%
  \today\relax%
  \fi%
  \fi%
  \ifnum\month=5\relax%
  \ifnum\day>31\relax%
  \day=\numexpr1\relax%
  \advance\month by 1\relax%
  \today\relax%
  \advance\month by -1\relax%
  \else%
  \today\relax%
  \fi%
  \fi%
  \ifnum\month=6\relax%
  \ifnum\day>30\relax%
  \day=\numexpr1\relax%
  \advance\month by 1\relax%
  \today\relax%
  \advance\month by -1\relax%
  \else%
  \today\relax%
  \fi%
  \fi%
  \ifnum\month=7\relax%
  \ifnum\day>31\relax%
  \day=\numexpr1\relax%
  \advance\month by 1\relax%
  \today\relax%
  \advance\month by -1\relax%
  \else%
  \today\relax%
  \fi%
  \fi%
  \ifnum\month=8\relax%
  \ifnum\day>31\relax%
  \day=\numexpr1\relax%
  \advance\month by 1\relax%
  \today\relax%
  \advance\month by -1\relax%
  \else%
  \today\relax%
  \fi%
  \fi%
  \ifnum\month=9\relax%
  \ifnum\day>30\relax%
  \day=\numexpr1\relax%
  \advance\month by 1\relax%
  \today\relax%
  \advance\month by -1\relax%
  \else%
  \today\relax%
  \fi%
  \fi%
  \ifnum\month=10\relax%
  \ifnum\day>31\relax%
  \day=\numexpr1\relax%
  \advance\month by 1\relax%
  \today\relax%
  \advance\month by -1\relax%
  \else%
  \today\relax%
  \fi%
  \fi%
  \ifnum\month=11\relax%
  \ifnum\day>30\relax%
  \day=\numexpr1\relax%
  \advance\month by 1\relax%
  \today\relax%
  \advance\month by -1\relax%
  \else%
  \today\relax%
  \fi%
  \fi%
  \ifnum\month=12\relax%
  \ifnum\day>31\relax%
  \day=\numexpr1\relax%
  \advance\month by 1\relax%
  \today\relax%
  \advance\month by -1\relax%
  \else%
  \today\relax%
  \fi%
  \fi%
  \day=\the\PfCrappeljour\relax%
}

\newcommand\PfCListeCompte[2][black]{%By egreg dans doc de gmp
  \mplibforcehmode
  \begin{mplibcode}
    n:=#2 ; color fuzzy_color ; fuzzy_color:=#1 ;
    height := 5pt ;
    span := 1/3 * height ;
    drift := 1/10 * height ;
    hsize := .7\mpdim{\linewidth} ;
    vstep := 10pt ;
    xmax := hsize div 5span ;
    pickup pencircle scaled (1/12 * height) ;
    def d = (uniformdeviate drift) enddef ;
    for i := 1 upto n :
      xpos := ((i-1) mod (5*xmax))*span ;
      ypos := ((i-1) div (5*xmax))*vstep ;
    draw
    if (i mod 5)=0 : ((-d-4.5span,d)--(+d-0.5span,height-d))
    else : ((-d,+d)--(+d,height-d)) fi
    shifted (xpos,-ypos+d-drift) withcolor fuzzy_color ;
    endfor;
    picture cp ;
    cp := currentpicture ; % for readability
    if (ypart ulcorner cp - ypart llcorner cp) <= vstep :
      setbounds currentpicture to
      (llcorner cp shifted (0,-ypart llcorner cp) --
      lrcorner cp shifted (0,-ypart lrcorner cp) --
      urcorner cp -- ulcorner cp -- cycle) ;
    fi
  \end{mplibcode}
}%

\NewDocumentCommand\MelangeLettres{smm}{%
  % #2 Nombre d'éléments à conserver
  % #3 Nom de la commande qui reçoit la liste.
  \setsepchar{,}\ignoreemptyitems%
  \readlist*\ListeInter{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z}%
  \xdef\faa{}% Liste construite
  \xdef\fii{}% Liste détruite
  \IfBooleanTF{#1}{%
    \xintFor* ##1 in {\xintSeq{1}{#2}}\do{%
      \xintifboolexpr{\ListeInterlen>1}{%
        \xdef\Alea{\fpeval{randint(\ListeInterlen)}}%
        \xdef\faa{\faa\ListeInter[\Alea],}%
        \xdef\fii{}%
        \xintFor* ##2 in {\xintSeq{1}{\ListeInterlen}}\do{%
          \xintifboolexpr{##2 == \Alea}{%
          }{%
            \xdef\fii{\fii \ListeInter[##2],}%
          }%
        }%
      }{%
        \xdef\faa{\faa\ListeInter[1]}%
      }%
      \readlist*\ListeInter{\fii}%
    }%
  }{%
    \xintFor* ##1 in {\xintSeq{1}{#2}}\do{%
      \xintifboolexpr{\ListeInterlen>1}{%
        \xdef\Alea{\fpeval{randint(\ListeInterlen)}}%
        \xdef\faa{\faa\ListeInter[\Alea]}%
        \xdef\fii{}%
        \xintFor* ##2 in {\xintSeq{1}{\ListeInterlen}}\do{%
          \xintifboolexpr{##2 == \Alea}{%
          }{%
            \xdef\fii{\fii \ListeInter[##2],}%
          }%
        }%
      }{%
        \xdef\faa{\faa\ListeInter[1]}%
      }%
      \readlist*\ListeInter{\fii}%
    }%
  }%
  \xdef#3{\faa}%
}%

\NewDocumentCommand\MelangeListe{smm}{%
  \IfBooleanTF{#1}{%
    %Si on cherche un seul élément, on peut l'utiliser directement 
    \MelangeListeOne{#2}{#3}%
  }{%
    \MelangeListeNoOne{#2}{#3}%
  }%
}

\NewDocumentCommand\MelangeListeOne{mm}{%
  % #1 Liste à mélanger
  % #2 Nombre d'éléments à conserver
  \setsepchar{,}\ignoreemptyitems%
  \readlist*\ListeInter{#1}%
  \xdef\faa{}% Liste construite
  \xdef\fii{}% Liste détruite
  % on crée les #2 premieres solutions.
  \xintFor* ##1 in {\xintSeq{1}{#2}}\do{%
    \xintifboolexpr{\ListeInterlen>1}{%
      \xdef\Alea{\fpeval{randint(\ListeInterlen)}}%
      \ifnum\fpeval{##1}=1\relax
        \xdef\faa{\ListeInter[\Alea]}%
      \else
        \xdef\faa{\faa,\ListeInter[\Alea]}%
      \fi
      \xdef\fii{}%
      \xintFor* ##2 in {\xintSeq{1}{\ListeInterlen}}\do{%
        \xintifboolexpr{##2 == \Alea}{%
        }{%
          \xdef\fii{\fii \ListeInter[##2],}%
        }%
      }%
    }{%
      \xdef\faa{\faa,\ListeInter[1]}%
    }%
    \readlist*\ListeInter{\fii}%
  }%
  \reademptyitems%
}%

\NewDocumentCommand\MelangeListeNoOne{mm}{%
  % #1 Liste à mélanger
  % #2 Nombre d'éléments à conserver
  \setsepchar{,}\ignoreemptyitems%
  \readlist*\ListeInter{#1}%
  \xdef\faa{}% Liste construite
  \xdef\fii{}% Liste détruite
  % on crée les #2 premieres solutions.
  \xintFor* ##1 in {\xintSeq{1}{#2}}\do{%
    \xintifboolexpr{\ListeInterlen>1}{%
      \xdef\Alea{\fpeval{randint(\ListeInterlen)}}%
      \xdef\faa{\faa \ListeInter[\Alea],}%
      \xdef\fii{}%
      \xintFor* ##2 in {\xintSeq{1}{\ListeInterlen}}\do{%
        \xintifboolexpr{##2 == \Alea}{%
        }{%
          \xdef\fii{\fii \ListeInter[##2],}%
        }%
      }%
    }{%
      \xdef\faa{\faa \ListeInter[1]}%
    }%
    \readlist*\ListeInter{\fii}%
  }%
  \reademptyitems%
}%

\newcommand\MelangeListeNewTwo[2]{%
  % #1 Liste à mélanger
  % #2 Nombre d'éléments à conserver
  \setsepchar{,}\ignoreemptyitems%
  \readlist*\ListeInter{#1}%
%  \xdef\faa{}% Liste construite
  \xdef\fii{}% Liste détruite
  % on crée les #2 premieres solutions.
  \xintFor* ##1 in {\xintSeq{1}{#2}}\do{%
    \xintifboolexpr{\ListeInterlen>1}{%
      \xdef\Alea{\fpeval{randint(\ListeInterlen)}}%
      \ifnum\fpeval{##1}=1\relax
        \xdef\faa{\ListeInter[\Alea]}%
      \else
        \xdef\faa{\faa,\ListeInter[\Alea]}%
      \fi
      \xdef\fii{}%
      \xintFor* ##2 in {\xintSeq{1}{\ListeInterlen}}\do{%
        \xintifboolexpr{##2 == \Alea}{%
        }{%
          \xdef\fii{\fii \ListeInter[##2],}%
        }%
      }%
    }{%
      \xdef\faa{\faa \ListeInter[1]}%
    }%
    \readlist*\ListeInter{\fii}%
  }%
  \reademptyitems%
}%

%%%
% Smiley
%%% https://tex.stackexchange.com/questions/3695/smileys-in-latex/227226
\tikzset{face/.style={shape=circle,minimum size=4ex,shading=radial,outer sep=0pt, inner color=white!50!yellow,outer color= yellow!70!orange}}

\newcommand\emoticon[2][]{%
\scalebox{.5}{\begin{tikzpicture}%
\node[face,#1,draw,thick] (emoticon) {};%
%% The eyes are fixed.
\draw[fill=white] (-1ex,0ex) ..controls (-0.5ex,0.2ex)and(0.5ex,0.2ex)..(1ex,0.0ex) ..controls ( 1.5ex,1.5ex)and( 0.2ex,1.7ex)..(0ex,0.4ex) ..controls (-0.2ex,1.7ex)and(-1.5ex,1.5ex)..(-1ex,0ex)--cycle;
#2%
\end{tikzpicture}}%
}%

\newcommand\pupils{%
%% standard pupils
\fill[shift={(0.5ex,0.5ex)},rotate=80] (0,0) ellipse (0.3ex and 0.15ex);%
\fill[shift={(-0.5ex,0.5ex)},rotate=100] (0,0) ellipse (0.3ex and 0.15ex);}%

\def\RKsmallsmile{%
\emoticon{%
\pupils
%% mouth
\draw[thick] (-0.5ex,-1ex)..controls (-0.25ex,-1.25ex)and(0.25ex,-1.25ex)..(0.5ex,-1ex);
}%\emoticon
}%

\def\RKsmile{%
\emoticon{%
\pupils
\draw[thick] (-1ex,-1ex)..controls (-0.5ex,-1.5ex)and(0.5ex,-1.5ex)..(1ex,-1ex);
}%\emoticon
}%

\def\RKbigsmile{%
\emoticon{%
\pupils
%% mouth
\draw[thick] (-1.5ex,-0.5ex)..controls (-0.7ex,-1.7ex)and(0.7ex,-1.7ex)..(1.5ex,-0.5ex);
}%\emoticon
}%

\def\RKsad{%
\emoticon{%
%% pupils
\fill[shift={( 0.5ex,0.5ex)},rotate=90] (0,0) ellipse (0.3ex and 0.15ex);
\fill[shift={(-0.5ex,0.5ex)},rotate=90] (0,0) ellipse (0.3ex and 0.15ex);
%% mouth
\draw[thick] (-1ex,-1ex)..controls(-0.5ex,-0.5ex)and(0.5ex,-0.5ex)..(1ex,-1ex);
}%\emoticon
}%

\def\RKneutral{%
\emoticon{%
%% pupils
\fill[shift={( 0.5ex,0.5ex)},rotate=90] (0,0) ellipse (0.3ex and 0.15ex);
\fill[shift={(-0.5ex,0.5ex)},rotate=90] (0,0) ellipse (0.3ex and 0.15ex);
%% mouth
\draw[thick] (-0.5ex,-1ex)--(0.5ex,-1ex);
}%\emoticon
}%

\def\RKconfused{%
\emoticon{%
\pupils
%% mouth
\draw[thick] (-1ex,-0.75ex)--(1ex,-1.25ex);
}%\emoticon
}

\def\RKsexy{%
\emoticon{%
\pupils
%% mouth
\draw[very thick,red,line cap=round] (-1ex,-1ex)..controls (-0.5ex,-1.5ex)and(0.5ex,-1.5ex)..(1ex,-1ex);
%% eyelashes
\draw (0.60ex,1.20ex)--(0.60ex,1.60ex)
  (0.85ex,1.25ex)--(0.95ex,1.45ex)
  (1.00ex,1.00ex)--(1.20ex,1.10ex)
  (0.35ex,1.15ex)--(0.25ex,1.35ex)
  (-0.60ex,1.20ex)--(-0.60ex,1.60ex)
  (-0.85ex,1.25ex)--(-0.95ex,1.45ex)
  (-1.00ex,1.00ex)--(-1.20ex,1.10ex)
  (-0.35ex,1.15ex)--(-0.25ex,1.35ex);
}%\emoticon
}%

\def\RKangry{%
\emoticon{%
%% pupils
\fill[shift={( 0.5ex,0.5ex)},rotate=90] (0,0) ellipse (0.3ex and 0.15ex);%
\fill[shift={(-0.5ex,0.5ex)},rotate=90] (0,0) ellipse (0.3ex and 0.15ex);%
%% mouth
\draw[thick] (-1ex,-1ex)..controls(-0.5ex,-0.5ex)and(0.5ex,-0.5ex)..(1ex,-1ex);%
%% eyebrows
\draw[thick] (0.2ex,1.15ex)--(0.5ex,1.6ex)(-0.2ex,1.15ex)--(-0.5ex,1.6ex);%
}%\emoticon
}%

\def\RKlookup{%
\emoticon{%
%% pupils
\fill[shift={( 0.5ex,1.05ex)},rotate= 80] (0,0) ellipse (0.2ex and 0.2ex);
\fill[shift={(-0.5ex,1.05ex)},rotate=100] (0,0) ellipse (0.2ex and 0.2ex);
%% mouth
\draw[thick] (-1ex,-1ex)..controls(-0.5ex,-1.5ex)and(0.5ex,-1.5ex)..(1ex,-1ex);
}%\emoticon
}

\def\RKlookdown{%
\emoticon{%
%% pupils
\fill[shift={( 0.5ex,0.3ex)},rotate= 80] (0,0) ellipse (0.2ex and 0.2ex);
\fill[shift={(-0.5ex,0.3ex)},rotate=100] (0,0) ellipse (0.2ex and 0.2ex);
%% mouth
\draw[thick] (-1ex,-1ex)..controls(-0.5ex,-1.5ex)and(0.5ex,-1.5ex)..(1ex,-1ex);
}%\emoticon
}

\def\RKlookleft{%
\emoticon{%
%% pupils
\fill[shift={( 0.25ex,0.5ex)},rotate=100] (0,0) ellipse (0.3ex and 0.15ex);
\fill[shift={(-0.95ex,0.5ex)},rotate=100] (0,0) ellipse (0.3ex and 0.15ex);
%% mouth
\draw[thick] (-1ex,-1ex)..controls(-0.5ex,-1.5ex)and(0.5ex,-1.5ex)..(1ex,-1ex);
}%\emoticon
}

\def\RKlookright{%
\emoticon{%
%% pupils
\fill[shift={( 0.95ex,0.5ex)},rotate=80] (0,0) ellipse (0.3ex and 0.15ex);
\fill[shift={(-0.25ex,0.5ex)},rotate=80] (0,0) ellipse (0.3ex and 0.15ex);
%% mouth
\draw[thick] (-1.0ex,-1ex)..controls(-0.5ex,-1.5ex)and(0.5ex,-1.5ex)..(1ex,-1ex);
}%\emoticon
}

\def\RKblush{%
\emoticon{%
\pupils
%% mouth
\draw[thick] (-0.5ex,-1ex)..controls (-0.25ex,-1.25ex)and(0.25ex,-1.25ex)..(0.5ex,-1ex);
%% blush
\shade[shading=radial,inner color=white!50!red,outer color= yellow!80!orange] ( 1ex,-0.5ex) circle (0.4ex);
\shade[shading=radial,inner color=white!50!red,outer color= yellow!80!orange] (-1ex,-0.5ex) circle (0.4ex);
}%\emoticon
}

\def\RKalmostcrying{%
\emoticon{%
%% pupils
\fill[shift={( 0.5ex,0.5ex)},rotate=105] (0,0) ellipse (0.3ex and 0.15ex);
\fill[shift={(-0.5ex,0.5ex)},rotate= 75] (0,0) ellipse (0.3ex and 0.15ex);
%% mouth
\draw[thick] (-1ex,-1ex)..controls
(-0.5ex,-0.8ex)and(0.5ex,-0.8ex)..(1ex,-1ex);
}%\emoticon
}

\def\RKmartian{%
\emoticon[inner color=white!50!green,outer color=green!70!red]{%
\pupils
%% mouth
\draw[thick] (-1ex,-1ex)..controls
(-0.5ex,-1.5ex)and(0.5ex,-1.5ex)..(1ex,-1ex);
}%\emoticon
}

\def\RKdevilish{%
\raisebox{-0.6ex}[0ex][0ex]{%
\emoticon[inner color=white!50!red,outer color= red!70!red!90!black]{%
\pupils
%% mouth
\draw[thick,line cap=round] (-1ex,-1ex)..controls (-0.5ex,-1.5ex)and(0.5ex,-1.5ex)..(1ex,-1ex);
%% tail
\draw[line width=0.45ex,-stealth,black] (emoticon.330)--++(330:0.01ex)..controls (3ex,-3ex)and(3.5ex,1ex)..(4.25ex,-3ex);
\draw[line width=0.27ex,-stealth,red!90!black] (emoticon.330)--++(330:0.01ex)..controls (3ex,-3ex)and(3.5ex,1ex)..(4.22ex,-2.8ex);
%% horns
\draw[fill] (emoticon.80)..controls ( 0.6ex,2.4ex)..( 1ex,2.5ex)..controls ( 0.8ex,2.3ex)..(emoticon.70);
\draw[fill] (emoticon.100)..controls (-0.6ex,2.4ex)..(-1ex,2.5ex)..controls (-0.8ex,2.3ex)..(emoticon.110); 
\draw[thick] (0,0) circle (2ex);
}%\emoticon
}%\raisebox
}%

\setsepchar[*]{,*/}\ignoreemptyitems
\readlist*\ListeMateriaux{aluminium/'/2.7,chêne/e~/0.69,bouleau/e~/0.65,sapin/e~/0.45,polystyrène/e~/1.04,porcelaine/la/2.5,acier/'/7.85,cuivre/e~/8.92,fer/e~/7.86,or/'/19.3,argent/'/10.5,bronze/e~/8.4,plomb/e~/11.35,marbre/e~/2.75,laiton/e~/7.3,titane/e~/4.5,PVC/e~/1.38}
\setsepchar{,}\reademptyitems

%Internationalisation
\def\PfCSymbolTimes{\times}%
\def\PfCSymbolDiv{\div}%
%
\NewDocumentCommand\PfCChoixAleaMulti{mmmm}{%
  % #1 nombre de valeurs à choisir qui peut être supérieur au nombre de valeurs entières disponibles
  % #2 valeur minimale
  % #3 valeur maximale
  % #4 Nom de la liste qui récupère les données.
  \xdef\PfMMixFoo{\fpeval{randint(#2,#3)}}%
  \xintFor* ##1 in{\xintSeq{1}{\fpeval{#1-1}}}\do{%
    \xdef\PfMMixFoo{\PfMMixFoo,\fpeval{randint(#2,#3)}}%
  }%
  \xdef#4{\PfMMixFoo}%
}%
\NewDocumentCommand\PfCChoixAleaMultiMixRep{mmmmm}{%
  % #1 nombre de valeurs à choisir
  % #2 valeur minimale
  % #3 valeur maximale
  % #4 valeur à exclure
  % #5 Nom de la liste qui récupère les données.
  \xdef\PfCRetiensRetenues{}%
  \xdef\PfMMixFoo{#2,#3}%
  \xdef\PfMMixFooExclues{#4}%
  \setsepchar{,}\ignoreemptyitems%
  \readlist*\ListeValeursExclues{\PfMMixFooExclues}%
  \reademptyitems%
  \xintFor* ##1 in{\xintSeq{\fpeval{#2+1}}{\fpeval{#3-1}}}\do{%
    \xdef\PfCRetiensExclues{0}%
    \xintFor* ##2 in{\xintSeq{1}{\ListeValeursExclueslen}}\do{%
      \xintifboolexpr{##1==\ListeValeursExclues[##2]}{\xdef\PfCRetiensExclues{\fpeval{\PfCRetiensExclues+1}}}{}%
    }%
    \ifnum\fpeval{\PfCRetiensExclues}=0\relax%
      \xdef\PfMMixFoo{\PfMMixFoo,##1}%
    \fi%
  }%
  \xintFor* ##1 in {\xintSeq{1}{#1}}\do{%
    \MelangeListe*{\PfMMixFoo}{1}%
    \xdef\PfCRetiensRetenues{\PfCRetiensRetenues,\faa}%
  }%
  \xdef#5{\PfCRetiensRetenues}%
}%
\NewDocumentCommand\PfCChoixAleaMultiMix{mmmmm}{%
  % #1 nombre de valeurs à choisir
  % #2 valeur minimale
  % #3 valeur maximale
  % #4 valeur(s) exclue(s)
  % #5 Nom de la liste qui récupère les données.
  \ifx\bla#4\bla%
    \PackageWarning{ProfCollege}{Il faut définir au moins une valeur à exclure.}%
  \else%
    \xdef\PfMMixFoo{#2}%
    \setsepchar{,}\ignoreemptyitems%
    \xdef\PfMMixFooEx{#4}%
    \readlist*\ListeValeursExclues{\PfMMixFooEx}%
%    Les valeurs exclues sont \showitems\ListeValeursExclues[]\par
    \xintFor* ##1 in{\xintSeq{\fpeval{#2+1}}{#3}}\do{%
      \xdef\PfMMixFoo{\PfMMixFoo,##1}%
    }%
    \readlist*\ListeValeursRetenues{\PfMMixFoo}%
    % Les valeurs retenues sont \showitems\ListeValeursRetenues[]\par
    \xintFor* ##1 in{\xintSeq{1}{\ListeValeursExclueslen}}\do{%
      \xdef\PfMMixFoo{}%
      \xintFor* ##2 in{\xintSeq{1}{\ListeValeursRetenueslen}}\do{%
        \xintifboolexpr{\ListeValeursRetenues[##2]==\ListeValeursExclues[##1]}{}{%
          \xdef\PfMMixFoo{\PfMMixFoo,\ListeValeursRetenues[##2]}%
        }%
      }%
      \ignoreemptyitems%
      \readlist*\ListeValeursRetenues{\PfMMixFoo}%
    }%
    % Les valeurs retenues au final sont \showitems\ListeValeursRetenues[]\par
    \ifnum\ListeValeursRetenueslen=1\relax
      \xdef#5{\PfMMixFoo}
    \else
      \MelangeListe{\PfMMixFoo}{#1}%
      \xdef#5{\faa}%
    \fi
  \fi%
}%

\def\PfCieme{\up{e}\xspace}%from french.ldf

% On bloque la graine de fabrication des nombres aléatoires.
\ExplSyntaxOn
\cs_new_eq:NN \PfCGraineAlea \sys_gset_rand_seed:n
\cs_new_eq:NN \PfCGraineAAfficher \sys_rand_seed:

\NewDocumentCommand\PfCEnsemble{m}{%
  \clist_set:Nn \l_tmpa_clist {#1}
  \int_set:Nn \l_tmpa_int {\clist_count:N \l_tmpa_clist}
  \ensuremath{
    \left\{\int_step_inline:nn {\fpeval{\l_tmpa_int-1}} {
      \clist_item:Nn \l_tmpa_clist {##1}\,; 
    }\clist_item:Nn \l_tmpa_clist {\l_tmpa_int}
    \right\}
  }
}
\ExplSyntaxOff
%%%

\NewDocumentCommand\useprofcollib{m}{%
  \setsepchar{,}\ignoreemptyitems%
  \readlist*\ListeLibrairies{#1}%
  \reademptyitems%
  \xintFor* ##1 in{\xintSeq{1}{\ListeLibrairieslen}}\do{%
    \input{\ListeLibrairies[##1]}%
  }%
}%

\RequirePackage{PfCInfixRPN}

\if@full
  \input{PfCRepresentationTuile}%
  \input{PfCTableLacunaire}%
  \input{PfCSymboles}%
  \input{PfCMappy}%
  \input{PfCVerreDoseur}%
  \input{PfCLogoJO}%
  \input{PfCGestionScore}%
  \input{PfCQuatrido}%
  \input{PfCDivisionCourte}%
  \input{PfCBillet}%
  \input{PfCGuideAne}
  \input{PfCThMilieu}
  \input{PfCCompteurVoiture}
  \input{PfCGratteCiel}
  \input{PfCModeleBarreCumulatif}
  \input{PfCCeinture}
  \input{PfCBoiteADix}
  \input{PfCMonnaieEuro}
  \input{PfCMulEthiopie}
  \input{PfCIteration}
  \input{PfCSystemeImage}
  \input{PfCPanneauxRoutiers}
  \input{PfCAireSimple}
  \input{PfCDecompFrac}
  \input{PfCScrabble}
  \input{PfCLignesBrisees}
  \input{PfCPatternJeton}
  \input{PfCPointsBlancs}
  \input{PfCDeAJouer}
  \input{PfCBandeNumerique}
  \input{PfCBalance}
  \input{PfCOpCroisees}
  \input{PfCRullo}
  \input{PfCCheque}
  \input{PfCCalculsDetailles}
  \input{PfCTableauDoubleEntree}
  \input{PfCUrneProba}
  \input{PfCProbaFrequence}
  \input{PfCVisualisationMulDeci}
  \input{PfCArbreChiffre}
  \input{PfCAssemblagesSolides}
  \input{PfCTicketCaisse}
  \input{PfCRecyclage}
  \input{PfCDontCountDots}
  \input{PfCConversion}
  \input{PfCCritere}
  \input{PfCLego}
  \input{PfCJeton}
  \input{PfCDessinAlgo}
  \input{PfCBonbon}
  \input{PfCPattern}
  \input{PfCNumerationsAnciennes}
  \input{PfCSerpent}
  \input{PfCFractionNombre}
  \input{PfCAllumettes}
  \input{PfCFractionAireCarre.tex}
  \input{PfCMulJal}
  \input{PfCCibleQOp}
  \input{PfCFubuki}
  \input{PfCMulJap}
  \input{PfCCryptarithme}
  \input{PfCDefiCalc}
  \input{PfCMulArt}
  \input{PfCGrimuku}
  \input{PfCHorloge}
  \input{PfCCible}
  \input{PfCMulPiecesPuzzle}
  \input{PfCPyraVoca}
  \input{PfCAutomatismes}
  \input{PfCNumberHive}
  \input{PfCPatronPaves}
  \input{PfCEratosthene}
  \input{PfCDobble}
  \input{PfCPavage}
  \input{PfCNonogramme}
  \input{PfCJeuRangement}
  \input{PfCTrio}
  \input{PfCCalculsFractions}
  \input{PfCDecDeci}
  \input{PfCKakurasu}
  \input{PfCMidpoint}
  \input{PfCGrades}
  \input{PfCSquaro}
  \input{PfCGaram}
  \input{PfCFutoshiki}
  \input{PfCRondeInfernale}
  \input{PfCHiddenMessage}
  \input{PfCPuzzleSommePyramide}
  \input{PfCCalisson}
  \input{PfCTectonic}
  \input{PfCEnigmeAire}
  \input{PfCBarresCalculs}
  \input{PfCSolides}
  \input{PfCVueCubes}
  \input{PfCRLE}
  \input{PfCEngrenagesBase}
  \input{PfCTortueBase}
  \input{PfCCompteBon}
  \input{PfCNombreAstral}
  \input{PfCMentalo}
  \input{PfCCalculsCroises}
  \input{PfCShikaku}
  \input{PfCKakuro}
  \input{PfCKenKen}
  \input{PfCPixelArt}
  \input{PfCYohaku}
  \input{PfCRose}
  \input{PfCPuissanceQuatre}
  \input{PfCBillard}
  \input{PfCRepresenterEntier}
  \input{PfCCAN}
  \input{PfCFrise}
  \input{PfCGeometrie}
  \input{PfCEnquete}
  \input{PfCModeleBarre}
  \input{PfCFicheMemo}
  \input{PfCOperationsTrou}
  \input{PfCCartographie}
  \input{PfCReseauxSociaux}
  \input{PfCBonSortie}
  \input{PfCEcritureLettres}
  \input{PfCDecompFracDeci}
  \input{PfCPyramideCalculs}
  \input{PfCTablesOperations}
  \input{PfCDefiTables}
  \input{PfCRangementNombres}
  \input{PfCMotsCodes}
  \input{PfCLabyrintheJeu}
  \input{PfCTriominos}
  \input{PfCLabyrintheNombre}
  \input{PfCMotsCroises}
  \input{PfCMotsEmpiles}
  \input{PfCColorilude}
  \input{PfCMosaique}
  \input{PfCQuiSuisJe}
  \input{PfCDessinGradue}
  \input{PfCAutonomie}
  \input{PfCCalculatrice}
  \input{PfCQuestionsFlash}
  \input{PfCRapido}
  \input{PfCRepresenterFraction}
  \input{PfCQuestionsRelier}
  \input{PfCEcrireunQCM}
  \input{PfCSommeAngles}
  \input{PfCPythagore}
  \input{PfCDistributivite}
  \input{PfCFactorisation}
  \input{PfCDecomposerNombrePremier}
  \input{PfCSimplifierFraction}
  \input{PfCThales}
  \input{PfCTrigonometrie}
  \input{PfCStatistiques}
  \input{PfCDiagrammeRadar}
  \input{PfCBarreNiveaux}
  \input{PfCResoudreEquation}
  \input{PfCPropor}
  \input{PfCPourcentage}
  \input{PfCDessinerRatio}
  \input{PfCCartesMentales}
  \input{PfCProprietesDroites}
  \input{PfCFonctionAffine}
  \input{PfCNotionFonction}
  \input{PfCRepresentationGraphique}
  \input{PfCRappelsFormules}
  \input{PfCProbabilites}
  \input{PfCReperage}
  \input{PfCEcritureUnites}
  \input{PfCTableauxUnites}
  \input{PfCCartesJeux}
  \input{PfCRepresenterTableur}
  \input{PfCDomino}
  \input{PfCProgrammeCalcul}
  \input{PfCPapiers}
  \input{PfCScratch}
  \input{PfCArbreCalcul}
\fi

%%%
% Puissances
%%%
\NewDocumentCommand\Puissances{mm}{%
  \ensuremath{%
    % \xintifboolexpr{#2==0}{1}{\xintifboolexpr{#2>0}{\ifnum#2=1\relax#1\else\xdef\TotalP{\fpeval{#2-1}}#1\xintFor* ##1 in{\xintSeq{1}{\TotalP}}\do{\times#1}\fi}{\xdef\TotalP{\fpeval{-#2-1}}\frac{1}{#1\xintFor* ##1 in{\xintSeq{1}{\TotalP}}\do{\times#1}}}}%
    \ifnum#2=0\relax%
      1%
    \else%
      \ifnum#2>0\relax%
        \xintFor* ##1 in{\xintSeq{1}{#2}}\do{%
          #1\xintifForLast{}{\times}%
        }%
      \else%
        \frac{1}{%
          \xintFor* ##1 in{\xintSeq{1}{\fpeval{abs(#2)}}}\do{%
            #1\xintifForLast{}{\times}%
          }%
        }%
      \fi%
    \fi%
  }%
}%

\newlength\PfCScratchHeight%
\newlength\PfCScratchDepth%

\settoheight{\PfCScratchHeight}{%
  ÉàÈÇABCDEFGHIJKLMNOPQRSTUVWXYZ%
  abcdefghijklmnopqrstuvwxyzàéèçùoôö%
}%
\settodepth{\PfCScratchDepth}{%
  ÉàÈÇABCDEFGHIJKLMNOPQRSTUVWXYZ%
  abcdefghijklmnopqrstuvwxyzàéèçùoôö%
}%

\NewDocumentCommand\EnLigne{sm}{%
  \IfBooleanTF{#1}{%
    \setbox1=\hbox{#2}%
    \xintifboolexpr{\fpeval{\ht1+\dp1}>\fpeval{\PfCScratchHeight+\PfCScratchDepth}}{%
      \raisebox{-\PfCScratchDepth}{\scalebox{\fpeval{(\PfCScratchHeight+\PfCScratchDepth)/(\ht1+\dp1)}}{\usebox1}}%
    }{%
      \raisebox{-\PfCScratchDepth}{#2}%
    }%
  }{%
    \raisebox{-0.5\height}{%
      #2
    }%
  }%
}%