diff options
author | Norbert Preining <norbert@preining.info> | 2023-08-01 03:01:19 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-08-01 03:01:19 +0000 |
commit | 84777905249300f2ab97a23141e31f952bceb865 (patch) | |
tree | 5621415ee6ecbcbe62e4c500977af3c41aeebd9c /macros | |
parent | 17d547a1effe2cafcdfbf704bdf8cb0484790ef2 (diff) |
CTAN sync 202308010301
Diffstat (limited to 'macros')
49 files changed, 3128 insertions, 522 deletions
diff --git a/macros/latex/contrib/caption/README b/macros/latex/contrib/caption/README index 3381d5b9eb..508a9a4d24 100644 --- a/macros/latex/contrib/caption/README +++ b/macros/latex/contrib/caption/README @@ -1,7 +1,7 @@ ========================================================================== The `caption' package bundle -Release 2023-07-28 +Release 2023-07-31 Copyright (C) 1994-2023 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm) License: LPPL = LaTeX Project Public Licence diff --git a/macros/latex/contrib/caption/caption.dtx b/macros/latex/contrib/caption/caption.dtx index 7f48c88b5a..8315f780b3 100644 --- a/macros/latex/contrib/caption/caption.dtx +++ b/macros/latex/contrib/caption/caption.dtx @@ -31,7 +31,7 @@ % % \fi % -% \CheckSum{2922} +% \CheckSum{2923} % % \iffalse %<*driver> @@ -4521,14 +4521,14 @@ % % Identify the current version of the package. % \begin{macrocode} -\ProvidesPackage{caption}[2023/07/28 v3.6m Customizing captions (AR)] +\ProvidesPackage{caption}[2023/07/31 v3.6n Customizing captions (AR)] % \end{macrocode} % % \subsection{Loading the kernel} % % Load a matching version of the \pkg{caption} kernel. % \begin{macrocode} -\RequirePackage{caption3}[2023/07/28] % needs v2.4c or newer +\RequirePackage{caption3}[2023/07/31] % needs v2.4d or newer % \end{macrocode} % % \subsection{Check against unknown document classes} @@ -6082,6 +6082,7 @@ % \begin{macro}{\caption@dblarg} % \changes{v3.1}{2007/02/05}{This macro added} % \changes{v3.3}{2012/03/25}{Support of option \opt{list-entry} added} +% \changes{v3.6n}{2023/07/31}{Only an empty list-entry will expand to \cs{relax}, otherwise it remains unchanged} % A |\relax| was added compared to |\@dblarg| so |\caption{}| will be % expanded to |\caption[\relax]{}| (and not to |\caption[]{}|). % Furthermore support for option \opt{list-entry} was added. @@ -6093,12 +6094,14 @@ % \end{macrocode} % \begin{macrocode} \newcommand\caption@xdblarg[2]{% - #1[{#2\relax}]{#2}} + \caption@iftokens{#2}{#1[{#2}]{#2}}{#1[\relax]{}}} % \end{macrocode} % \begin{macrocode} \long\def\caption@ydblarg#1[#2]#3{% \caption@iflistheading{#1[{#3}]{#3}}{#1[{#2}]{#3}}} % \end{macrocode} +% \begin{macrocode} +% \end{macrocode} % \end{macro} % % \begin{macro}{\caption@begin} diff --git a/macros/latex/contrib/caption/caption3.dtx b/macros/latex/contrib/caption/caption3.dtx index 9f3e21b296..be2a46ec67 100644 --- a/macros/latex/contrib/caption/caption3.dtx +++ b/macros/latex/contrib/caption/caption3.dtx @@ -31,7 +31,7 @@ % % \fi % -% \CheckSum{3865} +% \CheckSum{3853} % % \iffalse %<*driver> @@ -232,7 +232,7 @@ % % Identify the current version of the package. % \begin{macrocode} -\ProvidesPackage{caption3}[2023/07/28 v2.4c caption3 kernel (AR)] +\ProvidesPackage{caption3}[2023/07/31 v2.4d caption3 kernel (AR)] % \end{macrocode} % % \section{Generic helpers} @@ -586,6 +586,20 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\caption@iftokens} +% \changes{v2.4d}{2023/07/31}{This macro added} +% |\caption@iftokens|\marg{arg}\marg{yes-code}\marg{no-code}\\ +% This helper command checks if the given argument contains one or more tokens, i.e. is not empty. +% \begin{macrocode} +\newcommand\caption@iftokens[1]{% + \if\relax\detokenize{#1}\relax + \expandafter\@secondoftwo + \else + \expandafter\@firstoftwo + \fi} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\caption@AtBeginDocument} % \changes{v1.1}{2007/04/13}{This macro and its usage added} % \changes{v1.2e}{2010/01/09}{Adapted to the combine document class} @@ -1553,6 +1567,7 @@ % \changes{v1.3}{2010/11/07}{Support for option \opt{calcmargin} added} % \changes{v2.3}{2021/01/17}{Renamed from \cs{setcaptionmargin} to \cs{caption@setmargin}; sets \cs{caption@width} or \cs{caption@leftmargin} and \cs{caption@rightmargin} now} % \changes{v2.3}{2021/01/19}{Only the left or right margin can be set by leaving the other value blank} +% \changes{v2.4d}{2023/07/31}{Check for \cs{@empty} argument replaced by \cs{caption@iftokens}} % |\caption@setmargin*|\marg{amount}\\ % sets the caption margin to the given \meta{amount}. % \begin{macrocode} @@ -1571,20 +1586,14 @@ % \end{macrocode} % \begin{macrocode} \def\caption@@@@setmargin#1,#2,#3\@nil{% - \def\caption@tempa{#1#2}% - \ifx\caption@tempa\@empty - \caption@Error{Missing number}% - \else - \caption@@@@@setmargin{left}{#1}% - \caption@@@@@setmargin{right}{#2}% - \fi} + \caption@iftokens{#1#2}% + {\caption@@@@@setmargin{left}{#1}% + \caption@@@@@setmargin{right}{#2}}% + {\caption@Error{Missing number}}} % \end{macrocode} % \begin{macrocode} \newcommand*\caption@@@@@setmargin[2]{% - \def\caption@tempa{#2}% - \ifx\caption@tempa\@empty \else - \caption@setlength{#1margin}{#2}% - \fi} + \caption@iftokens{#2}{\caption@setlength{#1margin}{#2}}{}} % \end{macrocode} % \end{macro} % @@ -2307,17 +2316,13 @@ % \changes{v1.4}{2011/10/05}{Pre-defined text format `empty' added} % \changes{v1.7}{2015/09/16}{The text format `empty' now takes care of the \cs{label}} % \changes{v2.3}{2020/12/26}{Clearance of \cs{caption@thelabel} replaced by \cs{caption@clrlabel}} +% \changes{v2.4d}{2023/07/31}{Check for \cs{@empty} argument replaced by \cs{caption@iftokens}} % \begin{macrocode} \DeclareCaptionTextFormat{empty}{% \caption@get@label#1\caption@makeanchor{}\@nil \caption@thelabel\caption@clrlabel} \long\def\caption@get@label#1\caption@makeanchor#2#3\@nil{% - \def\caption@tempa{#2}% - \ifx\caption@tempa\@empty - \caption@getlabel{#1}% - \else - \caption@getlabel{#2}% - \fi} + \caption@iftokens{#2}{\caption@getlabel{#2}}{\caption@getlabel{#1}}} % \end{macrocode} % \begin{macrocode} \DeclareCaptionTextFormat{simple}{#1} @@ -4757,6 +4762,7 @@ % \changes{v1.13}{2020/07/29}{We don't re-use existing counters anymore (This was a bad idea anyway)} % \changes{v1.13b}{2022/04/06}{We don't re-use existing counters anymore (Part 2)} % \changes{v2.4}{2022/04/06}{If a counter is already defined the counter source will be included in the resulting error message} +% \changes{v2.4d}{2023/07/31}{Check for \cs{@empty} argument replaced by \cs{caption@iftokens}} % |\DeclareCaptionSubType*|\oarg{numbering scheme}\marg{type}\\ % The starred variant provides the numbering format % \meta{type}|.|\meta{subtype} while the non-starred variant simply uses @@ -4839,15 +4845,12 @@ % \end{macrocode} % \begin{macrocode} \long\def\caption@@@declaresublistentry#1\@dottedtocline#2\caption@nil#3{% - \def\@tempa{#1}% % Does \l@(sub)subsection start with \@dottedtocline? - \ifx\@tempa\@empty -% Yes - \caption@@@@declaresublistentry{#3}#2\caption@nil - \else + \caption@iftokens{#1}% % No - \caption@@@@declaresublistentry{#3}@{3.8em}{3.2em}\caption@nil - \fi} + {\caption@@@@declaresublistentry{#3}@{3.8em}{3.2em}\caption@nil}% +% Yes + {\caption@@@@declaresublistentry{#3}#2\caption@nil}} \@onlypreamble\caption@@@declaresublistentry % \end{macrocode} % \begin{macrocode} diff --git a/macros/latex/contrib/caption/captiondoc.cls b/macros/latex/contrib/caption/captiondoc.cls new file mode 100644 index 0000000000..39340af5fd --- /dev/null +++ b/macros/latex/contrib/caption/captiondoc.cls @@ -0,0 +1,121 @@ +%% +%% This is file `captiondoc.cls', +%% a common document class for all caption package bundle documentations. +%% +%% There is no need to distribute this file in tex/latex/caption since +%% it's of no use for the end-user, it's only needed to compile the package +%% documentations. +%% +%% Copyright (C) 2023 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm) +%% +%% https://gitlab.com/axelsommerfeldt/caption +%% +%% -------------------------------------------------------------------------- +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2003/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Axel Sommerfeldt. +%% +%% This work consists of the files +%% caption.ins, caption.dtx, caption-light.dtx, caption2.dtx, caption3.dtx, +%% caption-ams-smf.dtx, caption-beamer.dtx, caption-elsarticle.dtx, +%% caption-koma.dtx, caption-memoir.dtx, caption-ntg.dtx, +%% caption-thesis.dtx, bicaption.dtx, ltcaption.dtx, subcaption.dtx, +%% the derived files +%% caption.sty, caption-light.sty, caption2.sty, caption3.sty, +%% caption-ams-smf.sto, caption-beamer.sto, caption-elsarticle.sto, +%% caption-koma.sto, caption-memoir.sto, caption-ntg.sto, +%% caption-thesis.sto, bicaption.sty, ltcaption.sty, subcaption.sty. + +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{captiondoc}[2022/12/27 Document class used by caption documentation] + +\hbadness=9999 \newcount\hbadness \hfuzz=100pt % Make TeX shut up. + +\PassOptionsToPackage{breaklinks=true}{hyperref} + +\LoadClassWithOptions{ltxdoc} +\setlength\parindent{0pt} +\setlength\parskip{\smallskipamount} +\addtolength\marginparwidth{15pt} +\setlength\leftmargini{2em}% default = 2.5em + +\renewcommand\partname{Part} + +\RequirePackage{ifpdf} +\ifpdf + \RequirePackage{mathptmx,courier} + \RequirePackage[scaled=0.90]{helvet} +\fi + +\RequirePackage{hypdoc} +\ifpdf\RequirePackage{hypdestopt}\fi +\hypersetup{pdfstartpage={},pdfstartview={}} +\hypersetup{breaklinks=true} +\let\subsectionautorefname\sectionautorefname +\let\subsubsectionautorefname\sectionautorefname + +\DeclareRobustCommand*\eTeX{\leavevmode\hbox{$\varepsilon$}-\TeX} + +\DeclareRobustCommand*\AmS{\texorpdfstring + {{\protect\usefont{OMS}{cmsy}{m}{n}A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}% + {AMS}} +\DeclareRobustCommand*\KOMAScript{\textsf{K\kern.05em O\kern.05em M\kern.05em A\kern.1em-\kern.1em Script}} +\DeclareRobustCommand*\NTG{NTG} +\DeclareRobustCommand*\SmF{SMF} + +\newcommand*\NEWfeature{\NEW{New feature}} +\newcommand*\NEWdescription{\NEW{New description}} +\newcommand*\NEW[1]{\@ifstar{\@NEW{#1}{\vskip2pt}}{\@NEW{#1}{}}} +\newcommand*\@NEW[3]{\MARGINSYM{#2\footnotesize#1\\#3}} +\newcommand*\MARGINSYM[1]{\hskip 1sp \marginpar{\raggedleft\textcolor{blue}{{#1}}}} + +\newcommand*\LineBreak{\linebreak[3]} +\newcommand*\PageBreak{\pagebreak[3]} + +\newcommand*\longref{\@ifstar{\@longref\ref}{\@longref\autoref}} +\newcommand*\Longref{\@ifstar{\@longref\Ref}{\@longref\Autoref}} +\def\@longref#1#2{#1{#2}: \textit{\nameref{#2}}} + +\newcommand*\See[1]{\nopagebreak{\small (See #1)}} + +\newenvironment{Options}[1]% + {\list{}{\renewcommand\makelabel[1]{\texttt{##1}\hfil}% + \settowidth\labelwidth{\texttt{#1\space}}% + \setlength\leftmargin{10pt}% + \addtolength\leftmargin{\labelwidth}% + \addtolength\leftmargin{\labelsep}}}% + {\endlist} + +\newcommand*\purerm[1]{{\upshape\mdseries\rmfamily #1}} +\newcommand*\puresf[1]{{\upshape\mdseries\sffamily #1}} +\newcommand*\purett[1]{{\upshape\mdseries\ttfamily #1}} +\let\cls\puresf \let\pkg\puresf +\let\env\purett \let\opt\purett + +\newcommand*\csmarg[1]{\texttt{\char`\{#1\char`\}}} +\newcommand*\csoarg[1]{\texttt{\char`\[#1\char`\]}} +\newcommand*\issue[2][GitLab]{#1 issue~\##2} +\newcommand*\version[2][]{v$#2$} +\newcommand*\changenote[1]{} + +\RequirePackage{marvosym} +\newcommand*\INFO{\@ifstar{\@INFO{}}{\@INFO{\vbox to \ht\strutbox}}} +\newcommand*\@INFO[1]{\MARGINSYM{#1{\LARGE\Info}}} + +\RequirePackage[alpine]{ifsym} +\newenvironment{background}{\par\bigskip\csname background*\endcsname}{\csname endbackground*\endcsname} +\newenvironment{background*}{\small\MARGINSYM{\Mountain}\ignorespaces}{\par} + +\RequirePackage[bottom]{footmisc} + +\endinput + diff --git a/macros/latex/contrib/profcollege/doc/ProfCollege-doc.pdf b/macros/latex/contrib/profcollege/doc/ProfCollege-doc.pdf Binary files differindex 08d43af5fa..b804c418cc 100644 --- a/macros/latex/contrib/profcollege/doc/ProfCollege-doc.pdf +++ b/macros/latex/contrib/profcollege/doc/ProfCollege-doc.pdf diff --git a/macros/latex/contrib/profcollege/latex/LogoNumberHive.png b/macros/latex/contrib/profcollege/latex/LogoNumberHive.png Binary files differnew file mode 100644 index 0000000000..0ea4267931 --- /dev/null +++ b/macros/latex/contrib/profcollege/latex/LogoNumberHive.png diff --git a/macros/latex/contrib/profcollege/latex/PfCCalculatrice.tex b/macros/latex/contrib/profcollege/latex/PfCCalculatrice.tex index b6d70fe28e..79ffe0f582 100644 --- a/macros/latex/contrib/profcollege/latex/PfCCalculatrice.tex +++ b/macros/latex/contrib/profcollege/latex/PfCCalculatrice.tex @@ -110,10 +110,13 @@ \def\MPCalculatrice#1#2#3{ % #1 Calcul %2 r\'eponse \ifluatex + \mplibnumbersystem{double} \mplibforcehmode% \begin{mplibcode}% input PfCCalculatrice; LargeurEcran:=\useKV[ClesCalculatrice]{Largeur}; + boolean Calcul; + Calcul=\useKV[ClesCalculatrice]{Calcul}; LCD(#1)(#2)(#3); \end{mplibcode} \else @@ -123,15 +126,23 @@ \fi } -\setKVdefault[ClesCalculatrice]{Ecran=false,NbLignes=0,BL=0.775,Largeur=120} +\setKVdefault[ClesCalculatrice]{Ecran=false,NbLignes=0,BL=0.775,Largeur=120,Calcul=false} + +\newtoks\toklistenombrecalculatrice +\def\UpdatetoksCalculatrice#1\nil{\addtotok\toklistenombrecalculatrice{"\fpeval{#1}"}} \newcommand\Calculatrice[2][]{% \setstackgap{L}{\useKV[ClesCalculatrice]{BL}\baselineskip}% \useKVdefault[ClesCalculatrice]% \setKV[ClesCalculatrice]{#1}% \ifboolKV[ClesCalculatrice]{Ecran}{% - \setsepchar[*]{,*/}% - \readlist\ListeCalc{#2}% + \ifboolKV[ClesCalculatrice]{Calcul}{% + \setsepchar[*]{,*ยง}% + \readlist\ListeCalc{#2}% + }{% + \setsepchar[*]{,*/}% + \readlist\ListeCalc{#2}% + }% \MPCalculatrice{\ListeCalc[1,1]}{\ListeCalc[1,2]}{\useKV[ClesCalculatrice]{NbLignes}}% }{% \setsepchar[*]{,*/}% diff --git a/macros/latex/contrib/profcollege/latex/PfCCalculsFractions.tex b/macros/latex/contrib/profcollege/latex/PfCCalculsFractions.tex index 94e3a8d120..2e6ff56149 100644 --- a/macros/latex/contrib/profcollege/latex/PfCCalculsFractions.tex +++ b/macros/latex/contrib/profcollege/latex/PfCCalculsFractions.tex @@ -1,4 +1,5 @@ -\setKVdefault[CalculsFractions]{Couleur=Crimson} +\setKVdefault[CalculsFractions]{Couleurs=false} +\defKV[CalculsFractions]{Couleur=\setKV[CalculsFractions]{Couleurs}} \NewDocumentCommand\tofrac{m}{% \IfDecimal{#1}{#1}{% @@ -11,6 +12,7 @@ \NewDocumentCommand\AddFraction{soommo}{% \useKVdefault[CalculsFractions]% \setKV[CalculsFractions]{#2}% + \ifboolKV[CalculsFractions]{Couleurs}{\colorlet{CouleurDenoCom}{\useKV[CalculsFractions]{Couleur}}}{\colorlet{CouleurDenoCom}{black}}% \IfBooleanTF{#1}{% \xdef\PfCFractionOp{-}% }{% @@ -55,13 +57,13 @@ \else% \ifnum#3=1\relax% \ifnum\PfCPremierMul>1\relax% - \frac{\ListeFractions[1,1]_{\times\num{\PfCPremierMul}}}{\ListeFractions[1,2]_{\times\num{\PfCPremierMul}}} + \frac{\ListeFractions[1,1]_{\mathcolor{CouleurDenoCom}{\times\num{\PfCPremierMul}}}}{\ListeFractions[1,2]_{\mathcolor{CouleurDenoCom}{\times\num{\PfCPremierMul}}}} \else% \tofrac{#4}% \fi% \PfCFractionOp% \ifnum\PfCDeuxiemeMul>1\relax% - \frac{\ListeFractions[2,1]_{\times\num{\PfCDeuxiemeMul}}}{\ListeFractions[2,2]_{\times\num{\PfCDeuxiemeMul}}}% + \frac{\ListeFractions[2,1]_{\mathcolor{CouleurDenoCom}{\times\num{\PfCDeuxiemeMul}}}}{\ListeFractions[2,2]_{\mathcolor{CouleurDenoCom}{\times\num{\PfCDeuxiemeMul}}}}% \else% \tofrac{#5}% \fi% diff --git a/macros/latex/contrib/profcollege/latex/PfCCartesJeux.tex b/macros/latex/contrib/profcollege/latex/PfCCartesJeux.tex index 16a60d4a46..2871666b40 100644 --- a/macros/latex/contrib/profcollege/latex/PfCCartesJeux.tex +++ b/macros/latex/contrib/profcollege/latex/PfCCartesJeux.tex @@ -4,10 +4,17 @@ \setKVdefault[Cards]{Largeur=59,Hauteur=89,HauteurTheme=15,Marge=4,Landscape=false,Couleur=Cornsilk,Theme=Th\'eor\`eme\\de Pythagore,ThemeSol=Solution,AfficheTheme=false,Trame=false,Jointes=false,TrameVisible=false,RayonArc=5pt,Titre=false,NomTitre=Jeu 1,Loop,JaiQuia=false,Eleve=false,BackgroundAv=false,BackgroundAr=false,ImageAv=4813762.jpg,ImageAr=4813762.jpg,AffichageSolution=true,SolutionSeule=false,% % Pour la boite - NbCartes=16,TypeJeu=Boucle,Niveau=1,Numero=1,ThemeJeu=Nombres relatifs,CouleurTheme=black,CouleurNiveau=black,CouleurType=black,CouleurNb=black, + ANbCartes=false,ATypeJeu=false,ANiveau=false,ANumero=false,AThemeJeu=false,CouleurTheme=black,CouleurNiveau=black,CouleurType=black,CouleurNb=black, % Pour le trivial Trivial=false,Symboles={\faInfinity,\faSignal,\faProjectDiagram,\faHiking,\faRuler,\faLockOpen} }% +% Pour moduler l'affichage de textes sur la boite. +\defKV[Cards]{NbCartes=\setKV[Cards]{ANbCartes}}% +\defKV[Cards]{TypeJeu=\setKV[Cards]{ATypeJeu}}% +\defKV[Cards]{Niveau=\setKV[Cards]{ANiveau}}% +\defKV[Cards]{Numero=\setKV[Cards]{ANumero}}% +\defKV[Cards]{ThemeJeu=\setKV[Cards]{AThemeJeu}}% +% \defKV[Cards]{ThemeJaiQuiA=\setKV[Cards]{AfficheTheme}}% % \newtcolorbox{Mybox}[3]{% @@ -586,7 +593,7 @@ \def\BuildBoiteCartesCCCode{% Longueur=10cm; Largeur=7cm; - Epaisseur=\useKV[Cards]{NbCartes}*1mm; + Epaisseur=if \useKV[Cards]{ANbCartes}:\useKV[Cards]{NbCartes}*1mm else: 16mm fi; pair A[],B[],C[],D[]; A0=(0,0); A1-A0=Epaisseur*(1,0); @@ -644,6 +651,8 @@ \mplibforcehmode \begin{mplibcode} \BuildBoiteCartesCCCode; + boolean AThemeJeu; + AThemeJeu=\useKV[Cards]{AThemeJeu}; % trace chemin(A11,A12,A13,A0); trace chemin(D9,A11,A0,1/3[A1,A2]); @@ -688,15 +697,31 @@ trace polygone(D18,D17,D20,D19); trace chemin(1/3[D18,D17],D18,D19,D20,D17,2/3[D18,D17]); % label - drawoptions(withcolor \useKV[Cards]{CouleurTheme}); - label(btex \bfseries\Large\useKV[Cards]{ThemeJeu} etex,M2); + if AThemeJeu: +% drawoptions(withcolor \useKV[Cards]{CouleurTheme}); + label(TEX("\bfseries\Large\useKV[Cards]{ThemeJeu}"),M2); + drawoptions(); + fi; + if \useKV[Cards]{ANiveau}: + drawoptions(withcolor \useKV[Cards]{CouleurNiveau}); + label(TEX("\bfseries Niveau \useKV[Cards]{Niveau}"),M3); + drawoptions(); + fi; + if \useKV[Cards]{ANumero}: drawoptions(withcolor \useKV[Cards]{CouleurNiveau}); - label(btex \bfseries Niveau \useKV[Cards]{Niveau} etex,M3); - label(btex \bfseries Jeu \useKV[Cards]{Numero} etex,M4); + label(TEX("\bfseries Jeu \useKV[Cards]{Numero}"),M4); + drawoptions(); + fi; + if \useKV[Cards]{ANbCartes}: drawoptions(withcolor \useKV[Cards]{CouleurNb}); - label(btex \bfseries\useKV[Cards]{NbCartes} cartes etex,M5); + label(TEX("\bfseries\useKV[Cards]{NbCartes} cartes"),M5); + drawoptions(); + fi; + if \useKV[Cards]{ATypeJeu}: drawoptions(withcolor \useKV[Cards]{CouleurType}); - label(btex \bfseries\Huge\useKV[Cards]{TypeJeu} etex,M1); + label(TEX("\bfseries\Huge\useKV[Cards]{TypeJeu}"),M1); + drawoptions(); + fi; \end{mplibcode} \else \begin{mpost}[mpsettings={\BuildBoiteCartesCCCode;}] diff --git a/macros/latex/contrib/profcollege/latex/PfCCible.tex b/macros/latex/contrib/profcollege/latex/PfCCible.tex new file mode 100644 index 0000000000..f59ec3d593 --- /dev/null +++ b/macros/latex/contrib/profcollege/latex/PfCCible.tex @@ -0,0 +1,225 @@ +%%% +% Cibles +%%% +\newtoks\toklisteciblea% + +\def\UpdatetoksCibleA#1\nil{\addtotok\toklisteciblea{"#1",}}% + +\setKVdefault[Cible]{RayonBase=5mm,Ecart=5mm,Flechettes=false,RayonF=2.5cm,Impression=false}% + +\NewDocumentCommand\Cible{om}{% + \useKVdefault[Cible]% + \setKV[Cible]{#1}% + \toklisteciblea{}% + \xdef\PfCNombreZone{0}% + \ifboolKV[Cible]{Flechettes}{}{% + \setsepchar{,}% + \readlist*\PfCListeCible{#2}% + \foreachitem\compteur\in\PfCListeCible{\expandafter\UpdatetoksCibleA\compteur\nil}% + \xdef\PfCNombreZone{\PfCListeCiblelen}% + }% + \BuildCible{\the\toklisteciblea}% +}% + +\NewDocumentCommand\BuildCible{m}{% + \ifluatex% + \mplibforcehmode% + \begin{mplibcode} + Rayon=\useKV[Cible]{RayonBase}; + Ecart=\useKV[Cible]{Ecart}; + boolean Flechettes,Impression; + Flechettes=\useKV[Cible]{Flechettes}; + Impression=\useKV[Cible]{Impression}; + NombreCercles=\PfCNombreZone; + + vardef affichage(text t)= + pair O; + O=u*(5,5); + for k=NombreCercles downto 1: + if (k mod 2)=0: + fill cercles(O,Rayon+(k-1)*Ecart) withcolor 0.7white; + else: + fill cercles(O,Rayon+(k-1)*Ecart) withcolor white; + fi; + endfor; + for k=1 upto NombreCercles: + trace cercles(O,Rayon+(k-1)*Ecart); + endfor; + n:=0; + for p_=t: + n:=n+1; + if n=NombreCercles: + label(TEX(p_),O); + else: + label(TEX(p_),O+(NombreCercles+0.5-n)*(0,Ecart)); + label(TEX(p_),O-(NombreCercles+0.5-n)*(0,Ecart)); + fi; + endfor; + enddef; + + vardef affichageflechettes= + pair O; + O=u*(5,5); + RayonBase=\useKV[Cible]{RayonF}; + RayonA=(170/(0.5*451))*RayonBase; + RayonI=0.5*(RayonBase+RayonA); + RayonAa=(162/(0.5*451))*RayonBase; + RayonB=(107/(0.5*451))*RayonBase; + RayonBb=(99/(0.5*451))*RayonBase; + RayonC=(32/(0.5*451))*RayonBase; + RayonD=(12.7/(0.5*451))*RayonBase; + path cbase,ca,caa,cb,cbb,cc,cd; + cbase=cercles(O,RayonBase); + ca=cercles(O,RayonA); + caa=cercles(O,RayonAa); + cb=cercles(O,RayonB); + cbb=cercles(O,RayonBb); + cc=cercles(O,RayonC); + cd=cercles(O,RayonD); + fill cbase; + pair A[],Aa[],B[],Bb[],C[],D[],E[]; + for k=1 upto 21: + A[k]=pointarc(ca,9+(k-1)*18); + Aa[k]=pointarc(caa,9+(k-1)*18); + B[k]=pointarc(cb,9+(k-1)*18); + Bb[k]=pointarc(cbb,9+(k-1)*18); + C[k]=pointarc(cc,9+(k-1)*18); + D[k]=pointarc(cd,9+(k-1)*18); + E[k]=pointarc(cercles(O,RayonI),(k-1)*18); + endfor; + for k=2 step 2 until 20: + fill O--A[k]--arccercle(A[k],A[k+1],O)--cycle withcolor white; + endfor; + for k=1 upto 20: + if (k mod 2)=1: + fill Aa[k]--A[k]--arccercle(A[k],A[k+1],O)--reverse(arccercle(Aa[k],Aa[k+1],O))--cycle withcolor if Impression:0.4white else: Crimson fi; + fill Bb[k]--B[k]--arccercle(B[k],B[k+1],O)--reverse(arccercle(Bb[k],Bb[k+1],O))--cycle withcolor if Impression:0.4white else: Crimson fi; + else: + fill Aa[k]--A[k]--arccercle(A[k],A[k+1],O)--reverse(arccercle(Aa[k],Aa[k+1],O))--cycle withcolor if Impression:0.8white else: LightGreen fi; + fill Bb[k]--B[k]--arccercle(B[k],B[k+1],O)--reverse(arccercle(Bb[k],Bb[k+1],O))--cycle withcolor if Impression:0.8white else: LightGreen fi; + fi; + endfor; + fill cc withcolor if Impression:0.8white else: LightGreen fi; + fill cd withcolor if Impression:0.4white else: Crimson fi; + trace ca withcolor white; + trace caa withcolor white; + trace cb withcolor white; + trace cbb withcolor white; + trace cc withcolor white; + trace cd withcolor white; + enddef; + + vardef affichagetexteflechettes(text t)= + drawoptions(withcolor white); + n:=0; + for p_=t: + n:=n+1; + label(TEX("\bfseries "&p_),E[n]); + endfor; + enddef; + + if Flechettes: + affichageflechettes; + affichagetexteflechettes("6","13","4","18","1","20","5","12","9","14","11","8","16","7","19","3","17","2","15","10"); + else: + affichage(#1); + fi; + \end{mplibcode} + \else + \begin{mpost}[mpsettings={Rayon=\useKV[Cible]{RayonBase};Ecart=\useKV[Cible]{Ecart};boolean Flechettes,Impression;Flechettes=\useKV[Cible]{Flechettes};Impression=\useKV[Cible]{Impression};NombreCercles=\PfCNombreZone;}] + + vardef affichage(text t)= + pair O; + O=u*(5,5); + for k=NombreCercles downto 1: + if (k mod 2)=0: + fill cercles(O,Rayon+(k-1)*Ecart) withcolor 0.7white; + else: + fill cercles(O,Rayon+(k-1)*Ecart) withcolor white; + fi; + endfor; + for k=1 upto NombreCercles: + trace cercles(O,Rayon+(k-1)*Ecart); + endfor; + n:=0; + for p_=t: + n:=n+1; + if n=NombreCercles: + label(LATEX(p_),O); + else: + label(LATEX(p_),O+(NombreCercles+0.5-n)*(0,Ecart)); + label(LATEX(p_),O-(NombreCercles+0.5-n)*(0,Ecart)); + fi; + endfor; + enddef; + + vardef affichageflechettes= + pair O; + O=u*(5,5); + RayonBase=\useKV[Cible]{RayonF}; + RayonA=(170/(0.5*451))*RayonBase; + RayonI=0.5*(RayonBase+RayonA); + RayonAa=(162/(0.5*451))*RayonBase; + RayonB=(107/(0.5*451))*RayonBase; + RayonBb=(99/(0.5*451))*RayonBase; + RayonC=(32/(0.5*451))*RayonBase; + RayonD=(12.7/(0.5*451))*RayonBase; + path cbase,ca,caa,cb,cbb,cc,cd; + cbase=cercles(O,RayonBase); + ca=cercles(O,RayonA); + caa=cercles(O,RayonAa); + cb=cercles(O,RayonB); + cbb=cercles(O,RayonBb); + cc=cercles(O,RayonC); + cd=cercles(O,RayonD); + fill cbase; + pair A[],Aa[],B[],Bb[],C[],D[],E[]; + for k=1 upto 21: + A[k]=pointarc(ca,9+(k-1)*18); + Aa[k]=pointarc(caa,9+(k-1)*18); + B[k]=pointarc(cb,9+(k-1)*18); + Bb[k]=pointarc(cbb,9+(k-1)*18); + C[k]=pointarc(cc,9+(k-1)*18); + D[k]=pointarc(cd,9+(k-1)*18); + E[k]=pointarc(cercles(O,RayonI),(k-1)*18); + endfor; + for k=2 step 2 until 20: + fill O--A[k]--arccercle(A[k],A[k+1],O)--cycle withcolor white; + endfor; + for k=1 upto 20: + if (k mod 2)=1: + fill Aa[k]--A[k]--arccercle(A[k],A[k+1],O)--reverse(arccercle(Aa[k],Aa[k+1],O))--cycle withcolor if Impression:0.4white else: Crimson fi; + fill Bb[k]--B[k]--arccercle(B[k],B[k+1],O)--reverse(arccercle(Bb[k],Bb[k+1],O))--cycle withcolor if Impression:0.4white else: Crimson fi; + else: + fill Aa[k]--A[k]--arccercle(A[k],A[k+1],O)--reverse(arccercle(Aa[k],Aa[k+1],O))--cycle withcolor if Impression:0.8white else: LightGreen fi; + fill Bb[k]--B[k]--arccercle(B[k],B[k+1],O)--reverse(arccercle(Bb[k],Bb[k+1],O))--cycle withcolor if Impression:0.8white else: LightGreen fi; + fi; + endfor; + fill cc withcolor if Impression:0.8white else: LightGreen fi; + fill cd withcolor if Impression:0.4white else: Crimson fi; + trace ca withcolor white; + trace caa withcolor white; + trace cb withcolor white; + trace cbb withcolor white; + trace cc withcolor white; + trace cd withcolor white; + enddef; + + vardef affichagetexteflechettes(text t)= + drawoptions(withcolor white); + n:=0; + for p_=t: + n:=n+1; + label(LATEX("\bfseries "&p_),E[n]); + endfor; + enddef; + + if Flechettes: + affichageflechettes; + affichagetexteflechettes("6","13","4","18","1","20","5","12","9","14","11","8","16","7","19","3","17","2","15","10"); + else: + affichage(#1); + fi; + \end{mpost} + \fi +}%
\ No newline at end of file diff --git a/macros/latex/contrib/profcollege/latex/PfCCompteBon.tex b/macros/latex/contrib/profcollege/latex/PfCCompteBon.tex index 1610cc9378..c61d8cf870 100644 --- a/macros/latex/contrib/profcollege/latex/PfCCompteBon.tex +++ b/macros/latex/contrib/profcollege/latex/PfCCompteBon.tex @@ -166,15 +166,15 @@ \fbox{\PfCCBListeTirage[1]} \xintFor* ##1 in{\xintSeq{2}{\useKV[CompteBon]{Plaques}}}\do{\qquad \fbox{\PfCCBListeTirage[##1]}}% \end{center} - \xdef\PfCCBListeRappels{\the\tokPfCCBRappels} - \setsepchar[*]{,*=}\ignoreemptyitems - \readlist*\PfCCBDecompositionEtapes{\PfCCBListeRappels} - \reademptyitems + \xdef\PfCCBListeRappels{\the\tokPfCCBRappels}% + \setsepchar[*]{,*=}\ignoreemptyitems% + \readlist*\PfCCBDecompositionEtapes{\PfCCBListeRappels}% + \reademptyitems% \ifboolKV[CompteBon]{Solution}{% \begin{align*} \xintFor* ##1 in{\xintSeq{1}{\fpeval{\useKV[CompteBon]{Plaques}-1}}}\do{ \StrSubstitute{\PfCCBDecompositionEtapes[##1,1]}{*}{\times}[\PfCCBAffiche]\PfCCBAffiche&=\PfCCBDecompositionEtapes[##1,2]\xintifForLast{\\}{} - } + }% \end{align*} }{}% }% diff --git a/macros/latex/contrib/profcollege/latex/PfCDecomposerNombrePremier.tex b/macros/latex/contrib/profcollege/latex/PfCDecomposerNombrePremier.tex index 6fab8783f9..a70b818b25 100644 --- a/macros/latex/contrib/profcollege/latex/PfCDecomposerNombrePremier.tex +++ b/macros/latex/contrib/profcollege/latex/PfCDecomposerNombrePremier.tex @@ -30,7 +30,8 @@ \def\MPArbre#1{% \ifluatex - \mplibforcehmode + \mplibforcehmode + \mplibnumbersystem{double} \begin{mplibcode} input PfCArithmetique; numeric depart; @@ -84,7 +85,8 @@ \def\MPArbreComplet#1{% \ifluatex - \mplibforcehmode + \mplibforcehmode + \mplibnumbersystem{double} \begin{mplibcode} input PfCArithmetique; numeric depart; @@ -120,7 +122,8 @@ \def\MPArbreVide#1{% \ifluatex - \mplibforcehmode + \mplibforcehmode + \mplibnumbersystem{double} \begin{mplibcode} input PfCArithmetique; numeric depart; @@ -153,7 +156,8 @@ \def\MPArbreDessine#1#2{% \ifluatex% - \mplibforcehmode% + \mplibforcehmode% + \mplibnumbersystem{double} \begin{mplibcode} input PfCArithmetique; numeric depart; diff --git a/macros/latex/contrib/profcollege/latex/PfCDistributivite.tex b/macros/latex/contrib/profcollege/latex/PfCDistributivite.tex index a9c103ac85..b0d60d14e8 100644 --- a/macros/latex/contrib/profcollege/latex/PfCDistributivite.tex +++ b/macros/latex/contrib/profcollege/latex/PfCDistributivite.tex @@ -38,8 +38,8 @@ % y a dans un "seul calcul". \setcounter{NbCalculDistri}{0} -\setKVdefault[ClesDistributivite]{Cours=false,Etape=1,Lettre=x,Fleches=false,AideMul=false,Reduction=false,AideAdda=false,AideAddb=false,CouleurAide=red,CouleurReduction=black,CouleurFH=blue,CouleurFB=red,Somme=false,Difference=false,RAZ=false,Oppose=false,All=false,NomExpression=A,Fin=4,Numerique=false,Remarquable=false,Echange=0,Tuile=false,Vide=false,Reperes=false,Impression=false,Tableau=false}%,AideAdd=false:inutile ? - +\setKVdefault[ClesDistributivite]{Cours=false,Etape=1,Lettre=x,Fleches=false,AideMul=false,Reduction=false,AideAdda=false,AideAddb=false,CouleurAide=red,CouleurFH=blue,CouleurFB=red,Somme=false,Difference=false,RAZ=false,Oppose=false,All=false,NomExpression=A,Fin=4,Numerique=false,Remarquable=false,Echange=0,Tuile=false,Vide=false,Reperes=false,Impression=false,Tableau=false}%,AideAdd=false:inutile ? +\defKV[ClesDistributivite]{CouleurReduction=\colorlet{DCReduction}{#1}\setKV[ClesDistributivite]{Reduction}}% \newcommand\Tuile[4]{% \ifluatex \mplibforcehmode @@ -452,13 +452,14 @@ \xdef\SommeC{0}% \newcommand\Distri[5][]{% + \colorlet{DCReduction}{black}% \useKVdefault[ClesDistributivite]%obligatoire car la macro n'est pas dans un groupe. \setKV[ClesDistributivite]{#1}%On lit les arguments optionnels \ifboolKV[ClesDistributivite]{RAZ}{\xdef\SommeA{0}\xdef\SommeB{0}\xdef\SommeC{0}% \setcounter{NbCalculDistri}{0}% }{}% \colorlet{DCAide}{\useKV[ClesDistributivite]{CouleurAide}}% - \colorlet{DCReduction}{\useKV[ClesDistributivite]{CouleurReduction}}% +% \colorlet{DCReduction}{\useKV[ClesDistributivite]{CouleurReduction}}% \colorlet{DCFlechesh}{\useKV[ClesDistributivite]{CouleurFH}}% \colorlet{DCFlechesb}{\useKV[ClesDistributivite]{CouleurFB}}% \ifboolKV[ClesDistributivite]{Cours}{% @@ -778,6 +779,7 @@ }% \newcommand\DistriEchange[5][]{% + \colorlet{DCReduction}{black} \ensuremath{% \useKVdefault[ClesDistributivite]% \setKV[ClesDistributivite]{#1}% @@ -785,7 +787,7 @@ \setcounter{NbCalculDistri}{0}% }{}% \colorlet{DCAide}{\useKV[ClesDistributivite]{CouleurAide}}% - \colorlet{DCReduction}{\useKV[ClesDistributivite]{CouleurReduction}}% +% \colorlet{DCReduction}{\useKV[ClesDistributivite]{CouleurReduction}}% \colorlet{DCFlechesh}{\useKV[ClesDistributivite]{CouleurFH}}% \colorlet{DCFlechesb}{\useKV[ClesDistributivite]{CouleurFB}}% \ifboolKV[ClesDistributivite]{Remarquable}{% diff --git a/macros/latex/contrib/profcollege/latex/PfCEcritureLettres.tex b/macros/latex/contrib/profcollege/latex/PfCEcritureLettres.tex index 650847b21c..a2cd50db02 100644 --- a/macros/latex/contrib/profcollege/latex/PfCEcritureLettres.tex +++ b/macros/latex/contrib/profcollege/latex/PfCEcritureLettres.tex @@ -1,6 +1,3 @@ - - - %%% % Ecriture des nombres en lettres %%% diff --git a/macros/latex/contrib/profcollege/latex/PfCGrimuku.tex b/macros/latex/contrib/profcollege/latex/PfCGrimuku.tex new file mode 100644 index 0000000000..81e667533a --- /dev/null +++ b/macros/latex/contrib/profcollege/latex/PfCGrimuku.tex @@ -0,0 +1,222 @@ +%%% +% Grimuku +%%% +\setKVdefault[Grimuku]{TLargeur=7,Solution=false,Largeur=30pt,CouleurCase=0.7white}% +\defKV[Grimuku]{CouleurSolution=\setKV[Grimuku]{Solution}}% + +\newtoks\toklistegrimukupdt +\newtoks\toklistegrimukunb + +\def\UpdatetoksGrimCases#1/#2/#3/#4\nil{\addtotok\toklistegrimukunb{"*",}\addtotok\toklistegrimukupdt{"#1",}\addtotok\toklistegrimukupdt{"#2",}\addtotok\toklistegrimukupdt{"#3",}\addtotok\toklistegrimukupdt{"#4",}}% +\def\UpdatetoksGrimCasesNb#1\nil{\addtotok\toklistegrimukunb{"#1",}\addtotok\toklistegrimukupdt{"",}\addtotok\toklistegrimukupdt{"",}\addtotok\toklistegrimukupdt{"",}\addtotok\toklistegrimukupdt{"",}}% + +\NewDocumentCommand\Grimuku{om}{% + \toklistegrimukunb{}% + \toklistegrimukupdt{}% + \useKVdefault[Grimuku]% + \setKV[Grimuku]{#1}% + \setsepchar[*]{,*/}\reademptyitems% + \readlist*\ListeCasesGrim{#2}% + \xdef\PfCGrimLargeur{\useKV[Grimuku]{TLargeur}}% + \xdef\PfCGrimHauteur{\fpeval{\ListeCasesGrimlen/\PfCGrimLargeur}}% + \savecomparemode% + \comparestrict% + \foreachitem\compteur\in\ListeCasesGrim{% + \StrCount{\ListeCasesGrim[\compteurcnt]}{/}[\PfCTestLongueur]% + \xintifboolexpr{\PfCTestLongueur>0}{% + \expandafter\UpdatetoksGrimCases\compteur\nil% + }{% + \expandafter\UpdatetoksGrimCasesNb\compteur\nil% + }% + }% + \restorecomparemode% + \BuildGrimuku{\the\toklistegrimukupdt}{\the\toklistegrimukunb}% +}% + +\NewDocumentCommand\BuildGrimuku{mm}{% + \ifluatex + \mplibforcehmode + \begin{mplibcode} + color CouleurSolution,CouleurCase; + + boolean Solution; + Solution=\useKV[Grimuku]{Solution}; + if Solution: + CouleurSolution=\useKV[Grimuku]{CouleurSolution}; + fi; + Unite=\useKV[Grimuku]{Largeur}; + Largeur=\useKV[Grimuku]{TLargeur}; + Hauteur=\PfCGrimHauteur; + + CouleurCase=\useKV[Grimuku]{CouleurCase}; + + path Base; + Base=(unitsquare scaled Unite) shifted ((0,0)-(Unite/2,Unite/2)); + + + vardef TraceFleche(expr a,b,c)= + if a="g": + drawarrow (Unite*(b-0.4,c))--(Unite*(b-0.75,c)); + elseif a="gh": + drawarrow (Unite*(b-0.4,c))--(Unite*(b-0.6,c))--(Unite*(b-0.6,c+0.5)); + elseif a="gb": + drawarrow (Unite*(b-0.4,c))--(Unite*(b-0.6,c))--(Unite*(b-0.6,c-0.5)); + elseif a="d": + drawarrow (Unite*(b+0.4,c))--(Unite*(b+0.75,c)); + elseif a="dh": + drawarrow (Unite*(b+0.4,c))--(Unite*(b+0.6,c))--(Unite*(b+0.6,c+0.5)); + elseif a="db": + drawarrow (Unite*(b+0.4,c))--(Unite*(b+0.6,c))--(Unite*(b+0.6,c-0.5)); + elseif a="h": + drawarrow (Unite*(b,c+0.15))--(Unite*(b,c+0.5)); + elseif a="hd": + drawarrow (Unite*(b,c+0.15))--(Unite*(b,c+0.35))--(Unite*(b+0.5,c+0.35)); + elseif a="hg": + drawarrow (Unite*(b,c+0.15))--(Unite*(b,c+0.35))--(Unite*(b-0.5,c+0.35)); + elseif a="b": + drawarrow (Unite*(b,c-0.15))--(Unite*(b,c-0.5)); + elseif a="bd": + drawarrow (Unite*(b,c-0.15))--(Unite*(b,c-0.35))--(Unite*(b+0.5,c-0.35)); + elseif a="bg": + drawarrow (Unite*(b,c-0.15))--(Unite*(b,c-0.35))--(Unite*(b-0.5,c-0.35)); + fi; + enddef; + + vardef EcritureProduits(text t)= + n:=0; + m:=-1; + for p_=t: + q:=n div Largeur; + r:=n mod Largeur; + m:=m+1; + if (m mod 4)=0: + label(TEX(p_),Unite*(r,-q+0.25)); + elseif (m mod 4)=1: + TraceFleche(p_,r,-q+0.25); + elseif (m mod 4)=2: + label(TEX(p_),Unite*(r,-q-0.25)); + elseif (m mod 4)=3: + TraceFleche(p_,r,-q-0.25); + n:=n+1; + fi; + endfor; + enddef; + + vardef Ecriture(text t)= + n=0; + for p_=t: + q:=n div Largeur; + r:=n mod Largeur; + if p_="*": + fill (Base shifted (Unite*(r,-q))) withcolor CouleurCase; + draw (Unite*(r-0.5,-q))--(Unite*(r+0.5,-q)); + else: + if Solution: + drawoptions(withcolor CouleurSolution); + label(TEX(p_),Unite*(r,-q)); + drawoptions(); + fi; + fi; + n:=n+1; + endfor; + enddef; + + Ecriture(#2); + EcritureProduits(#1); + % On quadrille + for k=0 upto Largeur-1: + for l=0 upto Hauteur-1: + trace Base shifted(Unite*(k,-l)); + endfor; + endfor; + \end{mplibcode} + \else + \begin{mpost}[mpsettings={color CouleurSolution,CouleurCase;boolean Solution;Solution=\useKV[Grimuku]{Solution}; if Solution: + CouleurSolution=\useKV[Grimuku]{CouleurSolution}; + fi; + Unite=\useKV[Grimuku]{Largeur}; + Largeur=\useKV[Grimuku]{TLargeur}; + Hauteur=\PfCGrimHauteur; + CouleurCase=\useKV[Grimuku]{CouleurCase}; + };] + path Base; + Base=(unitsquare scaled Unite) shifted ((0,0)-(Unite/2,Unite/2)); + % + vardef TraceFleche(expr a,b,c)= + if a="g": + drawarrow (Unite*(b-0.4,c))--(Unite*(b-0.75,c)); + elseif a="gh": + drawarrow (Unite*(b-0.4,c))--(Unite*(b-0.6,c))--(Unite*(b-0.6,c+0.5)); + elseif a="gb": + drawarrow (Unite*(b-0.4,c))--(Unite*(b-0.6,c))--(Unite*(b-0.6,c-0.5)); + elseif a="d": + drawarrow (Unite*(b+0.4,c))--(Unite*(b+0.75,c)); + elseif a="dh": + drawarrow (Unite*(b+0.4,c))--(Unite*(b+0.6,c))--(Unite*(b+0.6,c+0.5)); + elseif a="db": + drawarrow (Unite*(b+0.4,c))--(Unite*(b+0.6,c))--(Unite*(b+0.6,c-0.5)); + elseif a="h": + drawarrow (Unite*(b,c+0.15))--(Unite*(b,c+0.5)); + elseif a="hd": + drawarrow (Unite*(b,c+0.15))--(Unite*(b,c+0.35))--(Unite*(b+0.5,c+0.35)); + elseif a="hg": + drawarrow (Unite*(b,c+0.15))--(Unite*(b,c+0.35))--(Unite*(b-0.5,c+0.35)); + elseif a="b": + drawarrow (Unite*(b,c-0.15))--(Unite*(b,c-0.5)); + elseif a="bd": + drawarrow (Unite*(b,c-0.15))--(Unite*(b,c-0.35))--(Unite*(b+0.5,c-0.35)); + elseif a="bg": + drawarrow (Unite*(b,c-0.15))--(Unite*(b,c-0.35))--(Unite*(b-0.5,c-0.35)); + fi; + enddef; + % + vardef EcritureProduits(text t)= + n:=0; + m:=-1; + for p_=t: + q:=n div Largeur; + r:=n mod Largeur; + m:=m+1; + if (m mod 4)=0: + label(LATEX(p_),Unite*(r,-q+0.25)); + elseif (m mod 4)=1: + TraceFleche(p_,r,-q+0.25); + elseif (m mod 4)=2: + label(LATEX(p_),Unite*(r,-q-0.25)); + elseif (m mod 4)=3: + TraceFleche(p_,r,-q-0.25); + n:=n+1; + fi; + endfor; + enddef; + % + vardef Ecriture(text t)= + n=0; + for p_=t: + q:=n div Largeur; + r:=n mod Largeur; + if p_="*": + fill (Base shifted (Unite*(r,-q))) withcolor CouleurCase; + draw (Unite*(r-0.5,-q))--(Unite*(r+0.5,-q)); + else: + if Solution: + drawoptions(withcolor CouleurSolution); + label(LATEX(p_),Unite*(r,-q)); + drawoptions(); + fi; + fi; + n:=n+1; + endfor; + enddef; + + Ecriture(#2); + EcritureProduits(#1); + % On quadrille + for k=0 upto Largeur-1: + for l=0 upto Hauteur-1: + trace Base shifted(Unite*(k,-l)); + endfor; + endfor; + \end{mpost} + \fi +}
\ No newline at end of file diff --git a/macros/latex/contrib/profcollege/latex/PfCHorloge.tex b/macros/latex/contrib/profcollege/latex/PfCHorloge.tex new file mode 100644 index 0000000000..1133714ecd --- /dev/null +++ b/macros/latex/contrib/profcollege/latex/PfCHorloge.tex @@ -0,0 +1,215 @@ +%%% +% Horloges +%%% +\setKVdefault[ClesHorloge]{Aiguilles,Numerique=false,Secondes,Cadre,Rayon=1,Impression=false} + +\NewDocumentCommand\Horloge{ }{%On dรฉsactive les : + \begingroup + \catcode`\:12 + \Horlogeaux +}% + +\NewDocumentCommand\Horlogeaux{om}{% + \endgroup + \useKVdefault[ClesHorloge] + \setKV[ClesHorloge]{#1} + \ifx\bla#2\bla + \timenow + \ifboolKV[ClesHorloge]{Numerique}{% + \MPAfficheurNew{\PfCTimeHeure}{\PfCTimeMinute}{0}% + }{% + \MPHorlogeNew{\PfCTimeHeure}{\PfCTimeMinute}{0}% + }% + \else + \setsepchar{:}% + \readlist*\PfCTime{#2}% + \ifboolKV[ClesHorloge]{Numerique}{% + \ifnum\PfCTimelen=1\relax + \MPAfficheurNew{\PfCTime[1]}{0}{0}% + \else + \ifnum\PfCTimelen=2\relax + \MPAfficheurNew{\PfCTime[1]}{\PfCTime[2]}{0}% + \else + \MPAfficheurNew{\PfCTime[1]}{\PfCTime[2]}{\PfCTime[3]}% + \fi + \fi + }{% + \ifnum\PfCTimelen=1\relax + \MPHorlogeNew{\PfCTime[1]}{0}{0}% + \else + \ifnum\PfCTimelen=2\relax + \MPHorlogeNew{\PfCTime[1]}{\PfCTime[2]}{0}% + \else + \MPHorlogeNew{\PfCTime[1]}{\PfCTime[2]}{\PfCTime[3]}% + \fi + \fi + }% + \fi% +}% + +\makeatletter +\def\timenow{\@tempcnta\time\relax + \@tempcntb\@tempcnta\relax + \divide\@tempcntb60\relax + \edef\PfCTimeHeure{\fpeval{\@tempcntb}}% + \multiply\@tempcntb60\relax + \advance\@tempcnta-\@tempcntb\relax + \edef\PfCTimeMinute{\fpeval{\@tempcnta}}% +}\relax +\makeatother + +\def\MPAfficheurNew#1#2#3{% + \ifluatex + \mplibforcehmode + \begin{mplibcode} + boolean Secondes,Impression; + Secondes=\useKV[ClesHorloge]{Secondes}; + Impression=\useKV[ClesHorloge]{Impression}; + if Impression: + LightSteelBlue:=0.9*white; + Crimson:=0.5*white; + fi; + u:=0.5u; + draw Afficheur(#1 div10,0); + draw Afficheur(#1 mod10,0) shifted(u*(1,0)); + draw Afficheur(10,0) shifted(u*(2,0)); + draw Afficheur(#2 div10,0) shifted(u*(3,0)); + draw Afficheur(#2 mod10,0) shifted(u*(4,0)); + if Secondes: + draw Afficheur(10,0) shifted(u*(5,0)); + draw Afficheur(#3 div10,0) shifted(u*(6,0)); + draw Afficheur(#3 mod10,0) shifted(u*(7,0)); + fi; + \end{mplibcode} + \else + \begin{mpost}[mpsettings={boolean Secondes;Secondes=\useKV[ClesHorloge]{Secondes};}] + u:=0.5u; + draw Afficheur(#1 div10,0); + draw Afficheur(#1 mod10,0) shifted(u*(1,0)); + draw Afficheur(10,0) shifted(u*(2,0)); + draw Afficheur(#2 div10,0) shifted(u*(3,0)); + draw Afficheur(#2 mod10,0) shifted(u*(4,0)); + if Secondes: + draw Afficheur(10,0) shifted(u*(5,0)); + draw Afficheur(#3 div10,0) shifted(u*(6,0)); + draw Afficheur(#3 mod10,0) shifted(u*(7,0)); + fi; + \end{mpost} + \fi +} + +\def\MPHorlogeNew#1#2#3{ + \ifluatex + \mplibforcehmode + \begin{mplibcode} + boolean Secondes,Aiguilles,Cadre; + Secondes=\useKV[ClesHorloge]{Secondes}; + Aiguilles=\useKV[ClesHorloge]{Aiguilles}; + Cadre=\useKV[ClesHorloge]{Cadre}; + marque_horloge=\useKV[ClesHorloge]{Rayon}; + save Hor; + picture Hor; + path gdeaig,pteaig,trot; + pair centrehorloge; + centrehorloge=(0,0); + path tourhorloge,toura; + tourhorloge=cercles(centrehorloge,marque_horloge*cm); + toura=cercles(centrehorloge,(marque_horloge+0.25)*cm); + Hor=image( + %% dessin du cadre + if Cadre: + pair A[]; + draw cercles(centrehorloge,(marque_horloge+0.5)*cm) withpen pencircle scaled 1.5; + for k=1 upto 12: + A[k]=pointarc(toura,90-30*k); + label(TEX(decimal(k)),A[k]); + endfor; + fi; + %% dessin de l'horloge + draw tourhorloge; + for i=0 upto 59: + if (i mod 5)=0: + if (i mod 15)=0: + draw pointarc(tourhorloge,6*i)--(pointarc(tourhorloge,6*i) shifted (7*unitvector(centrehorloge-pointarc(tourhorloge,6*i)))) withpen pencircle scaled 2bp; + else: + draw pointarc(tourhorloge,6*i)--(pointarc(tourhorloge,6*i) shifted (5*unitvector(centrehorloge-pointarc(tourhorloge,6*i)))) withpen pencircle scaled 1.5bp; + fi; + else: + draw pointarc(tourhorloge,6*i)--(pointarc(tourhorloge,6*i) shifted (3*unitvector(centrehorloge-pointarc(tourhorloge,6*i)))); + fi; + endfor; + path graduhorloge; + graduhorloge=cercles(centrehorloge,marque_horloge*cm+5*abs(unitvector(centrehorloge-pointarc(tourhorloge,0)))); + % + marque_p:="plein"; + pointe(centrehorloge); + marque_p:="rien"; + %% placement des aiguilles + if Aiguilles: + gdeaig=centrehorloge--(pointarc(tourhorloge,0) shifted (7*unitvector(centrehorloge-pointarc(tourhorloge,0)))); + pteaig=centrehorloge--(pointarc(tourhorloge,0) shifted (18*unitvector(centrehorloge-pointarc(tourhorloge,0)))); + if Secondes: + trot=centrehorloge--(pointarc(tourhorloge,0) shifted (10*unitvector(centrehorloge-pointarc(tourhorloge,0)))); + draw rotation(trot,centrehorloge,90-6*#3) withpen pencircle scaled0.4; + fi; + draw rotation(gdeaig,centrehorloge,90-6*#2) withpen pencircle scaled1.25; + draw rotation(pteaig,centrehorloge,90-30*(#1+#2/60)) withpen pencircle scaled 2bp; + fi; + ); + draw Hor; +\end{mplibcode} +\else + \begin{mpost}[mpsettings={boolean Secondes,Aiguilles,Cadre;Secondes=\useKV[ClesHorloge]{Secondes};Aiguilles=\useKV[ClesHorloge]{Aiguilles};Cadre=\useKV[ClesHorloge]{Cadre};marque_horloge=\useKV[ClesHorloge]{Rayon};}] + save Hor; + picture Hor; + path gdeaig,pteaig,trot; + pair centrehorloge; + centrehorloge=(0,0); + path tourhorloge,toura; + tourhorloge=cercles(centrehorloge,marque_horloge*cm); + toura=cercles(centrehorloge,(marque_horloge+0.25)*cm); + Hor=image( + %% dessin du cadre + if Cadre: + pair A[]; + draw cercles(centrehorloge,(marque_horloge+0.5)*cm) withpen pencircle scaled 1.5; + for k=1 upto 12: + A[k]=pointarc(toura,90-30*k); + label(LATEX(decimal(k)),A[k]); + endfor; + fi; + %% dessin de l'horloge + draw tourhorloge; + for i=0 upto 59: + if (i mod 5)=0: + if (i mod 15)=0: + draw pointarc(tourhorloge,6*i)--(pointarc(tourhorloge,6*i) shifted (7*unitvector(centrehorloge-pointarc(tourhorloge,6*i)))) withpen pencircle scaled 2bp; + else: + draw pointarc(tourhorloge,6*i)--(pointarc(tourhorloge,6*i) shifted (5*unitvector(centrehorloge-pointarc(tourhorloge,6*i)))) withpen pencircle scaled 1.5bp; + fi; + else: + draw pointarc(tourhorloge,6*i)--(pointarc(tourhorloge,6*i) shifted (3*unitvector(centrehorloge-pointarc(tourhorloge,6*i)))); + fi; + endfor; + path graduhorloge; + graduhorloge=cercles(centrehorloge,marque_horloge*cm+5*abs(unitvector(centrehorloge-pointarc(tourhorloge,0)))); + % + marque_p:="plein"; + pointe(centrehorloge); + marque_p:="rien"; + %% placement des aiguilles + if Aiguilles: + gdeaig=centrehorloge--(pointarc(tourhorloge,0) shifted (7*unitvector(centrehorloge-pointarc(tourhorloge,0)))); + pteaig=centrehorloge--(pointarc(tourhorloge,0) shifted (18*unitvector(centrehorloge-pointarc(tourhorloge,0)))); + if Secondes: + trot=centrehorloge--(pointarc(tourhorloge,0) shifted (10*unitvector(centrehorloge-pointarc(tourhorloge,0)))); + draw rotation(trot,centrehorloge,90-6*#3) withpen pencircle scaled0.4; + fi; + draw rotation(gdeaig,centrehorloge,90-6*#2) withpen pencircle scaled1.25; + draw rotation(pteaig,centrehorloge,90-30*(#1+#2/60)) withpen pencircle scaled 2bp; + fi; + ); + draw Hor; + \end{mpost} +\fi +}
\ No newline at end of file diff --git a/macros/latex/contrib/profcollege/latex/PfCLabyrintheNombre.tex b/macros/latex/contrib/profcollege/latex/PfCLabyrintheNombre.tex index a7463ec702..be5e05d673 100644 --- a/macros/latex/contrib/profcollege/latex/PfCLabyrintheNombre.tex +++ b/macros/latex/contrib/profcollege/latex/PfCLabyrintheNombre.tex @@ -1,18 +1,211 @@ %%% % Labyrinthe Nombre %%% -\setKVdefault[ClesLabyNb]{Multiple=5,XDepart=0,YDepart=0,Longueur=7,Largeur=4,XArrivee=6,YArrivee=3,Solution=false,Echelle=1,Angle=0,Couleur=red,Murs=false,Nom=Ex1,CouleurChemin=LightSteelBlue,DoubleOperation=false,Chemin=false,EntreeSortie=false,Entree="Nord",Sortie="Sud",SortieUnique=true} +\setKVdefault[ClesLabyNb]{Multiple=5,XDepart=0,YDepart=0,Longueur=7,Largeur=4,Solution=false,Echelle=1,Angle=0,Couleur=red,Murs=false,Nom=Ex1,CouleurChemin=LightSteelBlue,DoubleOperation=false,Multiplication=false,Chemin=false,EntreeSortie=false,Entree="Nord",Sortie="Sud",SortieUnique=true,Graines=false,XArrivees=false,YArrivees=false,ArriveeX=5,ArriveeY=5} +\defKV[ClesLabyNb]{Graine=\setKV[ClesLabyNb]{Graines}} +\defKV[ClesLabyNb]{XArrivee=\setKV[ClesLabyNb]{XArrivees}\setKV[ClesLabyNb]{ArriveeX=#1}} +\defKV[ClesLabyNb]{YArrivee=\setKV[ClesLabyNb]{YArrivees}\setKV[ClesLabyNb]{ArriveeY=#1}} \newcommand\LabyNombre[1][]{% \useKVdefault[ClesLabyNb]% \setKV[ClesLabyNb]{#1}% - \ifboolKV[ClesLabyNb]{Solution}{% - \TraceLabyFactoSolution{\useKV[ClesLabyNb]{Multiple}}{\useKV[ClesLabyNb]{Longueur}}{\useKV[ClesLabyNb]{Largeur}}{(\useKV[ClesLabyNb]{YDepart},\useKV[ClesLabyNb]{XDepart})}{(\useKV[ClesLabyNb]{YArrivee},\useKV[ClesLabyNb]{XArrivee})}{\useKV[ClesLabyNb]{Solution}}% + \ifboolKV[ClesLabyNb]{XArrivees}{}{\setKV[ClesLabyNb]{ArriveeX=\fpeval{\useKV[ClesLabyNb]{Longueur}-1}}} + \ifboolKV[ClesLabyNb]{YArrivees}{}{\setKV[ClesLabyNb]{ArriveeY=\fpeval{\useKV[ClesLabyNb]{Largeur}-1}}} + \ifboolKV[ClesLabyNb]{Multiplication}{% + \TraceLabyMul{\useKV[ClesLabyNb]{Multiple}}{\useKV[ClesLabyNb]{Longueur}}{\useKV[ClesLabyNb]{Largeur}}{(\useKV[ClesLabyNb]{YDepart},\useKV[ClesLabyNb]{XDepart})}{(\useKV[ClesLabyNb]{ArriveeY},\useKV[ClesLabyNb]{ArriveeX})}% }{% - \TraceLabyFacto{\useKV[ClesLabyNb]{Multiple}}{\useKV[ClesLabyNb]{Longueur}}{\useKV[ClesLabyNb]{Largeur}}{(\useKV[ClesLabyNb]{YDepart},\useKV[ClesLabyNb]{XDepart})}{(\useKV[ClesLabyNb]{YArrivee},\useKV[ClesLabyNb]{XArrivee})}{\useKV[ClesLabyNb]{Solution}}% - }% + \ifboolKV[ClesLabyNb]{Solution}{% + \TraceLabyFactoSolution{\useKV[ClesLabyNb]{Multiple}}{\useKV[ClesLabyNb]{Longueur}}{\useKV[ClesLabyNb]{Largeur}}{(\useKV[ClesLabyNb]{YDepart},\useKV[ClesLabyNb]{XDepart})}{(\useKV[ClesLabyNb]{ArriveeY},\useKV[ClesLabyNb]{ArriveeX})}{\useKV[ClesLabyNb]{Solution}}% + }{% + \TraceLabyFacto{\useKV[ClesLabyNb]{Multiple}}{\useKV[ClesLabyNb]{Longueur}}{\useKV[ClesLabyNb]{Largeur}}{(\useKV[ClesLabyNb]{YDepart},\useKV[ClesLabyNb]{XDepart})}{(\useKV[ClesLabyNb]{ArriveeY},\useKV[ClesLabyNb]{ArriveeX})}{\useKV[ClesLabyNb]{Solution}}% + }% + }% }% +\newcommand\TraceLabyMul[5]{ + \ifluatex + \mplibnumbersystem{double} + \mplibforcehmode + \begin{mplibcode} + input PfCLabyNombre; + + boolean Murs,Solution,Graines; + Murs=\useKV[ClesLabyNb]{Murs}; + Solution:=\useKV[ClesLabyNb]{Solution}; + Graines:=\useKV[ClesLabyNb]{Graines}; + if Graines: + randomseed:=\useKV[ClesLabyNb]{Graine} + fi; + + path Fullcircle; + Fullcircle=fullcircle shifted((0.5,0.5)); + + numeric Multiple; + Multiple=#1; + % Initialisation du labyrinthe + InitialisationLabyrintheMul(#2,#3); + % On initialise les paramรจtres du parcours + numeric choixligneD,choixligneA,choixcolonneD,choixcolonneA; + choixligneD=xpart(#4); + choixcolonneD=ypart(#4); + choixligneA=xpart(#5); + choixcolonneA=ypart(#5);% + pair Depart; + Depart=N[choixligneD][choixcolonneD]; + pair Arrivee; + Arrivee=N[choixligneA][choixcolonneA]; + pair Mobile; + Mobile=Depart; + RAZPileChemin; + % Exploration du labyrinthe + PushChemin((choixligneD,choixcolonneD)); + CaseExploree[choixligneD][choixcolonneD]:=true; + VoisinDispo(choixligneD,choixcolonneD); + forever: exitif Mobile=Arrivee;%nb=0; + nb:=ceiling(uniformdeviate(nbvoisin)); + if nb>0: + for k=1 upto nbvoisin: + CaseExploree[xpart(PileVoisin[k])][ypart(PileVoisin[k])]:=true; + endfor; + PushChemin((xpart(PileVoisin[nb]),ypart(PileVoisin[nb]))); + Mobile:=N[xpart(PileChemin[indiceChemin])][ypart(PileChemin[indiceChemin])]; + VoisinDispo(xpart(PileChemin[indiceChemin]),ypart(PileChemin[indiceChemin])); + else: + PopChemin; + fi; + endfor; + + vardef PremierInfCent= + Totalpremier:=25; + + numeric p[]; boolean n_is_prime; p[1]=2; kis:=1; + for nis=3 step 2 until infinity: + n_is_prime := true; + for jis=2 upto kis: + if nis mod p[jis]=0: n_is_prime := false; fi + exitif nis/p[jis] < p[jis]; + endfor + if n_is_prime: p[incr kis] := nis; exitif kis=Totalpremier; fi + endfor fi + + numeric PR[],pretiens[]; + + for ki=1 upto Totalpremier-1: + pretiens[ki]:=p[ki+1]; + endfor; + + Kk:=0; + + for ki=Totalpremier-1 downto 1: + alea:=1+floor(uniformdeviate(ki)); + PR[incr Kk]:=pretiens[alea]; + Kkl:=0; + for li=1 upto ki: + if li<>alea: + pretiens[incr Kkl]:=pretiens[li]; + fi; + endfor; + endfor; + enddef; + + vardef ListeDiviseurs(expr nbtest)= + numeric diviseurs[],nondiviseurs[],pas; + nbdiv:=0; + nbnondiv:=0; + pas=2; + forever: + if (nbtest mod pas)=0: + nbdiv:=nbdiv+1; + diviseurs[nbdiv]=pas; + else: + nbnondiv:=nbnondiv+1; + nondiviseurs[nbnondiv]=pas; + fi; + pas:=pas+1; + exitif pas>10; + endfor; + enddef; + + % Affichagefinal + % on sauvegarde les nombres alรฉatoires + numeric NbAffiche[]; + numeric NbSol[]; + % on รฉcrit des nombres premiers au hasard >10 + PremierInfCent; + numeric nbaffiche; + nbaffiche=0; + for k=0 upto LargeurLaby-1: + for l=0 upto LongueurLaby-1: + nbaffiche:=nbaffiche+1; + if (nbaffiche mod 2)=0: + nbpremier:=3+ceiling(uniformdeviate(Totalpremier-4)); + NbAffiche[nbaffiche]:=PR[nbpremier]; + else: + NbAffiche[nbaffiche]:=2+floor(uniformdeviate(8)); + fi; + endfor; + endfor; + % On crรฉe des multiples du nombre choisi + NbSol[1]=Multiple; + for k=2 upto indiceChemin: + if (k mod 2)=0: + NbSol[k]=NbSol[k-1]*(2+ceiling(uniformdeviate(8))); + else: + % Diviseurs du prรฉcรฉdent sauf 1 mais infรฉrieur ou รฉgal ร 10 + % choix alรฉatoire du diviseur + ListeDiviseurs(NbSol[k-1]); + choixdiv:=ceiling(uniformdeviate(nbdiv)); + NbSol[k]=diviseurs[choixdiv]; + fi; + endfor; + % On affiche + picture Corps; + Corps=image( + drawoptions(withcolor 0.7white); + for k=0 upto LargeurLaby-1: + trace (N[k][0]--N[k][LongueurLaby-1]) shifted((5mm,0.25*uv)); + endfor; + for k=0 upto LongueurLaby-1: + trace (N[0][k]--N[LargeurLaby-1][k]) shifted((5mm,0.25*uv)); + endfor; + drawoptions(); + nbaffiche:=0; + for k=0 upto LargeurLaby-1: + for l=0 upto LongueurLaby-1: + nbaffiche:=nbaffiche+1; + remplis ((Fullcircle scaled 10mm) shifted N[k][l]) withcolor white; + label(TEX("\num{"&decimal(NbAffiche[nbaffiche])&"}"),M[k][l]); + endfor; + endfor; + if Solution: + trace ((center Fullcircle scaled 10mm) shifted N[choixligneD][choixcolonneD]) + for k=2 upto indiceChemin-1: + -- ((center Fullcircle scaled 10mm) shifted N[xpart(PileChemin[k])][ypart(PileChemin[k])]) + endfor + --((center Fullcircle scaled 10mm) shifted Arrivee) dashed evenly withpen pencircle scaled 1.5 withcolor Brown; + fi; + remplis ((Fullcircle scaled 10mm) shifted N[choixligneD][choixcolonneD]) withcolor \useKV[ClesLabyNb]{Couleur}; + if (LargeurLaby mod 2)=0: + remplis ((unitsquare scaled 10mm) shifted Arrivee) withcolor \useKV[ClesLabyNb]{Couleur}; + else: + remplis ((Fullcircle scaled 10mm) shifted Arrivee) withcolor \useKV[ClesLabyNb]{Couleur}; + fi; + for k=2 upto indiceChemin-1: + remplis ((Fullcircle scaled 10mm) shifted N[xpart(PileChemin[k])][ypart(PileChemin[k])]) withcolor white; + label(TEX("\num{"&decimal(NbSol[k])&"}"),M[xpart(PileChemin[k])][ypart(PileChemin[k])]); + endfor; + k:=1; + label(TEX("\num{"&decimal(NbSol[k])&"}"),M[xpart(PileChemin[k])][ypart(PileChemin[k])]); + k:=indiceChemin; + label(TEX("\num{"&decimal(NbSol[k])&"}"),M[xpart(PileChemin[k])][ypart(PileChemin[k])]); + trace TraceLabyrintheMul; + ); + Corps:=(Corps scaled \useKV[ClesLabyNb]{Echelle}) rotated \useKV[ClesLabyNb]{Angle}; + trace Corps; +\end{mplibcode} +\fi +} + \newcommand\TraceLabyFacto[6]{% \mplibforcehmode% \xdef\PfCNomLabyrinthe{\useKV[ClesLabyNb]{Nom}}% diff --git a/macros/latex/contrib/profcollege/latex/PfCMulPiecesPuzzle.tex b/macros/latex/contrib/profcollege/latex/PfCMulPiecesPuzzle.tex new file mode 100644 index 0000000000..56a7ad6943 --- /dev/null +++ b/macros/latex/contrib/profcollege/latex/PfCMulPiecesPuzzle.tex @@ -0,0 +1,151 @@ +%%% +% Piรจces de puzzle pour multiplication +%%% +%https://mirror.gutenberg-asso.fr/tex.loria.fr/prod-graph/metafun.pdf +\newtoks\toklistepuzzlea% + +\def\UpdatetoksPuzzleA#1\nil{\addtotok\toklistepuzzlea{"#1",}}% + +\setKVdefault[ClesPuzzleMul]{Solution=false,Unite=1cm,Couleur=LightSteelBlue} + +\NewDocumentCommand\PuzzleMul{om}{% + \useKVdefault[ClesPuzzleMul]% + \setKV[ClesPuzzleMul]{#1}% + \setsepchar{,}% + \readlist*\PfCListePuzzle{#2}% + \StrLen{\PfCListePuzzle[1]}[\TaillePuzzle]% + \xdef\HauteurPuzzle{\PfCListePuzzlelen}% + \toklistepuzzlea{}% + \foreachitem\compteur\in\PfCListePuzzle{\expandafter\UpdatetoksPuzzleA\compteur\nil}% + \BuildPuzzle{\the\toklistepuzzlea}% +} + +\def\BuildPuzzleCode{% + def PreDrawPuzzle ( expr ww, hh, uu ) = + %randomseed := random_seed; + def rand (expr x) = + (((x)+(uniformdeviate 10))/100) + enddef; + w := ww; + h := hh; + un := uu/100; + boolean swapone; swapone := false; + boolean swaptwo; swaptwo := false; + path p[], pw[], ph[]; + def buildpath (expr len, num) = + for j=1 upto num: + clearxy; + swaptwo := not swaptwo; + if odd num: + swapone := not swaptwo; + else: + swapone := swaptwo; + fi; + for i=0 upto len+1: + x[i]c = ((i*100)*un); + y[i]c = ((j*100)*un); + x[i]m = (x[i]c+50*un); + if swapone: + y[i]m = (y[i]c-25*un) + else: + y[i]m = (y[i]c+25*un) + fi; + x[i]l = (rand(85)[x[i]c,x[i]m]); + x[i]r = (rand(15)[x[i]m,x[i+1]c]); + y[i]l = y[i]r=y[i]c; + x[i]ll = (rand(75)[x[i]c,x[i]m]); + x[i]rr = (rand(25)[x[i]m,x[i+1]c]); + y[i]ll = y[i]rr=.50[y[i]c,y[i]m]; + endfor; + p[j] := + for i=0 upto len: + z[i]c..z[i]l..z[i]ll..z[i]m..z[i]rr..z[i]r.. + endfor + z[len+1]c ; + endfor; + enddef; + pw[1] := (100*un,100*un)--(100*un,(h+1)*100*un); + pw[w+1] := ((w+1)*100*un,100*un)--((w+1)*100*un,(h+1)*100*un); + ph[1] := (100*un,100*un)--((w+1)*100*un,100*un); + ph[h+1] := (100*un,(h+1)*100*un)--((w+1)*100*un,(h+1)*100*un); + buildpath (w+1,h); + for k=2 upto h: + ph[k] := p[k] cutbefore pw[1]; + ph[k] := ph[k] cutafter pw[w+1]; + endfor; + buildpath (h+1,w); + for k=2 upto w: + pw[k] := p[w-k+2] rotated 90 shifted ((w+2)*100*un,0); + pw[k] := pw[k] cutbefore ph[1]; + pw[k] := pw[k] cutafter ph[h+1]; + endfor; + path phw[][]; + for kh=1 upto h: + for kw=1 upto w: + phw[kh][kw] := buildcycle (ph[kh], pw[kw], ph[kh+1], pw[kw+1]); + endfor; + endfor; +enddef; +def DrawWholePuzzle = + for k=1 upto h+1: + draw ph[k] withpen pencircle scaled (2.5*un) shifted (-100*un,-100*un); + endfor; + for k=1 upto w+1: + draw pw[k] withpen pencircle scaled (2.5*un) shifted (-100*un,-100*un); + endfor; +enddef; +def DrawPuzzlePiece (expr ww, hh) = +draw phw[ww][hh] withpen pencircle scaled (2.5*un) shifted (-100*un,-100*un); +enddef; +def DrawPuzzleBorder = +draw (pw[1]--ph[1]--pw[w+1]--ph[h+1]--cycle) +withpen pencircle scaled (2.5*un) shifted (-100*un,-100*un); +enddef; +% +vardef AffichagePiece(text t)= +ligne:=Hauteur+1; +for p_=t: +ligne:=ligne-1; +colonne:=0; +for k=1 upto Taille: +colonne:=colonne+1; +if substring(k-1,k) of p_="X": +DrawPuzzlePiece(ligne,colonne); +else: +if Solution: +path titi; +titi=phw[ligne][colonne]; +fill (titi shifted (-100*un,-100*un)) withcolor CoulSolution; +draw titi withpen pencircle scaled (2.5*un) shifted (-100*un,-100*un); +fi; +fi; +endfor; +endfor; +enddef; +}% + +\NewDocumentCommand\BuildPuzzle{m}{% + \ifluatex + \mplibforcehmode + \begin{mplibcode} + \BuildPuzzleCode + Taille:=\TaillePuzzle; + Hauteur:=\HauteurPuzzle; + Unite:=\useKV[ClesPuzzleMul]{Unite}; + boolean Solution; + Solution=\useKV[ClesPuzzleMul]{Solution}; + color CoulSolution; + CoulSolution=\useKV[ClesPuzzleMul]{Couleur}; + + PreDrawPuzzle(Taille, Hauteur, Unite); + + AffichagePiece(#1); + \end{mplibcode} + \else% + \begin{mpost}[mpsettings={\BuildPuzzleCode;Taille:=\TaillePuzzle;Hauteur:=\HauteurPuzzle;Unite:=\useKV[ClesPuzzleMul]{Unite};boolean Solution;Solution=\useKV[ClesPuzzleMul]{Solution};color CoulSolution;CoulSolution=\useKV[ClesPuzzleMul]{Couleur};}] + PreDrawPuzzle(Taille, Hauteur, Unite); + + AffichagePiece(#1); + \end{mpost} + \fi% +}%
\ No newline at end of file diff --git a/macros/latex/contrib/profcollege/latex/PfCNonogramme.tex b/macros/latex/contrib/profcollege/latex/PfCNonogramme.tex index 1493a2fcd8..8adfbd5654 100644 --- a/macros/latex/contrib/profcollege/latex/PfCNonogramme.tex +++ b/macros/latex/contrib/profcollege/latex/PfCNonogramme.tex @@ -46,6 +46,14 @@ \begin{mplibcode} Taille:=\useKV[Nono]{Taille}; u:=\useKV[Nono]{Unite}; + Unite=\useKV[Nono]{Unite}; + % + if u<7mm: + nu:=7mm; + else: + nu:=u; + fi; + % boolean Solution,Enonce; Solution:=\useKV[Nono]{Solution}; Enonce:=\useKV[Nono]{Enonce}; @@ -104,7 +112,7 @@ if unknown Sequence[cptnblignes][k]: else: nbpas:=nbpas+1; - label.lft(TEX(Sequence[cptnblignes][k]),(0,0) shifted (-(nbpas-1)*0.5*u-0.25*u,u*(-cptnblignes+0.5))); + label.lft(TEX(Sequence[cptnblignes][k]),(0,0) shifted (-(nbpas-1)*0.5*nu-0.25*nu,u*(-cptnblignes+0.5))); fi; endfor; endfor; @@ -130,7 +138,7 @@ if unknown SequenceCol[cptnbcolonnes][k]: else: nbpas:=nbpas+1; - label.top(TEX(SequenceCol[cptnbcolonnes][k]),(0,0) shifted (u*(cptnbcolonnes-0.5),(nbpas-1)*0.5*u+0.25*u)); + label.top(TEX(SequenceCol[cptnbcolonnes][k]),(0,0) shifted (u*(cptnbcolonnes-0.5),(nbpas-1)*0.5*nu+0.25*nu)); fi; endfor; endfor; diff --git a/macros/latex/contrib/profcollege/latex/PfCNotionFonction.tex b/macros/latex/contrib/profcollege/latex/PfCNotionFonction.tex index bb21fbb6ae..9b6c46725a 100644 --- a/macros/latex/contrib/profcollege/latex/PfCNotionFonction.tex +++ b/macros/latex/contrib/profcollege/latex/PfCNotionFonction.tex @@ -86,70 +86,163 @@ }% }% -\NewDocumentCommand\Fonctionold{o m}{% - \useKVdefault[ClesFonction]% - \setKV[ClesFonction]{#1}% - \ifboolKV[ClesFonction]{Trace}{% - \useKVdefault[TraceG]% - \setKV[TraceG]{#1}% - \tokPfCListeDesFonctions{}% - \tokPfCListeDesNomsFonctions{}% - \xdef\PfCFooFn{\useKV[ClesFonction]{Calcul}} - \xdef\PfCFooNomFn{\useKV[TraceG]{NomCourbe}} - \ifx\bla\PfCFooFn\bla% - \else - \readlist*\ListeDesFonctions{\PfCFooFn} - \foreachitem\compteur\in\ListeDesFonctions{\expandafter\UpdatePfCListeDesFonctions\compteur\nil}% - \fi - \ifx\bla\PfCFooNomFn\bla +\setKVdefault[LecGra]{NbPoints=7,Image=false,Antecedent=false,Equation=false,UniteX=1,UniteY=1,Epaisseur=1,CouleurTrace=black,Points} +\defKV[LecGra]{Graine=\PfCGraineAlea{#1}} + +\newread\myread + +\NewDocumentCommand\LectureGraphique{o}{% + \useKVdefault[LecGra]% + \setKV[LecGra]{#1}% + % Partie Trace + % On choisit les abscisses + \xdef\FooAbscisses{\fpeval{randint(-9,-5)}}% + \xdef\RappelA{\FooAbscisses}% + \xintFor*##1 in{\xintSeq{2}{\useKV[LecGra]{NbPoints}}}\do{% + \xdef\NewAbscisse{\fpeval{\RappelA+randint(2,3)}}% + \xdef\RappelA{\NewAbscisse}% + \xdef\FooAbscisses{\FooAbscisses,\NewAbscisse}% + }% + % on choisit les ordonnรฉes. + \xdef\FooOrdonnees{\fpeval{randint(-3,3)}}% + \xdef\RappelO{\FooOrdonnees}% + \xdef\ListeDesEcartsO{1,2,3}% + \xdef\FooListeDesOperations{+,-}% + \MelangeListe{\FooListeDesOperations}{2}% + \setsepchar{,}\ignoreemptyitems% + \readlist*\PfCListeChoixOperations{\faa}% + \xintFor*##1 in{\xintSeq{2}{\useKV[LecGra]{NbPoints}}}\do{% + \MelangeListe{\ListeDesEcartsO}{1}% + \setsepchar{,}\ignoreemptyitems% + \readlist*\PfCListeEcartSeul{\faa}% + \reademptyitems% + \modulo{##1}{2}\relax% + \ifnum\remainder=0\relax% + \xdef\NewOrdonnee{\fpeval{\RappelO\PfCListeChoixOperations[1]\PfCListeEcartSeul[1]}}% \else - \readlist*\ListeDesNomsFonctions{\PfCFooNomFn} - \foreachitem\compteur\in\ListeDesNomsFonctions{\expandafter\UpdatePfCListeDesNomsFonctions\compteur\nil}% + \xdef\NewOrdonnee{\fpeval{\RappelO\PfCListeChoixOperations[2]\PfCListeEcartSeul[1]}}% \fi - \TraceMultiGraphique{\the\tokPfCListeDesFonctions}{\the\tokPfCListeDesNomsFonctions}% - }{% - \ifboolKV[ClesFonction]{Points}{% - \toklistePtsFn{}% - \setsepchar[*]{ยง*/}%\ignoreemptyitems% - \readlist*\ListePoints{#2}% - \ifboolKV[ClesFonction]{Catmull}{% - \xdef\PfCFooListePoints{(\ListePoints[1,2],\ListePoints[1,3]),}% - \foreachitem\compteur\in\ListePoints{% - \xdef\PfCFooListePoints{\PfCFooListePoints (\ListePoints[\compteurcnt,2],\ListePoints[\compteurcnt,3]),}% - }% - \xdef\PfCFooListePoints{\PfCFooListePoints (\ListePoints[\ListePointslen,2],\ListePoints[\ListePointslen,3]),}% - \MPCatmull{\PfCFooListePoints}{\useKV[ClesFonction]{PasX}}{\useKV[ClesFonction]{PasY}}{\useKV[ClesFonction]{UniteX}}{\useKV[ClesFonction]{UniteY}}% - }{% - \xdef\PfCFooListePoints{} - \ifboolKV[ClesFonction]{Tangentes}{% - \foreachitem\compteur\in\ListePoints{% - \xdef\PfCFooListePoints{\PfCFooListePoints \ListePoints[\compteurcnt,1],(\ListePoints[\compteurcnt,2],\ListePoints[\compteurcnt,3]),\ListePoints[\compteurcnt,4],}% - }% - }{% - \foreachitem\compteur\in\ListePoints{% - \xdef\PfCFooListePoints{\PfCFooListePoints (\ListePoints[\compteurcnt,2],\ListePoints[\compteurcnt,3]),}% - }% - }% - \MPCourbeNew{\PfCFooListePoints}% - }% - }{% - \setsepchar{,}\ignoreemptyitems% - \roeadlist*\ListeFonction{#2}% - \StrSubstitute{\useKV[ClesFonction]{Calcul}}{\useKV[ClesFonction]{Variable}}{\i}[\temp]% - \StrSubstitute{\useKV[ClesFonction]{Calcul}}{**}{^}[\tempa]% - \StrSubstitute{\tempa}{*}{}[\tempab]% - \ifboolKV[ClesFonction]{Ecriture}{% - \ensuremath{\useKV[ClesFonction]{Nom}(\useKV[ClesFonction]{Variable})=\tempab}% - }{}% - \ifboolKV[ClesFonction]{Definition}{% - \ensuremath{\useKV[ClesFonction]{Nom}:\useKV[ClesFonction]{Variable}\mapsto\tempab}% - }{}% - \ifboolKV[ClesFonction]{Tableau}{% - \buildtabfonction% - }{}% - \reademptyitems% - }% + \xdef\RappelO{\NewOrdonnee}% + \xdef\FooOrdonnees{\FooOrdonnees,\NewOrdonnee}% + }% + \setsepchar{,}% + \readlist*\ListeAbscisses{\FooAbscisses}% + \readlist*\ListeOrdonnees{\FooOrdonnees}% + \xdef\FooPoints{0/\ListeAbscisses[1]/\ListeOrdonnees[1]/0}% + \xintFor*##1 in{\xintSeq{2}{\useKV[LecGra]{NbPoints}}}\do{% + \xdef\FooPoints{\FooPointsยง0/\ListeAbscisses[##1]/\ListeOrdonnees[##1]/0}% }% + \xdef\PfCOrdonneeMin{\fpeval{min(\FooOrdonnees)}}% + \xdef\PfCOrdonneeMax{\fpeval{max(\FooOrdonnees)}}% + \xdef\PfCAbscisseMin{\fpeval{min(\FooAbscisses)}}% + \xdef\PfCAbscisseMax{\fpeval{max(\FooAbscisses)}}% + \xdef\PfCChoixImage{\fpeval{randint(\PfCAbscisseMin,\PfCAbscisseMax)}}% + \xdef\PfCChoixAntecedent{\fpeval{randint(\PfCOrdonneeMin,\PfCOrdonneeMax)}}% + \ifboolKV[LecGra]{Image}{On effectue la lecture graphique ร partir du point $(\num{\PfCChoixImage};0)$.}{}% + \ifboolKV[LecGra]{Antecedent}{On effectue la lecture graphique en cherchant tous les points de la courbe ayant pour ordonnรฉe \num{\PfCChoixAntecedent}.}{}% + \begin{center} + \Fonction[ + Points, + Splines, + PointsCourbe=\useKV[LecGra]{Points}, + Epaisseur=\useKV[LecGra]{Epaisseur}, + CouleurTrace=\useKV[LecGra]{CouleurTrace}, + UniteX=\useKV[LecGra]{UniteX}, + UniteY=\useKV[LecGra]{UniteY}, + Traces={% + boolean PdtImage,PdtAntecedent,PdtEquation; + PdtImage:=\useKV[LecGra]{Image}; + PdtAntecedent:=\useKV[LecGra]{Antecedent}; + PdtEquation:=\useKV[LecGra]{Equation}; + % Image + PfCepsilon:=0.001; + pair A,B,C,D,Ant[]; + C=placepoint(\PfCChoixImage,0); + path droiteimage,AxeO,droiteantecedent; + droiteimage=placepoint(\PfCChoixImage,-100)--placepoint(\PfCChoixImage,100); + droiteantecedent=placepoint(-100,\PfCChoixAntecedent)--placepoint(100,\PfCChoixAntecedent); + AxeO=placepoint(0,-100)--placepoint(0,100); + intersectioncourbes(CourbeTotale,droiteimage); + A=pti[1]; + write decimal(ypart(retrouvecoord(A))) to "PfCValeurImage.tex";% + write EOF to "PfCValeurImage.tex"; + intersectioncourbes(CourbeTotale,AxeO); + if n>0: + B=pti[1]; + else: + B=placepoint(0,\PfCOrdonneeMax); + fi; + D=(xpart(B),ypart(A)); + if PdtImage: + drawoptions(dashed evenly); + drawarrow C--1/4[C,A]; + drawarrow A--3/4[A,D]; + trace (C--A--D) withpen pencircle scaled 1.25; + if ypart(A)>ypart(C): + label.bot(TEX("\num{\fpeval{\PfCChoixImage}}"),C); + else: + label.top(TEX("\num{\fpeval{\PfCChoixImage}}"),C); + fi; + drawoptions(); + fi; + %antecedent + intersectioncourbes(CourbeTotale,droiteantecedent); + for k=1 upto n: + Ant[k]=pti[k]; + endfor; + NbAntecedents:=1; + for k=2 upto n: + if abs(xpart(retrouvecoord(Ant[k]))-xpart(retrouvecoord(Ant[k-1])))>PfCepsilon: + NbAntecedents:=NbAntecedents+1; + Ant[NbAntecedents]:=pti[k]; + fi; + endfor; + write decimal(NbAntecedents) to "PfCNombreAntecedents.tex"; + write EOF to "PfCNombreAntecedents.tex"; + if NbAntecedents>0: + for k=1 upto NbAntecedents: + if PdtAntecedent or PdtEquation: + draw ((fullcircle scaled 1mm) shifted Ant[k]) withcolor red; + draw ((fullcircle scaled 1mm) shifted (xpart(Ant[k]),ypart(C))) withcolor red; + draw Ant[k]--(xpart(Ant[k]),ypart(C)) withcolor red; + drawarrow Ant[k]--1/4[Ant[k],(xpart(Ant[k]),ypart(C))] withcolor red; + fi; + write decimal(xpart(retrouvecoord(Ant[k]))) to "PfCListeAntecedents.tex"; + endfor; + fi; + write EOF to "PfCListeAntecedents.tex"; + if PdtAntecedent or PdtEquation: + draw droiteantecedent withcolor red; + if ypart(placepoint(0,\PfCChoixAntecedent))<ypart(B): + dotlabel.lrt(TEX("\num{\fpeval{\PfCChoixAntecedent}}"),placepoint(0,\PfCChoixAntecedent)); + else: + dotlabel.urt(TEX("\num{\fpeval{\PfCChoixAntecedent}}"),placepoint(0,\PfCChoixAntecedent)); + fi; + fi; + clip currentpicture to cadreexterieur; + }]{% + \FooPoints + } + \end{center} + \ifboolKV[LecGra]{Image}{% + \openin\myread=PfCValeurImage.tex + \read\myread to \LectureImage + L'image de \num{\PfCChoixImage} par la fonction $f$ est \num{\fpeval{round(\LectureImage,1)}}.% + }{}% + \ifboolKV[LecGra]{Antecedent}{% + \openin\myread=PfCNombreAntecedents.tex + \read\myread to \NombreAntecedents + \ifnum\NombreAntecedents=0\relax + Le nombre \num{\PfCChoixAntecedent} n'a pas d'antรฉcรฉdent par la fonction $f$.% + \else + Le nombre \num{\PfCChoixAntecedent} a \numberstringnum{\fpeval{\NombreAntecedents}} antรฉcรฉdent\ifnum\NombreAntecedents>1\relax s\fi{} par la fonction $f$. % Titia vaut \Titia + \openin\myread=PfCListeAntecedents.tex + Par lecture graphique, \ifnum\NombreAntecedents>1\relax ce sont \xintFor* ##1 in{\xintSeq{1}{\NombreAntecedents}}\do{% + \read\myread to \ListeNombreAntecedents% + \xintifForLast{ et }{\xintifForFirst{}{;}}\num{\fpeval{round(\ListeNombreAntecedents,1)}}% + }\else c'est \read\myread to \ListeNombreAntecedents\num{\fpeval{round(\ListeNombreAntecedents,1)}}\fi + \fi.% + }{}% }% \def\MPSplineCode{% @@ -173,6 +266,25 @@ (q,r)*cm enplace enddef; % + def replace= + xscaled (1/X.u) yscaled (1/Y.u) + enddef; +% + def retrouvecoord(expr p)=% + (p/cm) replace + enddef; +% + vardef intersectioncourbes(expr aa,bb)= + pair pti[]; + n:=0; + for k=0 upto nbpoints-1: + if ((subpath(k/nbpoints*length aa,(k+1)/nbpoints*length aa) of aa) intersectiontimes bb)<>(-1,-1): + n:=n+1; + pti[n]:=(subpath(k/nbpoints*length aa,(k+1)/nbpoints*length aa) of aa) intersectionpoint bb; + fi; + endfor; + enddef; + % nbspline=0; % nbpoints=50; @@ -189,14 +301,12 @@ xx[k]=xzero+(k/nbpoints)*(xuno-xzero); yy[k]=a[nbspline]*(xx[k]**3)+b[nbspline]*(xx[k]**2)+c[nbspline]*xx[k]+d[nbspline]; endfor; - save $; - picture $; - $=image( - draw placepoint(xzero,yzero) for k=1 upto nbpoints-1: + save Spline; + path Spline; + Spline=placepoint(xzero,yzero) for k=1 upto nbpoints-1: --placepoint(xx[k],yy[k]) endfor --placepoint(xuno,yuno); - ); - $ + Spline enddef; } @@ -284,9 +394,12 @@ % path cadreexterieur; cadreexterieur=(((MinX-1)*X.u*cm,(MinY-1)*Y.u*cm)--((MaxX+1)*X.u*cm,(MinY-1)*Y.u*cm)--((MaxX+1)*X.u*cm,(MaxY+1)*Y.u*cm)--((MinX-1)*X.u*cm,(MaxY+1)*Y.u*cm)--cycle); + path SplineRecap[],CourbeTotale; for l=1 upto N-1: - draw SplineCubique(xpart(Xn[l]),ypart(Xn[l]),xpart(Xn[l+1]),ypart(Xn[l+1]),ypart(Dn[l]),xpart(Dn[l+1])) withpen pencircle scaled Epaisseur withcolor CoulTrace; + SplineRecap[l]=SplineCubique(xpart(Xn[l]),ypart(Xn[l]),xpart(Xn[l+1]),ypart(Xn[l+1]),ypart(Dn[l]),xpart(Dn[l+1])); endfor; + CourbeTotale=SplineRecap[1] for l=2 upto N-1:..SplineRecap[l] endfor; + draw CourbeTotale withpen pencircle scaled Epaisseur withcolor CoulTrace; clip currentpicture to cadreexterieur; picture RetiensCourbe; RetiensCourbe=currentpicture; @@ -489,8 +602,9 @@ % RetiensCouleur(\useKV[TraceG]{CouleurTrace}); % - pair Origine; + pair Origine,DecalageOrigine; Origine=(xmin,ymin)+\useKV[TraceG]{Origine}; + DecalageOrigine=\useKV[TraceG]{Origine}; % boolean Grille,Vide,Graduations,Code,LegendeX,LegendeY; Grille=\useKV[TraceG]{Grille}; @@ -547,14 +661,14 @@ enddef; % vardef NommeCourbes(text texto)= - n:=0; + nc:=0; for p_=texto: - n:=n+1; + nc:=nc+1; numeric tp; - tp=pos[n]*length Cb[n]; + tp=pos[nc]*length Cb[n]; pair PT,Tangente; - PT:=point (tp) of Cb[n]; - Tangente:=unitvector(direction tp of Cb[n]); + PT:=point (tp) of Cb[nc]; + Tangente:=unitvector(direction tp of Cb[nc]); label(TEX(p_) rotated angle(Tangente),PT+2mm*(Tangente rotated 90)); endfor; enddef; @@ -595,46 +709,56 @@ \PfCTraceMGCode if Grille: drawoptions(withcolor 0.75white); - for k=xpart(Origine) step grillex until xmax: - trace u*(k,ymin)--u*(k,ymax); + for k=xpart(Origine) step grillex until (xmax+grillex): + trace u*(k,ymin-grilley)--u*(k,ymax+grilley); endfor; - for k=xpart(Origine) step -grillex until xmin: - trace u*(k,ymin)--u*(k,ymax); + for k=xpart(Origine) step -grillex until (xmin-grillex): + trace u*(k,ymin-grilley)--u*(k,ymax+grilley); endfor; - for k=ypart(Origine) step grilley until ymax: - trace u*(xmin,k)--u*(xmax,k); + for k=ypart(Origine) step grilley until (ymax+grilley): + trace u*(xmin-grillex,k)--u*(xmax+grillex,k); endfor; - for k=ypart(Origine) step -grilley until ymin: - trace u*(xmin,k)--u*(xmax,k); + for k=ypart(Origine) step -grilley until (ymin-grilley): + trace u*(xmin-grillex,k)--u*(xmax+grillex,k); endfor; drawoptions(); fi; if Graduations: - for k=gradx step gradx until bornesupmax:%xmax*gradx/grillex: - dotlabel.bot(TEX("\num{"&decimal(k)&"}"),(k*xu+xpart(Origine*cm),ypart(Origine*cm))); + for k=gradx step gradx until (((xmax-xmin)-xpart(DecalageOrigine))*pasx): + dotlabel.bot(TEX("\num{"&decimal(k)&"}"),Origine*cm+(k*xu,0)); endfor; - for k=-gradx step -gradx until borneinfmin:%xmin*gradx/grillex: - dotlabel.bot(TEX("\num{"&decimal(k)&"}"),(k*xu+xpart(Origine*cm),ypart(Origine*cm))); + for k=-gradx step -gradx until (xpart(-DecalageOrigine)*pasx): + dotlabel.bot(TEX("\num{"&decimal(k)&"}"),Origine*cm+(k*xu,0)); endfor; - for k=grady step grady until ymax*grady/grilley: - dotlabel.lft(TEX("\num{"&decimal(k)&"}"),(xpart(Origine*cm),k*yu+ypart(Origine*cm))); + for k=grady step grady until (((ymax-ymin)-ypart(DecalageOrigine))*pasy): + dotlabel.lft(TEX("\num{"&decimal(k)&"}"),Origine*cm+(0,k*yu)); endfor; - for k=-grady step -grady until ymin*grady/grilley: - dotlabel.lft(TEX("\num{"&decimal(k)&"}"),(xpart(Origine*cm),k*yu+ypart(Origine*cm))); + for k=-grady step -grady until (ypart(-DecalageOrigine)*pasy): + dotlabel.lft(TEX("\num{"&decimal(k)&"}"),Origine*cm+(0,k*yu)); endfor; fi; % drawoptions(withpen pencircle scaled(1)); - drawarrow (u*(0,ymin)--u*(0,ymax)) shifted (u*(xpart(Origine),0)); - drawarrow (u*(xmin,0)--u*(xmax,0)) shifted (u*(0,ypart(Origine))); + drawarrow (u*(0,ymin-grilley)--u*(0,ymax+grilley)) shifted (u*(xpart(Origine),0)); + drawarrow (u*(xmin-grillex,0)--u*(xmax+grillex,0)) shifted (u*(0,ypart(Origine))); label.llft(btex 0 etex,u*Origine); drawoptions(); if Vide: + if Grille: + clip currentpicture to polygone(u*(xmin-grillex,ymin-grilley),u*(xmax+grillex,ymin-grilley),u*(xmax+grillex,ymax+grilley),u*(xmin-grillex,ymax+grilley)); + draw polygone(u*(xmin-grillex,ymin-grilley),u*(xmax+grillex,ymin-grilley),u*(xmax+grillex,ymax+grilley),u*(xmin-grillex,ymax+grilley)) withcolor 0.75white; + else: clip currentpicture to polygone(u*(xmin,ymin),u*(xmax,ymin),u*(xmax,ymax),u*(xmin,ymax)); + fi; else: DessineCourbes(#1); NommeCourbes(#2); + if Grille: + clip currentpicture to polygone(u*(xmin-grillex,ymin-grilley),u*(xmax+grillex,ymin-grilley),u*(xmax+grillex,ymax+grilley),u*(xmin-grillex,ymax+grilley)); + draw polygone(u*(xmin-grillex,ymin-grilley),u*(xmax+grillex,ymin-grilley),u*(xmax+grillex,ymax+grilley),u*(xmin-grillex,ymax+grilley)) withcolor 0.75white; + else: clip currentpicture to polygone(u*(xmin,ymin),u*(xmax,ymin),u*(xmax,ymax),u*(xmin,ymax)); + fi; % if Code: EffectuerTraces; diff --git a/macros/latex/contrib/profcollege/latex/PfCOperationsTrou.tex b/macros/latex/contrib/profcollege/latex/PfCOperationsTrou.tex index e5c9c7a568..9567c563cd 100644 --- a/macros/latex/contrib/profcollege/latex/PfCOperationsTrou.tex +++ b/macros/latex/contrib/profcollege/latex/PfCOperationsTrou.tex @@ -68,4 +68,15 @@ transform canvas={xshift=0em,yshift=0em}},rectangle,rounded corners,ultra thick, \foreach \i in {1,...,\thesubxlop}{% \PfCentoure{A\i}{A\i} }% +}% + +\NewDocumentCommand\MultiAddition{om}{% + \useKVdefault[ClesOperations]% + \setKV[ClesOperations]{#1}% + \setcounter{addxlop}{0}% + \ifboolKV[ClesOperations]{Solution}{\opset{carryadd,carrystyle=\color{PfCSolOp}\scriptsize}\colorlet{PfCSolOp}{\useKV[ClesOperations]{CouleurSolution}}\colorlet{PfCCouleurVirgule}{PfCSolOp}}{\opset{carryadd=false}\colorlet{PfCSolOp}{\useKV[ClesOperations]{CouleurFond}}\colorlet{PfCCouleurVirgule}{\useKV[ClesOperations]{CouleurVirgule}}}% + \opmanyadd[decimalsepsymbol={,},lineheight=1.75em,columnwidth=1.5em,displayintermediary=all,vmanyoperator=bottom,intermediarystyle=\stepcounter{addxlop}\color{PfCSolOp}\PfCchiffre{A\theaddxlop},resultstyle=\stepcounter{addxlop}\color{PfCSolOp}\PfCchiffre{A\theaddxlop},resultstyle.d=\color{PfCCouleurVirgule}]#2 + \foreach \i in {1,...,\theaddxlop}{% + \PfCentoure{A\i}{A\i}% + }% }%
\ No newline at end of file diff --git a/macros/latex/contrib/profcollege/latex/PfCPourcentage.tex b/macros/latex/contrib/profcollege/latex/PfCPourcentage.tex index ff0bdd753f..1f6f18b19b 100644 --- a/macros/latex/contrib/profcollege/latex/PfCPourcentage.tex +++ b/macros/latex/contrib/profcollege/latex/PfCPourcentage.tex @@ -1,8 +1,8 @@ %%% % Application : pourcentage %%% -\setKVdefault[ClesPourcentage]{Appliquer,Calculer=false,Augmenter=false,Reduire=false,Fractionnaire=false,Decimal,Formule=false,Unite=g,Concret=false,GrandeurA=Grandeur A,GrandeurB=Total,Largeur=1cm,MotReduction=diminution,AideTableau=false,ColorFill=white,CouleurTab=gray!15} - +\setKVdefault[ClesPourcentage]{Appliquer,Calculer=false,Augmenter=false,Reduire=false,Fractionnaire=false,Decimal,Formule=false,Concret=false,GrandeurA=Grandeur A,GrandeurB=Total,Largeur=1cm,MotReduction=diminution,AideTableau=false,ColorFill=white,CouleurTab=gray!15} +\defKV[ClesPourcentage]{Unite=\setKV[ClesPourcentage]{Concret}} \newcommand\Pourcentage[3][]{% \useKVdefault[ClesPourcentage]% \setKV[ClesPourcentage]{#1}% diff --git a/macros/latex/contrib/profcollege/latex/PfCPyraVoca.tex b/macros/latex/contrib/profcollege/latex/PfCPyraVoca.tex new file mode 100644 index 0000000000..bfda696300 --- /dev/null +++ b/macros/latex/contrib/profcollege/latex/PfCPyraVoca.tex @@ -0,0 +1,28 @@ +%%% +% PyraVoca +%%% +\newlength{\PfCPyraVocaHauteur} + +\setKVdefault[PyraVoca]{Solution=false,Largeur=15pt} + +\NewDocumentCommand\PyraVoca{o m}{% + \useKVdefault[PyraVoca]% + \setKV[PyraVoca]{#1}% + \setsepchar[*]{,*/}\ignoreemptyitems% + \readlist*\PfCListePyraVoca{#2}% + \reademptyitems% + \StrLen{\PfCListePyraVoca[1,2]}[\Toto]% + \xdef\PfCFooNombreCases{\Toto}% + \xintFor* ##1 in{\xintSeq{2}{\PfCListePyraVocalen}}\do{% + \StrLen{\PfCListePyraVoca[##1,2]}[\Toto]% + \xdef\PfCFooNombreCases{\PfCFooNombreCases,\Toto}% + }% + \xdef\PfCNombreMaxCases{\fpeval{max(\PfCFooNombreCases)}}% + \setlength{\PfCPyraVocaHauteur}{\useKV[PyraVoca]{Largeur}+\tabcolsep}% + \begin{NiceTabular}{l*{\PfCNombreMaxCases}{m{\useKV[PyraVoca]{Largeur}}}}% + \xintFor* ##1 in{\xintSeq{1}{\PfCListePyraVocalen}}\do{% + \StrLen{\PfCListePyraVoca[##1,2]}[\Toto]% + \rule{0pt}{\PfCPyraVocaHauteur}\Block[draw,v-center,fill=\xintifboolexpr{\listlen\PfCListePyraVoca[##1]==3}{\PfCListePyraVoca[##1,3]}{white}]{1-1}{\PfCListePyraVoca[##1,1]}\xintFor* ##2 in{\xintSeq{1}{\Toto}}\do{&\Block[draw,v-center,fill=\xintifboolexpr{\listlen\PfCListePyraVoca[##1]==3}{\PfCListePyraVoca[##1,3]}{white}]{}{\ifboolKV[PyraVoca]{Solution}{\StrChar{\PfCListePyraVoca[##1,2]}{##2}}{}}}\\ + }% + \end{NiceTabular}% +}%
\ No newline at end of file diff --git a/macros/latex/contrib/profcollege/latex/PfCReperage.tex b/macros/latex/contrib/profcollege/latex/PfCReperage.tex index 96c2d6512d..0d4ba8b3d6 100644 --- a/macros/latex/contrib/profcollege/latex/PfCReperage.tex +++ b/macros/latex/contrib/profcollege/latex/PfCReperage.tex @@ -1,12 +1,13 @@ %%% % Reperage %%% -\setKVdefault[ClesReperage]{Unitex=1,Pasx=1,Unitey=1,Pasy=1,Unitez=1,Pasz=1,DemiDroite=false,Droite=false,Plan=false,Trace=false,ListeSegment={},Espace=false,Sphere=false,AnglePhi=30,CouleurLa=white,CouleurLon=Tomato,AffichageNom=false,AffichageGrad=false,AffichageAbs=0,AffichageCoord=false,LectureCoord=false,ValeurUnitex=1,ValeurUnitey=1,ValeurOrigine=0,NomOrigine=O,EchelleEspace=50,CouleurCoord=black,Thermometre=false,Mercure=false,CouleurMercure=black,Celsius,Kelvin=false,Farenheit=false,ValeurMin=-4000,ValeurMax=4000,Etages=4,Code=false,Globe=false,Rho=1500,Phi=22,Theta=10,CouleurE=orange,CouleurG=green,Axes=false,TypeProj="persp"} +\setKVdefault[ClesReperage]{Unitex=1,Pasx=1,Unitey=1,Pasy=1,Unitez=1,Pasz=1,DemiDroite=false,Droite=false,Plan=false,Trace=false,ListeSegment={},Espace=false,Sphere=false,AnglePhi=30,CouleurLa=white,CouleurLon=Tomato,AffichageUnites=true,MarquePrimaire=true,AffichageNom=false,AffichageGrad=false,AffichageAbs=0,AffichageCoord=false,LectureCoord=false,ValeurUnitex=1,ValeurUnitey=1,ValeurOrigine=0,NomOrigine=O,EchelleEspace=50,CouleurCoord=black,Thermometre=false,Mercure=false,CouleurMercure=black,Celsius,Kelvin=false,Farenheit=false,ValeurMin=-4000,ValeurMax=4000,Etages=4,Code=false,Globe=false,Rho=1500,Phi=22,Theta=10,CouleurE=orange,CouleurG=green,Axes=false,TypeProj="persp",Niveaux=false} \defKV[ClesReperage]{Traces=\setKV[ClesReperage]{Code}} +\defKV[ClesReperage]{Niveau=\setKV[ClesReperage]{Etages=#1}\setKV[ClesReperage]{Niveaux}} % ValeurOrigine permet de faire des morceaux de demi-droite gradu\'ee en passant par droite :) \def\Updatetoksdroite#1/#2\nil{\addtotok\toklistepointdroite{#1,"#2",}} -\def\Updatetoksdroite#1/#2\nil{\addtotok\toklistepointdroite{#1,"#2",}} +%\def\Updatetoksdroite#1/#2\nil{\addtotok\toklistepointdroite{#1,"#2",}} \def\Updatetoksdemidroite#1/#2\nil{\addtotok\toklistenompointdemidroite{"#2",}} \def\Updatetoksrepere#1/#2/#3\nil{\addtotok\toklistepointrepere{#1,#2,"#3",}} \def\Updatetoksespace#1/#2/#3/#4\nil{\addtotok\toklistepointespace{#1,#2,#3,"#4",}} @@ -48,6 +49,7 @@ \def\MPGlobe#1#2{% \ifluatex + \mplibnumbersystem{double} \mplibforcehmode \begin{mplibcode} input PfCSolid; @@ -89,7 +91,6 @@ AffichagePfC2; % AffichageObjet2; if \useKV[ClesReperage]{Axes}: - TraceAxes; drawoptions(withpen pencircle scaled 1.05 withcolor CouleurE); AffichageEquateur3; drawoptions(withpen pencircle scaled 1 withcolor CouleurG); @@ -1424,8 +1425,10 @@ AffichageGrad:=\AffichageGrad; AffichageCoord:=\useKV[ClesReperage]{AffichageAbs}; AffichageNom:=\AffichageNom; - boolean DemiDroite; + boolean DemiDroite,AffichageUnites,MarquePrimaire; DemiDroite=\useKV[ClesReperage]{DemiDroite}; + AffichageUnites=\useKV[ClesReperage]{AffichageUnites}; + MarquePrimaire=\useKV[ClesReperage]{MarquePrimaire}; numeric valeur[]; vardef titi(text t)= n:=0; @@ -1452,15 +1455,15 @@ if minx>(-pasx-1): minx:=-2*pasx-1; fi; + if DemiDroite: + minx:=0; + fi; if minx<\useKV[ClesReperage]{ValeurMin}: minx:=\useKV[ClesReperage]{ValeurMin}; fi; if maxx>\useKV[ClesReperage]{ValeurMax}: maxx:=\useKV[ClesReperage]{ValeurMax}; fi; - if DemiDroite: - minx:=0; - fi; % ----- pair A,B,C; A=(0,0); @@ -1480,25 +1483,29 @@ draw marquedemidroite(C,B); draw marquesegment((k/maxx)[A,B],((k+1)/maxx)[A,B]); endfor; - else: + else: for k=(minx) step 2 until (maxx-1): draw marquesegment((k/maxx)[A,B],((k+1)/maxx)[A,B]); - endfor; - fi; + endfor; + fi; % marquage primaire marque_s:=marque_s*3; - for k=0 step pasx until (maxx-pasx): + if MarquePrimaire: + for k=0 step pasx until (maxx-pasx): draw marquesegment((k/maxx)[A,B],((k+pasx)/maxx)[A,B]); endfor; for k=0 step -pasx until (minx+pasx): draw marquesegment((k/maxx)[A,B],((k-pasx)/maxx)[A,B]); endfor; + fi; % marquage des points m_c:=m_c*3; marque_p:="croix"; labeloffset:=labeloffset*3; + if AffichageUnites: label.bot(TEX("\footnotesize\num{"&decimal(ValeurUnitex)&"}"),unitex*(1,0)); label.bot(TEX("\footnotesize\num{"&decimal(ValeurOrigine)&"}"),A); + fi; if AffichageGrad>0: for k=((minx+(minx mod pasx)) div pasx) upto (maxx div pasx): if (k<0) or (k>1): @@ -1531,7 +1538,7 @@ if ACoord=3: drawarrow ((unitp*valeur[n],-7mm))--((unitp*valeur[n],-3mm)); label.bot(btex \hbox to2em{\dotfill} etex,((unitp*valeur[n],-8mm))); - pointe(unitp*(valeur[n]-ValeurOrigine,0)); + pointe(unitp*(valeur[n],0)); elseif ACoord=2: if ((ValeurUnitex*valeur[n]) mod pasx)<>0: label.bot(TEX("\footnotesize$\frac{\num{\fpeval{"&decimal(ValeurOrigine*pasx)&"+"&decimal(ValeurUnitex-ValeurOrigine)&"*"&decimal(valeur[n])&"}}}{\num{"&decimal(pasx)&"}}$"),unitp*(valeur[n],0)); @@ -2280,4 +2287,144 @@ label.lft(LATEX("\noexpand\footnotesize\noexpand\SI{\noexpand\fpeval{"&decimal(V \foreachitem\compteur\in\ListePointDroite{\xdef\Listedesvaleursaplacersurlademidroite{\Listedesvaleursaplacersurlademidroite,\ListePointDroite[\compteurcnt,1]}}% \MPNewDROITEGradueeMulti{\Listedesvaleursaplacersurlademidroite}{\the\toklistenompointdemidroite}% \setsepchar{,}% +}% + +\def\MPMultiZoom#1#2#3{% + % #1 : liste des points \`a placer en pas. pour g\'erer le cas des rep\'erages fractionnaires + % #2 : liste des noms des points + % #3 : la dรฉcomposition du nombre ร placer + \ifluatex + \mplibforcehmode + \begin{mplibcode} + unitex:=\useKV[ClesReperage]{Unitex}*cm; + pasx:=10; + unitp:=unitex/pasx; + ValeurUnitex:=\useKV[ClesReperage]{ValeurUnitex}; + ValeurOrigine:=\useKV[ClesReperage]{ValeurOrigine}; + AffichageGrad:=\AffichageGrad; + AffichageCoord:=\useKV[ClesReperage]{AffichageAbs}; + AffichageNom:=\AffichageNom; + NbEtages:=\useKV[ClesReperage]{Etages}; + EtagesMax=\LongueurPartieDecimale; + numeric valeur[]; + vardef titi(text t)= + n:=0; + for p_=t: + n:=n+1; + valeur[n]=p_; + endfor; + enddef; + titi(#1); + vardef toto(text t)= + n:=0; + for p_=t: + n:=n+1; + decomp[n]=p_; + endfor; + enddef; + toto(#3); + % Dรฉtermination des abscisses maximale et minimale + minx=floor(0); + maxx=ceiling(10); +% % ----- + pair A[],B[],C[]; + for l=0 upto (NbEtages-1): + A[l]=(0,-l*cm); + B[l]=unitp*(maxx,0)+(0,-l*cm); + C[l]=unitp*(minx,0)+(0,-l*cm); + % On trace la demi-droite + if floor(valeur[1]*(10**l))>0: + drawarrow (C[l]+unitp*(-0.75,0))--(B[l]+unitp*(0.75,0)); + else: + drawarrow A[l]--(B[l]+unitp*(0.75,0)); + fi; + % marquage secondaire + marque_s:=marque_s/3; + if ((maxx-minx) mod 2)=0: + for k=(minx+1) step 2 until (maxx-1): + draw marquedemidroite(C[l],B[l]); + draw marquesegment((k/maxx)[A[l],B[l]],((k+1)/maxx)[A[l],B[l]]); + endfor; + else: + for k=(minx) step 2 until (maxx-1): + draw marquesegment((k/maxx)[A[l],B[l]],((k+1)/maxx)[A[l],B[l]]); + endfor; + fi; + % marquage primaire + marque_s:=marque_s*3; + for k=0 step pasx until (maxx-pasx): + draw marquesegment((k/maxx)[A[l],B[l]],((k+pasx)/maxx)[A[l],B[l]]); + endfor; + for k=0 step -pasx until (minx+pasx): + draw marquesegment((k/maxx)[A[l],B[l]],((k-pasx)/maxx)[A[l],B[l]]); + endfor; + endfor; + for k=0 upto (\useKV[ClesReperage]{Etages}-2): + lp:=decomp[k+2]; + draw ((lp/10)[A[k],B[k]]--((lp+1)/10)[A[k],B[k]]) withpen pencircle scaled 1.5; + draw (lp/10)[A[k],B[k]]--A[k+1] dashed evenly scaled 0.5 withcolor 0.5white; + draw ((lp+1)/10)[A[k],B[k]]--B[k+1] dashed evenly scaled 0.5 withcolor 0.5white; + if lp>0: + label.bot(TEX("\footnotesize\num{\fpeval{floor("&decimal(valeur[1])&","&decimal(k+1)&")}}"),(lp/10)[A[k],B[k]]+(0,6mm)); + fi; + if lp<9: + label.bot(TEX("\footnotesize\num{\fpeval{ceil("&decimal(valeur[1])&","&decimal(k+1)&")}}"),((lp+1)/10)[A[k],B[k]]+(0,6mm)); + fi; + endfor; + Decomp=0; + for k=0 upto (NbEtages-1): + label.bot(TEX("\footnotesize\num{\fpeval{floor("&decimal(valeur[1])&","&decimal(k)&")}}"),A[k]+(0,6mm)); + label.bot(TEX("\footnotesize\num{\fpeval{ceil("&decimal(valeur[1])&","&decimal(k)&")}}"),B[k]+(0,6mm)); + endfor; + vardef tata(text t)=%on place les points + labeloffset:=labeloffset*2; + if AffichageNom>0: + for p_=t: + label.top(TEX("\footnotesize"&p_),unitp*(decomp[NbEtages+1],0)+(0,(-\useKV[ClesReperage]{Etages}+1)*cm)); + endfor; + fi; + if AffichageCoord=3: + for p_=t: + drawarrow (unitp*(decomp[NbEtages+1],-1)+(0,(-\useKV[ClesReperage]{Etages}+1)*cm))--(unitp*(decomp[NbEtages+1],-0.3)+(0,(-\useKV[ClesReperage]{Etages}+1)*cm)); + label.bot(TEX("\hbox to4em{\dotfill}"),(unitp*(decomp[NbEtages+1],-1))+(0,(-NbEtages+0.8)*cm)); + endfor; + else: + label.bot(TEX("\footnotesize\num{\fpeval{"&decimal(valeur[1])&"}}"),unitp*(decomp[NbEtages+1],0)+(0,(-\useKV[ClesReperage]{Etages}+1)*cm)); + fi; + labeloffset:=labeloffset/2; + enddef; + %%% + if NbEtages=EtagesMax: + tata(#2); + fi; + \end{mplibcode} + \fi +} + +\NewDocumentCommand\ReperageZoom{o m}{% + \useKVdefault[ClesReperage]% + \setKV[ClesReperage]{#1}% + \setsepchar[*]{,*/}\ignoreemptyitems% + \readlist*\ListePointDroite{#2}% + \StrBefore{\ListePointDroite[1,1]}{.}[\PartieEntiere]% + \StrBehind{\ListePointDroite[1,1]}{.}[\PartieDecimale]% + \StrLen{\PartieDecimale}[\LongueurPartieDecimale]% + \ifboolKV[ClesReperage]{Niveaux}{}{ + \setKV[ClesReperage]{Etages=\LongueurPartieDecimale}% + } + \xdef\Foo{\PartieEntiere}% + \xintFor* ##1 in {\xintSeq{1}{\LongueurPartieDecimale}}\do{% + \StrChar{\PartieDecimale}{##1}[\LettreActuelle]% + \xdef\Foo{\Foo,\LettreActuelle}% + }% + \toklistepointdroite{}% + \toklistenompointdemidroite{}% + \xdef\AffichageNom{0}\ifboolKV[ClesReperage]{AffichageNom}{\xdef\AffichageNom{1}}{}% + \xdef\AffichageCoord{\useKV[ClesReperage]{AffichageAbs}}% + \xdef\AffichageGrad{0}\ifboolKV[ClesReperage]{AffichageGrad}{\xdef\AffichageGrad{1}}{}% + \foreachitem\compteur\in\ListePointDroite{\expandafter\Updatetoksdemidroite\compteur\nil}% + \xdef\Listedesvaleursaplacersurlademidroite{}% + \foreachitem\compteur\in\ListePointDroite{\xdef\Listedesvaleursaplacersurlademidroite{\Listedesvaleursaplacersurlademidroite,\ListePointDroite[\compteurcnt,1]}}% + \MPMultiZoom{\Listedesvaleursaplacersurlademidroite}{\the\toklistenompointdemidroite}{\Foo}% + \setsepchar{,}% }%
\ No newline at end of file diff --git a/macros/latex/contrib/profcollege/latex/PfCRepresenterTableur.tex b/macros/latex/contrib/profcollege/latex/PfCRepresenterTableur.tex index 8f15672708..fd505aa3e0 100644 --- a/macros/latex/contrib/profcollege/latex/PfCRepresenterTableur.tex +++ b/macros/latex/contrib/profcollege/latex/PfCRepresenterTableur.tex @@ -59,21 +59,21 @@ wc{20pt}Y*{\fpeval{\useKV[Tableur]{Colonnes}-1}}{X}}[hvlines]% \CodeBefore % on colorie en gris toute la premiรจre ligne - \tikz\draw[fill=gray!15](row-1-|col-1) rectangle (row-2-|last);% + \tikz\fill[gray!15](row-1-|col-1) rectangle (row-2-|last);% % on colorie en gris toute la premiรจre colonne - \tikz\draw[fill=gray!15](row-1-|col-1) rectangle (last-|col-2);% + \tikz\fill[gray!15](row-1-|col-1) rectangle (last-|col-2);% % \xintifboolexpr{\useKV[Tableur]{Ligne}==0 || \useKV[Tableur]{Colonne}==0}{}{% \ifboolKV[Tableur]{Selection}{% \xdef\PfCTabCouleur{\useKV[Tableur]{Couleur}}% % on colorie les cellules sans les tracer - \tikz\draw[fill=\PfCTabCouleur!50](row-\fpeval{\useKV[Tableur]{Ligne}+1}-|col-\fpeval{\useKV[Tableur]{Colonne}+1}) rectangle (row-\fpeval{\useKV[Tableur]{Ligne}+1+\useKV[Tableur]{PasL}}-|col-\fpeval{\useKV[Tableur]{Colonne}+1+\useKV[Tableur]{PasC}});% + \tikz\fill[\PfCTabCouleur!50](row-\fpeval{\useKV[Tableur]{Ligne}+1}-|col-\fpeval{\useKV[Tableur]{Colonne}+1}) rectangle (row-\fpeval{\useKV[Tableur]{Ligne}+1+\useKV[Tableur]{PasL}}-|col-\fpeval{\useKV[Tableur]{Colonne}+1+\useKV[Tableur]{PasC}});% % on trace la premiรจre cellule qui a servi ร sรฉlectionner \tikz\draw[line width=1.25pt,fill=\PfCTabCouleur!50](row-\fpeval{\useKV[Tableur]{Ligne}+1}-|col-\fpeval{\useKV[Tableur]{Colonne}+1}) rectangle (row-\fpeval{\useKV[Tableur]{Ligne}+1+1}-|col-\fpeval{\useKV[Tableur]{Colonne}+1+1});% % on colorie la zone nรฉcessaire sur la premiรจre ligne - \tikz\draw[fill=\PfCTabCouleur](row-1-|col-\fpeval{\useKV[Tableur]{Colonne}+1}) rectangle (row-2-|col-\fpeval{\useKV[Tableur]{Colonne}+1+\useKV[Tableur]{PasC}});% + \tikz\fill[\PfCTabCouleur](row-1-|col-\fpeval{\useKV[Tableur]{Colonne}+1}) rectangle (row-2-|col-\fpeval{\useKV[Tableur]{Colonne}+1+\useKV[Tableur]{PasC}});% % on colorie la zone nรฉcessaire sur la premiรจre colonne - \tikz\draw[fill=\PfCTabCouleur](row-\fpeval{\useKV[Tableur]{Ligne}+1}-|col-1) rectangle (row-\fpeval{\useKV[Tableur]{Ligne}+1+\useKV[Tableur]{PasL}}-|col-2);% + \tikz\fill[\PfCTabCouleur](row-\fpeval{\useKV[Tableur]{Ligne}+1}-|col-1) rectangle (row-\fpeval{\useKV[Tableur]{Ligne}+1+\useKV[Tableur]{PasL}}-|col-2);% }{% \tikz\draw[line width=1.25pt](row-\fpeval{\useKV[Tableur]{Ligne}+1}-|col-\fpeval{\useKV[Tableur]{Colonne}+1}) rectangle (row-\fpeval{\useKV[Tableur]{Ligne}+1+\useKV[Tableur]{PasL}}-|col-\fpeval{\useKV[Tableur]{Colonne}+1+\useKV[Tableur]{PasC}});% }% diff --git a/macros/latex/contrib/profcollege/latex/PfCRondeInfernale.tex b/macros/latex/contrib/profcollege/latex/PfCRondeInfernale.tex index 8426646d55..7917c5138b 100644 --- a/macros/latex/contrib/profcollege/latex/PfCRondeInfernale.tex +++ b/macros/latex/contrib/profcollege/latex/PfCRondeInfernale.tex @@ -46,17 +46,25 @@ \fi } -\setKVdefault[RondeInfernale]{Solution=false,Relatifs=false,Etapes=4,Perso=false,Cles=false,Vide,Rayon=2.5cm,Graines=false,Rectangle=false}% -\defKV[RondeInfernale]{Graine=\setKV[RondeInfernale]{Graines}}% +\setKVdefault[RondeInfernale]{Solution=false,Relatifs=false,Etapes=4,Perso=false,Cles=false,Vide,Rayon=2.5cm,Rectangle=false}% +\defKV[RondeInfernale]{Graine=\PfCGraineAlea{#1}} \defKV[RondeInfernale]{Cle=\setKV[RondeInfernale]{Cles}\setKV[RondeInfernale]{Vide=false}}% \defKV[RondeInfernale]{ListeOperations=\setKV[RondeInfernale]{Perso}}% \defKV[RondeInfernale]{ListeNombres=\setKV[RondeInfernale]{Perso}}% -% -\NewDocumentCommand\RondeInfernale{o}{% +% + +\NewDocumentCommand\RondeInfernale{ }{%Mise en place pour les germanistes : le " est actif :( + \begingroup + \catcode`\"12 + \RondeInfernaleaux +}% + +\NewDocumentCommand\RondeInfernaleaux{o}{% + \endgroup \useKVdefault[RondeInfernale]% \setKV[RondeInfernale]{#1}% % Graine - \ifboolKV[RondeInfernale]{Graines}{\PfCGraineAlea{\useKV[RondeInfernale]{Graine}}}{}% +% \ifboolKV[RondeInfernale]{Graines}{\PfCGraineAlea{\useKV[RondeInfernale]{Graine}}}{}% % Nombre clรฉ \ifboolKV[RondeInfernale]{Cles}{% \xdef\PfCRINombreCle{\useKV[RondeInfernale]{Cle}}% diff --git a/macros/latex/contrib/profcollege/latex/PfCRose.tex b/macros/latex/contrib/profcollege/latex/PfCRose.tex index 2c8ff3fd06..e238d42390 100644 --- a/macros/latex/contrib/profcollege/latex/PfCRose.tex +++ b/macros/latex/contrib/profcollege/latex/PfCRose.tex @@ -1,20 +1,257 @@ %%% % Rose %%% -\setKVdefault[ClesRose]{Vide=false,Couleur=white,Produits=false,Solution=false,Rayon=2cm,Petales=7,Aide=false,FacteurMin=2,FacteurMax=10,ProduitVide=false,CaseVide=false,Polygone=false,Nom=Rose1}% +\setKVdefault[ClesRose]{Vide=false,Couleur=white,Produits=false,Solution=false,Rayon=2cm,Petales=7,Aide=false,FacteurMin=2,FacteurMax=10,ProduitVide=false,CaseVide=false,Polygone=false,Nom=Rose1,Creation=false,Addition=false}% +\defKV[ClesRose]{LesNombres=\setKV[ClesRose]{Creation}}% +\defKV[ClesRose]{LesProduits=\setKV[ClesRose]{Creation}}% +\defKV[ClesRose]{LesSommes=\setKV[ClesRose]{Addition}}% + +\def\UpdatetoksRM#1\nil{\addtotok\toklisterosemul{"#1",}}% \NewDocumentCommand\RoseMul{o}{% + \newtoks\toklisterosemul% \useKVdefault[ClesRose]% \setKV[ClesRose]{#1}% - \ifluatex% - \ifboolKV[ClesRose]{Solution}{% - \DessineRoseMulSol% + \ifboolKV[ClesRose]{Creation}{% + \xdef\PfCFooRoseMul{\useKV[ClesRose]{LesNombres}}% + \ifboolKV[ClesRose]{Addition}{% + \xdef\PfCFooRoseMul{\PfCFooRoseMul,\useKV[ClesRose]{LesSommes}}% + }{% + \xdef\PfCFooRoseMul{\PfCFooRoseMul,\useKV[ClesRose]{LesProduits}}% + }% + \setsepchar{,}% + \readlist*\ListeCompleteRoseMul{\PfCFooRoseMul}% + \foreachitem\compteur\in\ListeCompleteRoseMul{\expandafter\UpdatetoksRM\compteur\nil}% + \xdef\PfCRetiensLesFacteurs{}% + \foreachitem\compteur\in\ListeCompleteRoseMul{% + \StrLen{\ListeCompleteRoseMul[\compteurcnt]}[\PfCLongueurArg]% + \ifnum\PfCLongueurArg>0\relax% + \xdef\PfCRetiensLesFacteurs{\PfCRetiensLesFacteurs \ListeCompleteRoseMul[\compteurcnt],}% + \else% + \xdef\PfCRetiensLesFacteurs{\PfCRetiensLesFacteurs "a",}% + \fi% + }% + \DessineRoseMulPerso{\the\toklisterosemul}{\PfCRetiensLesFacteurs}% }{% - \DessineRoseMul% + \ifluatex% + \ifboolKV[ClesRose]{Solution}{% + \DessineRoseMulSol% + }{% + \DessineRoseMul% + }% + \else% + \DessineRoseMul% + \fi% }% - \else% - \DessineRoseMul% - \fi% +}% + +\def\DessineRoseMulPersoCode{% + pair A[],B[],O; + O=(0,0); + path cc; + cc=cercles(O,Rayon); + for k=0 upto Petales: + A[k]=pointarc(cc,(360/Petales)*k); + endfor; + for k=0 upto Petales-1: + B[k]=iso(A[k],A[k+1]); + endfor; + B[Petales]=B[0]; + path BoiteRec; + if Polygone: + BoiteRec=(pointarc(fullcircle,0) for k=1 upto Petales:--pointarc(fullcircle,k*(360/Petales)) endfor --cycle) scaled 1u; + else: + BoiteRec=((-0.4,-0.5)--(0.4,-0.5){dir0}..{dir90}(0.5,-0.4)--(0.5,0.4){dir90}..{dir180}(0.4,0.5)--(-0.4,0.5){dir180}..{dir-90}(-0.5,0.4)--(-0.5,-0.4){dir-90}..cycle) scaled 1u; + fi; + % On rรฉcupรจre la liste des nombres et facteurs + vardef RecupListe(text t)= + nbpetales:=0; + nbfacteur:=0; + nbproduit:=0; + numfacteurconnu:=0; + for p_=t: + if nbpetales<Petales: + if string p_: + else: + Facteur[nbfacteur]=p_; + NumFacteurConnu[numfacteurconnu]=nbfacteur; + FacteurConnu[numfacteurconnu]=p_; + numfacteurconnu:=numfacteurconnu+1; + fi; + nbfacteur:=nbfacteur+1; + else: + if string p_: + else: + Produit[nbproduit]=p_; + fi; + nbproduit:=nbproduit+1; + fi; + nbpetales:=nbpetales+1; + endfor; + if unknown Facteur[0]: + else: + Facteur[Petales]=Facteur[0]; + fi; + if unknown Produit[0]: + else: + Produit[Petales]=Produit[0]; + fi; + TotalFacteursConnus:=numfacteurconnu; + enddef; + % + vardef RechercheFacteurs= + if Solution: + for k=1 upto TotalFacteursConnus: + for l=(NumFacteurConnu[k-1]) downto 0: + if (known Produit[l-1]): + if (known Facteur[l]): + FacteurSol[l-1]:=Produit[l-1]/Facteur[l]; + Facteur[l-1]:=FacteurSol[l-1]; + fi; + fi; + endfor; + for l=(NumFacteurConnu[k-1]) upto Petales-1: + if (known Produit[l]): + if (known Facteur[l]): + FacteurSol[l+1]:=Produit[l]/Facteur[l]; + Facteur[l+1]:=FacteurSol[l+1]; + fi; + fi; + endfor; + endfor; + fi; + enddef; + vardef RechercheTermes= + if Solution: + for k=1 upto TotalFacteursConnus: + for l=(NumFacteurConnu[k-1]) downto 0: + if (known Produit[l-1]): + if (known Facteur[l]): + FacteurSol[l-1]:=Produit[l-1]-Facteur[l]; + Facteur[l-1]:=FacteurSol[l-1]; + fi; + fi; + endfor; + for l=(NumFacteurConnu[k-1]) upto Petales-1: + if (known Produit[l]): + if (known Facteur[l]): + FacteurSol[l+1]:=Produit[l]-Facteur[l]; + Facteur[l+1]:=FacteurSol[l+1]; + fi; + fi; + endfor; + endfor; + fi; + enddef; + % on labelise + vardef AffichagedelaListe(text t)= + nbpetales:=0; + for p_=t: + if nbpetales<Petales: + if p_="": + if Solution: + fill rotation(polygone(O,B[Petales-1],A[0],B[Petales]),O,nbpetales*(360/Petales)) withcolor Fond; + if unknown FacteurSol[nbpetales]: + else: + label(TEX("\num{"&decimal(FacteurSol[nbpetales])&"}"),(0.5[O,A[nbpetales]]-center BoiteRec)); + fi; + fi; + else: + label(TEX("\num{"&p_&"}"),(0.5[O,A[nbpetales]]-center BoiteRec)); + fi; + else: + if p_="": + if Solution: + fill (BoiteRec shifted (B[nbpetales-Petales]+0.5*Rayon*unitvector(B[nbpetales-Petales]))) withcolor Fond; + if Addition: + label(TEX("\num{\noexpand\fpeval{"&decimal(Facteur[nbpetales-Petales])&"+"&decimal(Facteur[nbpetales+1-Petales])&"}}"),(B[nbpetales-Petales]+0.5*Rayon*unitvector(B[nbpetales-Petales]))); + else: + label(TEX("\num{\noexpand\fpeval{"&decimal(Facteur[nbpetales-Petales])&"*"&decimal(Facteur[nbpetales+1-Petales])&"}}"),(B[nbpetales-Petales]+0.5*Rayon*unitvector(B[nbpetales-Petales]))); + fi; + fi; + else: + label(TEX("\num{"&p_&"}"),(B[nbpetales-Petales]+0.5*Rayon*unitvector(B[nbpetales-Petales]))); + fi; + fi; + nbpetales:=nbpetales+1; + endfor; + enddef; +} + +\NewDocumentCommand\DessineRoseMulPerso{mm}{% + \ifluatex% + \mplibforcehmode% + \begin{mplibcode} + Rayon=\useKV[ClesRose]{Rayon}; + boolean Aide,Solution,Polygone,Addition; + Aide=\useKV[ClesRose]{Aide}; + Solution=\useKV[ClesRose]{Solution}; + Addition=\useKV[ClesRose]{Addition}; + Polygone=\useKV[ClesRose]{Polygone}; + Petales=\useKV[ClesRose]{Petales}; + color Fond; + Fond=\useKV[ClesRose]{Couleur}; + \DessineRoseMulPersoCode + RecupListe(#2); + if Addition: + RechercheTermes; + else: + RechercheFacteurs; + fi; + AffichagedelaListe(#1); + if Aide: + for k=0 upto Petales-1: + drawarrow (0.5[O,A[k]]--1.75[O,B[k]]) cutbefore segment(A[k],A[k+1]) cutafter BoiteRec shifted (B[k]+0.5*Rayon*unitvector(B[k])) dashed evenly scaled 0.5; + drawarrow (0.5[O,A[k+1]]--1.75[O,B[k]]) cutbefore segment(A[k],A[k+1]) cutafter BoiteRec shifted (B[k]+0.5*Rayon*unitvector(B[k])) dashed evenly scaled 0.5; + endfor; + fi; + trace A0 for k=1 upto Petales:--A[k] endfor --cycle; + for k=0 upto Petales-1: + trace segment(O,B[k]) dashed withdots scaled 0.25; + draw BoiteRec shifted (B[k]+0.5*Rayon*unitvector(B[k])) dashed evenly scaled 0.5; + endfor; + fill cercles(O,3mm) withcolor white; + draw cercles(O,3mm); + if Addition: + label(TEX("\Large$+$"),O); + else: + label(TEX("\Large$\times$"),O); + fi; + \end{mplibcode} + \else + \begin{mpost}[mpsettings={Rayon:=\useKV[ClesRose]{Rayon}; + boolean Aide,Solution,Polygone; + Aide:=\useKV[ClesRose]{Aide}; + Solution:=\useKV[ClesRose]{Solution}; + Polygone:=\useKV[ClesRose]{Polygone}; + Petales:=\useKV[ClesRose]{Petales}; + color Fond; + Fond:=\useKV[ClesRose]{Couleur}; + \PfCDessineRoseMulPersoCode + }] + RecupListe(#2); + RechercheFacteurs; + AffichagedelaListe(#1); + if Aide: + for k=0 upto Petales-1: + drawarrow (0.5[O,A[k]]--1.75[O,B[k]]) cutbefore segment(A[k],A[k+1]) cutafter BoiteRec shifted (B[k]+0.5*Rayon*unitvector(B[k])) dashed evenly scaled 0.5; + drawarrow (0.5[O,A[k+1]]--1.75[O,B[k]]) cutbefore segment(A[k],A[k+1]) cutafter BoiteRec shifted (B[k]+0.5*Rayon*unitvector(B[k])) dashed evenly scaled 0.5; + endfor; + fi; + trace A0 for k=1 upto Petales:--A[k] endfor --cycle; + for k=0 upto Petales-1: + trace segment(O,B[k]) dashed withdots scaled 0.25; + draw BoiteRec shifted (B[k]+0.5*Rayon*unitvector(B[k])) dashed evenly scaled 0.5; + endfor; + fill cercles(O,4mm) withcolor white; + draw cercles(O,4mm); + if Addition: + label(TEX("\Huge$+$"),O); + else: + label(TEX("\Huge$\times$"),O); + fi; + \end{mpost} + \fi }% \newcommand\DessineRoseMulSol{% @@ -22,7 +259,8 @@ \mplibforcehmode% \xdef\PfCNomRose{\useKV[ClesRose]{Nom}}% \begin{mplibcode}[\PfCNomRose] - boolean Aide,Produits,Solution,Vide,ProduitVide,CaseVide,Polygone; + boolean Aide,Produits,Solution,Vide,ProduitVide,CaseVide,Polygone,Addition; + Addition=\useKV[ClesRose]{Addition}; Aide:=\useKV[ClesRose]{Aide}; Vide:=\useKV[ClesRose]{Vide}; Solution:=\useKV[ClesRose]{Solution}; @@ -71,6 +309,13 @@ trace segment(O,B[k]) dashed withdots scaled 0.25; draw BoiteRec shifted (B[k]+0.5*Rayon*unitvector(B[k])) dashed evenly scaled 0.5; endfor; + fill cercles(O,3mm) withcolor white; + draw cercles(O,3mm); + if Addition: + label(TEX("\Large$+$"),O); + else: + label(TEX("\Large$\times$"),O); + fi; \end{mplibcode} \fi } @@ -108,7 +353,8 @@ enddef; pair A[],B[],O; Rayon:=\useKV[ClesRose]{Rayon}; - boolean Aide,Produits,Solution,Vide,ProduitVide,CaseVide,Polygone; + boolean Aide,Produits,Solution,Vide,ProduitVide,CaseVide,Polygone,Addition; + Addition=\useKV[ClesRose]{Addition}; Aide:=\useKV[ClesRose]{Aide}; Vide:=\useKV[ClesRose]{Vide}; Solution:=\useKV[ClesRose]{Solution}; @@ -145,7 +391,11 @@ endfor; Facteur[Petales]:=Facteur[0]; for k=0 upto Petales-1: + if Addition: + Produit[k]:=Facteur[k]+Facteur[k+1]; + else: Produit[k]:=Facteur[k]*Facteur[k+1]; + fi; endfor; %on labelise if Vide=false: @@ -187,6 +437,13 @@ trace segment(O,B[k]) dashed withdots scaled 0.25; draw BoiteRec shifted (B[k]+0.5*Rayon*unitvector(B[k])) dashed evenly scaled 0.5; endfor; + fill cercles(O,3mm) withcolor white; + draw cercles(O,3mm); + if Addition: + label(TEX("\Large$+$"),O); + else: + label(TEX("\Large$\times$"),O); + fi; \end{mplibcode} \else \begin{mpost}[mpsettings={Rayon:=\useKV[ClesRose]{Rayon}; @@ -297,6 +554,13 @@ trace segment(O,B[k]) dashed withdots scaled 0.25; draw BoiteRec shifted (B[k]+0.5*Rayon*unitvector(B[k])) dashed evenly scaled 0.5; endfor; + fill cercles(O,3mm) withcolor white; + draw cercles(O,3mm); + if Addition: + label(TEX("\Large$+$"),O); + else: + label(TEX("\Large$\times$"),O); + fi; \end{mpost} \fi }%
\ No newline at end of file diff --git a/macros/latex/contrib/profcollege/latex/PfCSolides.tex b/macros/latex/contrib/profcollege/latex/PfCSolides.tex index ef0829af90..7ae73c4b00 100644 --- a/macros/latex/contrib/profcollege/latex/PfCSolides.tex +++ b/macros/latex/contrib/profcollege/latex/PfCSolides.tex @@ -8,8 +8,9 @@ \newcommand\MPSolideCylindre[3]{% \ifluatex - \mplibforcehmode - \begin{mplibcode} + \mplibnumbersystem{double} + \mplibforcehmode + \begin{mplibcode} input PfCSolid; boolean NommeSommets,Code,Sections,Axes,RemplisSection; @@ -213,6 +214,7 @@ \newcommand\MPSolidePyramide[4]{% \ifluatex + \mplibnumbersystem{double} \mplibforcehmode \begin{mplibcode} @@ -384,6 +386,7 @@ \newcommand\MPSolideCone[3]{% \ifluatex + \mplibnumbersystem{double} \mplibforcehmode \begin{mplibcode} boolean NommeSommets,Code,Sections,Axes,RemplisSection; @@ -534,6 +537,7 @@ \newcommand\MPSolidePave[5]{% \ifluatex + \mplibnumbersystem{double} \mplibforcehmode \begin{mplibcode} input PfCSolid; @@ -710,6 +714,7 @@ \newcommand\MPSolideSphere[3]{% \ifluatex + \mplibnumbersystem{double} \mplibforcehmode \begin{mplibcode} boolean NommeSommets,Code,Sections,Axes,RemplisSection; @@ -866,5 +871,8 @@ {sphere}{% \MPSolideSphere{\useKV[ClesSolides]{ListeSommets}}{\the\toksolidelistesommets}{\useKV[ClesSolides]{PointsSection}}% }% + {boule}{% + \MPSolideSphere{\useKV[ClesSolides]{ListeSommets}}{\the\toksolidelistesommets}{\useKV[ClesSolides]{PointsSection}}% + }% }% }%
\ No newline at end of file diff --git a/macros/latex/contrib/profcollege/latex/PfCStatistiques.tex b/macros/latex/contrib/profcollege/latex/PfCStatistiques.tex index 75913cc025..37952adfda 100644 --- a/macros/latex/contrib/profcollege/latex/PfCStatistiques.tex +++ b/macros/latex/contrib/profcollege/latex/PfCStatistiques.tex @@ -16,7 +16,7 @@ FreqVide=false,AngVide=false,ECCVide=false,TotalVide=false,Sondage=false,Liste=false,% Tableau=false,Stretch=1,Frequence=false,EffectifTotal=false,% Etendue=false,Moyenne=false,SET=false,ValeurExacte=false,MoyenneA,Somme,Mediane=false,DetailsMediane=false,UneMediane=false,QuartileUn=false,QuartileTrois=false,Total=false,Concret=false,% -Largeur=1cm,Precision=2,PrecisionF=0,Donnee=Valeurs,Effectif=Effectif,Grille=false,Origine=0,Angle=false,SemiAngle=false,Qualitatif=false,Classes=false,TableauVide=false,ECC=false,Coupure=10,CouleurTab=gray!15,Graphique=false,Batons=true,% +Largeur=1cm,Precision=2,PrecisionF=0,Donnee=Valeurs,Effectif=Effectif,Grille=false,Origine=0,Angle=false,SemiAngle=false,Qualitatif=false,Classes=false,TableauVide=false,ECC=false,Coupure=10,CouleurTab=gray!15,Graphique=false,Batons=true,Centre=false,CentreVide=false,Crochets=false,% % Pour les diags batons EpaisseurBatons=1,ListeCouleursB={a},Lecture=false,LectureFine=false,AideLecture=false,Reponses=false,DonneesSup=false,AbscisseRotation=false,Tiret=false,AngleRotationAbscisse=0,Pasx=1,Pasy=1,Unitex=0.5,Unitey=0.5,Depart=0,CouleurDefaut=black,Date=false,GrandNombrey=false,GrandNombrex=false,% % Pour les diags circulaires @@ -1303,11 +1303,14 @@ Histogramme=false,UniteAire=1,MemeAmpli,DepartHisto=1% \columncolor{\useKV[ClesStat]{CouleurTab}}{1}% \Body \useKV[ClesStat]{Donnee}\xintFor* ##1 in{\xintSeq{1}{\ListeDepartlen}}\do{% - &$\num{\ListeDepart[##1,1]}\leqslant\dots<\num{\ListeDepart[##1,2]}$ + &\ifboolKV[ClesStat]{Crochets}{$[\num{\ListeDepart[##1,1]}\,;\,\num{\ListeDepart[##1,2]}[$}{$\num{\ListeDepart[##1,1]}\leqslant\dots<\num{\ListeDepart[##1,2]}$}% }\\ \useKV[ClesStat]{Effectif}\xintFor* ##1 in{\xintSeq{1}{\ListeDepartlen}}\do{% &\ifboolKV[ClesStat]{EffVide}{}{\num{\ListeDepart[##1,3]}}% - }\\ + }\\ + % centre + \ifboolKV[ClesStat]{Centre}{\stepcounter{PfCCompteLignes}Centre de la classe\xintFor* ##1 in {\xintSeq {1}{\ListeDepartlen}}\do{&\ifboolKV[ClesStat]{TableauVide}{}{\ifboolKV[ClesStat]{CentreVide}{}{\num{\fpeval{\ListeDepart[##1,2]-\ListeDepart[##1,1]}}}}}\\}{}% + % \ifboolKV[ClesStat]{Frequence}{\stepcounter{PfCCompteLignes}Fr\'equence (\%)\xintFor* ##1 in {\xintSeq {1}{\ListeDepartlen}}\do{&\ifboolKV[ClesStat]{TableauVide}{}{\ifboolKV[ClesStat]{FreqVide}{}{\num{\CalculFrequenceClasses{##1}}}}}\\ }{}% \ifboolKV[ClesStat]{ECC}{\stepcounter{PfCCompteLignes}E.C.C.\xintFor* ##1 in {\xintSeq {1}{\ListeDepartlen}}\do{&\ifboolKV[ClesStat]{TableauVide}{}{\ifboolKV[ClesStat]{ECCVide}{}{\CalculECCClasses{##1}}}}\\}{}% @@ -1344,6 +1347,7 @@ Histogramme=false,UniteAire=1,MemeAmpli,DepartHisto=1% \NewDocumentCommand\MPBuildHisto{mmmm}{% \ifluatex +% \mplibnumbersystem{double} \mplibforcehmode \begin{mplibcode} maxx:=-infinity; @@ -1396,8 +1400,8 @@ Histogramme=false,UniteAire=1,MemeAmpli,DepartHisto=1% fi; endfor; enddef; - % on r\'ecup\`ere les couleurs Depart=\useKV[ClesStat]{DepartHisto}; + % on r\'ecup\`ere les couleurs color Col[],CoulDefaut; CoulDefaut=white; n:=0; @@ -1486,11 +1490,11 @@ Histogramme=false,UniteAire=1,MemeAmpli,DepartHisto=1% Ajout:=3; fi; drawoptions(withcolor 0.7white); - for k=0 upto ((maxx-minx)/Pasx+2): + for k=0 upto ((maxx-minx)/Pasx+2+Depart): trace (unitex*k,0)--(unitex*k,(maxy+Ajout)*unitey);%withcolor red; endfor; for k=0 upto (maxy+Ajout): - trace (0,k*unitey)--(unitex*((maxx-minx)/Pasx+2),k*unitey);% withcolor blue; + trace (0,k*unitey)--(unitex*((maxx-minx)/Pasx+2+Depart),k*unitey);% withcolor blue; endfor; drawoptions(); enddef; @@ -1603,13 +1607,13 @@ Histogramme=false,UniteAire=1,MemeAmpli,DepartHisto=1% % fi; fi; % On trace l'axe des abscisses - drawarrow (0,0)--unitex*((maxx-minx)/Pasx+2,0); + drawarrow (0,0)--unitex*((maxx-minx)/Pasx+2+Depart,0); %On labelise l'axe des abscisses dotlabel.bot(TEX("\num{"&decimal(X[1])&"}"),unitex*(Depart,0)); for k=2 step 2 until TotalAbscisses: dotlabel.bot(TEX("\num{"&decimal(X[k])&"}"),unitex*(Depart+(X[k]-X[1])/Pasx,0)); endfor; - label.rt(TEX("\useKV[ClesStat]{Donnee}"),(unitex*((maxx-minx)/Pasx+2),0)); + label.rt(TEX("\useKV[ClesStat]{Donnee}"),(unitex*((maxx-minx)/Pasx+2+Depart),0)); %On affiche les donnรฉes sup ou pas. AfficheLegende(#2); \end{mplibcode} diff --git a/macros/latex/contrib/profcollege/latex/PfCTableauxUnites.tex b/macros/latex/contrib/profcollege/latex/PfCTableauxUnites.tex index 8da863a7b1..23f8e431fe 100644 --- a/macros/latex/contrib/profcollege/latex/PfCTableauxUnites.tex +++ b/macros/latex/contrib/profcollege/latex/PfCTableauxUnites.tex @@ -9,6 +9,22 @@ \newlength\PfCTableauPuissances% +\def\PfCCG{centaines de milliards} +\def\PfCDG{dizaines de milliards} +\def\PfCUG{unit\'es de milliards} +\def\PfCCM{centaines de millions} +\def\PfCDM{dizaines de millions} +\def\PfCUM{unit\'es de millions} +\def\PfCCm{centaines de milliers} +\def\PfCDm{dizaines de milliers} +\def\PfCUm{unit\'es de milliers} +\def\PfCC{centaines} +\def\PfCD{dizaines} +\def\PfCU{unit\'es} +\def\PfCd{dixi\`emes} +\def\PfCc{centi\'emes} +\def\PfCm{milli\`emes} + \newcommand\Tableau[2][]{% \useKVdefault[ClesTableaux]% \setKV[ClesTableaux]{#1}% @@ -543,26 +559,26 @@ }%ok \hline \ifboolKV[ClesTableaux]{Milliards}{% - \Block[draw]{}{\fontsize{\TailleFonte}{\TailleFonte}\selectfont centaines de milliards}% - &\Block[draw]{}{\fontsize{5}{5}\selectfont dizaines de milliards}% - &\Block[draw]{}{\fontsize{5}{5}\selectfont unit\'es de milliards}% - &\Block[draw]{}{\fontsize{5}{5}\selectfont centaines de millions}% - &\Block[draw]{}{\fontsize{5}{5}\selectfont dizaines de millions}% - &\Block[draw]{}{\fontsize{5}{5}\selectfont unit\'es de millions}% + \Block[draw]{}{\fontsize{\TailleFonte}{\TailleFonte}\selectfont\PfCCG}% + &\Block[draw]{}{\fontsize{5}{5}\selectfont\PfCDG}% + &\Block[draw]{}{\fontsize{5}{5}\selectfont\PfCUG}% + &\Block[draw]{}{\fontsize{5}{5}\selectfont\PfCCM}% + &\Block[draw]{}{\fontsize{5}{5}\selectfont\PfCDM}% + &\Block[draw]{}{\fontsize{5}{5}\selectfont\PfCUM}% & }{} \ifboolKV[ClesTableaux]{Millions}{% - \Block[draw]{}{\fontsize{5}{5}\selectfont centaines de millions}% - &\Block[draw]{}{\fontsize{5}{5}\selectfont dizaines de millions}% - &\Block[draw]{}{\fontsize{5}{5}\selectfont unit\'es de millions}% + \Block[draw]{}{\fontsize{5}{5}\selectfont\PfCCM}% + &\Block[draw]{}{\fontsize{5}{5}\selectfont\PfCDM}% + &\Block[draw]{}{\fontsize{5}{5}\selectfont\PfCUM}% & }{} - \Block[draw]{}{\fontsize{5}{5}\selectfont centaines de milliers}% - &\Block[draw]{}{\fontsize{5}{5}\selectfont dizaines de milliers}% - &\Block[draw]{}{\fontsize{5}{5}\selectfont unit\'es de milliers}% - &\Block[draw]{}{\fontsize{5}{5}\selectfont centaines}% - &\Block[draw]{}{\fontsize{5}{5}\selectfont dizaines}% - &\Block[draw]{}{\fontsize{5}{5}\selectfont unit\'es}\\% + \Block[draw]{}{\fontsize{5}{5}\selectfont\PfCCm}% + &\Block[draw]{}{\fontsize{5}{5}\selectfont\PfCDm}% + &\Block[draw]{}{\fontsize{5}{5}\selectfont\PfCUm}% + &\Block[draw]{}{\fontsize{5}{5}\selectfont\PfCC}% + &\Block[draw]{}{\fontsize{5}{5}\selectfont\PfCD}% + &\Block[draw]{}{\fontsize{5}{5}\selectfont\PfCU}\\% \ifboolKV[ClesTableaux]{Nombres}{% \xdef\DecalageLigne{\fpeval{\DecalageLigne+1}}% \ifboolKV[ClesTableaux]{Milliards}{% @@ -707,7 +723,7 @@ \ifboolKV[ClesTableaux]{Milliards}{\xdef\PfCDerniereColonne{16}}{\ifboolKV[ClesTableaux]{Millions}{\xdef\PfCDerniereColonne{13}}{\xdef\PfCDerniereColonne{10}}}% \begin{NiceTabular}{*{\ifboolKV[ClesTableaux]{Milliards}{12}{% \ifboolKV[ClesTableaux]{Millions}{9}{6}% - }}{m{4.75em}}>{\columncolor{gray!15}}{c}*{3}{m{4.75em}}}% + }}{m{\useKV[ClesTableaux]{Largeur}}}>{\columncolor{gray!15}}{c}*{3}{m{\useKV[ClesTableaux]{Largeur}}}}% % %%% Prise en compte de la cl\'e Partie % @@ -741,33 +757,33 @@ }{}% % %%% Valeurs ci-dessous par d\'efaut - % + % \hline \ifboolKV[ClesTableaux]{Milliards}{% - \Block[borders={left,right}]{}{\fontsize{5}{5}\selectfont centaines de milliards}% - &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont dizaines de milliards}% - &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont unit\'es de milliards}% - &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont centaines de millions}% - &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont dizaines de millions}% - &\Block[]{}{\fontsize{5}{5}\selectfont unit\'es de millions}% + \Block[borders={left,right}]{}{\fontsize{5}{5}\selectfont\PfCCG}% + &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont\PfCDG}% + &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont\PfCUG}% + &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont\PfCCM}% + &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont\PfCDM}% + &\Block[]{}{\fontsize{5}{5}\selectfont\PfCUM}% & }{}% \ifboolKV[ClesTableaux]{Millions}{% - \Block[borders={left,right}]{}{\fontsize{5}{5}\selectfont centaines de millions}% - &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont dizaines de millions}% - &\Block[]{}{\fontsize{5}{5}\selectfont unit\'es de millions}% + \Block[borders={left,right}]{}{\fontsize{5}{5}\selectfont\PfCCM}% + &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont\PfCDM}% + &\Block[]{}{\fontsize{5}{5}\selectfont\PfCUM}% & }{}% - \Block[borders={left,right}]{}{\fontsize{5}{5}\selectfont centaines de milliers}% - &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont dizaines de milliers}% - &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont unit\'es de milliers}% - &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont centaines}% - &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont dizaines}% - &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont unit\'es}% + \Block[borders={left,right}]{}{\fontsize{5}{5}\selectfont\PfCCm}% + &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont\PfCDm}% + &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont\PfCUm}% + &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont\PfCC}% + &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont\PfCD}% + &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont\PfCU}% &\Block[borders={right}]{}{\ifboolKV[ClesTableaux]{Virgule}{,}{}}% - &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont dixi\`emes}% - &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont centi\`emes}% - &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont milli\`emes}\\ + &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont\PfCd}% + &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont\PfCc}% + &\Block[borders={right}]{}{\fontsize{5}{5}\selectfont\PfCm}\\ % %%% Prise en compte de la cl\'e Nombres % diff --git a/macros/latex/contrib/profcollege/latex/PfCVueCubes.tex b/macros/latex/contrib/profcollege/latex/PfCVueCubes.tex index 91f90c96d2..5f284e051e 100644 --- a/macros/latex/contrib/profcollege/latex/PfCVueCubes.tex +++ b/macros/latex/contrib/profcollege/latex/PfCVueCubes.tex @@ -1,7 +1,7 @@ %%% % Vue Cubes %%% -\setKVdefault[VueCubes]{Solution=false,Hauteur=5,Profondeur=4,Largeur=3,Angle=60,Nom=Ex1,Trou=false,Echelle=0.25,CouleurCube=LightSteelBlue,CouleurFleche=LightGray,Face=false,Creation=false,Grilles=false} +\setKVdefault[VueCubes]{Solution=false,Hauteur=5,Profondeur=4,Largeur=3,Angle=60,Nom=Ex1,Trou=false,Echelle=0.25,CouleurCube=LightSteelBlue,CouleurFleche=LightGray,Face=false,Creation=false,Grilles=false,Seul=false} \newtoks\toklisteVueCube% \def\UpdatetoksVueCube#1\nil{\addtotok\toklisteVueCube{#1,}}% @@ -162,8 +162,9 @@ endfor; fi; \end{mplibcode} + \ifboolKV[VueCubes]{Seul}{}{% \ifboolKV[VueCubes]{Grilles}{}{% - \hspace*{1.5cm} +% \hspace*{1.5cm} \begin{mplibcode}[\PfCVueCubeNom] input PfCSolid; @@ -216,6 +217,7 @@ DessineFusion; \end{mplibcode} }% + }% \fi }% diff --git a/macros/latex/contrib/profcollege/latex/ProfCollege.sty b/macros/latex/contrib/profcollege/latex/ProfCollege.sty index 7be8c2783f..c51b7afc58 100644 --- a/macros/latex/contrib/profcollege/latex/ProfCollege.sty +++ b/macros/latex/contrib/profcollege/latex/ProfCollege.sty @@ -2,9 +2,9 @@ % licence : Released under the LaTeX Project Public License v1.3c % or later, see http://www.latex-project.org/lppl.txtf \NeedsTeXFormat{LaTeX2e}% -\def\filedate{2023/07/05}% +\def\filedate{2023/08/01}% \let\PfCfiledate\filedate% -\def\fileversion{0.99-z-o}% +\def\fileversion{0.99-z-p}% \let\PfCfileversion\fileversion% \ProvidesPackage{ProfCollege}[\filedate\space v\fileversion\space Aide pour utiliser LaTeX au college]% @@ -95,13 +95,13 @@ \RequirePackage{xlop}% \RequirePackage{xfp}% -\RequirePackage[most]{tcolorbox}% +\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}% -\usetikzlibrary{backgrounds}% +\usetikzlibrary{calc,shapes,arrows,tikzmark,chains,positioning,shapes.symbols,babel,fit,backgrounds}% \RequirePackage{suffix}%pour la commande รฉtoilรฉe @@ -571,7 +571,12 @@ \draw[thick] (0,0) circle (2ex); }%\emoticon }%\raisebox -} +}% +\input{PfCGrimuku} +\input{PfCHorloge} +\input{PfCCible} +\input{PfCMulPiecesPuzzle} +\input{PfCPyraVoca} \input{PfCAutomatismes} \input{PfCNumberHive} \input{PfCPatronPaves} diff --git a/macros/latex/contrib/profcollege/latex/dobblePfC.lua b/macros/latex/contrib/profcollege/latex/dobblePfC.lua index 83cf8f6218..06df34391b 100644 --- a/macros/latex/contrib/profcollege/latex/dobblePfC.lua +++ b/macros/latex/contrib/profcollege/latex/dobblePfC.lua @@ -8,7 +8,7 @@ function dobble(p) -- du mรชme nombre de symboles -- on va gรฉnรฉrer un tableau oรน chaque case correspond -- ร une carte et contient la liste des numรฉros de symbole ร mettre - for i=1,7 do + for i=1,1+p+p*p do symbole[i] = "\\PfCListeSymboleDobble["..i.."]" end local cartes={}; diff --git a/macros/latex/contrib/profcollege/metapost/PfCCalculatrice.mp b/macros/latex/contrib/profcollege/metapost/PfCCalculatrice.mp index 406f720594..633b3ab6a7 100644 --- a/macros/latex/contrib/profcollege/metapost/PfCCalculatrice.mp +++ b/macros/latex/contrib/profcollege/metapost/PfCCalculatrice.mp @@ -38,7 +38,7 @@ Math=true; decahoriz:=0; -vardef Test(expr cptk,cptnt)= +vardef Test(expr cptk)(text cptnt)= pair Decalage; if nblignes mod 2=0: Decalage:=u*((LargeurEcran,-8*(nblignes-1))-6*(length(cptnt)-cptk,0)); @@ -192,9 +192,17 @@ vardef LCD(text nt)(text rep)(expr NB)= Ecran:=(u*(0,-1)--u*(LargeurEcran,-1)--u*(LargeurEcran,7)--u*(0,7)--cycle) shifted(u*(0,-8*(nblignes-1))); fill Ecran withcolor if print=true:0.8white else:CouleurEcran fi; draw Ecran withcolor if print=true:0.8white else:CouleurEcran fi; + if Calcul: + string toto; + toto=decimal(rep); + for k=0 upto length(toto)-1: + Test(k,toto); + endfor; + else: for k=0 upto length(rep)-1: Test(k,rep); endfor; + fi; enddef; endinput; diff --git a/macros/latex/contrib/profcollege/metapost/PfCLabyNombre.mp b/macros/latex/contrib/profcollege/metapost/PfCLabyNombre.mp index 1ef8c39607..18a4e97931 100644 --- a/macros/latex/contrib/profcollege/metapost/PfCLabyNombre.mp +++ b/macros/latex/contrib/profcollege/metapost/PfCLabyNombre.mp @@ -193,7 +193,47 @@ vardef TraceLabyrinthe= fi; ); $ -enddef; +enddef; + +vardef InitialisationLabyrintheMul(expr long,larg)= + LargeurLaby:=larg; + LongueurLaby:=long; + uh=2u; + uv=2u; + pair M[][],N[][];%centre de la case, coinbg de la case + boolean CaseExploree[][];%Case Exploree ou pas + %on initialise les cases comme non explorรฉes pour celles qui sont ร l'intรฉrieur du labyrinthe + for k=-1 upto larg: + for l=-1 upto long: + M[k][l]:=(5mm,-uv+5mm)+(l*uh,-k*uv); + N[k][l]:=(l*uh,(-k-1)*uv); + if (k=-1) or (k=larg) or (l=-1) or (l=long): + CaseExploree[k][l]:=true; + else: + CaseExploree[k][l]:=false; + fi; + endfor; + endfor; +enddef; + +vardef TraceLabyrintheMul= + save $; + picture $; + $=image( + n:=0; + for k=0 upto LargeurLaby-1: + for l=0 upto LongueurLaby-1: + n:=n+1; + if (n mod 2)=1: + draw (Fullcircle scaled 10mm) shifted N[k][l]; + else: + draw (unitsquare scaled 10mm) shifted N[k][l]; + fi; + endfor; + endfor; + ); + $ +enddef; vardef murgauche= save $; diff --git a/macros/latex/contrib/profcollege/metapost/PfCObjets.mp b/macros/latex/contrib/profcollege/metapost/PfCObjets.mp index 6998c54e26..0fe551dc9c 100644 --- a/macros/latex/contrib/profcollege/metapost/PfCObjets.mp +++ b/macros/latex/contrib/profcollege/metapost/PfCObjets.mp @@ -18,7 +18,7 @@ boolean creux; creux=false;%pour g้rer les solides creux boolean transformation; transformation=false;%pour g้rer les transformations boolean Ferme[];%pour g้rer les faces : si le solide est ferm้, toutes les faces non vues ne sont pas int้gr้es aux calculs boolean perso[];%pour g้rer les gestions personnelles des couleurs -for k=0 upto 100: +for k=0 upto 1000: perso[k]=false; endfor; boolean numeroteface; diff --git a/macros/latex/contrib/profcollege/metapost/PfCSolid.mp b/macros/latex/contrib/profcollege/metapost/PfCSolid.mp index b5f90b3ae4..765533109d 100644 --- a/macros/latex/contrib/profcollege/metapost/PfCSolid.mp +++ b/macros/latex/contrib/profcollege/metapost/PfCSolid.mp @@ -121,12 +121,13 @@ vardef Projette(expr M)= elseif typerepre="cabinet": % (0.5*cosd(30)*Xpart(GCoord(M)),0.75*sind(30)*Ypart(GCoord(M)))*unit*DE % (Xpart(M)+0.5*cosd(30)*Zpart(M),Ypart(M)+0.5*sind(30)*Zpart(M))*20 - %(Xpart(M)+0.5*cosd(30)*Ypart(M),Zpart(M)+0.5*sind(30)*Ypart(M))*20 - %(Ypart(M)+0.5*cosd(30)*Xpart(M),Zpart(M)+0.5*sind(30)*Xpart(M))*20%Good avec Theta=-20/Phi=-10 +% (Xpart(M)+0.5*cosd(30)*Ypart(M),Zpart(M)+0.5*sind(30)*Ypart(M))*20 +% (Ypart(M)+0.5*cosd(30)*Xpart(M),Zpart(M)+0.5*sind(30)*Xpart(M))*20%Good avec Theta=-20/Phi=-10 %(Ypart(GCoord(M))+0.5*cosd(-30)*Xpart(GCoord(M)),Zpart(GCoord(M))+0.5*sind(-30)*Xpart(GCoord(M)))*20%Good avec Theta=-20/Phi=-10 - (Xpart(GCoord(M))*cosd(90-30),Ypart(GCoord(M))*sind(90-30)*0.5)*DE%เ garder peut-๊tre -% (Zpart(GCoord(M))+0.5*cosd(-30)*Ypart(GCoord(M)),Xpart(GCoord(M))+0.5*sind(-30)*Ypart(GCoord(M)))*20 - % (0.5*cosd(45)*Xpart(GCoord(M)),0.5*sind(45)*Ypart(GCoord(M)))*unit*DE +% (Xpart(GCoord(M))*cosd(90-30),Ypart(GCoord(M))*sind(90-30)*0.5)*DE%เ garder peut-๊tre ? + (Xpart(GCoordcabinet(M)),Ypart(GCoordcabinet(M)))*DE% + %(Zpart(GCoord(M))+0.5*cosd(-30)*Ypart(GCoord(M)),Xpart(GCoord(M))+0.5*sind(-30)*Ypart(GCoord(M)))*20 +% (0.5*cosd(45)*Xpart(GCoord(M)),0.5*sind(45)*Ypart(GCoord(M)))*unit*DE % (Xpart(GCoord(M)),Ypart(GCoord(M)))*unit*DE %(Xpart(GCoord(M)),Ypart(GCoord(M)))*10 fi diff --git a/macros/latex/contrib/siunitx/CHANGELOG.md b/macros/latex/contrib/siunitx/CHANGELOG.md index 003c810d2b..235ce5fbfa 100644 --- a/macros/latex/contrib/siunitx/CHANGELOG.md +++ b/macros/latex/contrib/siunitx/CHANGELOG.md @@ -7,6 +7,49 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to ## [Unreleased] +## [v3.3.0] - 2023-07-31 + +### Added +- Support for Italian (see issue + [\#650](https://github.com/josephwright/siunitx/issues/650)) +- Abbreviations `\T`, `\mT`, `\uT` (see issue + [\#670](https://github.com/josephwright/siunitx/issues/670)) +- Option `range-open-phrase` +- Option `round-direction` to allow 'truncation' of rounded + values (see issue + [\#664](https://github.com/josephwright/siunitx/issues/664)) +- Option `uncertainty-round-direction` (see issue + [\#628](https://github.com/josephwright/siunitx/issues/628)) +- Support for asymmetrical uncertainties, including new option + `input-uncertainty-divider` (see issue + [\#675](https://github.com/josephwright/siunitx/issues/675)) +- Options for bracket control: + - `compound-close-bracket` + - `compound-open-bracket` + - `list-close-bracket` + - `list-open-bracket` + - `product-close-bracket` + - `product-open-bracket` + - `range-close-bracket` + - `range-open-bracket` + (see issue + [\#262](https://github.com/josephwright/siunitx/issues/262)) +- Option `table-model-setup` (see issue + [\#659](https://github.com/josephwright/siunitx/issues/659)) +- Options `list-input-separator` and `product-input-separator` (see issue + [\#603](https://github.com/josephwright/siunitx/issues/603)) +- Options `compound-independent-prefix`, `list-independent-prefix`, + `product-independent-prefix` and `range-independent-prefix` (see issue + [\#554](https://github.com/josephwright/siunitx/issues/554)) +- Hint for overloading `\num` and `\qty` (see issue + [\#648](https://github.com/josephwright/siunitx/issues/648)) + +### Changed + +- Support bracing of decimal marker in tables as an alternative + to `\mathord` (see issue + [\#527](https://github.com/josephwright/siunitx/issues/527)) + ## [v3.2.9] - 2023-07-26 ### Fixed @@ -1928,7 +1971,8 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to ### Added - First public testing release (as `si`) -[Unreleased]: https://github.com/josephwright/siunitx/compare/v3.2.9...HEAD +[Unreleased]: https://github.com/josephwright/siunitx/compare/v3.3.0...HEAD +[v3.3.0]: https://github.com/josephwright/siunitx/compare/v3.2.9...v3.3.0 [v3.2.9]: https://github.com/josephwright/siunitx/compare/v3.2.8...v3.2.9 [v3.2.8]: https://github.com/josephwright/siunitx/compare/v3.2.7...v3.2.8 [v3.2.7]: https://github.com/josephwright/siunitx/compare/v3.2.6...v3.2.7 diff --git a/macros/latex/contrib/siunitx/siunitx-abbreviation.dtx b/macros/latex/contrib/siunitx/siunitx-abbreviation.dtx index 152f56608a..2d4e60e1d4 100644 --- a/macros/latex/contrib/siunitx/siunitx-abbreviation.dtx +++ b/macros/latex/contrib/siunitx/siunitx-abbreviation.dtx @@ -127,6 +127,10 @@ % Abbreviations for charge. % \end{function} % +% \begin{function}{\T, \mT \uT} +% Abbreviations for magneticc field. +% \end{function} +% % \begin{function}{\dB} % Abbreviation for decibel. % \end{function} @@ -306,6 +310,14 @@ \siunitx_declare_unit:Nn \mC { \milli \coulomb } % \end{macrocode} % \end{macro} +% \begin{macro}{\T, \uT, \mT} +% Magnetic field. +% \begin{macrocode} +\siunitx_declare_unit:Nn \T { \tesla } +\siunitx_declare_unit:Nn \uT { \micro \tesla } +\siunitx_declare_unit:Nn \mT { \milli \tesla } +% \end{macrocode} +% \end{macro} % \begin{macro}{\N, \mN, \kN, \MN} % Forces. % \begin{macrocode} diff --git a/macros/latex/contrib/siunitx/siunitx-angle.dtx b/macros/latex/contrib/siunitx/siunitx-angle.dtx index a2335a2c9b..69bb9a53fb 100644 --- a/macros/latex/contrib/siunitx/siunitx-angle.dtx +++ b/macros/latex/contrib/siunitx/siunitx-angle.dtx @@ -337,6 +337,30 @@ % \end{macrocode} % \end{variable} % +% \begin{macro}{\@@_suppress_exp_uncert:, \@@_suppress_comp_sign:} +% Pre-compilation of keys to suppress uncertainties and exponents, +% and +% \begin{macrocode} +\keys_precompile:nnN + { siunitx } + { + input-close-uncertainty = , + input-exponent-markers = , + input-open-uncertainty = , + input-uncertainty-signs = + } + \l_@@_tmp_tl +\cs_set_protected:Npx \@@_suppress_exp_uncert: + { \exp_not:V \l_@@_tmp_tl } +\keys_precompile:nnN + { siunitx } + { input-comparators = , input-signs = } + \l_@@_tmp_tl +\cs_set_protected:Npx \@@_suppress_comp_sign: + { \exp_not:V \l_@@_tmp_tl } +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\@@_arc_sign:nnn} % \begin{macro}{\@@_arc_sign:nn} % \begin{macro}{\@@_extract_sign:nnnnnnnn} @@ -348,13 +372,7 @@ \cs_new_protected:Npn \@@_arc_sign:nnn #1#2#3 { \group_begin: - \keys_set:nn { siunitx } - { - input-close-uncertainty = , - input-exponent-markers = , - input-open-uncertainty = , - input-uncertainty-signs = - } + \@@_suppress_exp_uncert: \tl_clear:N \l_@@_sign_tl \@@_arc_sign:nn {#1} { degrees } \@@_arc_sign:nn {#2} { minutes } @@ -420,8 +438,7 @@ \tl_set:cn { l_@@_ #8 _tl } { {#1} { } {#3} {#4} {#5} {#6} {#7} } \tl_set:Nn \l_@@_sign_tl {#2} - \keys_set:nn { siunitx } - { input-comparators = , input-signs = } + \@@_suppress_comp_sign: } } \cs_new:Npn \@@_sign:nnnnnnn #1#2#3#4#5#6#7 diff --git a/macros/latex/contrib/siunitx/siunitx-code.pdf b/macros/latex/contrib/siunitx/siunitx-code.pdf Binary files differindex 8a2b8e5992..fdc1658a42 100644 --- a/macros/latex/contrib/siunitx/siunitx-code.pdf +++ b/macros/latex/contrib/siunitx/siunitx-code.pdf diff --git a/macros/latex/contrib/siunitx/siunitx-compound.dtx b/macros/latex/contrib/siunitx/siunitx-compound.dtx index 51701c6915..b16aa63f30 100644 --- a/macros/latex/contrib/siunitx/siunitx-compound.dtx +++ b/macros/latex/contrib/siunitx/siunitx-compound.dtx @@ -137,6 +137,35 @@ % Phrase (or similar) used between limits of a range. % \end{variable} % +% \begin{function}{compound-boundary-mode} +% \begin{syntax} +% |compound-boundary-mode| = |number|\verb"|"|text| +% \end{syntax} +% Choice which determines whether the material at the start and +% end of a compound quantity are typeset a |number| or as |text|; +% the latter is the standard setting. +% \end{function} +% +% \begin{function}{compound-close-boundary, compound-open-boundary} +% \begin{syntax} +% |compound-close-boundary| = \meta{tokens}\\ +% |compound-open-boundary| = \meta{tokens} +% \end{syntax} +% Literals which are inserted at the opening and closing boundary of a compound +% quantity; they are not used when the number of items is one. +% The standard settings set these empty. +% \end{function} +% +% \begin{function}{compound-close-bracket, compound-open-bracket} +% \begin{syntax} +% |compound-close-bracket| = \meta{token} \\ +% |compound-open-bracket| = \meta{token} +% \end{syntax} +% Literals containing the tokens inserted at the start and end of a compound +% value when |compounds-units| is set to |bracket|. The standard settings are +% |(| and |)|. +% \end{function} +% % \begin{function}{compound-exponents} % \begin{syntax} % |compound-exponents| = |combine|\verb"|"|combine-bracket|\verb"|"|individual| @@ -149,6 +178,15 @@ % \end{syntax} % \end{function} % +% \begin{function}{compound-independent-prefix} +% \begin{syntax} +% |compound-independent-prefix| = |true|\verb"|"|false| +% \end{syntax} +% Switch which determines whether unit prefixes are calculated +% independently when units are repeated. The standard setting is +% |false|. +% \end{function} +% % \begin{function}{compound-pair-separator} % \begin{syntax} % |compound-pair-separator| = \meta{text} @@ -165,6 +203,9 @@ % \begin{syntax} % |compound-separator-mode| = |number|\verb"|"|text| % \end{syntax} +% Choice which determines whether the separators between components +% of compound quantity are typeset a |number| or as |text|; +% the latter is the standard setting. % \end{function} % % \begin{function}{compound-units} @@ -173,6 +214,15 @@ % \end{syntax} % \end{function} % +% \begin{function}{list-close-bracket, list-open-bracket} +% \begin{syntax} +% |list-close-bracket| = \meta{token} \\ +% |list-open-bracket| = \meta{token} +% \end{syntax} +% Literals containing the tokens inserted at the start and end of a list when +% |list-units| is set to |bracket|. The standard settings are |(| and |)|. +% \end{function} +% % \begin{function}{list-exponents} % \begin{syntax} % |list-exponents| = |combine|\verb"|"|combine-bracket|\verb"|"|individual| @@ -185,6 +235,15 @@ % \end{syntax} % \end{function} % +% \begin{function}{list-independent-prefix} +% \begin{syntax} +% |list-independent-prefix| = |true|\verb"|"|false| +% \end{syntax} +% Switch which determines whether unit prefixes are calculated +% independently when units are repeated. The standard setting is +% |false|. +% \end{function} +% % \begin{function}{list-pair-separator} % \begin{syntax} % |list-pair-separator| = \meta{text} @@ -203,12 +262,31 @@ % \end{syntax} % \end{function} % +% \begin{function}{product-close-bracket, product-open-bracket} +% \begin{syntax} +% |product-close-bracket| = \meta{token} \\ +% |product-open-bracket| = \meta{token} +% \end{syntax} +% Literals containing the tokens inserted at the start and end of a product +% when |product-units| is set to |bracket|. The standard settings are |(| +% and |)|. +% \end{function} +% % \begin{function}{product-exponents} % \begin{syntax} % |product-exponents| = |combine|\verb"|"|combine-bracket|\verb"|"|individual| % \end{syntax} % \end{function} % +% \begin{function}{product-independent-prefix} +% \begin{syntax} +% |product-independent-prefix| = |true|\verb"|"|false| +% \end{syntax} +% Switch which determines whether unit prefixes are calculated +% independently when units are repeated. The standard setting is +% |false|. +% \end{function} +% % \begin{function}{product-mode} % \begin{syntax} % |product-mode| = |phrase|\verb"|"|choice| @@ -233,10 +311,40 @@ % \end{syntax} % \end{function} % +% \begin{function}{range-close-bracket, range-open-bracket} +% \begin{syntax} +% |range-close-bracket| = \meta{token} \\ +% |range-open-bracket| = \meta{token} +% \end{syntax} +% Literals containing the tokens inserted at the start and end of a range when +% |range-units| is set to |bracket|. The standard settings are |(| and |)|. +% \end{function} +% +% \begin{function}{range-independent-prefix} +% \begin{syntax} +% |range-independent-prefix| = |true|\verb"|"|false| +% \end{syntax} +% Switch which determines whether unit prefixes are calculated +% independently when units are repeated. The standard setting is +% |false|. +% \end{function} +% +% \begin{function}{range-open-phrase} +% \begin{syntax} +% |range-open-phrase| = \meta{text} +% \end{syntax} +% Literal containing the material to be inserted at the start of a range. +% The standard setting is empty. +% \end{function} +% % \begin{function}{range-phrase} % \begin{syntax} % |range-phrase| = \meta{text} % \end{syntax} +% Literal containing the material to be inserted between the start and end +% of a range. The standard setting contains the word \texttt{to} inside the +% \cs{text} command, along with appropriate spacing commands to allow this +% material to work in both math and text typesetting modes. % \end{function} % % \begin{function}{range-units} @@ -258,6 +366,7 @@ % % \begin{macrocode} \cs_generate_variant:Nn \keys_set:nn { nx } +\cs_generate_variant:Nn \seq_use:Nnnn { NVVV } % \end{macrocode} % % \subsection{General mechanism} @@ -318,29 +427,26 @@ % \end{macrocode} % \end{variable} % -% \begin{variable}{\l_@@_bracket_close_tl, \l_@@_bracket_open_tl} -% Purely internal for the present. -% \begin{macrocode} -\tl_new:N \l_@@_bracket_close_tl -\tl_new:N \l_@@_bracket_open_tl -\tl_set:Nn \l_@@_bracket_open_tl { ( } -\tl_set:Nn \l_@@_bracket_close_tl { ) } -% \end{macrocode} -% \end{variable} -% % \begin{variable} % { +% \l_@@_boundary_close_tl , +% \l_@@_bracket_close_tl , +% \l_@@_independent_bool , % \l_@@_separator_final_tl , % \l_@@_separator_pair_tl , +% \l_@@_boundary_open_tl , +% \l_@@_bracket_open_tl , % \l_@@_separator_tl , % \l_@@_separator_text_bool , % \l_@@_exp_bracket_bool , % \l_@@_exp_combine_bool , % \l_@@_unit_bracket_bool , -% \l_@@_unit_repeat_bool +% \l_@@_unit_power_bool , +% \l_@@_unit_repeat_bool , % } % List options. % \begin{macrocode} +\bool_new:N \l_@@_boundary_text_bool \bool_new:N \l_@@_exp_bracket_bool \bool_new:N \l_@@_exp_combine_bool \bool_new:N \l_@@_separator_text_bool @@ -349,6 +455,15 @@ \bool_new:N \l_@@_unit_repeat_bool \keys_define:nn { siunitx } { + compound-boundary-mode .choice: , + compound-boundary-mode / number .code:n = + { \bool_set_false:N \l_@@_delim_text_bool } , + compound-boundary-mode / text .code:n = + { \bool_set_true:N \l_@@_delim_text_bool } , + compound-close-boundary .tl_set:N = + \l_@@_boundary_close_tl , + compound-close-bracket .tl_set:N = + \l_@@_bracket_close_tl , compound-exponents .choice: , compound-exponents / combine .code:n = { @@ -367,8 +482,14 @@ } , compound-final-separator .tl_set:N = \l_@@_separator_final_tl , + compound-independent-prefix .bool_set:N = + \l_@@_independent_bool , compound-pair-separator .tl_set:N = \l_@@_separator_pair_tl , + compound-open-boundary .tl_set:N = + \l_@@_boundary_open_tl , + compound-open-bracket .tl_set:N = + \l_@@_bracket_open_tl , compound-separator .tl_set:N = \l_@@_separator_tl , compound-separator-mode .choice: , @@ -406,7 +527,7 @@ \bool_set_false:N \l_@@_unit_bracket_bool \bool_set_false:N \l_@@_unit_power_bool \bool_set_false:N \l_@@_unit_repeat_bool - } + } } % \end{macrocode} % \end{variable} @@ -664,7 +785,12 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\siunitx_compound_quantity:nn} +% \begin{macro} +% { +% \siunitx_compound_quantity:nn , +% \@@_quantity_auxi:nn , +% \@@_quantity_auxii:nn +% } % For quantities, life is more complex as there are interactions between the % options for exponents and units. The \cs{c_empty_tl} suppresses any % leading \texttt{1} if the unit starts \cs{per}; the \pkg{siunitx-print} @@ -673,37 +799,76 @@ \cs_new_protected:Npn \siunitx_compound_quantity:nn #1#2 { \group_begin: - \bool_if:NT \l_@@_unit_bracket_bool - { \bool_set_true:N \l_@@_exp_bracket_bool } - \bool_if:NT \l_@@_unit_repeat_bool - { \bool_set_false:N \l_@@_exp_combine_bool } - \bool_lazy_or:nnT - { \l_@@_unit_bracket_bool } - { ! \l_@@_unit_repeat_bool } - { \bool_set_false:N \l_siunitx_number_bracket_ambiguous_bool } - \bool_set_true:N \l_@@_unit_bool - \@@_format:nn {#1} {#2} - \bool_if:NF \l_siunitx_number_parse_bool - { \siunitx_unit_format:nN {#2} \l_@@_unit_tl } - \str_if_eq:VnT \l_siunitx_quantity_prefix_mode_tl { combine-exponent } - { \tl_clear:N \l_@@_exp_tl } - \bool_if:NTF \l_@@_unit_repeat_bool - { \@@_print:N \@@_print_quantity:x } + \bool_lazy_all:nTF { - \bool_lazy_and:nnTF - { \l_@@_unit_bracket_bool } - { \tl_if_empty_p:N \l_@@_exp_tl } - { - \siunitx_print_number:V \l_@@_bracket_open_tl - \@@_print:N \siunitx_print_number:x - \siunitx_print_number:V \l_@@_bracket_close_tl - } - { \@@_print:N \siunitx_print_number:x } - \@@_print_quantity:n { \c_empty_tl } + { \l_@@_independent_bool } + { + \str_if_eq_p:Vn + \l_siunitx_quantity_prefix_mode_tl + { combine-exponent } + } + { \int_compare_p:nNn { \tl_count:n {#1} } > 1 } } + { \@@_quantity_auxi:nn } + { \@@_quantity_auxii:nn } + {#1} {#2} \group_end: } % \end{macrocode} +% The rather special case where all units are printed independently: +% we just convert to a simple sequence then print. +% \begin{macrocode} +\cs_new_protected:Npn \@@_quantity_auxi:nn #1#2 + { + \@@_print_boundary:V \l_@@_boundary_close_tl + \seq_clear:N \l_@@_tmp_seq + \tl_map_inline:nn {#1} + { + \seq_put_right:Nn \l_@@_tmp_seq + { \siunitx_quantity:nn {##1} {#2} } + } + \seq_use:NVVV \l_@@_tmp_seq + \l_@@_separator_pair_tl + \l_@@_separator_tl + \l_@@_separator_final_tl + \@@_print_boundary:V \l_@@_boundary_close_tl + } +% \end{macrocode} +% The business end for all other cases. +% \begin{macrocode} +\cs_new_protected:Npn \@@_quantity_auxii:nn #1#2 + { + \bool_if:NT \l_@@_unit_bracket_bool + { \bool_set_true:N \l_@@_exp_bracket_bool } + \bool_if:NT \l_@@_unit_repeat_bool + { \bool_set_false:N \l_@@_exp_combine_bool } + \bool_lazy_or:nnT + { \l_@@_unit_bracket_bool } + { ! \l_@@_unit_repeat_bool } + { \bool_set_false:N \l_siunitx_number_bracket_ambiguous_bool } + \bool_set_true:N \l_@@_unit_bool + \@@_format:nn {#1} {#2} + \bool_if:NF \l_siunitx_number_parse_bool + { \siunitx_unit_format:nN {#2} \l_@@_unit_tl } + \str_if_eq:VnT \l_siunitx_quantity_prefix_mode_tl { combine-exponent } + { \tl_clear:N \l_@@_exp_tl } + \bool_if:NTF \l_@@_unit_repeat_bool + { \@@_print:N \@@_print_quantity:x } + { + \bool_lazy_and:nnTF + { \l_@@_unit_bracket_bool } + { \tl_if_empty_p:N \l_@@_exp_tl } + { + \siunitx_print_number:V \l_@@_bracket_open_tl + \@@_print:N \siunitx_print_number:x + \siunitx_print_number:V \l_@@_bracket_close_tl + } + { \@@_print:N \siunitx_print_number:x } + \@@_print_quantity:n { \c_empty_tl } + } + } +% \end{macrocode} +% \end{macro} % \end{macro} % % \begin{macro}{\@@_print:N} @@ -712,7 +877,11 @@ % \begin{macro}{\@@_print_aux:n} % \begin{macro}{\@@_print_aux:nn} % \begin{macro}{\@@_print_quantity:n, \@@_print_quantity:x} -% \begin{macro}{\@@_print_separator:n, \@@_print_separator:V} +% \begin{macro} +% { +% \@@_print_boundary:n, \@@_print_boundary:V, +% \@@_print_separator:n, \@@_print_separator:V +% } % We now need to know how many entries there are: the reason we don't use % \cs{seq_use:Nnnn} is that we want to be able to insert % \cs{siunitx_print_\dots:n} in a controlled way. @@ -757,6 +926,7 @@ } { 2 } { + \@@_print_boundary:V \l_@@_boundary_open_tl #4 { \exp_not:n {#2} @@ -768,6 +938,7 @@ \seq_item:Nn \l_@@_tmp_seq { 2 } \exp_not:n {#3} } + \@@_print_boundary:V \l_@@_boundary_open_tl } } { @@ -775,9 +946,11 @@ \tl_set:Nn \l_@@_start_tl {#2} \tl_set:Nn \l_@@_end_tl {#3} \cs_set_eq:NN \@@_print_aux:n #4 + \@@_print_boundary:V \l_@@_boundary_open_tl \seq_map_indexed_function:NN \l_@@_tmp_seq \@@_print_aux:nn + \@@_print_boundary:V \l_@@_boundary_close_tl } } \cs_new_protected:Npn \@@_print_aux:n #1 { } @@ -816,6 +989,16 @@ \cs_new_protected:Npn \@@_print_quantity:n #1 { \siunitx_quantity_print:nV {#1} \l_@@_unit_tl } \cs_generate_variant:Nn \@@_print_quantity:n { x } +\cs_new_protected:Npn \@@_print_boundary:n #1 + { + \tl_if_blank:nF {#1} + { + \bool_if:NTF \l_@@_boundary_text_bool + { #1 } + { \siunitx_print_number:n {#1} } + } + } +\cs_generate_variant:Nn \@@_print_boundary:n { V } \cs_new_protected:Npn \@@_print_separator:n #1 { \bool_if:NTF \l_@@_separator_text_bool @@ -872,8 +1055,11 @@ % % \begin{variable} % { +% \l_@@_bracket_close_tl , +% \l_@@_independent_bool , % \l_siunitx_list_separator_tl , % \l_siunitx_list_separator_final_tl , +% \l_@@_bracket_open_tl , % \l_siunitx_list_separator_pair_tl , % \l_@@_exp_tl , % \l_@@_units_tl @@ -884,14 +1070,20 @@ \tl_new:N \l_@@_units_tl \keys_define:nn { siunitx } { + list-close-bracket .tl_set:N = + \l_@@_bracket_close_tl , list-exponents .choices:nn = { combine , combine-bracket , individual } { \tl_set_eq:NN \l_@@_exp_tl \l_keys_choice_tl } , list-final-separator .tl_set:N = \l_siunitx_list_separator_final_tl , + list-independent-prefix .bool_set:N = + \l_@@_independent_bool , + list-open-bracket .tl_set:N = + \l_@@_bracket_open_tl , list-pair-separator .tl_set:N = \l_siunitx_list_separator_pair_tl , list-separator .tl_set:N = \l_siunitx_list_separator_tl , list-units .choices:nn = - { bracket , repeat , single } + { bracket , independent , repeat , single } { \tl_set_eq:NN \l_@@_units_tl \l_keys_choice_tl } } % \end{macrocode} @@ -920,15 +1112,23 @@ { \keys_set:nx { siunitx } { - compound-exponents = \l_@@_exp_tl , - compound-final-separator = + compound-close-bracket = + { \exp_not:V \l_@@_bracket_close_tl } , + compound-close-boundary = , + compound-exponents = \l_@@_exp_tl , + compound-final-separator = { \exp_not:V \l_siunitx_list_separator_final_tl } , - compound-pair-separator = + compound-independent-prefix = + \bool_if:NTF \l_@@_independent_bool { true } { false } , + compound-open-boundary = , + compound-open-bracket = + { \exp_not:V \l_@@_bracket_open_tl } , + compound-pair-separator = { \exp_not:V \l_siunitx_list_separator_pair_tl } , - compound-separator = + compound-separator = { \exp_not:V \l_siunitx_list_separator_tl } , - compound-separator-mode = text , - compound-units = \l_@@_units_tl + compound-separator-mode = text , + compound-units = \l_@@_units_tl } } % \end{macrocode} @@ -946,10 +1146,13 @@ % % \begin{variable} % { -% \l_@@_exp_tl , -% \l_@@_phrase_bool , -% \l_@@_phrase_tl , -% \l_@@_symbol_tl , +% \l_@@_bracket_close_tl , +% \l_@@_exp_tl , +% \l_@@_independent_bool , +% \l_@@_bracket_open_tl , +% \l_@@_phrase_bool , +% \l_@@_phrase_tl , +% \l_@@_symbol_tl , % \l_@@_units_tl % } % Options for products. @@ -959,18 +1162,24 @@ \tl_new:N \l_@@_units_tl \keys_define:nn { siunitx } { + product-close-bracket .tl_set:N = + \l_@@_bracket_close_tl , product-exponents .choices:nn = { combine , combine-bracket , individual } { \tl_set_eq:NN \l_@@_exp_tl \l_keys_choice_tl } , + product-independent-prefix .bool_set:N = + \l_@@_independent_bool , product-mode .choice: , product-mode / phrase .code:n = { \bool_set_true:N \l_@@_phrase_bool } , product-mode / symbol .code:n = { \bool_set_false:N \l_@@_phrase_bool } , + product-open-bracket .tl_set:N = + \l_@@_bracket_open_tl , product-phrase .tl_set:N = \l_@@_phrase_tl , product-symbol .tl_set:N = \l_@@_symbol_tl , product-units .choices:nn = - { bracket , bracket-power , power , repeat , single } + { bracket , bracket-power , independent , power , repeat , single } { \tl_set_eq:NN \l_@@_units_tl \l_keys_choice_tl } } % \end{macrocode} @@ -1006,13 +1215,21 @@ { \keys_set:nx { siunitx } { - compound-exponents = \l_@@_exp_tl , - compound-final-separator = { \exp_not:n {#1} } , - compound-pair-separator = { \exp_not:n {#1} } , - compound-separator = { \exp_not:n {#1} } , - compound-separator-mode = + compound-close-boundary = , + compound-close-bracket = + { \exp_not:V \l_@@_bracket_close_tl } , + compound-exponents = \l_@@_exp_tl , + compound-final-separator = { \exp_not:n {#1} } , + compound-independent-prefix = + \bool_if:NTF \l_@@_independent_bool { true } { false } , + compound-open-boundary = , + compound-open-bracket = + { \exp_not:V \l_@@_bracket_open_tl } , + compound-pair-separator = { \exp_not:n {#1} } , + compound-separator = { \exp_not:n {#1} } , + compound-separator-mode = \bool_if:NTF \l_@@_phrase_bool { text } { number } , - compound-units = \l_@@_units_tl + compound-units = \l_@@_units_tl } } \cs_generate_variant:Nn \@@_aux:n { x } @@ -1032,7 +1249,11 @@ % % \begin{variable} % { +% \l_@@_bracket_close_tl , % \l_@@_exp_tl , +% \l_@@_independent_bool , +% \l_@@_bracket_open_tl , +% \l_@@_open_tl , % \l_siunitx_range_phrase_tl , % \l_@@_units_tl % } @@ -1042,12 +1263,19 @@ \tl_new:N \l_@@_units_tl \keys_define:nn { siunitx } { + range-close-bracket .tl_set:N = + \l_@@_bracket_close_tl , range-exponents .choices:nn = { combine , combine-bracket , individual } { \tl_set_eq:NN \l_@@_exp_tl \l_keys_choice_tl } , + range-independent-prefix .bool_set:N = + \l_@@_independent_bool , + range-open-bracket .tl_set:N = + \l_@@_bracket_open_tl , + range-open-phrase .tl_set:N = \l_@@_open_tl , range-phrase .tl_set:N = \l_siunitx_range_phrase_tl , range-units .choices:nn = - { bracket , repeat , single } + { bracket , independent , repeat , single } { \tl_set_eq:NN \l_@@_units_tl \l_keys_choice_tl } } % \end{macrocode} @@ -1076,10 +1304,20 @@ { \keys_set:nx { siunitx } { - compound-exponents = \l_@@_exp_tl , - compound-pair-separator = { \exp_not:V \l_siunitx_range_phrase_tl } , - compound-separator-mode = text , - compound-units = \l_@@_units_tl + compound-boundary-mode = text , + compound-close-boundary = , + compound-close-bracket = + { \exp_not:V \l_@@_bracket_close_tl } , + compound-exponents = \l_@@_exp_tl , + compound-independent-prefix = + \bool_if:NTF \l_@@_independent_bool { true } { false } , + compound-open-boundary = { \exp_not:V \l_@@_open_tl } , + compound-open-bracket = + { \exp_not:V \l_@@_bracket_open_tl } , + compound-pair-separator = + { \exp_not:V \l_siunitx_range_phrase_tl } , + compound-separator-mode = text , + compound-units = \l_@@_units_tl } } % \end{macrocode} @@ -1095,57 +1333,73 @@ % \begin{macrocode} \keys_set:nn { siunitx } { - compound-exponents = individual , - compound-final-separator = + compound-boundary-mode = text , + compound-close-boundary = , % ( + compound-close-bracket = ) , + compound-exponents = individual , + compound-final-separator = { \ifmmode \ \else \space \fi \text { and } \ifmmode \ \else \space \fi } , - compound-pair-separator = + compound-independent-prefix = false , + compound-open-boundary = , + compound-open-bracket = ( , % ) + compound-pair-separator = { \ifmmode \ \else \space \fi \text { and } \ifmmode \ \else \space \fi } , - compound-separator = + compound-separator = { , \ifmmode \ \else \space \fi } , - compound-separator-mode = text , - compound-units = repeat , - list-exponents = individual , - list-final-separator = + compound-separator-mode = text , + compound-units = repeat , % ( + list-close-bracket = ) , + list-exponents = individual , + list-final-separator = { \ifmmode \ \else \space \fi \text { and } \ifmmode \ \else \space \fi } , - list-pair-separator = + list-independent-prefix = false , + list-open-bracket = ( , % ) + list-pair-separator = { \ifmmode \ \else \space \fi \text { and } \ifmmode \ \else \space \fi } , - list-separator = + list-separator = { , \ifmmode \ \else \space \fi } , - list-units = repeat , - product-exponents = individual , - product-mode = symbol , - product-phrase = + list-units = repeat , % ( + product-close-bracket = ) , + product-exponents = individual , + product-independent-prefix = false , + product-mode = symbol , + product-open-bracket = ( , % ) + product-phrase = { \ifmmode \ \else \space \fi \text { by } \ifmmode \ \else \space \fi } , - product-symbol = \times , - product-units = repeat , - range-exponents = individual , - range-phrase = + product-symbol = \times , + product-units = repeat , % ( + range-close-bracket = ) , + range-exponents = individual , + range-independent-prefix = false , + range-open-bracket = ( , % ) + range-open-phrase = , + range-phrase = { \ifmmode \ \else \space \fi \text { to } \ifmmode \ \else \space \fi } , - range-units = repeat + range-units = repeat } % \end{macrocode} % diff --git a/macros/latex/contrib/siunitx/siunitx-locale.dtx b/macros/latex/contrib/siunitx/siunitx-locale.dtx index 43f432733a..da12029bc9 100644 --- a/macros/latex/contrib/siunitx/siunitx-locale.dtx +++ b/macros/latex/contrib/siunitx/siunitx-locale.dtx @@ -108,6 +108,12 @@ inter-unit-product = \, , output-decimal-marker = { , } } , + locale / IT .meta:n = + { + exponent-product = \times , + inter-unit-product = \, , + output-decimal-marker = { , } + } , locale / PL .meta:n = { exponent-product = \cdot , @@ -150,6 +156,7 @@ { \RequirePackage { translations } \DeclareTranslation { Catalan } { and } { i } + \DeclareTranslation { Italian } { and } { e } \DeclareTranslation { Portuguese } { and } { e } \DeclareTranslation { Slovene } { and } { in } \DeclareTranslation { Brazilian } { to~(numerical~range) } { a } @@ -157,6 +164,7 @@ \DeclareTranslation { English } { to~(numerical~range) } { to } \DeclareTranslation { French } { to~(numerical~range) } { ร } \DeclareTranslation { German } { to~(numerical~range) } { bis } + \DeclareTranslation { Italian } { to~(numerical~range) } { a } \DeclareTranslation { Polish } { to~(numerical~range) } { do } \DeclareTranslation { Portuguese } { to~(numerical~range) } { a } \DeclareTranslation { Slovene } { to~(numerical~range) } { do } diff --git a/macros/latex/contrib/siunitx/siunitx-number.dtx b/macros/latex/contrib/siunitx/siunitx-number.dtx index 8bc0a2dd71..faf216ac67 100644 --- a/macros/latex/contrib/siunitx/siunitx-number.dtx +++ b/macros/latex/contrib/siunitx/siunitx-number.dtx @@ -411,6 +411,12 @@ % \end{syntax} % \end{function} % +% \begin{function}{input-uncertainty-divider} +% \begin{syntax} +% |input-uncertainty-divider| = \meta{tokens} +% \end{syntax} +% \end{function} +% % \begin{function}{minimum-decimal-digits} % \begin{syntax} % |minimum-decimal-digits| = \meta{min} @@ -522,6 +528,18 @@ % The standard setting is |false|. % \end{function} % +% \begin{function}{round-direction} +% \begin{syntax} +% |round-direction| = |down|\verb"|"|nearest|\verb"|"|up| +% \end{syntax} +% Choice which determines how values values are rounded. The setting +% |up| means that the value is always rounded away from zero, whereas the +% setting |down| means that the value will be rounded toward zero. The +% setting |nearest| means that the value will be rounded to the nearest +% (either up or down), taking account of the setting of |round-half|. +% The standard setting is |nearest| +% \end{function} +% % \begin{function}{round-half} % \begin{syntax} % |round-half| = |even|\verb"|"|up| @@ -636,6 +654,18 @@ % |full| style is used. The standard setting is |compact|. % \end{function} % +% \begin{function}{uncertainty-round-direction} +% \begin{syntax} +% |uncertainty-round-direction| = |down|\verb"|"|nearest|\verb"|"|up| +% \end{syntax} +% Choice which determines how uncertainty values are rounded. The setting +% |up| means that the uncertainty is always rounded away from zero, whereas +% the setting |down| means that the uncertainty will be rounded toward zero. +% The setting |nearest| means that the uncertainty will be rounded to the +% nearest (either up or down), taking account of the setting of |round-half|. +% The standard setting is |nearest| +% \end{function} +% % \begin{function}{uncertainty-separator} % \begin{syntax} % |uncertainty-separator| = \meta{separator} @@ -776,6 +806,12 @@ % containing an identifier, then zero or more brace groups which contain % the uncertainty data. In this release, the known uncertainty types are % \begin{itemize} +% \item \texttt{A}: An unsymmetrical uncertainty made up of two values. +% Each is stored as uncertainty in significant digits, with no radix point +% in the stored value. The two parts are stored within one brace group, +% within which are two brace groups: the first contains the positive +% component, the second the negative component. Neither component has a +% sign. % \item \texttt{S}: A symmetrical statistical uncertainty made up of % a single value. These are stored as uncertainty in significant digits, % with no radix point in the stored value. @@ -797,6 +833,7 @@ % \l_siunitx_number_input_exponent_tl , % \l_@@_input_ignore_tl , % \l_@@_input_uncert_open_tl , +% \l_@@_input_uncert_divide_tl , % \l_siunitx_number_input_sign_tl , % \l_@@_input_uncert_sign_tl , % \l_@@_explicit_decimal_bool , @@ -838,6 +875,8 @@ { \tl_put_right:Nn \l_siunitx_number_input_sign_tl {##1} } } } , + input-uncertainty-divider .tl_set:N = + \l_@@_input_uncert_divide_tl , parse-numbers .bool_set:N = \l_siunitx_number_parse_bool , retain-explicit-decimal-marker .bool_set:N = @@ -911,11 +950,21 @@ % \end{macrocode} % \end{variable} % -% \begin{variable}{\l_@@_uncert_tl} +% \begin{variable} +% { +% \l_@@_tolerance_tl , +% \l_@@_uncert_tl , +% \l_@@_uncert_offset_int, +% \l_@@_uncert_types_tl +% } % To allow multiple uncertainties, we want to build this up as possibly -% multiple entries. +% multiple entries. For asymmetrical uncertainties/tolerances, we need +% an additional store. % \begin{macrocode} +\tl_new:N \l_@@_tolerance_tl \tl_new:N \l_@@_uncert_tl +\int_new:N \l_@@_uncert_offset_int +\tl_new:N \l_@@_uncert_types_tl % \end{macrocode} % \end{variable} % @@ -992,6 +1041,7 @@ \group_begin: \tl_clear:N \l_@@_parsed_tl \tl_clear:N \l_@@_uncert_tl + \tl_clear:N \l_@@_uncert_types_tl \tl_map_inline:Nn \l_@@_input_ignore_tl { \token_if_macro:NT ##1 @@ -1576,7 +1626,6 @@ \cs_new_protected:Npn \@@_parse_loop_main_uncert:NN #1#2 { \@@_parse_loop_main_store:NNN #1 #2 \c_false_bool - \tl_clear:N \l_@@_uncert_tl \@@_parse_uncert:N } % \end{macrocode} @@ -1647,6 +1696,7 @@ { \tl_clear:N \l_@@_flex_tl \tl_clear:N \l_@@_parsed_tl + \tl_clear:N \l_@@_uncert_tl } % \end{macrocode} % \end{macro} @@ -1695,14 +1745,21 @@ % % \begin{macro}{\@@_parse_uncert:N} % \begin{macro}{\@@_parse_uncert:NNN} -% \begin{macro}{\@@_parse_uncert_auxi:N, \@@_parse_uncert_auxii:N} -% \begin{macro}{\@@_parse_uncert_auxii:} +% \begin{macro} +% { +% \@@_parse_uncert_auxi:N , +% \@@_parse_uncert_auxii:N , +% \@@_parse_uncert_auxiv:N +% } +% \begin{macro}{\@@_parse_uncert_auxiv:} % \begin{macro}{\@@_parse_uncert_marker:} % \begin{macro}{\@@_parse_uncert_marker:nnn} % \begin{macro}{\@@_parse_uncert_marker:nnnw} % \begin{macro}{\@@_parse_uncert_marker:Nnnn} % \begin{macro}{\@@_parse_uncert_marker:w} % \begin{macro}{\@@_parse_uncert_marker:nnnnN} +% \begin{macro}{\@@_parse_uncert_marker:nnnnnN} +% \begin{macro}{\@@_parse_uncert_marker:nnnnnnN} % \begin{macro}{\@@_parse_uncert_after:N} % Parsing a combined uncertainty has a very restricted range of allowed % tokens. A closing uncertainty token in the first place is an error, @@ -1754,7 +1811,7 @@ { \tl_if_in:NnTF \l_siunitx_number_input_decimal_tl {#1} { \@@_parse_uncert_marker: } - { \@@_parse_loop_break:w } + { \@@_parse_uncert_auxiv:N #1 } } } \cs_new_protected:Npn \@@_parse_uncert_auxii:N #1 @@ -1764,7 +1821,7 @@ \@@_parse_uncert_auxiii: \@@_parse_uncert_after:N } - { \@@_parse_loop_break:w } + { \@@_parse_uncert_auxiv:N #1 } } % \end{macrocode} % Deal with the closing bracket, which might leave us with nothing if there @@ -1778,6 +1835,24 @@ { \tl_set:Nn \l_@@_partial_tl { 0 } } } % \end{macrocode} +% A common auxiliary for the case where the token is not a digit, a +% decimal mark or a closing parenthesis. +% \begin{macrocode} +\cs_new_protected:Npn \@@_parse_uncert_auxiv:N #1 + { + \tl_if_empty:NTF \l_@@_tolerance_tl + { + \tl_if_in:NnTF \l_@@_input_uncert_divide_tl {#1} + { + \cs_set_eq:NN \l_@@_tolerance_tl \l_@@_partial_tl + \tl_clear:N \l_@@_partial_tl + \@@_parse_uncert:N + } + { \@@_parse_loop_break:w } + } + { \@@_parse_loop_break:w } + } +% \end{macrocode} % Handling a decimal marker in the uncertainty is a bit tricky: we need to make % sure it's valid. First, we need to be sure that the integer part of the captured % uncertainty is not too long. Then we need to check that the decimal part is @@ -1785,7 +1860,7 @@ % Both of these require data from the collected partial number, % so we extract that first. Checking the decimal part needs the length of the % not-yet-collected uncertainty. There may be one or more parts to that, so -% we have to grab p to the \emph{first} closing token to count the length: +% we have to grab up to the \emph{first} closing token to count the length: % just grabbing everything only works if there is only a single uncertainty. % We take protective steps against an entirely-missing closing token so that % there is not an uncontrolled error. @@ -1826,22 +1901,62 @@ % With the separated out main part and the current uncertainty part % available, we can pad the main part if required then restart the % collection of the uncertainty having thrown away the decimal marker -% and with the lengths lined up. +% and with the lengths lined up. To account for asymmetrical +% uncertainties, there is a bit of work in tracking. % \begin{macrocode} \cs_new_protected:Npn \@@_parse_uncert_marker:nnnnN #1#2#3#4#5 { + \tl_set:Nx \l_@@_tmp_tl { \tl_head:V \l_@@_input_uncert_divide_tl } + \tl_if_empty:NTF \l_@@_tmp_tl + { \@@_parse_uncert_marker:nnnnnN {#1} {#2} {#3} {#4} { } #5 } + { + \use:x + { + \cs_set_protected:Npn \exp_not:N \@@_parse_uncert_marker:w + ####1 \l_@@_tmp_tl ####2 \l_@@_tmp_tl ####3 \exp_not:N \q_stop + { + \exp_not:N \tl_if_blank:nTF {####2} + { + \@@_parse_uncert_marker:nnnnnN + \exp_not:n { {#1} {#2} {#3} } + {####1} { } + } + { + \@@_parse_uncert_marker:nnnnnN + \exp_not:n { {#1} {#2} {#3} } + {####1} { \l_@@_tmp_tl ####2 } + } + \exp_not:N #5 + } + \exp_not:N \@@_parse_uncert_marker:w #4 + \l_@@_tmp_tl \l_@@_tmp_tl \exp_not:N \q_stop + } + } + } +\cs_new_protected:Npn \@@_parse_uncert_marker:nnnnnN #1#2#3#4#5#6 + { + \exp_args:Ne \@@_parse_uncert_marker:nnnnnnN + { \int_eval:n { \tl_count:n {#4} } } + {#1} {#2} {#3} {#4} {#5} #6 + } +\cs_new_protected:Npn \@@_parse_uncert_marker:nnnnnnN #1#2#3#4#5#6#7 + { + \bool_lazy_and:nnF + { \tl_if_empty_p:N \l_@@_tolerance_tl } + { \tl_if_empty_p:N \l_@@_uncert_types_tl } + { + \int_compare:nNnF {#1} = \l_@@_uncert_offset_int + { \@@_parse_loop_break:w } + } + \int_set:Nn \l_@@_uncert_offset_int {#1} \tl_set:Nx \l_@@_parsed_tl { - {#1} {#2} + {#3} { - #3 + #4 \prg_replicate:nn - { - \int_max:nn - { 0 } - { \tl_count:n {#4} - \tl_count:n {#3} } - } + { \int_max:nn { 0 } { #1 - \tl_count:n {#4} } } { 0 } } } @@ -1854,7 +1969,7 @@ \@@_parse_uncert:NNN \c_true_bool \@@_parse_uncert_auxii:N } - #4#5 + #5#6#7 } % \end{macrocode} % At the end of collection, we can either start another one or be done: @@ -1866,9 +1981,26 @@ { \exp_not:V \l_@@_uncert_tl \tl_if_empty:NF \l_@@_partial_tl - { { \exp_not:V \l_@@_partial_tl } } + { + { + \tl_if_empty:NTF \l_@@_tolerance_tl + { \exp_not:V \l_@@_partial_tl } + { + { \exp_not:V \l_@@_tolerance_tl } + { \exp_not:V \l_@@_partial_tl } + } + } + } + } + \tl_set:Nx \l_@@_uncert_types_tl + { + \l_@@_uncert_types_tl + \tl_if_empty:NTF \l_@@_tolerance_tl + { S } + { A } } \tl_clear:N \l_@@_partial_tl + \tl_clear:N \l_@@_tolerance_tl \quark_if_recursion_tail_stop_do:Nn #1 { \tl_set:Nx \l_@@_parsed_tl @@ -1877,17 +2009,14 @@ { \tl_if_empty:NF \l_@@_uncert_tl { - { - \prg_replicate:nn - { \tl_count:N \l_@@_uncert_tl } - { S } - } + { \l_@@_uncert_types_tl } \exp_not:V \l_@@_uncert_tl } } } \tl_clear:N \l_@@_partial_tl \tl_clear:N \l_@@_uncert_tl + \int_zero:N \l_@@_uncert_offset_int } \tl_if_in:NnTF \l_@@_input_uncert_open_tl {#1} { \@@_parse_uncert:N } @@ -1905,6 +2034,8 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} % % \subsection{Processing numbers} % @@ -1917,11 +2048,13 @@ % \l_@@_exponent_fixed_int , % \l_@@_min_decimal_int , % \l_@@_min_integer_int , +% \l_@@_round_dir_tl , % \l_@@_round_half_even_bool , % \l_@@_round_mode_tl , % \l_@@_round_pad_bool , % \l_@@_round_precision_int , -% \l_@@_round_positive_bool +% \l_@@_round_positive_bool , +% \l_@@_round_uncert_dir_tl % } % \begin{macrocode} \keys_define:nn { siunitx } @@ -1943,6 +2076,9 @@ \l_@@_min_decimal_int , minimum-integer-digits .int_set:N = \l_@@_min_integer_int , + round-direction .choices:nn = + { down , nearest , up } + { \tl_set_eq:NN \l_@@_round_dir_tl \l_keys_choice_tl } , round-half .choice: , round-half / even .code:n = { \bool_set_true:N \l_@@_round_half_even_bool } , @@ -1958,11 +2094,16 @@ round-precision .int_set:N = \l_@@_round_precision_int , round-zero-positive .bool_set:N = - \l_@@_round_positive_bool + \l_@@_round_positive_bool , + uncertainty-round-direction .choices:nn = + { down , nearest , up } + { \tl_set_eq:NN \l_@@_round_uncert_dir_tl \l_keys_choice_tl } , } \bool_new:N \l_@@_round_half_even_bool \tl_new:N \l_@@_exponent_mode_tl +\tl_new:N \l_@@_round_dir_tl \tl_new:N \l_@@_round_mode_tl +\tl_new:N \l_@@_round_uncert_dir_tl % \end{macrocode} % \end{variable} % @@ -2611,15 +2752,16 @@ % \end{macro} % % \begin{macro}[EXP]{\@@_round:nnn, \@@_round:fnn} +% \begin{macro}[EXP]{\@@_round:nnnn, \@@_round:Vnnn} % \begin{macro}[EXP] % { -% \@@_round_auxi:nnnN , -% \@@_round_auxii:nnnN , -% \@@_round_auxiii:nnnN +% \@@_round_auxi:nnnnN , +% \@@_round_auxii:nnnnN , +% \@@_round_auxiii:nnnnN , +% \@@_round_auxiv:nnnnN % } -% \begin{macro}[EXP]{\@@_round_auxiv:nnN, \@@_round_auxv:nnN} -% \begin{macro}[EXP]{\@@_round_auxvi:nN} -% \begin{macro}[EXP]{\@@_round_auxvii:nnTF} +% \begin{macro}[EXP]{\@@_round_auxv:nnnN, \@@_round_auxvi:nnnN} +% \begin{macro}[EXP]{\@@_round_auxvii:nnnTF} % \begin{macro}[EXP]{\@@_round_auxviii:nnN, \@@_round_auxix:nnN} % \begin{macro}[EXP]{\@@_round_final_integer:nnw, \@@_round_final_decimal:nnw} % \begin{macro}[EXP]{\@@_round_final_signicant:n} @@ -2648,34 +2790,40 @@ % \begin{macrocode} \cs_new:Npn \@@_round:nnn #1#2#3 { - \@@_round_auxi:nnnN {#1} {#2} { } - #3 \q_recursion_tail \q_recursion_stop + \@@_round:Vnnn \l_@@_round_dir_tl + {#1} {#2} {#3} } \cs_generate_variant:Nn \@@_round:nnn { f } -\cs_new:Npn \@@_round_auxi:nnnN #1#2#3#4 +\cs_new:Npn \@@_round:nnnn #1#2#3#4 { - \quark_if_recursion_tail_stop_do:Nn #4 + \@@_round_auxi:nnnnN {#1} {#2} {#3} { } + #4 \q_recursion_tail \q_recursion_stop + } +\cs_generate_variant:Nn \@@_round:nnnn { V } +\cs_new:Npn \@@_round_auxi:nnnnN #1#2#3#4#5 + { + \quark_if_recursion_tail_stop_do:Nn #5 { - \@@_round_auxii:nnnN {#1} {#3} { } #2 + \@@_round_auxii:nnnnN {#1} {#2} {#4} { } #3 \q_recursion_tail \q_recursion_stop } - \@@_round_auxi:nnnN {#1} {#2} {#4#3} + \@@_round_auxi:nnnnN {#1} {#2} {#3} {#5#4} } -\cs_new:Npn \@@_round_auxii:nnnN #1#2#3#4 +\cs_new:Npn \@@_round_auxii:nnnnN #1#2#3#4#5 { - \quark_if_recursion_tail_stop_do:Nn #4 + \quark_if_recursion_tail_stop_do:Nn #5 { - \tl_if_blank:nTF {#2} + \tl_if_blank:nTF {#3} { - \@@_round_auxiv:nnnN {#1} { } { } #3 + \@@_round_auxiv:nnnnN {#2} {#1} { } { } #4 \q_recursion_tail \q_recursion_stop } { - \@@_round_auxiii:nnnN {#1} {#3} { } #2 + \@@_round_auxiii:nnnnN {#2} {#1} {#4} { } #3 \q_recursion_tail \q_recursion_stop } } - \@@_round_auxii:nnnN {#1} {#2} {#4#3} + \@@_round_auxii:nnnnN {#1} {#2} {#3} {#5#4} } % \end{macrocode} % We now have the input reversed plus how many digits we need to discard @@ -2688,74 +2836,87 @@ % of the integer: that may product a value of $1\dots$: we tidy up the % case where it comes out as $0$ later. % \begin{macrocode} -\cs_new:Npn \@@_round_auxiii:nnnN #1#2#3#4 +\cs_new:Npn \@@_round_auxiii:nnnnN #1#2#3#4#5 { - \quark_if_recursion_tail_stop_do:Nn #4 + \quark_if_recursion_tail_stop_do:Nn #5 { - \@@_round_auxiv:nnnN {#1} { } {#3} #2 + \@@_round_auxiv:nnnnN {#1} {#2} { } {#4} #3 \q_recursion_tail \q_recursion_stop } \int_compare:nNnTF {#1} > 0 { - \exp_args:Nf \@@_round_auxiii:nnnN - { \int_eval:n { #1 - 1 } } {#2} { #4#3 } + \exp_args:Nf \@@_round_auxiii:nnnnN + { \int_eval:n { #1 - 1 } } {#2} {#3} { #5#4 } } - { \@@_round_auxv:nnN {#3} {#2} #4 } + { \@@_round_auxv:nnnN {#2} {#4} {#3} #5 } } -\cs_new:Npn \@@_round_auxiv:nnnN #1#2#3#4 +\cs_new:Npn \@@_round_auxiv:nnnnN #1#2#3#4#5 { - \quark_if_recursion_tail_stop_do:Nn #4 + \quark_if_recursion_tail_stop_do:Nn #5 { \int_compare:nNnTF {#1} = 0 { - \@@_round_auxvi:nnN {#3} {#2} + \@@_round_auxvi:nnnN {#2} {#4} {#3} 0 \q_recursion_tail \q_recursion_stop } { { 0 } { } } } \int_compare:nNnTF {#1} > 0 { - \exp_args:Nf \@@_round_auxiv:nnnN - { \int_eval:n { #1 - 1 } } { #2 0 } { #4#3 } + \exp_args:Nf \@@_round_auxiv:nnnnN + { \int_eval:n { #1 - 1 } } {#2} { #3 0 } { #5#4 } } - { \@@_round_auxvi:nnN {#3} {#2} #4 } + { \@@_round_auxvi:nnnN {#2} {#4} {#3} #5 } } % \end{macrocode} -% The lead off to rounding proper needs to deal with the half-even rule: -% it can only apply at this stage, when the \emph{discarded} value can -% be exactly half. +% We now have the discarded digits, the matching filler and the +% next digit. So we can make the decision on rounding: that +% is handled by a common auxiliary. % \begin{macrocode} -\cs_new:Npn \@@_round_auxv:nnN #1#2#3 +\cs_new:Npn \@@_round_auxv:nnnN #1#2#3#4 { - \quark_if_recursion_tail_stop_do:Nn #3 + \quark_if_recursion_tail_stop_do:Nn #4 { - \@@_round_auxvi:nnN - {#1} { } #2 \q_recursion_tail \q_recursion_stop + \@@_round_auxvi:nnnN + {#1} {#2} { } #3 \q_recursion_tail \q_recursion_stop } - \@@_round_auxvii:nnTF {#1} {#3} + \@@_round_auxvii:nnnTF {#1} {#2} {#4} { \@@_round_final_decimal:nnw } { \@@_round_auxviii:nnN } - {#2} { } #3 + {#3} { } #4 } -\cs_new:Npn \@@_round_auxvi:nnN #1#2#3 +\cs_new:Npn \@@_round_auxvi:nnnN #1#2#3#4 { - \quark_if_recursion_tail_stop_do:Nn #3 + \quark_if_recursion_tail_stop_do:Nn #4 { { 0 } { } } - \@@_round_auxvii:nnTF {#1} {#3} + \@@_round_auxvii:nnnTF {#1} {#2} {#4} { \@@_round_final_integer:nnw } { \@@_round_auxix:nnN } - { } {#2} #3 + { } {#3} #4 } -\cs_new:Npn \@@_round_auxvii:nnTF #1#2 +% \end{macrocode} +% For rounding up or down, the decision here is easy: pick the appropriate +% branch. For rounding to nearest, we need to deal with the half-even rule: +% it can only apply at this stage, when the \emph{discarded} value can +% be exactly half. +% \begin{macrocode} +\cs_new:Npn \@@_round_auxvii:nnnTF #1#2#3 { - \bool_lazy_or:nnTF - { \int_compare_p:nNn { 0 \tl_head:n {#1} } < 5 } + \str_case:nnF {#1} + { + { down } { \use_i:nn } + { up } { \use_ii:nn } + } { - \bool_lazy_all_p:n + \bool_lazy_or:nnTF + { \int_compare_p:nNn { 0 \tl_head:n {#2} } < 5 } { - { \l_@@_round_half_even_bool } - { ! \int_if_odd_p:n {#2} } - { \@@_round_if_half_p:n {#1} } + \bool_lazy_all_p:n + { + { \l_@@_round_half_even_bool } + { ! \int_if_odd_p:n {#3} } + { \@@_round_if_half_p:n {#2} } + } } } } @@ -3271,8 +3432,9 @@ \use:e { \exp_not:N \@@_round_uncertainty:nnnnnn - \@@_round:nnn {#1} { } {#4} - {#2} {#3} {#1} {#4} + \@@_round:Vnnn + \l_@@_round_uncert_dir_tl {#1} { } {#4} + {#2} {#3} {#1} {#4} } } % \end{macrocode} @@ -4240,6 +4402,7 @@ \@@_output_uncert_A:nnnn \cs_new:Npx \@@_output_uncert_A:nnnnn #1#2#3#4#5 { + { } ^ { + @@ -4631,6 +4794,7 @@ retain-explicit-plus = false , retain-negative-zero = false , retain-zero-uncertainty = false , + round-direction = nearest , round-half = up , round-minimum = 0 , round-mode = none , @@ -4642,15 +4806,19 @@ uncertainty-descriptor-separator = \ , uncertainty-descriptors = , uncertainty-mode = compact , + uncertainty-round-direction = nearest , uncertainty-separator = , zero-decimal-as-symbol = false , zero-symbol = \mbox { --- } } % \end{macrocode} -% One awkward setting. +% Two awkward settings. % \begin{macrocode} \keys_set:nx { siunitx } - { exponent-thresholds = -3 \c_colon_str 3 } + { + exponent-thresholds = -3 \c_colon_str 3 , + input-uncertainty-divider = \c_colon_str + } % \end{macrocode} % % \begin{macrocode} diff --git a/macros/latex/contrib/siunitx/siunitx-table.dtx b/macros/latex/contrib/siunitx/siunitx-table.dtx index 823a20edef..3fe8d34a5d 100644 --- a/macros/latex/contrib/siunitx/siunitx-table.dtx +++ b/macros/latex/contrib/siunitx/siunitx-table.dtx @@ -190,6 +190,15 @@ % the same size. % \end{function} % +% \begin{function}{table-model-setup} +% \begin{syntax} +% |table-model-setup| = \meta{commands} +% \end{syntax} +% Additional commands to be inserted when using the |table-format| to +% create a model for alignment of cells. Typically this will be used to +% handle variable-width fonts in columns. The standard setting is empty. +% \end{function} +% % \begin{function}{table-number-alignment} % \begin{syntax} % |table-number-alignment| = |center|\verb"|"|left|\verb"|"|right| @@ -818,7 +827,12 @@ % \end{macro} % % \begin{variable} -% {\l_@@_auto_round_bool, \l_@@_align_mode_tl, \l_@@_align_number_tl} +% { +% \l_@@_auto_round_bool, +% \l_@@_model_setup_tl , +% \l_@@_align_mode_tl , +% \l_@@_align_number_tl +% } % Options for tables with defined space. % \begin{macrocode} \keys_define:nn { siunitx } @@ -842,6 +856,8 @@ \exp_args:NV \@@_generate_model:n \l_@@_model_tl \tl_set:Nn \l_@@_align_mode_tl { format } } , + table-model-setup .tl_set:N = + \l_@@_model_setup_tl , table-number-alignment .choices:nn = { center , left , right } { \tl_set_eq:NN \l_@@_align_number_tl \l_keys_choice_tl } @@ -1174,7 +1190,12 @@ % \@@_print_format_auxxii:w , % \@@_print_format_auxxiii:w % } -% \begin{macro}{\@@_print_format_box:Nn} +% \begin{macro} +% { +% \@@_print_format_box:Nn, \@@_print_format_box:No , +% \@@_print_model_box:Nn, \@@_print_model_box:No +% } +% \begin{macro}{\@@_print_format_box:nNn, \@@_print_format_box:VNn} % \begin{macro}{\@@_print_format_after:N} % \begin{macro}{\@@_print_none:nnn} % \begin{macrocode} @@ -1325,7 +1346,7 @@ #1 \q_nil #2 \q_mark #3 \q_nil #4 \q_stop { \@@_color_check:w #3 \q_nil \q_stop - \@@_print_format_box:Nn \l_@@_tmp_box {#1} + \@@_print_model_box:Nn \l_@@_tmp_box {#1} \bool_if:NTF \l_@@_align_before_bool { \hbox_set_to_wd:Nnn \l_@@_integer_box @@ -1365,7 +1386,7 @@ \cs_new_protected:Npn \@@_print_format_auxii:w #1 \q_nil #2 \q_nil #3 \q_mark #4 \q_nil #5 \q_nil #6 \q_stop { - \@@_print_format_box:Nn \l_@@_tmp_box {#1#2} + \@@_print_model_box:Nn \l_@@_tmp_box {#1#2} \dim_set:Nn \l_@@_tmp_dim { \box_wd:N \l_@@_tmp_box } \@@_print_format_box:Nn \l_@@_tmp_box {#4#5} \dim_compare:nNnT { \box_wd:N \l_@@_tmp_box } > \l_@@_tmp_dim @@ -1425,19 +1446,20 @@ \@@_fil: \hbox_unpack:N \l_@@_before_box } - \@@_print_format_auxiii:w #3 \q_mark #6 \q_stop + \@@_print_format_auxiii:w ? #3 \q_mark ? #6 \q_stop } % \end{macrocode} % We now deal with the decimal part: there is nothing already in the % |decimal| box, so the basics are easy. We need to \enquote{carry forward} % any white space, as where it gets inserted depends on the options for -% subsequent parts. +% subsequent parts. The \cs{use_none:n} here remove the two |?| above: +% those are added to preserve braces around the decimal marker. % \begin{macrocode} \cs_new_protected:Npn \@@_print_format_auxiii:w #1 \q_nil #2 \q_nil #3 \q_mark #4 \q_nil #5 \q_nil #6 \q_stop { - \@@_print_format_box:Nn \l_@@_tmp_box {#1#2} - \@@_print_format_box:Nn \l_@@_decimal_box {#4#5} + \@@_print_model_box:No \l_@@_tmp_box { \use_none:n #1#2 } + \@@_print_format_box:No \l_@@_decimal_box { \use_none:n #4#5 } \dim_set:Nn \l_@@_carry_dim { \box_wd:N \l_@@_tmp_box @@ -1505,7 +1527,7 @@ #1 \q_nil #2 \q_nil #3 \q_mark #4 \q_nil #5 \q_nil #6 \q_stop { - \@@_print_format_box:Nn \l_@@_tmp_box {#1#2} + \@@_print_model_box:Nn \l_@@_tmp_box {#1#2} \hbox_set_to_wd:Nnn \l_@@_tmp_box { \box_wd:N \l_@@_uncert_box @@ -1535,7 +1557,7 @@ #1 \q_nil #2 \q_mark #3 \q_nil #4 \q_stop { - \@@_print_format_box:Nn \l_@@_tmp_box { { } #1 } + \@@_print_model_box:Nn \l_@@_tmp_box { { } #1 } \dim_set:Nn \l_@@_tmp_dim { \box_wd:N \l_@@_tmp_box } \@@_print_format_box:Nn \l_@@_tmp_box { { } #3 } \@@_print_format_auxxii:w #2 \q_mark #4 \q_stop @@ -1562,7 +1584,7 @@ { \tl_if_blank:nF {#2} { - \@@_print_format_box:Nn \l_@@_tmp_box { { } #1#2 } + \@@_print_model_box:Nn \l_@@_tmp_box { { } #1#2 } \dim_set:Nn \l_@@_tmp_dim { \box_wd:N \l_@@_tmp_box } \@@_print_format_box:Nn \l_@@_tmp_box { @@ -1570,7 +1592,7 @@ { \l_@@_align_exponent_bool } { \tl_if_blank_p:n {#3} } { - \@@_print_format_box:Nn \l_@@_tmp_box { { } #1 { } } + \@@_print_model_box:Nn \l_@@_tmp_box { { } #1 { } } \@@_skip:n { \box_wd:N \l_@@_tmp_box } } { } #3#4 @@ -1580,16 +1602,27 @@ } % \end{macrocode} % A simple auxiliary to avoid relatively expensive use of the print routine -% for empty parts. +% for empty parts. There is a separate function for the model as this allows +% for the case where different font widths are in use. % \begin{macrocode} \cs_new_protected:Npn \@@_print_format_box:Nn #1#2 + { \@@_print_format_box:nNn { } #1 {#2} } +\cs_generate_variant:Nn \@@_print_format_box:Nn { No } +\cs_new_protected:Npn \@@_print_model_box:Nn #1#2 + { \@@_print_format_box:VNn \l_@@_model_setup_tl #1 {#2} } +\cs_generate_variant:Nn \@@_print_model_box:Nn { No } +\cs_new_protected:Npn \@@_print_format_box:nNn #1#2#3 { - \hbox_set:Nn #1 + \hbox_set:Nn #2 { - \tl_if_blank:nF {#2} - { \siunitx_print_number:n {#2} } + \tl_if_blank:nF {#3} + { + #1 + \siunitx_print_number:n {#3} + } } } +\cs_generate_variant:Nn \@@_print_format_box:nNn { V } % \end{macrocode} % A common routine for placing material after the decimal marker and % \enquote{shuffling}. @@ -1653,6 +1686,7 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} % % \subsection{Standard settings for module options} % diff --git a/macros/latex/contrib/siunitx/siunitx.dtx b/macros/latex/contrib/siunitx/siunitx.dtx index d33a8c24b2..52dacc5c54 100644 --- a/macros/latex/contrib/siunitx/siunitx.dtx +++ b/macros/latex/contrib/siunitx/siunitx.dtx @@ -122,7 +122,7 @@ % % Identify the package and give the over all version information. % \begin{macrocode} -\ProvidesExplPackage {siunitx} {2023-07-26} {3.2.9} +\ProvidesExplPackage {siunitx} {2023-07-31} {3.3.0} {A comprehensive (SI) units package} % \end{macrocode} % @@ -184,16 +184,22 @@ % % \subsection{Load time options} % -% \begin{variable}{\l_@@_column_type_tl} +% \begin{variable}{\l_@@_list_tl, \l_@@_product_tl, \l_@@_column_type_tl} % \begin{macrocode} \keys_define:nn { siunitx } { + list-input-separator .tl_set:N = + \l_@@_list_tl , + product-input-separator .tl_set:N = + \l_@@_product_tl , table-column-type .tl_set:N = \l_@@_column_type_tl } \keys_set:nn { siunitx } { - table-column-type = S + list-input-separator = ; , + product-input-separator = x , + table-column-type = S } % \end{macrocode} % \end{variable} @@ -257,7 +263,11 @@ % \begin{macrocode} \IfFormatAtLeastTF { 2020-10-01 } { } - { \RequirePackage { xparse } } + { + \RequirePackage { xparse } + \providecommand \ExpandArgs [1] + { \cs_if_exist_use:c { exp_args:N #1 } } + } % \end{macrocode} % % \subsubsection{Preamble commands} @@ -375,8 +385,12 @@ % {\qtylist, \numlist, \qtyproduct, \numproduct, \qtyrange, \numproduct} % Interfaces for compound values. % \begin{macrocode} -\NewDocumentCommand \qtylist - { O { } > { \SplitList { ; } } m > { \TrimSpaces } m } +\ExpandArgs { Ne } \NewDocumentCommand \qtylist + { + O { } + > { \SplitList { \exp_not:V \l_@@_list_tl } } m + > { \TrimSpaces } m + } { \mode_leave_vertical: \group_begin: @@ -385,7 +399,11 @@ \siunitx_quantity_list:nn {#2} {#3} \group_end: } -\NewDocumentCommand \numlist { O { } > { \SplitList { ; } } m } +\ExpandArgs { Ne } \NewDocumentCommand \numlist + { + O { } + > { \SplitList { \exp_not:V \l_@@_list_tl } } m + } { \mode_leave_vertical: \group_begin: @@ -393,8 +411,12 @@ \siunitx_number_list:nn {#2} \group_end: } -\NewDocumentCommand \qtyproduct - { O { } > { \SplitList { x } } m > { \TrimSpaces } m } +\ExpandArgs { Ne } \NewDocumentCommand \qtyproduct + { + O { } + > { \SplitList { \exp_not:V \l_@@_product_tl } } m + > { \TrimSpaces } m + } { \mode_leave_vertical: \group_begin: @@ -403,8 +425,11 @@ \siunitx_quantity_product:nn {#2} {#3} \group_end: } -\NewDocumentCommand \numproduct - { O { } > { \SplitList { x } } > { \TrimSpaces } m } +\ExpandArgs { Ne } \NewDocumentCommand \numproduct + { + O { } + > { \SplitList { \exp_not:V \l_@@_product_tl } } m + } { \mode_leave_vertical: \group_begin: @@ -435,11 +460,8 @@ % \begin{macro}{\complexnum, \complexqty} % Interfaces for complex numbers. % \begin{macrocode} -\use:e - { - \NewDocumentCommand \exp_not:N \complexnum - { O { } > { \SplitArgument { 1 } { \c_colon_str } } m } - } +\ExpandArgs { Ne } \NewDocumentCommand \complexnum + { O { } > { \SplitArgument { 1 } { \c_colon_str } } m } { \mode_leave_vertical: \group_begin: @@ -447,11 +469,8 @@ \@@_complex_number_aux:nn #2 \group_end: } -\use:e - { - \NewDocumentCommand \exp_not:N \complexqty - { O { } > { \SplitArgument { 1 } { \c_colon_str } } m m } - } +\ExpandArgs { Ne } \NewDocumentCommand \complexqty + { O { } > { \SplitArgument { 1 } { \c_colon_str } } m m } { \mode_leave_vertical: \group_begin: diff --git a/macros/latex/contrib/siunitx/siunitx.ins b/macros/latex/contrib/siunitx/siunitx.ins index 6250eed33a..b2a35b2d4e 100644 --- a/macros/latex/contrib/siunitx/siunitx.ins +++ b/macros/latex/contrib/siunitx/siunitx.ins @@ -81,11 +81,11 @@ This work consists of the files siunitx.dtx, \file{siunitx.sty} {% \from{siunitx.dtx} {package,init} + \from{siunitx-number.dtx} {package} \from{siunitx-angle.dtx} {package} \from{siunitx-complex.dtx} {package} \from{siunitx-compound.dtx} {package} \from{siunitx-locale.dtx} {package} - \from{siunitx-number.dtx} {package} \from{siunitx-print.dtx} {package} \from{siunitx-table.dtx} {package} \from{siunitx-unit.dtx} {package} diff --git a/macros/latex/contrib/siunitx/siunitx.pdf b/macros/latex/contrib/siunitx/siunitx.pdf Binary files differindex 5b832eb7e1..299ec6f781 100644 --- a/macros/latex/contrib/siunitx/siunitx.pdf +++ b/macros/latex/contrib/siunitx/siunitx.pdf diff --git a/macros/latex/contrib/siunitx/siunitx.tex b/macros/latex/contrib/siunitx/siunitx.tex index c3fad6bbc7..7b7221f66a 100644 --- a/macros/latex/contrib/siunitx/siunitx.tex +++ b/macros/latex/contrib/siunitx/siunitx.tex @@ -1,6 +1,6 @@ \iffalse meta-comment -File: siunitx.tex Copyright (C) 2014-2022 Joseph Wright +File: siunitx.tex Copyright (C) 2014-2023 Joseph Wright It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of this @@ -640,9 +640,9 @@ The spelling \enquote{\cs{deka}} is provided for US users as an alternative to \DescribePrefix{hecto} & 2 \\ \DescribePrefix{yocto} & -24 & \DescribePrefix{kilo} & 3 \\ - \DescribePrefix{atto} & -18 & - \DescribePrefix{mega} & 6 \\ \DescribePrefix{zepto} & -21 & + \DescribePrefix{mega} & 6 \\ + \DescribePrefix{atto} & -18 & \DescribePrefix{giga} & 9 \\ \DescribePrefix{femto} & -15 & \DescribePrefix{tera} & 12 \\ @@ -883,6 +883,12 @@ occur (for example with the standard \cs{pm} symbol). \midrule + \DescribeUnit[tesla]{T} \\ + \DescribeUnit[millitesla]{mT} \\ + \DescribeUnit[microtesla]{uT} \\ + + \midrule + \DescribeUnit[kelvin]{K} \\ \midrule @@ -1305,6 +1311,7 @@ Table~\ref{tab:opt:num:in}. input-ignore & Literal & \meta{none} \\ input-open-uncertainty & Literal & ( \\ ^^A ) input-signs & Literal & +-\cs{pm}\cs{mp} \\ + input-uncertainty-divider & Literal & : \\ input-uncertainty-signs & Literal & \cs{pm} \\ parse-numbers & Switch & true \\ retain-explicit-decimal-marker & Switch & false \\ @@ -1364,18 +1371,38 @@ Uncertainties which cross the decimal marker may be given with or without a decimal marker in \enquote{compact} form. These are treated as equivalent by the code.\footnote{The package author favors the form without a decimal marker, and formal guidance is ambiguous on which is correct. The form with a decimal -marker is seen in for example some \acro{NIST} publications.} +marker is seen in for example some \acro{NIST} publications.} Where multiple +uncertainty values cross the decimal marker, they should all have the same +number of digits. \begin{LaTeXdemo} \num{123.4(12)} \\ \num{123.4(1.2)} \end{LaTeXdemo} -Multiple uncertainties may also be given: these must all either be in the short -or the long form. +Multiple symmetrical uncertainties may also be given: these must all either be +in the short or the long form. \begin{LaTeXdemo} \num{123.4(12)(45)} \\ \num{123.4 \pm 1.2 \pm 4.5} \end{LaTeXdemo} +\DescribeOption{input-uncertainty-divider} +In some areas, uncertainties (or tolerances) are given in an asymmetric format. +This is supported in the \enquote{compact} input form in \pkg{siunitx}, with +the positive and negative parts of the uncertainty divided by a symbol listed +in \opt{input-uncertainty-divider}. When given in this divided form, the +two parts are interpreted as first the positive and then the negative +component. Asymmetric uncertainties which cross the decimal marker are +supported provided both components have the same number of digits. +\begin{LaTeXdemo} + \num{10.56(12:34)} \\ + \num{123.4(4.6:7.8)} +\end{LaTeXdemo} +Symmetrical and asymmetrical uncertainties may be intermixed. +\begin{LaTeXdemo} + \num{10.56(1:2)(3)} \\ + \num{6.45(2)(3:4)} +\end{LaTeXdemo} + \DescribeOption{parse-numbers} The \opt{parse-numbers} option turns the entire parsing system on and off. The option is made available for two reasons. First, if all of the numbers in a @@ -1445,20 +1472,22 @@ way; the options are summarised in Table~\ref{tab:opt:num:post}. Type & \multicolumn{1}{l@{}}{Default} \\ \midrule - drop-exponent & Switch & false \\ - drop-uncertainty & Switch & false \\ - drop-zero-decimal & Switch & false \\ - exponent-mode & Switch & input \\ - exponent-thresholds & Literal & -3:3 \\ - fixed-exponent & Integer & 0 \\ - minimum-integer-digits & Integer & 0 \\ - minimum-decimal-digits & Integer & 0 \\ - round-half & Choice & up \\ - round-minimum & Literal & 0 \\ - round-mode & Choice & none \\ - round-pad & Switch & true \\ - round-precision & Integer & 2 \\ - round-zero-positive & Switch & true \\ + drop-exponent & Switch & false \\ + drop-uncertainty & Switch & false \\ + drop-zero-decimal & Switch & false \\ + exponent-mode & Switch & input \\ + exponent-thresholds & Literal & -3:3 \\ + fixed-exponent & Integer & 0 \\ + minimum-integer-digits & Integer & 0 \\ + minimum-decimal-digits & Integer & 0 \\ + round-direction & Choice & nearest \\ + round-half & Choice & up \\ + round-minimum & Literal & 0 \\ + round-mode & Choice & none \\ + round-pad & Switch & true \\ + round-precision & Integer & 2 \\ + round-zero-positive & Switch & true \\ + uncertainty-round-direction & Choice & nearest \\ \bottomrule \end{tabular} \end{table} @@ -1593,11 +1622,31 @@ is controlled by the switch \opt{round-pad}, which is \opt{true} as standard. \num[round-pad = false]{12.3} \end{LaTeXdemo} +\DescribeOption{round-direction} \DescribeOption{round-half} -In cases where the rounded part of a number is exactly half, there are two -common methods for \enquote{breaking the tie}. The choice of method is -determined by the option \opt{round-half}, which recognises the choices -\opt{up} and \opt{even}. +The detail of which approach to use for rounding may be adjusted using the +options \opt{round-direction} and \opt{round-half}. The option +\opt{round-direction} determines which direction a value is rounded toward: a +choice of \opt{nearest}, \opt{up} or \opt{down}. The standard setting, +\opt{nearest}, gives the common outcome that values round depending on whether +the preceding digit is greater or less than \num{5}. The options \opt{up} and +\opt{down} mean that values are always rounded in one direction: the \opt{down} +option may be thought of as \enquote{truncation}. +\begin{LaTeXdemo} + \sisetup{round-mode = places} + \num{0.054} \\ + \num{0.046} \\ + \sisetup{round-direction = down}% + \num{0.054} \\ + \num{0.046} \\ + \sisetup{round-direction = up}% + \num{0.054} \\ + \num{0.046} +\end{LaTeXdemo} +For rounding to \opt{nearest}, where the rounded part of a number is exactly +half, there are two common methods for \enquote{breaking the tie}. The choice +of method is determined by the option \opt{round-half}, which recognises the +choices \opt{up} and \opt{even}. \begin{LaTeXdemo} \sisetup{ round-mode = figures, @@ -1611,6 +1660,17 @@ determined by the option \opt{round-half}, which recognises the choices \num{0.045} \end{LaTeXdemo} +\DescribeOption{uncertainty-round-direction} +When rounding with uncertainties, the direction to round the uncertainty part +may be set independently of the main number: this is typically used to round +the uncertainty strictly upward. +\begin{LaTeXdemo} + \sisetup{round-mode = uncertainty} + \num{0.123(41)} \\ + \sisetup{uncertainty-round-direction = up}% + \num{0.123(41)} +\end{LaTeXdemo} + \DescribeOption{round-minimum} There are cases in which rounding will result in the number reaching zero. It may be desirable to show such results as below a threshold value. This can be @@ -1944,20 +2004,30 @@ specialised options, which apply to these more unusual input forms \multicolumn{1}{l}{Option name} & Type & \multicolumn{1}{l}{Default\tnote{*}} \\ - \midrule - list-exponents & Choice & individual \\ - list-final-separator & Literal & \verb*= \text{and} = \\ - list-pair-separator & Literal & \verb*= \text{and} = \\ - list-separator & Literal & \verb*=\text{,} = \\ - list-units & Choice & repeat \\ - product-exponents & Choice & individual \\ - product-mode & Choice & symbol \\ - product-phrase & Literal & \verb*= \text{by} = \\ - product-symbol & Literal & \cs{times} \\ - product-units & Choice & repeat \\ - range-exponents & Choice & individual \\ - range-phrase & Literal & \verb*= \text{to} = \\ - range-units & Choice & repeat \\ + \midrule % ( + list-close-bracket & Literal & ) \\ + list-exponents & Choice & individual \\ + list-final-separator & Literal & \verb*= \text{and} = \\ + list-independent-prefix & Switch & false \\ + list-open-bracket & Literal & ( \\ % ) + list-pair-separator & Literal & \verb*= \text{and} = \\ + list-separator & Literal & \verb*=\text{,} = \\ + list-units & Choice & repeat \\ % ( + product-close-bracket & Literal & ) \\ + product-exponents & Choice & individual \\ + product-independent-prefix & Switch & false \\ + product-mode & Choice & symbol \\ + product-open-bracket & Literal & ( \\ % ) + product-phrase & Literal & \verb*= \text{by} = \\ + product-symbol & Literal & \cs{times} \\ + product-units & Choice & repeat \\ % ( + range-close-bracket & Literal & ) \\ + range-exponents & Choice & individual \\ + range-independent-prefix & Switch & false \\ + range-open-bracket & Literal & ( \\ % ) + range-open-phrase & Literal & \meta{empty} \\ + range-phrase & Literal & \verb*= \text{to} = \\ + range-units & Choice & repeat \\ \bottomrule \end{tabular} \footnotesize @@ -2008,6 +2078,7 @@ as for numbers. \numproduct[product-phrase = { BY }]{5 x 100 x 2} \\ \end{LaTeXdemo} +\DescribeOption{range-open-phrase} \DescribeOption{range-phrase} Ranges of numbers can be given as input. These will have an appropriate word or symbol inserted between the two entries: this is stored using the @@ -2017,6 +2088,12 @@ extra space is added. The phrase is always printed in text mode. \numrange{5}{100} \\ \numrange[range-phrase = --]{5}{100} \end{LaTeXdemo} +In some languages, an opening phrase is \emph{required}; this is supported +using the \opt{range-open-phrase} key. +\begin{LaTeXdemo} + \numrange{10}{12} \\ + \numrange[range-open-phrase = {\text{from} }]{5}{100} +\end{LaTeXdemo} \DescribeOption{list-exponents} \DescribeOption{product-exponents} @@ -2078,6 +2155,48 @@ The option \opt{product-units} also offers the settings \opt{bracket-power} and \qtyproduct[product-units = bracket-power]{2 x 4}{\metre} \\ \qtyproduct[product-units = power]{2 x 4}{\metre} \end{LaTeXdemo} +\DescribeOption{list-close-bracket} +\DescribeOption{list-open-bracket} +\DescribeOption{product-close-bracket} +\DescribeOption{product-open-bracket} +\DescribeOption{range-close-bracket} +\DescribeOption{range-open-bracket} +The brackets used can be customised using the relevant \texttt{\dots-close-bracket} +and \texttt{\dots-open-bracket} options. +\begin{LaTeXdemo} + \sisetup{ + list-units = bracket , + list-open-bracket = ( , + list-close-bracket = ) + } + \numlist{5e3;7e3;9e3;1e4} \\ + \sisetup{ + product-units = bracket , + product-open-bracket = ( , + product-close-bracket = ) + } + \numproduct{5e3 x 7e3 x 9e3 x 1e4} \\ + \sisetup{ + range-units = bracket , + range-open-bracket = ( , + range-close-bracket = ) + } + \qtyrange{2}{4}{\degreeCelsius} +\end{LaTeXdemo} + +\DescribeOption{list-independent-prefix} +\DescribeOption{product-independent-prefix} +\DescribeOption{range-independent-prefix} +When converting exponents to prefixes, there are two possible approaches to the +case where units are repeated. They can all be converted to use the same +(initial) prefix, or they can be processed separately. The +\texttt{\dots-independent-prefix} options are used to control this outcome. +\begin{LaTeXdemo} + \sisetup{exponent-to-prefix = true}% + \qtyrange{1e3}{1e9}{\watt}\\ + \sisetup{range-independent-prefix = true}% + \qtyrange{1e3}{1e9}{\watt} +\end{LaTeXdemo} \subsection{Complex numbers} @@ -2664,19 +2783,20 @@ to the layout of tabular material (Table~\ref{tab:opt:tables}). Type & \multicolumn{1}{l@{}}{Default} \\ \midrule - table-align-comparator & Switch & true \\ - table-align-exponent & Switch & true \\ - table-align-text-after & Switch & true \\ - table-align-text-before & Switch & true \\ - table-align-uncertainty & Switch & true \\ - table-alignment & Meta & center \\ - table-alignment-mode & Choice & marker \\ - table-auto-round & Switch & false \\ - table-column-width & Length & 0pt \\ - table-fixed-width & Switch & false \\ - table-format & Special & 2.2 \\ - table-number-alignment & Choice & center \\ - table-text-alignment & Choice & center \\ + table-align-comparator & Switch & true \\ + table-align-exponent & Switch & true \\ + table-align-text-after & Switch & true \\ + table-align-text-before & Switch & true \\ + table-align-uncertainty & Switch & true \\ + table-alignment & Meta & center \\ + table-alignment-mode & Choice & marker \\ + table-auto-round & Switch & false \\ + table-column-width & Length & 0pt \\ + table-fixed-width & Switch & false \\ + table-format & Special & 2.2 \\ + table-model-setup & Literal & \meta{empty} \\ + table-number-alignment & Choice & center \\ + table-text-alignment & Choice & center \\ \bottomrule \end{tabular} \end{table} @@ -2794,6 +2914,12 @@ table format argument are set to be absent (the number of figures is set to zero). Setting the \opt{table-format} option also resets \opt{table-alignment-mode} to \opt{format}. +\DescribeOption{table-model-setup} +In some tables (particularly those using bold extended fonts), it may be +necessary to insert additional information when creating the \enquote{model}. +This is handled using the \opt{table-model-setup} key. An example of the use of +this key is given in Section~\ref{sec:hint:heading}. + Space for material before and after the \texttt{S} column can be reserved by giving model text as part of the \opt{table-format} key. This is then used to provide the necessary gap while maintaining alignment (Table~\ref{tab:S:ends}). @@ -3122,6 +3248,15 @@ option is used to switch to a particular locale. \subsection{Preamble-only options} +\DescribeOption{list-input-separator} +\DescribeOption{product-input-separator} +The separator between \emph{input} elements of lists (\cs{numlist}, +\cs{qtylist}) and products (\cs{numproduct}, \cs{qtyproduct}) can be adjusted +using the options \opt{list-input-separator} and \opt{product-input-separator}, +respectively. These are load-time only options as the separator here is part of +the \enquote{document interface} rather than part of the individual number(s). +The supplied value should be a \emph{single} marker. + \DescribeOption{table-column-type} The letter(s) used to create table columns can be adjusted using the \opt{table-column-type} option. The standard setting is |S|, but one or more @@ -3753,20 +3888,30 @@ best approach is to make the \cs{bfseries} macro \enquote{robust} (as demonstrated in Section~\ref{sec:hint:expanding}), then to use this macro to make the heading cells bold. This approach is illustrated in Table~\ref{tab:xmpl:headers}, along with the use of \cs{rowcolor} to provide a -background color. +background color. Some typical \LaTeX{} font arrangements use a wider +(extended) width for the bold font compared with the normal font. This will +disturb the alignment if the \opt{table-format} is not symmetrical. For these +cases, the \opt{table-model-setup} key may be used to apply the wider font to +the \enquote{model} used in ensuring alignment. \begin{LaTeXdemo}[code and float] \begin{table} \caption{Header row in a table.% \label{tab:xmpl:headers}} \robustify\bfseries \centering + \sisetup{text-series-to-math} \begin{tabular} - {@{}S[text-series-to-math, table-format = 3.3]@{}} + { + @{} + S[table-format = 3.3] + S[table-format = 3.6, table-model-setup = \bfseries] + @{} + } \rowcolor[gray]{0.9} - \bfseries 123.456 \\ - 23.45 \\ - 123.4 \\ - 3.456 \\ + \bfseries 123.456 & \bfseries 123.456789 \\ + 23.45 & 23.45 \\ + 123.4 & 123.4 \\ + 3.456 & 3.456 \\ \end{tabular} \end{table} \end{LaTeXdemo} @@ -3852,6 +3997,63 @@ be loaded in the preamble using \input{siunitx-local-units} \end{LaTeXdemo} +\subsection{Overloading the standard interfaces% + \label{sec:hint:overload}} + +The interfaces in \pkg{siunitx} deliberately split up different types of +numerical input (ranges, products, etc.) for semantic reasons. This also means +that there is less chance of confusion in parsing input. However, some users +would prefer to overload the \cs{num} and \cs{qty} commands such that they +accept multiple different types of input. There is a code-level interface that +could be used for this, but most end-users will likely want to avoid this. A +possible approach that covers most of the common cases is. +\begin{LaTeXdemo}[code only] + \ExplSyntaxOn + \cs_gset_eq:NN \ifstrpresent \tl_if_in:nnTF + \ExplSyntaxOff + \NewCommandCopy\oldnum\num + \NewCommandCopy\oldnumrange\numrange + \RenewDocumentCommand\num{O{}m}{% + \ifstrpresent{#2}{x} + {\numproduct[#1]{#2}} + {% + \ifstrpresent{#2}{;} + {\numlist[#1]{#2}} + {% + \ifstrpresent{#2}{:} + {\numrange[#1]{#2}} + {\oldnum[#1]{#2}}% + }% + }% + } + \RenewDocumentCommand\numrange{O{}>{\SplitList{:}}m} + {\oldnumrange[#1]#2} +\end{LaTeXdemo} +for the \cs{num} command and +\begin{LaTeXdemo}[code only] + \ExplSyntaxOn + \cs_gset_eq:NN \ifstrpresent \tl_if_in:nnTF + \ExplSyntaxOff + \NewCommandCopy\oldqty\qty + \NewCommandCopy\oldqtyrange\qtyrange + \RenewDocumentCommand\qty{O{}mm}{% + \ifstrpresent{#2}{x} + {\qtyproduct[#1]{#2}{#3}} + {% + \ifstrpresent{#2}{;} + {\qtylist[#1]{#2}{#3}} + {% + \ifstrpresent{#2}{:} + {\qtyrange[#1]{#2}{#3}} + {\oldqty[#1]{#2}{#3}}% + }% + }% + } + \RenewDocumentCommand\qtyrange{O{}>{\SplitList{:}}mm} + {\oldqtyrange[#1]#2{#3}} +\end{LaTeXdemo} +for \cs{qty}. + \section{Using (\acro{SI}) units} Consistent and logical units are a necessity for scientific work, and have |