texlive[68675] Master: calcfrac (27oct23)
commits+karl at tug.org
commits+karl at tug.org
Fri Oct 27 21:58:06 CEST 2023
Revision: 68675
https://tug.org/svn/texlive?view=revision&revision=68675
Author: karl
Date: 2023-10-27 21:58:06 +0200 (Fri, 27 Oct 2023)
Log Message:
-----------
calcfrac (27oct23)
Modified Paths:
--------------
trunk/Master/tlpkg/bin/tlpkg-ctan-check
trunk/Master/tlpkg/libexec/ctan2tds
trunk/Master/tlpkg/tlpsrc/collection-plaingeneric.tlpsrc
Added Paths:
-----------
trunk/Master/texmf-dist/doc/generic/calcfrac/
trunk/Master/texmf-dist/doc/generic/calcfrac/README
trunk/Master/texmf-dist/tex/generic/calcfrac/
trunk/Master/texmf-dist/tex/generic/calcfrac/calcfrac.sty
trunk/Master/texmf-dist/tex/generic/calcfrac/calcfrac.tex
trunk/Master/tlpkg/tlpsrc/calcfrac.tlpsrc
Added: trunk/Master/texmf-dist/doc/generic/calcfrac/README
===================================================================
--- trunk/Master/texmf-dist/doc/generic/calcfrac/README (rev 0)
+++ trunk/Master/texmf-dist/doc/generic/calcfrac/README 2023-10-27 19:58:06 UTC (rev 68675)
@@ -0,0 +1,61 @@
+____________________________________
+
+ calcfrac
+ v0.1
+ 26/10/2023
+
+ TeX & LaTeX package
+____________________________________
+
+Author : TeXpérimental
+Email : texperimental at mailo.fr
+Licence : Released under the LaTeX Project Public License v1.3c or
+ later, see http://www.latex-project.org/lppl.txt
+Status : maintained
+
+************************ LISEZ-MOI FRANÇAIS ************************
+Ce package a des intentions pédagogiques. Les vidéos montrant la
+totalité de son écriture à partir de rien sont disponibles sur
+youtube à partir de l'épisode 24 :
+
+ https://youtu.be/6lF4P6B3msw
+
+C'est pourquoi il est livré sans aucune documentation autre que
+la brève description ci-dessous.
+
+ Ce package met à disposition la macro \calcfrac qui admet comme
+ argument obligatoire une expression numérique contenant des
+ fractions. Par exemple
+ \calcfrac{1/2-2/3+3/4-2}
+ \calcfrac{2/(1/2-1/3)-2/3}
+ \calcfrac{1-(2-(3-(4-2/3)))/5}
+
+ Elle renvoie 3 arguments qui sont le signe, le numérateur et
+ le dénominateur du résultat.
+ Ces 3 arguments sont passés à une macro publique \cfdisp que
+ l'utilisateur peut programmer à sa guise (une version générique
+ qui devrait convenir au plus grand nombre est fournie)
+
+
+************************** README ENGLISH **************************
+This package is intended for educational purposes. The videos
+showing its writing from scratch are available on youtube from
+episode 24:
+
+ https://youtu.be/6lF4P6B3msw
+
+This is why it is delivered without any documentation other than
+the brief description below.
+
+ This package provides the \calcfrac macro, which accepts one
+ mandatory argument being a numerical expression containing
+ fractions. For example
+ \calcfrac{1/2-2/3+3/4-2}
+ \calcfrac{2/(1/2-1/3)-2/3}
+ \calcfrac{1-(2-(3-(4-2/3)))/5}
+
+ It returns 3 arguments which are the sign, the numerator
+ and the denominator of the result.
+ These 3 arguments are passed to a public macro \cfdisp
+ which the users can program as they wish (a generic version
+ which should be suitable for most users is provided)
Property changes on: trunk/Master/texmf-dist/doc/generic/calcfrac/README
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/generic/calcfrac/calcfrac.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/calcfrac/calcfrac.sty (rev 0)
+++ trunk/Master/texmf-dist/tex/generic/calcfrac/calcfrac.sty 2023-10-27 19:58:06 UTC (rev 68675)
@@ -0,0 +1,13 @@
+\input calcfrac.tex
+\ProvidesPackage{\calcfracname}[\calcfracver\space Calcul d'expressions avec fractions]
+\def\cfdisp#1#2#3{%
+ \ensuremath
+ {\ifnum#11=-1 -\fi
+ {\ifnum#3=1
+ #2%
+ \else
+ \frac{#2}{#3}%
+ \fi
+ }%
+ }%
+}
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/tex/generic/calcfrac/calcfrac.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/generic/calcfrac/calcfrac.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/calcfrac/calcfrac.tex (rev 0)
+++ trunk/Master/texmf-dist/tex/generic/calcfrac/calcfrac.tex 2023-10-27 19:58:06 UTC (rev 68675)
@@ -0,0 +1,246 @@
+% ____________________________________
+
+% calcfrac
+% v0.1
+% 26/10/2023
+
+% TeX & LaTeX package
+% ____________________________________
+
+% Author : TeXpérimental
+% Email : texperimental at mailo.fr
+% Licence : Released under the LaTeX Project Public License v1.3c or
+% later, see http://www.latex-project.org/lppl.txt
+% Status : maintained
+
+\csname calcfraconce\endcsname
+\let\calcfraconce\endinput
+\def\calcfracname{calcfrac}
+\def\calcfracver{0.1}
+\def\calcfracdate{2023/10/26}
+
+\catcode`\@11
+\def\cf at test@ifx#1{%
+ \ifx#1\expandafter\cf at execfirst\else\expandafter\cf at execsecond\fi
+}
+\def\cf at test@ifnum#1{%
+ \ifnum#1\expandafter\cf at execfirst\else\expandafter\cf at execsecond\fi
+}
+\def\cf at execfirst#1#2{#1}
+\def\cf at execsecond#1#2{#2}
+\def\cf at execarg#1{#1}
+\def\cf at matharg#1{$#1$}
+%###########################################
+%############# boucle \cf at for ##############
+%###########################################
+\def\cf at for#1=#2to#3#{%
+ \cf at for@a{#1}{#2}{#3}%
+}
+\def\cf at for@a#1#2#3#4{%
+ \edef#1{\number\numexpr#2}%
+ \edef\cf at maxint{\number\numexpr#3}%
+ \def\cf at for@b{%
+ \unless\ifnum#1>\cf at maxint\relax
+ #4%
+ \edef#1{\number\numexpr#1+1}%
+ \expandafter\cf at for@b
+ \fi
+ }%
+ \cf at for@b
+}
+%###########################################
+%###########################################
+%###########################################
+\newcount\cf at tmp@count
+\newcount\cf at frac@cnt
+\newif\if at inparen
+\def\calcfrac at err#1#2\relax{%
+ \errmessage{Illegal char "#1", "#2" ignored}%
+}
+\def\calcfrac{%
+ \begingroup
+ \catcode32=9 % espaces ignorés
+ \calcfrac at a
+}
+\def\calcfrac at a#1{%
+ \endgroup
+ \ifcat\relax\detokenize{#1}\relax
+ \else
+ \cf at frac@cnt=0
+ \@inparenfalse
+ \expandafter\cf at read@frac\detokenize{#1}\relax
+ \fi
+}
+\def\cf at read@frac{% [1 signe optionnel + ou-]<entier non signé>[1 signe / ou * suivi d'un entier non signé]*n
+ \advance\cf at frac@cnt1
+ \let\cf at current@sign\empty
+ \def\cf at current@numer{1}%
+ \def\cf at current@denom{1}%
+ \def\cf at current@op{*}%
+ \cf at read@sign
+}
+\def\cf at read@sign#1{%
+ \cf at test@ifnum{0\ifx+#11\fi\ifx-#11\fi=1 }
+ {%
+ \def\cf at current@sign{#1}%
+ \cf at read@int
+ }
+ {%
+ \cf at read@int#1%
+ }%
+}
+\def\cf at read@int#1{%
+ \cf at test@ifnum{0\ifnum`#1<`0 1\fi\ifnum`#1>`9 1\fi=0 }
+ {%
+ \afterassignment\cf at update@afterint
+ \cf at tmp@count#1%
+ }
+ {% TODO : si #1=parenthèse
+ \if(#1\expandafter\cf at execfirst\else\expandafter\cf at execsecond\fi
+ {%
+ \begingroup
+ \@inparentrue
+ \cf at frac@cnt=0
+ \cf at read@frac
+ }
+ {%
+ \calcfrac at err#1%
+ }%
+ }%
+}
+\def\cf at update@afterint{%
+ \if*\cf at current@op\expandafter\cf at execfirst\else\expandafter\cf at execsecond\fi
+ {%
+ \edef\cf at current@numer{\cf at current@numer*\the\cf at tmp@count}%
+ \cf at read@op
+ }
+ {%
+ \if/\cf at current@op\expandafter\cf at execfirst\else\expandafter\cf at execsecond\fi
+ {%
+ \edef\cf at current@denom{\cf at current@denom*\the\cf at tmp@count}%
+ \cf at read@op
+ }
+ {%
+ \errmessage{This error should not occur, \string\cf at current@op=\cf at current@op}%
+ }%
+ }%
+}
+\def\cf at read@op#1{%
+ \cf at test@ifnum{0\ifx*#11\fi\ifx/#11\fi=1 }
+ {%
+ \def\cf at current@op{#1}%
+ \cf at read@int
+ }
+ {%
+ \cf at compute@frac#1%
+ }%
+}
+\def\cf at compute@frac#1{%
+ \edef\cf at current@numer{\the\numexpr\cf at current@numer}%
+ \edef\cf at current@denom{\the\numexpr\cf at current@denom}%
+ \expandafter\cf at calc@gcd\expanded{{\cf at current@numer}{\cf at current@denom}}\cf at tem@gcd
+ \expandafter\edef\csname sign@\the\cf at frac@cnt\endcsname{\ifnum\cf at current@sign1=1+\else-\fi}%
+ \expandafter\edef\csname numer@\the\cf at frac@cnt\endcsname{\the\numexpr\cf at current@numer/\cf at tem@gcd}%
+ \expandafter\edef\csname denom@\the\cf at frac@cnt\endcsname{\the\numexpr\cf at current@denom/\cf at tem@gcd}%
+ \cf at test@ifnum{0\ifx\relax#111\fi\if at inparen1\fi\if)#11\fi=11 }% si <#1=\relax> OU <inparen=vrai ET #1=")">
+ {%
+ \cf at add@allfrac
+ }
+ {%
+ \cf at read@frac#1%
+ }%
+}
+\def\cf at calc@gcd#1#2{% #1, #2=entiers
+ \cf at test@ifnum{#1>#2\relax}
+ {%
+ \cf at calc@gcd at a{#2}{#1}%
+ }
+ {%
+ \cf at calc@gcd at a{#1}{#2}%
+ }%
+}
+\def\cf at calc@gcd at a#1#2{% #1=diviseur #2=dividende
+ \cf at test@ifnum{#1>0 }
+ {%
+ \cf at tmp@count=#2\relax
+ \divide\cf at tmp@count#1\relax
+ \expandafter\cf at calc@gcd at a\expandafter{\the\numexpr#2-\cf at tmp@count*#1}{#1}%
+ }
+ {%
+ \cf at calc@gcd at b{#2}%
+ }%
+}
+\def\cf at calc@gcd at b#1#2{% #1=PGCD #2=macro qui stocke le PGCD
+ \def#2{#1}%
+}
+\def\calc at lcm#1#2#3{% #1, #2=entiers #3=macro recevant le PPCM
+ \cf at calc@gcd{#1}{#2}\cf at tem@gcd%
+ \edef#3{\the\numexpr#1*#2/\cf at tem@gcd}%
+}
+\def\cf at add@allfrac{%
+ \cf at test@ifnum{\cf at frac@cnt>1 }
+ {%
+ \expandafter\let\expandafter\cf at result@denom\csname denom at 1\endcsname
+ \cf at for\cf at temp@index=2 to \cf at frac@cnt{%
+ \expandafter\calc at lcm\expanded{{\cf at result@denom}{\csname denom@\cf at temp@index\endcsname}}\cf at result@denom
+ }%
+ \def\cf at result@numer{0}%
+ \cf at for\cf at temp@index=1 to \cf at frac@cnt{%
+ \edef\cf at result@numer{%
+ \the\numexpr
+ \cf at result@numer
+ \csname sign@\cf at temp@index\endcsname% <- + ou -
+ \csname numer@\cf at temp@index\endcsname*\cf at result@denom/\csname denom@\cf at temp@index\endcsname
+ }%
+ }%
+ \ifnum\cf at result@numer<0
+ \edef\cf at result@numer{\the\numexpr-\cf at result@numer}%
+ \def\cf at result@sign{-}%
+ \else
+ \def\cf at result@sign{+}%
+ \fi
+ \expandafter\cf at calc@gcd\expanded{{\cf at result@numer}{\cf at result@denom}}\cf at tem@gcd
+ \ifnum\cf at tem@gcd>1
+ \edef\cf at result@numer{\the\numexpr\cf at result@numer/\cf at tem@gcd}%
+ \edef\cf at result@denom{\the\numexpr\cf at result@denom/\cf at tem@gcd}%
+ \fi
+ }
+ {%
+ \expandafter\let\expandafter\cf at result@sign\csname sign at 1\endcsname
+ \expandafter\let\expandafter\cf at result@numer\csname numer at 1\endcsname
+ \expandafter\let\expandafter\cf at result@denom\csname denom at 1\endcsname
+ }%
+ \if at inparen\expandafter\cf at execfirst\else\expandafter\cf at execsecond\fi
+ {%
+ \expandafter
+ \endgroup
+ \expanded{%
+ \def\noexpand\cf at paren@sign{\cf at result@sign}%
+ \def\noexpand\cf at paren@numer{\cf at result@numer}%
+ \def\noexpand\cf at paren@denom{\cf at result@denom}%
+ }%
+ \edef\cf at current@sign{\cf at current@sign\cf at paren@sign}%
+ \expandafter\cf at read@int\expanded{\cf at paren@numer\if*\cf at current@op/\else*\fi\cf at paren@denom}%
+ }
+ {%
+ \expandafter\cfdisp\expanded{{\cf at result@sign}{\cf at result@numer}{\cf at result@denom}}%
+ }%
+}
+\def\cfdisp#1#2#3{%
+ \ifmmode\expandafter\cf at execfirst\else\expandafter\cf at execsecond\fi
+ {\cf at execarg}
+ {\cf at matharg}
+ {\ifnum#11=-1 -\fi
+ {\ifnum#3=1
+ #2%
+ \else
+ #2\over#3%
+ \fi
+ }%
+ }%
+}
+\catcode`\@12
+\endinput
+
+VERSIONS :
+v0.1 : version initiale
\ No newline at end of file
Property changes on: trunk/Master/texmf-dist/tex/generic/calcfrac/calcfrac.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check 2023-10-27 19:56:22 UTC (rev 68674)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check 2023-10-27 19:58:06 UTC (rev 68675)
@@ -161,7 +161,7 @@
bxjalipsum bxjscls bxnewfont bxorigcapt bxtexlogo bxwareki
byo-twemojis byrne bytefield
c90 c-pascal cabin cachepic cahierprof
- caladea calcage calctab calculation calculator
+ caladea calcage calcfrac calctab calculation calculator
calligra calligra-type1 callouts calrsfs cals calxxxx-yyyy cancel
canoniclayout cantarell
capt-of captcont captdef caption
Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds 2023-10-27 19:56:22 UTC (rev 68674)
+++ trunk/Master/tlpkg/libexec/ctan2tds 2023-10-27 19:58:06 UTC (rev 68675)
@@ -2068,6 +2068,7 @@
'breqn', '\.sty|\.sym',
'buctthesis', 'buct.*cls',
'c-pascal', '^[^d].*\.tex|' . $standardtex, # not demo*.tex
+ 'calcfrac', '^calcfrac\.tex|' . $standardtex,
'calxxxx', 'cal.*\.tex',
'calxxxx-yyyy','cal.*\.tex',
'captcont', '\.sty|[^c]\.cfg', # omit ltxdoc.cfg, would be system-wide
Added: trunk/Master/tlpkg/tlpsrc/calcfrac.tlpsrc
===================================================================
Modified: trunk/Master/tlpkg/tlpsrc/collection-plaingeneric.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-plaingeneric.tlpsrc 2023-10-27 19:56:22 UTC (rev 68674)
+++ trunk/Master/tlpkg/tlpsrc/collection-plaingeneric.tlpsrc 2023-10-27 19:58:06 UTC (rev 68675)
@@ -14,6 +14,7 @@
depend bitelist
depend borceux
depend c-pascal
+depend calcfrac
depend catcodes
depend chronosys
depend collargs
More information about the tex-live-commits
mailing list.