% -*- coding: utf-8; time-stamp-format: "%02d-%02m-%:y at %02H:%02M:%02S %Z" -*- % This file: xint.dtx. Proudly produced by xint-dtxbuild.sh. % Run etex on this file to extract all xint*sty files. %<*dtx> \def\xintdtxtimestamp {Time-stamp: <07-09-2025 at 00:47:30 CEST>} % % % To build xint.pdf (with both user manual and commented source code), % the recommended way is: % % - step 1: etex xint.dtx (stop here if you only need the xint*sty files) % - step 2: make --file=Makefile.mk xint.pdf % % The above step 2 requires make + latexmk and uses latex + dvipdfmx. % % Other make targets are % - xintmanual.pdf (contains only the user documentation) % - xintsource.pdf (contains only the commented source code) % % Alternative for building xint.pdf (and extracting the xint*sty files): % % Direct runs of pdflatex, xelatex or lualatex on xint.dtx, % or (better) of latexmk -pdf (or -pdfxe, -pdflua) on xint.dtx. % % (if using xelatex, it must be with -8bit option for extracted Makefile.mk % to be valid, but this has no impact on the xint*sty files and xint.pdf). % %<*xintmandrv|xintsrcdrv|xintalldrv> %% --------------------------------------------------------------- \def\xintdocdate {2025/09/06} \def\xintbndldate{2025/09/06} \def\xintbndlversion {1.4o} % %% README %% xint 1.4o %% 2025/09/06 % % Source: xint.dtx 1.4o 2025/09/06 (doc 2025/09/06) % Author: Jean-François Burnol % Info: Expandable operations on big integers, decimals, fractions % License: LPPL 1.3c % %<*!readme&!makefile> %% --------------------------------------------------------------- %% The xint bundle 1.4o 2025/09/06 %% Copyright (C) 2013-2022, 2025 Jean-Francois Burnol %%% xintkernel: Paraphernalia for the xint packages %%% xinttools: Expandable and non-expandable utilities %%% xintcore: Expandable arithmetic on big integers %%% xint: Expandable operations on big integers %%% xintfrac: Expandable operations on fractions %%% xintexpr: Expandable expression parser %%% xintbinhex: Expandable radix conversions (2, 8, 10, and 16) %%% xintgcd: Euclidean algorithm with xint package %%% xintseries: Expandable partial sums with xint package %%% xintcfrac: Expandable continued fractions with xint package %%% xinttrig: Trigonometry for the xintexpr package %%% xintlog: Logarithms and exponentials for xintexpr %% --------------------------------------------------------------- % %<*dtx> \bgroup\catcode2 0 \catcode`\\ 12 ^^Biffalse % %<*readme>-------------------------------------------------------- Description =========== The main functionality is `\xintfloateval` which parses expressions involving floating point numbers, functions, variables and other syntax elements. The precision defaults to `16` decimal digits. The logarithm, exponential, direct and inverse trigonometric functions are supported up to `62` digits. The four basic operations and square-root extraction are implemented with correct rounding up to thousands of digits (roughly up to a maximum of 26000 digits for the output). A variant `\xinteval` computes with fractions. And `\xintiieval` handles only (arbitarily large) integers. All three parsers obtain their result purely expandably. They handle comma separated inputs and nested structures using square brackets. The user can declare custom variables and functions. Usage ===== The way of loading `xintexpr` depends on whether you are using `LaTeX` or not. - with `LaTeX`, add `\usepackage{xintexpr}` to the document preamble, - else, do `\input xintexpr.sty` and compile with either one of `etex`, `pdftex`, `xetex`, `luatex` (they all default to the `Plain TeX` format), or with `optex` (i.e. `luatex` with `OpTeX` format), or with `context` (`luametatex` engine). Example ======= Here is an example typical of the `xintexpr` users morning routine since many years (`xintexpr` was first released in 2013): \xinteval{reduce(add(1/i^3, i=1..25))} It expands (in two steps) to: 2560976152652211536408111110189/2131858131361319942957376000000 Repository ========== It is at https://github.com/jfbu/xint and the issue tracker is at https://github.com/jfbu/xint/issues. Documentation ============= Both the user manual and the commented source code are in `xint.pdf`. A file `CHANGES.html` is provided at https://jfbu.github.io/xint. Its source `xintchanges.md` is part of the CTAN upload, and you can access it in TeXLive using `texdoc xintchanges.md`. License ======= Copyright © 2013-2022, 2025 Jean-François Burnol This Work may be distributed and/or modified under the conditions of the LaTeX Project Public License version 1.3c. This version of this license is in > and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later. This Work has the LPPL maintenance status *author-maintained*. The Author of this Work is Jean-François Burnol. This Work consists of the file `xint.dtx` and `README.md` and their derived files such as `xint.pdf`. %-------------------------------------------------------- %<*dates>------------------------------------------------------- `1.4o (2025/09/06)` `1.4n (2025/09/05)` `1.4m (2022/06/10)` `1.4l (2022/05/29)` `1.4k (2022/05/18)` `1.4j (2021/07/13)` `1.4i (2021/06/11)` `1.4h (2021/05/27)` `1.4g (2021/05/25)` `1.4f (2021/05/10)` `1.4e (2021/05/05)` `1.4d (2021/03/29)` `1.4c (2021/02/20)` `1.4b (2020/02/25)` `1.4a (2020/02/19)` `1.4 (2020/01/31)` `1.3f (2019/09/10)` `1.3e (2019/04/05)` `1.3d (2019/01/06)` `1.3c (2018/06/17)` `1.3b (2018/05/18)` `1.3a (2018/03/07)` `1.3 (2018/03/01)` `1.2q (2018/02/06)` `1.2p (2017/12/05)` `1.2o (2017/08/29)` `1.2n (2017/08/06)` `1.2m (2017/07/31)` `1.2l (2017/07/26)` `1.2k (2017/01/06)` `1.2j (2016/12/22)` `1.2i (2016/12/13)` `1.2h (2016/11/20)` `1.2g (2016/03/19)` `1.2f (2016/03/12)` `1.2e (2015/11/22)` `1.2d (2015/11/18)` `1.2c (2015/11/16)` `1.2b (2015/10/29)` `1.2a (2015/10/19)` `1.2 (2015/10/10)` `1.1c (2015/09/12)` `1.1b (2015/08/31)` `1.1a (2014/11/07)` `1.1 (2014/10/28)` `1.09n (2014/04/01)` `1.09m (2014/02/26)` `1.09kb (2014/02/13)` `1.09k (2014/01/21)` `1.09j (2014/01/09)` `1.09i (2013/12/18)` `1.09h (2013/11/28)` `1.09g (2013/11/22)` `1.09f (2013/11/04)` `1.09e (2013/10/29)` `1.09d (2013/10/22)` `1.09c (2013/10/09)` `1.09b (2013/10/03)` `1.09a (2013/09/24)` `1.08b (2013/06/14)` `1.08a (2013/06/11)` `1.08 (2013/06/07)` `1.07 (2013/05/25)` `1.06b (2013/05/14)` `1.06 (2013/05/07)` `1.05 (2013/05/01)` `1.04 (2013/04/25)` `1.03 (2013/04/14)` `1.0 (2013/03/28)` %------------------------------------------------------ %<*makefile>------------------------------------------------------ # This file: Makefile.mk (generated from xint.dtx) # "make --file=Makefile.mk help" # The 1.4n CTAN zip includes an xintchanges.md but no CHANGES.html # anymore. The xintchanges.md is not extracted from the dtx but # kept separate. # The 1.4n CTAN zip does not ship with a commodity Makefile anymore, # use -f Makefile.mk as above or rename it to Makefile. # Also it does not include CHANGES.html. It can be build via make # or checked at https://jfbu.github.io/xint/CHANGES.html. # With 1.4n also, sourcexint.pdf got renamed into xintsource.pdf # and xint.pdf became what was called xint-all.pdf, i.e. (as was also # the case originally) it contains both user manual and documented # source code. This allows to benefit from hyperlinks between the two, # which were added already in 2022. # Starting with xint 1.3c, Latexmk is used for easier compilation of # sourcexint.pdf as the latter then included indices. These indices # got removed at 1.3e but usage of Latexmk is maintained for the build. # Originally tested on Mac OS X Mavericks with GNU Make 3.81, # TeXLive 2014 and Pandoc 1.13.1. # Note to myself: I wanted to use .RECIPEPREFIX = > but it is # supported only with GNU Make 3.82 and later. # this crazyness is to circumvent a problem with docstrip generation # of the Makefile; we do not want two empty lines becoming only one nullstring := define newline $(nullstring) endef # will speed-up a little, I think. newline := $(newline) define helptext ==== INSTRUCTIONS It is recommended to work with xint.dtx and Makefile moved to some otherwise empty temporary repertory. make help Display this help using the more pager. make helpless Display this help using the less pager. make doc Produce all documentation, requires Latexmk and Pandoc. make all Produce all documentation, then creates xint.tds.zip. make xint.tds.zip Same as "make all" make xintmanual.pdf Extract files and produce xintmanual.pdf (user manual), using latex and dvipdfmx. This requires Latexmk. make xintsource.pdf Extract files and produce xintsource.pdf (source code), using latex and dvipdfmx. This requires Latexmk. make xint.pdf Extract files and produce xint.pdf (manual + code), using latex and dvipdfmx. This requires Latexmk. make CHANGES.html This requires Pandoc. make clean Remove auxiliary files and repertories. make cleanmore Remove also PDFs and ZIP archives and a few more. ==== INSTALLING The following has been tested on a TeXLive installation: make installhome Create xint.tds.zip, and unzip it in make installlocal Create xint.tds.zip, unzip it in and then does texhash Depending on access rights "sudo make installlocal" might be needed. In case of doubt run first "make doc" then "make installlocal". If the latter fails, then try "sudo make installlocal". make uninstallhome Remove all xint files and repertories from make uninstalllocal Remove all xint files and repertories from and then does texhash Might need "sudo". endef # Quelques difficultés à trouver le bon choix de ' ou " et de \# # et l'utilisation des \ en fins de ligne pour que ça fonctionne. highlighting-css = ' body{margin: 0; margin-left : 10%; margin-right : 15%; margin-top: 4ex; font-size: 20px; font-family: serif; max-width: 100%; padding: 0; }\ pre {white-space: pre-wrap;}\ code {white-space: pre-wrap;}\ a:link { color: blue; }\ a:visited { color: green; }\ a:hover { text-decoration: underline; color: hotpink }\ a:active { color: brown; }\ \#TOC {float: right; position: relative; top: 100px; margin-bottom: 100px; margin-left: 20px;}' .PHONY: help helpless all doc clean cleanmore\ installhome uninstallhome installlocal uninstalllocal # for printf with subst and \n, got it from # http://stackoverflow.com/a/5887751 # I could do the trick with := here, for \n substitution, but this would add # tiny overhead to all other operations of make help: @printf '$(subst $(newline),\n,$(helptext))' | more helpless: @printf '$(subst $(newline),\n,$(helptext))' | less # RM = rm -f JF_tmpdir := $(shell mktemp -d TEMP_XINT_XXX) TEXMF_local = $(shell kpsewhich -var-value TEXMFLOCAL) TEXMF_home = $(shell kpsewhich -var-value TEXMFHOME) packages = xintkernel.sty xintcore.sty xint.sty xintfrac.sty xintexpr.sty\ xintgcd.sty xintbinhex.sty xintseries.sty xintcfrac.sty\ xinttools.sty xinttrig.sty xintlog.sty # Makefile.mk n'est pas mis dans $(extrated) pour éviter des messages # de make. Les sty (aussi extraits) sont dans $(packages). extracted = xintmanual.tex xintsource.tex xint.tex\ README.md xint-dates.txt filesfortex = $(packages) filesforsource = xint.dtx filesfordoc = xint.pdf README.md xintchanges.md auxiliaryfiles = xintmanual.dvi xintmanual.aux xintmanual.toc xintmanual.log\ xintsource.dvi xintsource.aux xintsource.toc xintsource.log\ xint.dvi xint.aux xint.toc xint.log all: $(packages) $(extracted) doc xint.tds.zip @echo 'make all done.' $(packages): xint.dtx etex xint.dtx $(extracted): xint.dtx etex xint.dtx doc: xintmanual.pdf xintsource.pdf CHANGES.html @echo 'make doc done.' xintmanual.pdf: xint.dtx xintmanual.tex latexmk xintmanual.tex dvipdfmx xintmanual.dvi xintsource.pdf: xint.dtx xintsource.tex latexmk xintsource.tex dvipdfmx xintsource.dvi xint.pdf: xint.dtx xint.tex latexmk xint.tex dvipdfmx xint.dvi CHANGES.html: xintchanges.md pandoc -o CHANGES.html -s --toc -V highlighting-css=$(highlighting-css) xintchanges.md xint.tds.zip: $(filesfordoc) $(filesforsource) $(filesfortex) rm -fr $(JF_tmpdir) mkdir -p $(JF_tmpdir)/doc/generic/xint mkdir -p $(JF_tmpdir)/source/generic/xint mkdir -p $(JF_tmpdir)/tex/generic/xint chmod -R ugo+rwx $(JF_tmpdir) cp -a $(filesfordoc) $(JF_tmpdir)/doc/generic/xint cp -a $(filesforsource) $(JF_tmpdir)/source/generic/xint cp -a $(filesfortex) $(JF_tmpdir)/tex/generic/xint cd $(JF_tmpdir); chmod -R ugo+r doc source tex umask 0022 && cd $(JF_tmpdir) &&\ zip -r xint.tds.zip doc source tex &&\ mv -f xint.tds.zip ../ rm -fr $(JF_tmpdir) @echo 'make xint.tds.zip done.' xint.zip: $(filesfordoc) $(filesforsource) $(filesfortex) xint.tds.zip mkdir -p $(JF_tmpdir)/xint chmod ugo+rwx $(JF_tmpdir)/xint cp -a $(filesfordoc) $(JF_tmpdir)/xint cp -a $(filesforsource) $(JF_tmpdir)/xint chmod -R ugo+r $(JF_tmpdir)/xint mv xint.tds.zip $(JF_tmpdir)/ umask 0022 && cd $(JF_tmpdir) && zip -r xint.zip xint.tds.zip xint mv $(JF_tmpdir)/xint.tds.zip ./ mv -f $(JF_tmpdir)/xint.zip ./ rm -fr $(JF_tmpdir) @echo 'make xint.zip done.' installhome: xint.tds.zip unzip xint.tds.zip -d $(TEXMF_home) uninstallhome: cd $(TEXMF_home) && rm -fr doc/generic/xint \ source/generic/xint \ tex/generic/xint # cf http://stackoverflow.com/a/1909390 # as kpsewhich is very slow (.5s) I want to evaluate once only. installlocal: xint.tds.zip $(eval $@_tmp := $(TEXMF_local)) unzip xint.tds.zip -d $($@_tmp) && texhash $($@_tmp) uninstalllocal: cd $(TEXMF_local) && rm -fr doc/generic/xint \ source/generic/xint \ tex/generic/xint && texhash . clean: rm -fr auto/ .auto/ TEMP*/ rm -f $(auxiliaryfiles)\ xintmanual.fls xintmanual.fdb_latexmk\ xintsource.fls xintsource.fdb_latexmk\ xint.fls xint.fdb_latexmk cleanmore: clean rm -f xintmanual.pdf xintsource.pdf xint.pdf xint.tds.zip xint.zip %$----------------------------------------------------- %<*xintmandrv>----------------------------------------------------------- %% To extract files: %% etex xint.dtx %% %% Then execute: %% make --file=Makefile.mk xintmanual.pdf %% %% Alternative for build without `make': %% latexmk xintmanual.tex %% dvipdfmx xintmanual.dvi %% %% One can also tell latexmk to use pdflatex, lualatex or xelatex. %% Or use one of them directly enough times on xintmanual.tex. \NeedsTeXFormat{LaTeX2e} \ProvidesFile{xintmanual.tex}% [\xintbndldate\space v\xintbndlversion\space xint documentation (JFB)]% \PassOptionsToClass{a4paper,fontsize=10pt}{scrartcl} \chardef\NoSourceCode 1 \input xint.dtx %%% Local Variables: %%% mode: latex %%% TeX-PDF-from-DVI: "Dvipdfmx" %%% End: %----------------------------------------------------------- %<*xintsrcdrv>----------------------------------------------------------- %% To extract files: %% etex xint.dtx %% %% Then execute: %% make --file=Makefile.mk xintsource.pdf %% %% Alternative for build without `make': %% latexmk xintsource.tex %% dvipdfmx xintsource.dvi %% %% One can also tell latexmk to use pdflatex, lualatex or xelatex. %% Or use one of them directly enough times on xintsource.tex. \NeedsTeXFormat{LaTeX2e} \ProvidesFile{xintsource.tex}% [\xintbndldate\space v\xintbndlversion\space xint commented code (JFB)]% \PassOptionsToClass{a4paper,fontsize=10pt}{scrartcl} \chardef\NoSourceCode=0\chardef\doxintsource=1 \input xint.dtx %%% Local Variables: %%% mode: latex %%% TeX-PDF-from-DVI: "Dvipdfmx" %%% End: %----------------------------------------------------------- %<*xintalldrv>----------------------------------------------------------- %% To extract files: (but this is probably already done as you read this) %% etex xint.dtx %% %% Then execute: %% make --file=Makefile.mk xint.pdf %% to obtain a PDF containing both user manual and source code. %% %% Alternative for build without `make': %% %% latexmk xint.tex %% dvipdfmx xint.dvi %% %% One can also use pdflatex/lualatex/xelatex directly on xint.tex, %% (or better latexmk with suitable engine option). \NeedsTeXFormat{LaTeX2e} \ProvidesFile{xint.tex}% [\xintbndldate\space v\xintbndlversion\space xint user plus source doc (JFB)]% \PassOptionsToClass{a4paper,fontsize=10pt}{scrartcl} \chardef\NoSourceCode=0 \input xint.dtx %%% Local Variables: %%% mode: latex %%% TeX-PDF-from-DVI: "Dvipdfmx" %%% End: %----------------------------------------------------------- %<*dtx>----------------------------------------------------------- ^^Bfi^^Begroup \chardef\noetex 0 \ifx\numexpr\undefined\chardef\noetex 1 \fi % changed 2021/05/30: do not extract files at all if not using etex \ifnum\noetex=1 \chardef\extractfiles 3 % no extract, no typeset \else \ifx\PassOptionsToClass\undefined \chardef\extractfiles 0 % no LaTeX2e: probably etex, xetex, ... on xint.dtx \else \ifx\NoSourceCode\undefined % latex/pdflatex/xelatex/lualatex on xint.dtx, we will extract all files \chardef\extractfiles 1 % 1 = extract and typeset, 2 = only typeset \chardef\NoSourceCode 0 % 0 = include source code, 1 = do not \NeedsTeXFormat{LaTeX2e}% \PassOptionsToClass{a4paper,fontsize=10pt}{scrartcl}% \else % latex/pdflatex/xelatex/lualatex on xint{manual,source,}.tex \chardef\extractfiles 2 % no extractions, but typeset \fi \ProvidesFile{xint.dtx}[bundle source (\xintbndlversion, \xintbndldate) % and documentation (\xintdocdate)]% \fi \fi \ifnum\extractfiles<2 % extract files \def\MessageDeFin{\newlinechar10 \let\Msg\message \Msg{^^J}% \Msg{********************************************************************^^J}% \Msg{*^^J}% \Msg{* To finish the installation you have to move the following^^J}% \Msg{* files into a directory searched by TeX:^^J}% \Msg{*^^J}% \Msg{* \space\space\space\space xintkernel.sty^^J}% \Msg{* \space\space\space\space xintcore.sty^^J}% \Msg{* \space\space\space\space xint.sty^^J}% \Msg{* \space\space\space\space xintbinhex.sty^^J}% \Msg{* \space\space\space\space xintgcd.sty^^J}% \Msg{* \space\space\space\space xintfrac.sty^^J}% \Msg{* \space\space\space\space xintseries.sty^^J}% \Msg{* \space\space\space\space xintcfrac.sty^^J}% \Msg{* \space\space\space\space xintexpr.sty^^J}% \Msg{* \space\space\space\space xinttools.sty^^J}% \Msg{* \space\space\space\space xinttrig.sty^^J}% \Msg{* \space\space\space\space xintlog.sty^^J}% \Msg{*^^J}% \Msg{* Rename Makefile.mk to Makefile if the latter is absent^^J}% \Msg{* (or use --file=Makefile.mk option of "make")^^J}% \Msg{* then "make xint.pdf" builds a PDF including both the user manual^^J}% \Msg{* and the commented source code.^^J}% \Msg{*^^J}% \Msg{* Building with "make" requires "Latexmk".^^J}% \Msg{* The target "CHANGES.html" requires "Pandoc".^^J}% \Msg{*^^J}% \Msg{* Instructions for building without "make" are in file xint.tex.^^J}% \Msg{*^^J}% \Msg{* Happy TeXing!^^J}% \Msg{*^^J}% \Msg{********************************************************************^^J}% }% \ifx\XeTeXinterchartoks\undefined\else \expandafter\def\expandafter\MessageDeFin\expandafter{\MessageDeFin \Msg{* ATTENTION! extraction with xetex must be made with -8bit option.^^J}% \Msg{* Extracted file Makefile.mk is invalid if this was not the case.^^J}% \Msg{********************************************************************^^J}% }% \fi \begingroup \input docstrip.tex \askforoverwritefalse \catcode9 11 % do not kill TAB in producing Makefile.mk \generate{\nopreamble\nopostamble \file{README.md}{\from{xint.dtx}{readme}} % 1.4n of September 2025 omits including (renamed) xintchanges.md in dtx \file{xint-dates.txt}{\from{xint.dtx}{dates}} % pure tex will use ^^I notation for TAB character, don't want that. % anyway, since 2021/05/30, tex xint.dtx has been made a no-op. % there is a problem with xelatex, it generates ^^I if not with -8bit \file{Makefile.mk}{\from{xint.dtx}{makefile}} \usepreamble\defaultpreamble \usepostamble\defaultpostamble \file{xintmanual.tex}{\from{xint.dtx}{xintmandrv}} \file{xintsource.tex}{\from{xint.dtx}{xintsrcdrv}} \file{xint.tex}{\from{xint.dtx}{xintalldrv}} \file{xintkernel.sty}{\from{xint.dtx}{xintkernel}} \file{xinttools.sty}{\from{xint.dtx}{xinttools}} \file{xintcore.sty}{\from{xint.dtx}{xintcore}} \file{xint.sty}{\from{xint.dtx}{xint}} \file{xintbinhex.sty}{\from{xint.dtx}{xintbinhex}} \file{xintgcd.sty}{\from{xint.dtx}{xintgcd}} \file{xintfrac.sty}{\from{xint.dtx}{xintfrac}} \file{xintseries.sty}{\from{xint.dtx}{xintseries}} \file{xintcfrac.sty}{\from{xint.dtx}{xintcfrac}} \file{xintexpr.sty}{\from{xint.dtx}{xintexpr}} \file{xinttrig.sty}{\from{xint.dtx}{xinttrig}} \file{xintlog.sty}{\from{xint.dtx}{xintlog}}} \endgroup \fi % end of file extraction (from etex/latex/pdflatex/... run on xint.dtx) \ifnum\extractfiles=0 % no LaTeX, files now extracted. Stop. \MessageDeFin\expandafter\end \fi \ifnum\extractfiles=1 % direct run on xint.dtx \expandafter\def\expandafter\MessageDeFin\expandafter{\MessageDeFin \Msg{* Direct (*)latex run on xint.dtx: repeat as necessary. *^^J}% \Msg{********************************************************************^^J}% }% \fi \ifnum\extractfiles=3 % \newlinechar10 \errhelp{Extraction must be done via an engine with e-TeX extensions.^^J% Please try again, using etex rather.^^J% (and if with xetex, you must use -8bit option).}% \errmessage{Extraction aborted (must be done with etex)}% \expandafter\end \fi % From this point on, run is necessarily with e-TeX. % Check if \MessageDeFin got defined, if yes put it at end of run. \ifdefined\MessageDeFin\AtEndDocument{\MessageDeFin}\fi %----------------------------------------------------------------- % \makeatletter % counts used in particular in the samples from the documentation of the % xintseries.sty package \newcount\cnta \newcount\cntb \newcount\cntc \ifdefined\doxintsource \chardef\NoSourceCode 0 \else \chardef\doxintsource 0 \fi % \doxintsource=1 means producing only source code. % It is set in xintsource.tex. Prior to 1.4l it was % set in the call with latexmk + \input syntax. % % \doxintsource=0 and \NoSourceCode=1 : include only user doc % \doxintsource=0 and \NoSourceCode=0 : combine user doc and source code % \doxintsource=1 and \NoSourceCode=1 : never happens but would mean to do % nothing! % default is to assume latex + dvipdfmx \chardef\Withdvipdfmx 1 \RequirePackage{iftex} \ifpdf \chardef\Withdvipdfmx 0 \fi \ifxetex\chardef\Withdvipdfmx 0 \fi \iftutex % they are used at some locations in this doc (independently of loading xint) \let\pdfsetrandomseed\setrandomseed \let\pdfuniformdeviate\uniformdeviate \fi % 2019/09/10 % Get rid of HARASSMENT by KOMA-Script % Must be located before \documentclass \def\class@shoulddisablepackagewarning@list{tocloft.} \ifnum\Withdvipdfmx=1 \def\pgfsysdriver{pgfsys-dvipdfm.def} \documentclass [dvipdfm, dvipdfmx]{scrartcl} \else \documentclass {scrartcl} \fi %%% START OF CUSTOM doc.sty LOADING (May 21, 2022) % % For some legacy reason (because I started like this and it % worked to my satisfaction) I had used scrdoc.cls all those % years, without in fact needing most of its features. % % It loads ltxdoc class, from which again I need very little. On % testing May 20, 2022 the upcoming LaTeX 2022-06-01 I had some % problems with ltxdoc not having suitable interface for rolling % back to doc=V2. % % I did experiment with indices for xintsource.pdf from 2018 to % 2019 but it made the build process significantly lengthier, % created heavy-sized PDF, had various issues in my context % (possibly the kind of issues doc V3 addresses about indexing % non-macro things, hyperlinks,...), and these indices basically % had not any real use as PDF search proves efficient enough, % and the structures of local tables of contents makes for % agreeable enough navigation via the input mark-up using % sectioning commands. % % Thus it turns out I need very little of doc.sty, and almost % nothing of ltxdoc.cls and scrdoc.cls. % % Let's load the doc=V2 version to avoid having to work around % hypdoc loading interfering with my use of hyperref and as said % above I don't need the hyperlinked cross-referencing as I have % it via my own mark-up to a sufficiently good enough extent, % and this holds for many many years. And I will not now change % my mark-up. \ifdefined\IfFormatAtLeastTF \IfFormatAtLeastTF{2022/06/01}% {% \IfFileExists{doc-2021-06-01.sty}% {\usepackage{doc}[=v2]}% % Why on earth do I lose my time doing this? {\GenericError {(xint build doc)\@spaces}% {xint build error: % Your LaTeX installation seems to be broken, format is\MessageBreak 2022-06-01 or later but `doc' package in its `v2' version\MessageBreak seems to not be available. \space Will try with `doc' but if\MessageBreak its `v3' is used there will be an option clash error\MessageBreak regarding hyperref.}% {}% {Please make sure `doc' package matches your LaTeX format.}% \usepackage{doc}% }% }% {\usepackage{doc}}% \else \usepackage{doc} \fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % MACROS OF doc.sty WILL BE HACKED (2022/06/06) FOR THE IMPLEMENTATION PART % % First we want to turn CodelineNo into a real LaTeX counter % This will spare defining an extra counter for the hyperlinks with \hyperref \begingroup\let\newcount\@gobble\@definecounter{CodelineNo}\endgroup %%% Next line is not needed because \theCodelineNo already got that definition %%% from doc-2021-06-01.sty, and \@definecounter does not overwrite it. % \def\theCodelineNo{\reset@font\scriptsize\arabic{CodelineNo}} % But as we will reset CodelineNo at each style file we need some unique id \def\theHCodelineNo{\the\value{section}.\the\value{CodelineNo}} % This is all for now. % The further hacks are to be found after the \StopEventually (i.e. a few % thousands lines down from here if you don't have access to the private % sources, which is probably the case if you are not the author). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % As explained above I was formerly using scrdoc hence ltxdoc indirectly. % Let's emulate here the little I appear to need from ltxdoc.cls and % srcdoc.cls. % \AtBeginDocument{\MakeShortVerb{\|}} \DeclareFontShape{OT1}{cmtt}{bx}{n}{<-> ssub * cmtt/m/n}{} \DeclareFontFamily{OMS}{cmtt}{\skewchar\font 48} % '60 \DeclareFontShape{OMS}{cmtt}{m}{n}{<-> ssub * cmsy/m/n}{} \DeclareFontShape{OMS}{cmtt}{bx}{n}{<-> ssub * cmsy/b/n}{} \DeclareFontShape{OT1}{cmss}{m}{it}{<->ssub*cmss/m/sl}{} \ifnum\NoSourceCode=1 \OnlyDescription \fi \CodelineNumbered \EnableCrossrefs % but this will be hacked % \setcounter{StandardModuleDepth}{1} % we don't use this mechanism currently \def\cmd#1{\cs{\expandafter\cmd@to@cs\string#1}} \def\cmd@to@cs#1#2{\char\number`#2\relax} % Here I am loading doc=v2 but formerly I was using ltxdoc via scrdoc % which I dropped at release 1.4l (2022-05-29) and without much % thinking I had kept this. \DeclareRobustCommand\cs[1]{\texttt{\bslash#1}} % As I may have the * active, or macro names with _ or ^, I should % add \detokenize. But see below for a redefinition anyhow. % % More urgent is that I am also using hyperref and this definition gives wrong % bookmarks if \cs is used in section titles. As I had very very few usags of % \cs in the whole of xint.dtx, it took me a while to realize the problem % here. Turns out that doc=v3 by default loads hypdoc which includes this % configuation for hyperref compatibility: \AtBeginDocument{% \pdfstringdefDisableCommands{\def\cs#1{\textbackslash\detokenize{#1}}}% }% % As I have not loaded hyperref yet I must delay it to AtBeginDocument. % Late May, early June 2022 I added to my custom \verb automated detection % of potential hyperlinks. So I decided to replace \cs ltxdoc definition % by suitable \verb usage. It is not important to be efficient here, % I can leave some \expandafter, in fact there are a handful of uses. \DeclareRobustCommand\cs[1]{\expandafter\verb\expandafter~\bslash#1~} % As my \verb does a verbatimizing \scantokens I don't need to worry % here about active characters but I need in the PDF string, hence % the \detokenize above. \providecommand\marg[1]{% {\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}} \providecommand\oarg[1]{% {\ttfamily[}\meta{#1}{\ttfamily]}} \providecommand\parg[1]{% {\ttfamily(}\meta{#1}{\ttfamily)}} % \@addtoreset{CodelineNo}{part}% No need for this here % \def\partname{File}% \partname is "fixed" somewhere further down anyhow % No need for this, anyhow I don't build the indices (I did in 2018-2019 only). % \gdef\codeline@wrindex#1{\if@filesw % \begingroup % \let\protect\noexpand % \immediate\write\@indexfile % {\string\indexentry{#1}% % {\filesep\number\c@CodelineNo}}% % \endgroup\fi} % \let\filesep\@empty % There is very little we seem to need from the scrdoc extras: page geometry % is set by geometry package and a4paper option from xint.tex file. So it % seems I only need the hologo loading: \usepackage{hologo} \DeclareRobustCommand*{\eTeX}{\hologo{eTeX}}% \DeclareRobustCommand*{\LuaTeX}{\hologo{LuaTeX}}% % %%% end of ltxdoc+srcdoc emulation. See after \StopEventually for doc.sty hacks. % Remove from sectioning commands insertion of marks, because we % will do it ourself. \usepackage{etoolbox} \patchcmd{\@sect}% {\expandafter\csname#1mark\expandafter\endcsname\expandafter{\@currentheadentry}}% {}{}{\Error@CouldNotApplyFirstPatch@sect} \patchcmd{\@sect}% {\expandafter\csname#1mark\expandafter\endcsname\expandafter{\@currentheadentry}}% {}{}{\Error@CouldNotApplySecondPatch@sect} % This one now needed too, Jeudi 30 janvier 2020 % \expandafter \ifx \csname #1mark\endcsname \@gobble \@mkboth {}{}\else % \csname #1mark\expandafter \endcsname \expandafter {\@currentheadentry }\fi % \@gobble est long donc simplement \def\partmark #1{}% \pagestyle{headings} \iftutex % (if lualatex or xelatex are used to compile the documentation) % xinttools is not yet loaded hence the \AtBeginDocument % Note the subtlety: we can't do \def#1, because #1 will be the % character still with letter catcode. \AtBeginDocument{% \xintForpair #1#2 in {(δ, \delta), (ξ, \xi), (π, \pi), (≠, \neq), (α, \alpha), (τ, \tau), (λ, \lambda), (ν, \nu)} \do{\catcode`#1\active \begingroup\lccode`~=\lccode`#1 \lowercase{\endgroup\def~}{\ensuremath{#2}}}% }% \else \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} % (2016/03/02): \delta utilisé dans les commentaires de la division de xint.sty % (2017/01/03): \xi pour doc \xintnewdummy % (2019/03/31): \pi utilisé dans mes commentaires de xinttrig.sty % (2019/04/24): \neq utilisé dans un commentaire de xintlog.sty % (2025/08/30): \alpha, \tau, \lambda, \nu pour doc \xintnewdummy % % As we now (2025/08/30) load lgrmath (farther below), we have to delay this % to at begin document. \AtBeginDocument{% \DeclareUnicodeCharacter{03B4}{\ensuremath{\delta}}% δ \DeclareUnicodeCharacter{03BE}{\ensuremath{\xi}}% ξ \DeclareUnicodeCharacter{03C0}{\ensuremath{\pi}}% π \DeclareUnicodeCharacter{2260}{\ensuremath{\neq}}% ≠ \DeclareUnicodeCharacter{03B1}{\ensuremath{\alpha}}% α \DeclareUnicodeCharacter{03C4}{\ensuremath{\tau}}% τ \DeclareUnicodeCharacter{03BB}{\ensuremath{\lambda}}% λ \DeclareUnicodeCharacter{03BD}{\ensuremath{\nu}}% ν } \fi \usepackage{multicol} \usepackage{geometry} \AtBeginDocument {\ttzfamily % package newtxtt is loaded in preamble \newgeometry{textwidth=\dimexpr92\fontcharwd\font`X\relax, vscale=0.75}} \unless\ifnum\doxintsource=1 \usepackage{xintexpr} \usepackage{xintbinhex} \usepackage{xintgcd} \usepackage{xintseries} \usepackage{xintcfrac} \usepackage{amsmath}% for \cfrac usage \DeclareMathOperator{\sinc}{sinc} \fi \usepackage{pifont}% for \ding{73} (hollow star) % needed also for build of xintsource.pdf \usepackage{xinttools} \usepackage{enumitem} \usepackage{varioref} \usepackage{xspace} \usepackage[para]{footmisc} \usepackage{picture} \usepackage{graphicx} \usepackage[english]{babel} % 2022/06/05 % \usepackage{csquotes} \def\myenquote#1{{\sffamily\textquotedblleft}#1{\sffamily\textquotedblright}} % 2022/05/24, commenting out this at it appears to not be used anywhere now. % \usepackage[autolanguage,np]{numprint} % \AtBeginDocument{\npthousandsep{,\hskip .5pt plus .1pt minus .1pt}} % But surprisingly it is via numprint that I was loading array package % whose extended syntax for tabular preambles is required! \usepackage{array} \usepackage[dvipsnames,svgnames]{xcolor} %%% DEFINITIONS OF COLORS USED IN DOCUMENT % color for the \xintname, \xintexprname, etc macros \definecolor{xintnamecolor}{RGB}{228,57,0} \colorlet{XINTNAMECOLOR}{xintnamecolor} % color for their analogs \xintnameimp, etc... in implementation part \colorlet{xintnameimpcolor}{blue} \colorlet{XINTNAMEIMPCOLOR}{xintnameimpcolor} % colors for hyperref \definecolor{xinturlcolor}{RGB}{38,128,192} \colorlet{xintlinkcolor}{blue} % colors for custom \verb and everbatim/everbatim* environments % % the commented-out legacy colors used in xint.pdf for many years up to % xint 1.4j (2021/07/13) (I should retrieve since when exactly) % % \colorlet{verbcolor}{jfbrown} % \colorlet{verbsoftwrapiconcolor}{blue} % \colorlet{everbatimfgcolor}{Brown} % \colorlet{everbatimbgcolor}{yellow!5} % \colorlet{everbatimxfgcolor}{OrangeRed} % % https://contrast-ratio.com/#rgb%28165%2C100%2C10%29-on-white % says the contrast ratio on white is 4.74 and I do see the contrast % is less strong than % for the DarkBlue/Beige and Maroon/White combinations seen below % \colorlet{verbcolor}{jfbrown} % I will simply use also Maroon \colorlet{verbcolor}{Maroon} \colorlet{digitsttcolor}{verbcolor} \colorlet{verbsoftwrapiconcolor}{DarkBlue} \colorlet{everbatimfgcolor}{DarkBlue} % % According to % https://contrast-ratio.com/#rgb%2811%2C35%2C139%29-on-rgb%28245%2C244%2C220%29 % the DarkBlue on Beige % gives a contrast-ratio of 11.58 which confirmed my intuition it is not bad % "Passes AAA level for any size text and AA for user interface components and % graphical objects" % % memo: with Apple ColorPicker it seems one needs to select "sRVB" (I guess % "sRGB" in English) for values matching xcolor RGB input or the above html % page rgb(R,G,B) input, also this did not work % 100%, most probably due to the window transparency by default on my mac? \colorlet{everbatimbgcolor}{Beige} % % https://contrast-ratio.com/#rgb%28128%2C31%2C19%29-on-white % gives 9.89 contrast ratio which is a bit less but still AAA \colorlet{everbatimxfgcolor}{Maroon} % % colors for margin notes \colorlet{marginnotecolor}{PineGreen} \colorlet{marginwarningcolor}{Red} % colors for toc \colorlet{tocstylesectioncolor}{cyan} \colorlet{tocstylesectionimpcolor}{RoyalPurple} \colorlet{tocstylebundlesectioncolor}{xintnamecolor} % colors for macro code and comments \colorlet{privatecommentcolor}{cyan} \colorlet{macrocodecommentcolor}{gray} \colorlet{macrocodenewmacrocolor}{verbcolor} \colorlet{macrocodelinktouserdoccolor}{xintnamecolor}% and bold face \colorlet{macrocodelinktosectioncolor}{DarkBlue}% and bold face \colorlet{macrocodelinktocodelinecolor}{DarkBlue} \colorlet{macrocodenoncscolor}{Green} % colors for the implementation part and the modified macrocode macros % are to be found after \StopEventually \usepackage{eso-pic}% après xcolor sinon Option clash for package xcolor. \ifnum\doxintsource=1 \else % Dependency graph done using TikZ (manually) \usepackage{tikz} \usetikzlibrary{shapes,arrows.meta} \fi \usepackage{framed} % SNUGFRAMED % ========== \newenvironment{snugframed}{% \fboxsep \dimexpr2\fontcharwd\font`X\relax \advance\linewidth-2\fboxsep \advance\csname @totalleftmargin\endcsname \fboxsep \def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep \fbox{##1}\hskip-\fboxsep % There is no \@totalrightmargin, so: \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}% \MakeFramed {\advance\hsize-\width \@totalleftmargin\z@ \linewidth\hsize \@setminipage}% }{\par\unskip\@minipagefalse\endMakeFramed} % HYPERREF % ======== \usepackage{hyperref} % 2022/06/10 reduce clutter in console and log output, there are already % enough messages telling we have to execute latex once more \catcode`_ 11 \def\perhapshyperref[#1]{\ifcsname r@#1\endcsname \xint_afterfi{\hyperref[#1]}\fi} \catcode`_ 8 \hypersetup{% linktoc=all,% breaklinks=true,% colorlinks=true,% urlcolor=xinturlcolor,% linkcolor=xintlinkcolor,% pdfauthor={Jean-Fran\c cois Burnol},% pdftitle={The xintexpr and allied packages},% pdfsubject={Arithmetic with TeX},% pdfkeywords={Expansion, arithmetic, TeX},% pdfstartview=FitH,% pdfpagemode=UseNone,% } \usepackage{hypcap} \ifnum\doxintsource=1 \hypersetup{pdftitle={The xintexpr and allied packages source code}} \fi \usepackage{bookmark} % This is for having similarly named labels to get hyperlinks either to the % user documentation or to the implementation part. From source mark-up with % \csbxint, \csbXINT, \csb, or automated ones from |...| and the custom \verb % However in the user manual I have so far (2022/06/11) used manually typed-in % \label's in contrast to the almost exclusively automated ones of the implementation % part. So for time being I keep an empty prefix here in place of something % reasonable such as usr-. \let\xintdoclabelprefix\empty \def\xintimplabelprefix{src-} % used by \csbxint etc... \let\xintlabelprefix\xintdoclabelprefix % FONTS % ===== \usepackage[zerostyle=d,straightquotes,scaled=0.95]{newtxtt} \usepackage{newtxmath} \input ts1newtxttz.fd % Fix what appears to be typos in ts1newtxttz.fd 2024/03/03 % where one sees tcx in RHS of <-> in place of tx. % Needed to typeset the \textasciigrave in particular. \DeclareFontShape{TS1}{newtxttz}{m}{n}{ %medium <-> \newtxtt@@scale newtxttz\newtxtt@@fig% }{} \DeclareFontShape{TS1}{newtxttz}{m}{sl}{ %slanted <-> \newtxtt@@scale newtxttzsl\newtxtt@@fig% }{} \DeclareFontShape{TS1}{newtxttz}{b}{n}{ %bold <-> \newtxtt@@scale newtxbttz\newtxtt@@fig% }{} \DeclareFontShape{TS1}{newtxttz}{b}{sl}{ %bold slanted <-> \newtxtt@@scale newtxbttzsl\newtxtt@@fig% }{} \renewcommand\familydefault\ttdefault \usepackage[noendash]{mathastext}% pas de endash dans newtxtt % A (somewhat surprising a priori, at least to me) effect of % \DeclareFontEncoding{LGR}{}{} (which loads lgrenc.dfu) is that % it redeclares all UTF-8 Greek ! So for example ξ will expand to \textxi. % So we delayed our own \DeclareUnicodeCharacter's to \begin{document} \usepackage[style=up,font=cmss]{lgrmath} % 2024/01/15: upstream update by Michael Sharpe to newtxtt, % in particular a shorter "extra space" for the nomono font % I thus try again with \nonfrenchspacing. % \frenchspacing % sans-serif in footnotes, TOC, titles, etc... \renewcommand\familydefault\sfdefault % TABLES OF CONTENTS % ================== \usepackage{tocloft} \usepackage{etoc} \def\gobbletodot #1.{} \newif\ifinmanualmaintoc \ifnum\doxintsource=0 \inmanualmaintoctrue \fi \def\tocstylesectionbracedcolor{{tocstylesectioncolor}} \def\tocstyleMARGEPAGENO {1.5em}% changera pour la partie implémentation \def\tocstylesectionVSKIP{\vskip\bigskipamount} \etocsetstyle{section}{} {\normalfont} {\etociffirst{}{\tocstylesectionVSKIP}% \rightskip \tocstyleMARGEPAGENO\relax \parfillskip -\tocstyleMARGEPAGENO\relax \bfseries \leftskip \leftmarginii \noindent\llap % \llap {\makebox[\leftmarginii][l]% et \leftmargini le 12/10/2014 {\expandafter\textcolor\tocstylesectionbracedcolor{\etocnumber}}}% \strut\etocname \mdseries\nobreak\leaders\etoctoclineleaders\hfill\nobreak\strut \makebox[\tocstyleMARGEPAGENO][r]{\etocpage}\par \let\ETOCsectionnumber\etocthenumber }% {}% \newdimen\tocstyleLEFTMARGIN \AtBeginDocument{\tocstyleLEFTMARGIN \dimexpr 5\fontcharwd\font`X\relax} \etocsetstyle{subsection} {\begingroup\normalfont \setlength{\premulticols}{0pt}% \setlength{\multicolsep}{0pt}% \setlength{\columnsep}{\leftmarginii}% \setlength{\columnseprule}{.4pt}% n'influence pas séparation colonnes \parskip\z@skip \raggedcolumns \addvspace{\smallskipamount}% \begin{multicols}{2} \leftskip \tocstyleLEFTMARGIN % 12 octobre 2014 \ifinmanualmaintoc \rightskip \tocstyleMARGEPAGENO \else \rightskip \tocstyleMARGEPAGENO plus 2em minus 1em \fi \parfillskip -\tocstyleMARGEPAGENO\relax } {} {\noindent \etocifnumbered{\llap{\makebox[\tocstyleLEFTMARGIN][l]{\ttzfamily\bfseries\etoclink {\ifinmanualmaintoc\expandafter\textcolor\tocstylesectionbracedcolor {\normalfont\bfseries\ETOCsectionnumber}\fi .\expandafter\gobbletodot\etocthenumber}}}}{\kern-\tocstyleLEFTMARGIN}% \strut\etocname\nobreak \unless\ifinmanualmaintoc\leaders\etoctoclineleaders\fi \hfill\nobreak \strut\makebox[\tocstyleMARGEPAGENO][r]{\small\etocpage}\endgraf } {\end{multicols}\endgroup }% \etocsetstyle{subsubsection} {\begingroup\normalfont\small \leftskip\dimexpr\leftmargini+1em\relax } {} {\noindent \llap{\makebox[\dimexpr\leftmargini+1em\relax][l]% {\ttzfamily\bfseries\etoclink {\tocstylesubsubsectionHOOK.\expandafter\gobbletodot\etocthenumber}}}% \strut\etocname\nobreak \leaders\etoctoclineleaders \hfill\nobreak \strut\makebox[\tocstyleMARGEPAGENO][r]{\small\etocpage}\endgraf } {\endgroup }% % 2018/02/28 % quick hack to get style I want in "User defined functions" section of manual \let\tocstylesubsubsectionHOOK\empty \etocsetlevel{xinttable}{6}% formerly "table" was used, but forbidden since % etoc 1.2 of 2023/10/01 \addtocontents{toc}{\protect\hypersetup{hidelinks}} % ===================== % MISCELLANEOUS MARK-UP % ===================== \def\digitstt #1{\begingroup\color{digitsttcolor}#1\endgroup} \let\dtt\digitstt % \fexpan 22 octobre 2013 \newcommand\fexpan {\perhapshyperref[ssec:expansions]{\textit{f}-expan}} % \xexpan ajouté 28 mai 2022 \newcommand\xexpan {\perhapshyperref[ssec:expansions]{\textit{x}-expan}} % Septembre 2015 % Address updated to github repo's one, May 2018 % They did s/master/main/ already a few years back, May 2022 \def\liiibigint {\href{https://github.com/latex3/latex3/tree/main/l3trial/l3bigint}{l3bigint}} % May 2022 \def\liiistrformat % {\href{https://github.com/latex3/latex3/tree/main/l3experimental/l3str}{l3str}} {\href{https://ctan.org/pkg/l3experimental}{l3str-format}} %\def\liiistrformatnew % {\href{https://github.com/latex3/latex3/tree/main/l3trial/l3str-format-new}{l3str-format-new}} % Margin Notes % ============ % Nothing here can be used in vertical mode directly. \def\MyMarginNote {\@ifnextchar[\@MyMarginNote{\@MyMarginNote[]}}% \let\inmarg\MyMarginNote % \smash needs \hbox here since LaTeX 2018/12/01 % https://github.com/latex3/latex2e/issues/108 \def\@MyMarginNote [#1]#2{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\color{marginnotecolor}\normalfont\small \hsize 1.6cm\rightskip.5cm minus.5cm \hss\vtop{#2}\ $\to$#1\ }}}% \vskip\dp\strutbox }\strut\@esphack} \def\MyMarginNoteWithBrace #1#2{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\color{marginnotecolor}%\normalfont\small \hss #1\ $\bigg\{$#2}}}% \vskip\dp\strutbox }\strut\@esphack} \def\IMPORTANT {\MyMarginNoteWithBrace {\raisebox{-.5\height}{\resizebox{2\width}{!}{\ding{43}}}}{\ }} \def\IMPORTANTf {\MyMarginNoteWithBrace {\raisebox{-.5\height}{\resizebox{2\width}{!}{\ding{43}}}}% {\kern\dimexpr\FrameSep+\FrameRule\relax\ }} \def\etype #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color{marginnotecolor}% \itshape \xintListWithSep{\,}{#1}\ $\star$\quad }}}% \vskip\dp\strutbox }\strut\@esphack} \def\xtype #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color{marginnotecolor}% \itshape \xintListWithSep{\,}{#1}\ \ding{73}\quad }}}% \vskip\dp\strutbox }\strut\@esphack} \def\ntype #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color{marginnotecolor}% \itshape \xintListWithSep{\,}{#1}\quad }}}% \vskip\dp\strutbox }\strut\@esphack} % \def\Numf {{\vbox{\halign{\hfil##\hfil\cr \footnotesize \upshape Num\cr \noalign{\hrule height 0pt \vskip1pt\relax} \itshape f\cr}}}} \def\Ff {{\vbox{\halign{\hfil##\hfil\cr \footnotesize \upshape Frac\cr \noalign{\hrule height 0pt \vskip1pt\relax} \itshape f\cr}}}} \def\numx {{\vbox{\halign{\hfil##\hfil\cr \footnotesize \upshape num\cr \noalign{\hrule height 0pt \vskip1pt\relax} \itshape x\cr}}}} % \def\NewWith #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color{marginnotecolor}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent New with #1}\ }}}% \vskip\dp\strutbox }\strut\@esphack} % \def\CHANGED #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color{marginwarningcolor}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent Changed at #1!}\ }}}% \vskip\dp\strutbox }\strut\@esphack} \def\DNU#1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color{marginwarningcolor}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent Do not use! #1}\ }}}% \vskip\dp\strutbox }\strut\@esphack} \def\UNSTABLE#1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color{marginwarningcolor}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent Unstable! #1}\ }}}% \vskip\dp\strutbox }\strut\@esphack} \def\unstable#1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color{marginwarningcolor}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent unstable? #1}\ }}}% \vskip\dp\strutbox }\strut\@esphack} \def\DEPRECATED #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color{marginnotecolor}% \normalfont\small\bfseries \hsize 2cm\rightskip.5cm minus.5cm \vtop{\noindent Deprecated! (#1)}\ }}}% \vskip\dp\strutbox }\strut\@esphack} % \def\CHANGEDf #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color{marginwarningcolor}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent Changed at #1!}\ \kern\dimexpr\FrameSep+\FrameRule\relax}}}% \vskip\dp\strutbox }\strut\@esphack} % \def\NewWithf #1{\@bsphack \vadjust{\vskip-\dp\strutbox \hbox{\smash{\hbox to 0pt {\hss\color{marginnotecolor}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent New with #1}\ \kern\dimexpr\FrameSep+\FrameRule\relax}}}% \vskip\dp\strutbox }\strut\@esphack} % \centeredline: OUR OWN LITTLE MACRO FOR CENTERING LINES % ======================================================= % 7 mars 2013 % Note (2020): now a package \usepackage{centeredline} % \leftedline % =========== % 12 octobre 2014 % Note (2020): somewhat obsoleted for many years by my usage of % everbatim and everbatim* environments. \newif\ifinlefted \newcommand*\leftedline {% \ifhmode \\\relax \def\leftedline@{\hss\egroup\hskip\z@skip\ignorespaces }% \else \def\leftedline@{\hss\egroup }% \fi \afterassignment\@leftedline \let\next=} \def\@leftedline {\hbox to \linewidth \bgroup \inleftedtrue \everbatimeverypar \bgroup \aftergroup\leftedline@ } % verbatim macros and environments % ================================ % % June 2013, then October 2014. % ----------------------------- % \catcode`_ 11 % some of my verbatim environments do not make the space active (\lverb e.g.). Then % \do@noligs must be modified, \char`#1 must be followed by a space token, else, % the `#1 expansion will swallow one space. \def\do@noligs #1{% \catcode`#1\active \begingroup \lccode`~`#1\relax \lowercase{% \endgroup\def~{\leavevmode\kern\z@\char`#1 }}% } % \lowast \def\lowast{\raisebox{-.25\height}{*}} \catcode`* 13 \def\makestarlowast {\let*\lowast\catcode`\*\active}% \catcode`* 12 % \verb % ===== % Initially, June 2013, then Sep 9, 2014, and Oct 9-12 2014 % % Initial motivation was simply that doc.sty and related classes \verb % macro is with a hard-coded \ttfamily. There were further issues. % % 1. With |stuff with space|, paragraph reformatting in the Emacs/AUCTeX % buffer caused havoc. Thus I wanted the input to accept linebreaks in % its contents. % % 2. Hence I did not want to have obeyed spaces obeyed, (Emacs reflowing % of paragraph in certain contexts often adds spaces at beginning of a line) % % 3. Also I wanted to allow hyphenated output, at least at some % locations. I did a first version which treated spaces, \, {, and } % specially. % % 4. At some point I wanted to add some colored background (I have % dropped that since due to pdf file size increase). % % 5. And also I got fed up from the non-compatibility with footnotes due % to catcode freeze. % % Because of 5. I opted for a \scantokens approach, hence for a macro % with delimited argument. Here is what I do now, this is compatible % with short verbs. \def\verbcolorcmd{\color{verbcolor}} \def\verbsoftwrapiconcolorcmd{\color{verbsoftwrapiconcolor}} \def\restoreMicroFont {\def\MicroFont {\ttfamily\makestarlowast \ifinlefted\else\verbcolorcmd\fi }} \restoreMicroFont \def\verb {% \relax \ifmmode\else\leavevmode\null\fi \bgroup \let\do\@makeother \dospecials \@ifstar{\@sverb}% \verb* is used in the index (obsolete: no indices at 1.3e), % leave it using ambient font {\MicroFont % used to change font (\ttfamily), color, % will make * active via \makestarlowast \catcode 32 10 \endlinechar 32 % allows to fetch across line breaks \frenchspacing % since 2024/01/15 not done globally in document \@@jfverb}% }% % Note (Oct 12, 2014): in the improbable situation a newlinechar is % found in the ##1, \scantokens will convert this to an end of line in % its "write" phase, which will be then ignored in its "read" phase due % to \endlinechar-1. This also avoids possible creation of \par which % would defeat \@@jfverb@@. Thus it is good. \def\@@jfverb #1{% \ifcat\noexpand#1\noexpand~\catcode`#1\active\fi % No problem with the EOL for the line where the short verb delimiter stands. \def\next ##1#1{% % 2022/06/04 % automated hyperlink detection % - \detokenize needed due to * \active from \makestarlowast in \MicroFont % - gobbling first char rather than checking if it is backslash % (and there is an \@empty first so gobbling two tokens) % mark-up using \csbxint is better way as it allow hyphenation after xint % Usage of \xintlabelprefix to modify behaviour in implementation part. % This will NOT WORK if the catcodes were already frozen... \ifcsname r@\xintlabelprefix\detokenize\expandafter{\xint_gobble_ii##1}\endcsname \hyperref[\xintlabelprefix\detokenize\expandafter{\xint_gobble_ii##1}]{##1}% \egroup \else % this will add \discretionary's for wrapping at end of line \@vobeyspaces\everyeof{\relax}\endlinechar\m@ne \expandafter\@@jfverb_a\scantokens\expandafter{##1}% \fi}% % hack with \@empty to prevent brace stripping if catcodes have been % frozen earlier, like in footnotes. \next \@empty } % We don't want a \discretionary at the very start. % But then an empty argument is forbidden! \def\@@jfverb_a #1{#1\@@jfverb_b } \def\@@jfverb_b #1{\ifx\relax #1% \egroup \else % \penalty\z@, or rather (Oct 11, 2014) but I then adjust the textwidth % precisely: \discretionary{\copy\SoftWrapIcon}{}{}% #1\expandafter\@@jfverb_b\fi } \DeclareFontFamily{U}{MdSymbolC}{} \DeclareFontShape {U}{MdSymbolC}{m}{n}{<-> MdSymbolC-Regular}{} \newbox\SoftWrapIcon \def\SetSoftWrapIcon{% \setbox\SoftWrapIcon\hb@xt@\z@ {\kern.5ex%\hb@xt@\z@%\fontdimen2\font %{ \smash{\lower3pt\hbox{% \verbsoftwrapiconcolorcmd\usefont{U}{MdSymbolC}{m}{n}\char 151 }}%\hss}% \hss}% } \AtBeginDocument {\SetSoftWrapIcon }% ok car ttzfamily déjà fait \catcode`_ 8 % everbatim environment % ===================== \def\restoreMacroFont {\def\MacroFont {\ttfamily \ifinlefted\else\color{everbatimfgcolor}\fi }} \restoreMacroFont % Notice that \macrocode uses \macro@font which stores the \MacroFont meaning % in force at \begin{document}. But doc.sty's verbatim uses current \MacroFont % not the meaning at \begin{document}. Comprenne qui pourra... % October 13-14, 2014 % Verbatim with an \everypar hook, mainly to have background color, followed by % execution of the contents (not limited by a group-scope) \catcode`_ 11 \def\everbatim {\s@everbatim\@everbatim} \@namedef{everbatim*}{\s@everbatim\@everbatimx} % Note: one can not use everbatim inside itself or everbatim* inside itself \def\s@everbatim {% % \ineverbtrue \everbatimtop % put there size changes \topsep \z@skip \partopsep \z@skip \itemsep \z@skip \parsep \z@skip \parskip \z@skip \lineskip \z@skip \let\do\@makeother \dospecials \let\do\do@noligs \verbatim@nolig@list \makestarlowast \everbatimhook \trivlist \@topsepadd \z@skip \item\relax \leftskip \@totalleftmargin \rightskip \z@skip \parindent \z@ \parfillskip\@flushglue \parskip \z@skip \@@par \def\par{\leavevmode\null\@@par\pagebreak[1]}% \everypar\expandafter{\the\everypar \unpenalty \everbatimeverypar \everypar \expandafter{\the\everypar\everbatimeverypar}% }% \obeylines \@vobeyspaces } % 27 mai 2022, plus de \small \def\everbatimtop {\MacroFont }% \let\everbatimhook\empty \def\everbatimeverypar{\strut {\color{everbatimbgcolor}\vrule\@width\linewidth }% \kern-\linewidth \kern\everbatimindent } \def\everbatimindent {\z@}% voir plus loin atbegindocument \begingroup \lccode`X 13 \catcode`X \active \lccode`Y `* % this is because of \makestarlowast. % I have to think whether this is useful: obviously if I were to provide % everbatim and everbatim* in a package I wouldn't do that. \catcode`Y \active \catcode`| 0 \catcode`[ 1 \catcode`] 2 \catcode`* 12 \catcode`{ 12 \catcode`} 12 |catcode`\\ 12 |lowercase[|endgroup% both freezes catcodes and converts X to active ^^M |def|@everbatim #1X#2\end{everbatim}% [#2|end[everbatim]|everbatimbottom ] |def|@everbatimx #1X#2\end{everbatimY}]% {#2\end{everbatim*}% % No group here: this allows executed code to make macro % definitions which may reused in later uses of everbatim. % refactored 2022/01/11, rather than passing \newlinechar value % as was done formerly via everbatim* (see above) and fetching it here as #1 % it is thus assumed executed contents do not terminate a scope \edef\everbatimrestorenewlinechar{\newlinechar\the\newlinechar\relax}% \newlinechar 13 % refactored 2022/01/11 to fix a \parskip issue % attention, \parskip thus set to zero for execution of contents % reason: avoid extra space if everbatim* is in an \item of a list % between verbatim and output of execution, if it starts a paragraph % a \vskip-\parskip approach (cf former \everbatimundoparskip) % would be no good in case contents create a display \edef\everbatimrestoreparskip{\parskip\the\parskip\relax}% \parskip\z@skip % execution of the contents (expected to be LaTeX code...) \everbatimxprehook \scantokens {#2}% \everbatimrestorenewlinechar \everbatimrestoreparskip \everbatimxposthook % input after \end{everbatim*} on same line in source is allowed }% % L'espace venant du endofline final mis par \scantokens sera inhibé si #2 se % termine par un % ou un \x, etc... \let\everbatimbottom\empty \def\endeverbatim{\if@newlist \leavevmode\fi\endtrivlist} \@namedef{endeverbatim*}{\endeverbatim} % There is an issue with how to inhibit the \parskip if execution % of contents generate a paragraph. Because the design is aimed at % keeping output close to verbatim input. % Even in a document with zero \parskip overall, the \parskip will possibly % be reset to some annoying high value e.g. if we are in an \item of a list % environment. % In this documentation, many usage of everbatim* are indeed inside such % \item's. The former (2020) approach was to do: % \@namedef{endeverbatim*}{\endeverbatim\aftergroup\everbatimundoparskip} % \def\everbatimundoparskip{\vbox{}\kern-\baselineskip\kern-\parskip\leavevmode} % but it had its problems if executed contents start a display, with % not enough vertical whitespace then % Also if source had two everbatim* environments one after the other, % the first one not producing any ouput, this caused overlap. % The new approach (Feb 2022) is much simpler and avoids these problems. % These definitions are provisory and get overwritten below in order % to avoid color stack overflow problems with latex + dvipdfmx, and xelatex \def\everbatimxprehook {\colorlet{everbsavedcolor}{.}% \color{everbatimxfgcolor}}% \def\everbatimxposthook{\color{everbsavedcolor}} % actual definitions: {\sbox0{\color{everbatimxfgcolor}\xdef\@tempa{\current@color}}} \ifpdf \ifluatex \edef\everbatimxprehook {\pdfextension colorstack\noexpand\@pdfcolorstack push{\@tempa}\relax} \def\everbatimxposthook {\pdfextension colorstack\@pdfcolorstack pop\relax} \else \edef\everbatimxprehook {\pdfcolorstack\noexpand\@pdfcolorstack push{\@tempa}\relax} \def\everbatimxposthook{\pdfcolorstack\@pdfcolorstack pop\relax} \fi \else % Le 24 juin 2021 je vérifie que ceci est encore nécessaire avex xelatex % (sinon color leak de OrangeRed à partir de la page 97 dans la doc) % et aussi pour dvipdfmx (sinon color stack overflow au moment de la page 98 % lors du passage par dvipdfmx) \ifxetex \edef\everbatimxprehook{\special{color push \@tempa}} \def\everbatimxposthook{\special{color pop}} \else \ifnum\Withdvipdfmx=1 \edef\everbatimxprehook{\special{color push \@tempa}} \def\everbatimxposthook{\special{color pop}} \fi \fi \fi % \everb % ====== % % Original was called \dverb and I did it in June 2013. % Then after doing everbatim, I transformed \dverb, now called \everb % for itself being as compatible as standard verbatim with list making % surrounding environments. % Supposed to be used as % \everb|@ this will be ignored % stuff % escape character: " % | not necessarily starting a line. % I chose @ as comment character, mainly for pretty-formatting of the % source, this can be changed by \everbhook. % " comme caractère d'échappement. Par exemple pour colorier des parties. % Le "" redonne à { et } leurs catcodes normaux mais attention c'est % alors à utiliser avec un terminateur ;! pour la partie concernée \def\restoreeverbhook{\def\everbhook{% \def\"{\begingroup\catcode123 1 \catcode 125 2 \everbescape }% \catcode`\" 0 \catcode`\@ 14 }}\restoreeverbhook \def\everbescape #1;!{#1\endgroup } \def\everb {% \bgroup \let\everbatimhook\everbhook \s@everbatim \@everb } \def\@everb #1{\catcode`#1\active \lccode`\~`#1% \lowercase{\def~{\if@newlist \leavevmode\fi \endtrivlist \egroup \@doendpe \everbatimbottom }}% }% \catcode`_8 % \printnumber % ============ \catcode`_ 11 \catcode`& 3 \def\allowsplits_a {\futurelet\printnumber_token\allowsplits_b }% \def\allowsplits_b{\ifx\printnumber_token\@sptoken\space\fi\allowsplits_c } \def\allowsplits_c #1{\ifx \xint_dothis\xint_gobble_i\fi \if ,#1\xint_dothis {\discretionary{\rlap,}{}{,}}\fi \xint_orthat{\discretionary {\copy\SoftWrapIcon}% {}% {}#1}\allowsplits_a }% \def\printnumber #1{\expandafter\allowsplits_a \romannumeral-`0#1&}% \hyphenpenalty \z@ \catcode`& 4 \catcode`_ 8 % Parameters for lists % ==================== \AtBeginDocument{% \leftmargini \dimexpr4\fontcharwd\font`X\relax \leftmarginii\dimexpr3\fontcharwd\font`X\relax \leftmarginiii \leftmarginii \leftmarginiv \leftmarginii \parindent\dimexpr2\fontcharwd\font`X\relax \leftmargin\leftmargini % pourquoi pas 0? % formerly everbatim indent was set to leftmargingi, reduce it (2017/08/26) % \edef\everbatimindent{\the\dimexpr\leftmargini\relax\space }% % setting it to \parindent does not work with \everb construct % \def\everbatimindent{\parindent}% \edef\everbatimindent{\the\dimexpr2\fontcharwd\font`X\relax\space}% \cftsubsecnumwidth 2\leftmarginii \cftsubsubsecnumwidth 2\leftmargini \cftsubsecindent 0pt \cftsubsubsecindent \cftsubsecnumwidth }% % ========== % Hyperlinks % ========== % \csa, \csbxint, \csh etc... % =========================== % The underscore and caret things are for implementation part \DeclareRobustCommand\csa[1] {{\ttzfamily\char92\endlinechar-1 \makestarlowast \catcode`_ 12 \catcode`^ 12 \scantokens\expandafter{\detokenize{#1}}}} % csan: n means no backslash \DeclareRobustCommand\csan[1] {{\ttzfamily\endlinechar-1 \makestarlowast \catcode`_ 12 \catcode`^ 12 \scantokens\expandafter{\detokenize{#1}}}} % For some legacy reasons rather than doing: % \pdfstringdefDisableCommands{% % \def\csa#1{\textbackslash\detokenize{#1}}% % \def\csan#1{\detokenize{#1}}% % }% % I defined years ago variants for usage within section titles. These % variants will get redefined in implementation section to automatically % insert \label's and use \csa and \csan. Here in user manual, they simply % use \csa or \csan, but are careful to do \texorpdfstring. \newcommand\csh[1] {\texorpdfstring{\csa{#1}}{\textbackslash\detokenize{#1}}} % This one is actually never used inside the user manual, only encountered % in the implementation part. \newcommand\cshn[1] {\texorpdfstring{\csan{#1}}{\detokenize{#1}}} % Let's preserve these meanings for when I will want to use them in sections % of the implementation part but not insert labels. \let\cshnolabel\csh \let\cshnnolabel\cshn % 2022/06/10 % If producing xint-all.pdf add hyperlinks from user documentation % to source code. Should have I used some superscript? Less trouble % and less work intensive for TeX I guess than the centered align. % \def\myalign@vbox#1{\leavevmode\vbox{\baselineskip\z@skip \lineskip.75ex% % \ialign{\hfil##\hfil\crcr#1\crcr}}} % %%\def\oalign#1{\leavevmode\vtop{\baselineskip\z@skip \lineskip.25ex% % %% \ialign{##\crcr#1\crcr}}} % \myalign@vbox{\hyperref[\xintimplabelprefix\detokenize{#1}]{\usebox\sourcelinkbox}\cr % \csa{#1}}% \def\myalign@vbox#1{%\leavevmode \vbox{% \@tempboxa is not used by \smash... and I hope \hyperref too \baselineskip\z@skip\lineskip.75ex\relax \sbox\@tempboxa{\csa{#1}}% \hbox to\wd\@tempboxa{\hss \hyperref[\xintimplabelprefix\detokenize{#1}]{\usebox\sourcelinkbox}% \hss}% \box\@tempboxa }% }% \newsavebox\sourcelinkbox % \familydefault already configured % trying to add some \vphantom{X} has no impact it seems on the % size of the clickable area (tested with Skim and Preview on mac os) % so using \small not \footnotesize \sbox\sourcelinkbox{\color{macrocodelinktosectioncolor}% \normalfont\small\itshape source} \def\cswithsourcelink#1{\smash{\myalign@vbox{#1}}}% % the references should exist on second LaTeX pass % and we don't want complications in tables of contents \def\csperhapswithlink#1{\ifx\thepage\relax\csa{#1}\else \ifcsname r@\xintimplabelprefix\detokenize{#1}\endcsname \cswithsourcelink{#1}% \else \csa{#1}% \fi\fi } \ifnum\doxintsource=0 \ifnum\NoSourceCode=0 \renewcommand\csh[1] {\texorpdfstring {\csperhapswithlink{#1}} {\textbackslash\detokenize{#1}}% } % \renewcommand\cshn[1] % but it is used nowhere in user manual \fi\fi % The "b" is there originally for "blue" in fact, from the hyperlink. \DeclareRobustCommand\csb [1] {\perhapshyperref[\xintlabelprefix\detokenize{#1}]% {{\char92 \endlinechar-1 \makestarlowast \catcode`_ 12 \catcode`^ 12 \scantokens\expandafter{\detokenize{#1}}}}} \DeclareRobustCommand\csbn[1] {\perhapshyperref[\xintlabelprefix\detokenize{#1}]% {{\endlinechar-1 \makestarlowast \catcode`_ 12 \catcode`^ 12 \scantokens\expandafter{\detokenize{#1}}}}} \DeclareRobustCommand\csbxint[1] {\perhapshyperref[\xintlabelprefix\detokenize{xint#1}]% {{\char92\mbox{xint}\-\endlinechar-1 \makestarlowast \catcode`_ 12 \catcode`^ 12 \scantokens\expandafter{\detokenize{#1}}}}} \DeclareRobustCommand\csbXINT[1] {\perhapshyperref[\xintlabelprefix\detokenize{XINT#1}]% {{\char92\mbox{XINT}\-\endlinechar-1 \makestarlowast \catcode`_ 12 \catcode`^ 12 \scantokens\expandafter{\detokenize{#1}}}}} % 2022/06/08, I finally add this % although this is is not immediately useful as I have interiorized for years % not to use \csbxint et al. in section titles... \pdfstringdefDisableCommands{% \let\csb\cs % \cs already in DisableCommands, I hope its redefinition is done % first, well yes one has to chase \ltx@GlobalAppendToMacro % all the way to ltxcmds... \let\csbn\detokenize \def\csbxint#1{\textbackslash xint\detokenize{#1}}% \def\csbXINT#1{\textbackslash XINT\detokenize{#1}}% }% % \func, \funcdesc, \keyword, \keyworddesc, \prec, \precdesc, \oper, \operdesc % ============================================================================ \newcommand\func[1]{\hyperlink{\detokenize{func-#1}}{#1}()} \newcommand\funcdesc[2][x]{\item[#2({#1})]\hypertarget{\detokenize{func-#2}}{}}% \newcommand\keyword[1]{\hyperlink{\detokenize{kwd-#1}}{#1}} \newcommand\keyworddesc[1]{\item[#1]\hypertarget{\detokenize{kwd-#1}}{}}% \let\prec\relax % sinon, c'est \mathchar"321E \newcommand\prec[1]{\hyperlink{\detokenize{prec-#1}}{#1}} \newcommand\precdesc[1]{\item[\texttt{#1}]\hypertarget{\detokenize{prec-#1}}{}\leavevmode}% %\let\var\relax % défini par koma-script-source-doc que scrdoc % utilise avec LaTeX 2022/06/01 % mais finalement je n'utilise plus scrdoc/ltxdoc % mais doc directement. \newcommand\var[1]{\hyperlink{\detokenize{var-#1}}{#1}} \newcommand\vardesc[1]{\item[#1]\hypertarget{\detokenize{var-#1}}{}}% \newcommand\oper[1]{\hyperlink{\detokenize{oper-#1}}{#1}} \newcommand\operdesc[1]{\item[\texttt{#1}]\hypertarget{\detokenize{oper-#1}}{}}% % \xintname, \xintnameimp etc... % ============================== \xintForpair #1#2 in {(kernel,kernel), (tools,tools), (core,core),(,xint),(binhex,binhex),(gcd,gcd),% (frac,frac),(series,series),(cfrac,cfrac),(expr,expr),% (trig, trig), (log, log)} \do {% \expandafter\def\csname xint#1name\endcsname {\texorpdfstring {\perhapshyperref[sec:#2]% {{\color{xintnamecolor}\MakeNameUp {\mbox{xint}\-#1} {xint#1}% }% }% }% {xint#1}% \xspace }% \expandafter\def\csname xint#1nameimp\endcsname {\texorpdfstring {\perhapshyperref[sec:#2imp]% {{\color{xintnameimpcolor}\MakeNameUp {\mbox{xint}\-#1} {xint#1}% }% }% }% {xint#1}% \xspace }% }% \def\xintbundlename {\texorpdfstring {\perhapshyperref[sec:bundle]% {{\color{xintnamecolor}\MakeNameUp {\mbox{xint} bundle} {xintbundle}% }% }% }% {xint bundle}% \xspace }% \def\DOCxintfrontpage {\perhapshyperref[frontpage]{{\color{xintnamecolor}TOC}}}% \ifnum\doxintsource=1 % xintsource.pdf \gdef\DOCxintfrontpage {\perhapshyperref[frontpage]{{\color{xintnameimpcolor}TOC}}}% \else \ifnum\NoSourceCode=0 % xint-all.pdf % Not using \hypersetup with linkcolor because a few pages are with % a TOC à cheval on two pages, and my eTOCs are configured to do % \hypersetup{hidelinks} \protected\def\DOCxintfrontpage {\smash{\vbox{\hbox{\perhapshyperref[partiii]{{\color{xintnameimpcolor}TOC}}}% \kern1ex \hbox{\perhapshyperref[frontpage]{{\color{xintnamecolor}TOC}}}}}}% \fi\fi \protected\def\MakeNameUp#1#2{% \ifcsname #2nameUp\endcsname \expandafter\@firstoftwo\else \expandafter\@secondoftwo \fi % \ifinheader 2020/01/30 {\ifinheader\fbox{\textup{#1}}\else#1\fi}% {#1}% } \newif\ifinheader % doit être protégé \protected\def\inheadertrue{\let\ifinheader\iftrue} % \RaisedLabel % ============ % Samedi 16 juin 2018 à 15:23:22 % trick to see header of target page % there is probably better way to use the already in place % anchor from \section, but no time to go into hyperref source \newcommand\RaisedLabel[2][6]{% \vspace*{-#1\baselineskip}% \begingroup \let\leavevmode\relax\phantomsection \label{#2}% \endgroup \vspace*{#1\baselineskip}% } % It seems I need this for a bookmark in xint-all.pdf % reaching the top of the page where Part III starts % 2022/06/10 \newcommand\RaisedTarget[2][6]{% \vspace*{-#1\baselineskip}% \hypertarget{#2}{}% \vspace*{#1\baselineskip}% } % begin{document} % =============== % \ttzfamily done at begin document \DeclareRobustCommand\ctanpackage[1]{\href{https://ctan.org/pkg/#1}{#1}} \makeatother \begin{document}\thispagestyle{empty} \pdfbookmark[1]{Title page}{TOP} \def\partname{Part} \addto\captionsenglish{\def\partname{Part}} \ifnum\doxintsource=1 \noindent\begin{minipage}[t][8\baselineskip][c]{\linewidth} \normalfont\Huge \centering The \xintexprnameimp and allied packages source code\par \else \begingroup \normalfont\Huge \centering The \xintexprname and allied packages\par \endgroup \fi \RaisedLabel{frontpage} \normalsize\ttzfamily {\centering \textsc{Jean-Fran\c cois Burnol}\par \footnotesize jfbu (at) free (dot) fr\par Package version: \xintbndlversion\ (\xintbndldate); documentation date: \xintdocdate.\par {From source file \texttt{xint.dtx}. \xintdtxtimestamp.}\par } \ifnum\doxintsource=1 \end{minipage} \else \medskip \fi % 31 janvier 2020 % 2022/06/10 no need for \texorpdfstring here \def\DOCxintexprintro {\perhapshyperref[part:1]{{\color{xintnamecolor}% \MakeNameUp{Start here}% {Start here}% }% }% }% \def\DOCxintexprmacros {\perhapshyperref[sec:oldxintexpr]{{\color{xintnamecolor}% \MakeNameUp{xintexpr (old doc)}% {xintexpr (old doc)}% }% }% }% \def\DOCexamples {\perhapshyperref[sec:examples]{{\color{xintnamecolor}% \MakeNameUp{Examples}{Examples}% }% }% }% % Vendredi 15 juin 2018 % Someone makes the comma active (not me! not sure if doc.sty or KOMA) and % this derails xspace.sty, in the headers, as it uses \scantokens on a list of % tokens, so it fails to recognize the commas which of course are of catcode12 % Update Friday, June 25 2021 % I finally take the time to go to the root of this: the culprit is everbatim % when its output crosses pagebreaks, but the same of course happens with % verbatim. % I opened ticket https://github.com/latex3/latex2e/issues/600 \def\xintRunningHeader{{\inheadertrue\catcode`,12\relax \DOCxintfrontpage, \DOCxintexprintro, \xintexprname, \DOCxintexprmacros, \xinttrigname, \xintlogname, \xinttoolsname, \DOCexamples, \xintbundlename}} \markboth{\makebox[0pt]{\xintRunningHeader}}{\makebox[0pt]{\xintRunningHeader}} % 18 mai 2019, turned into an environment 27 mai 2022 \newenvironment{TeXnote}{\par\small\medskip\noindent\textbf{\TeX-hackers note: }}{\par\medskip} % Skips safely. \ifnum\doxintsource=1 \catcode`+ 0 \catcode0 9 % n'importe quoi sauf 15 (car ^^@) \catcode`\\ 12 +expandafter+iffalse+fi \fi % \makeatletter \etocsetlevel{toctobookmark}{6} \etocsetlevel{xinttable}{2}% subsection \let\orig@etoctoclineleaders\etoctoclineleaders \def\etoctoclineleaders {\hbox{\normalfont\normalsize\hbox to 1ex {\hss.\hss}}} \def\etocbelowtocskip{\z@skip} \def\etocinnertopsep{\z@skip} \etocsettocstyle{}{} \etocsettagdepth {part1A}{subsection}% style de subsection défini dans preamble \etocsettagdepth {part1B}{section}% style de section aussi \etocsettagdepth {macros}{none} \etocsettagdepth {implementation}{none} \etocsettocdepth{subsection} %% Legacy etoc style for part, with an improvement to get "Part" %% hyperlinked %% Also some hack to let the TOC of xint-all.pdf fit on one page %% `part': \etocsetstyle{part} {\ifnum\doxintsource=0 \ifnum\NoSourceCode=0 % both true only for xint-all.pdf \def\etocabovetocskip{\z@skip}% \def\etocsepminusone{\bigskipamount}% \def\etocsepzero{\medskipamount}% \def\tocstylesectionVSKIP{\vskip\smallskipamount}% \fi\fi \addpenalty\@M\etocskipfirstprefix} {\addpenalty\@secpenalty} {% \begingroup \etocfontminusone \addvspace{\etocsepminusone}% \parindent \z@ \leftskip \etocminusoneleftmargin \rightskip \etocminusonerightmargin \parfillskip \@flushglue % original from etoc : %\vbox{\etocifnumbered{\etocpartname\enspace\etocnumber.\quad}{}...} \vbox{\etocifnumbered{\etoclink{\etocpartname\enspace\etocthenumber.}\quad}{}% \etocname \baselineskip\etocbaselinespreadminusone\baselineskip \par}% \addpenalty\@M \addvspace{\etocsepzero}% \endgroup} {}% % THIS IS THE FIRST HALF OF THE TOC ON PAGE 1 \tableofcontents % May 23 2022, some hack to replace the \etocmulticolstyle and % have same output except that Part line will use full line width % % Formerly I used this but the Part was then folded... % \etocmulticolstyle [2]{\parskip\z@skip%\raggedcolumns % \setlength{\columnsep}{\leftmarginii}% % \setlength{\columnseprule}{0pt}% % }% % \etocsetstyle{part}% @minusone in etoc.sty {\if1\ifnum\doxintsource=1 0\fi\ifnum\NoSourceCode=1 0\fi1% xint-all.pdf \def\etocabovetocskip{\z@skip}% \def\etocsepminusone{\bigskipamount}% \def\etocsepzero{\medskipamount}% \fi \addpenalty\@M\etocskipfirstprefix} % May 23, 2022 % Small hack to configure to our taste the TOC for the pdf combining % the user manual and the source code. We want a Part III in the TOC, % and the sections of Part II with a multicols. We can not open the % multicols in the `part' style and have it closed in the 4th argument % of \etocsettyle, as it needs to be closed when Part III will be % typeset. Thanks to \etocskipfirstprefix we can simply close it % in the "EtocPrefix", this \end{multicols} will be skipped for the % first one. % % However, as this closes a group we will use \etocglobaldefs for this % toc else \etocname, etc... would not have the good meanings. I think % there must be some hack like this in etoc manual. {\end{multicols}% \addpenalty\@secpenalty } {% % \kern and not \vskip to avoid multicolumn balncing columns \def\tocstylesectionVSKIP{\kern\smallskipamount}% \if1\ifnum\doxintsource=1 0\fi\ifnum\NoSourceCode=1 0\fi1% % xint-all.pdf only % quite a challenge to get everything on single page, but not too cramped... \def\tocstylesectionVSKIP{\kern.75\smallskipamount}% \fi \begingroup % adapted from etoc.sty default Part style \etocfontminusone \addvspace{\etocsepminusone}% \parindent \z@ \leftskip \etocminusoneleftmargin \rightskip \etocminusonerightmargin \parfillskip \@flushglue % \etoclink is handy else only the number get hyperlinked \vbox{\etocifnumbered{\etoclink{\etocpartname\enspace\etocthenumber.\quad}}{}\etocname \baselineskip\etocbaselinespreadminusone\baselineskip \par}% \addpenalty\@M\addvspace{\etocsepzero}% \endgroup % now emulate what \etocmulticolstyle would have set-up \let\etocoldpar\par% surely fishy by now but I am copying from % how \etocsettocstyle is used by \etocmulticolstyle \addvspace{\etocabovetocskip}% configured below \multicolpretolerance\etocmulticolpretolerance \multicoltolerance\etocmulticoltolerance \setlength{\columnsep}{\etoccolumnsep}% \setlength{\multicolsep}{\etocmulticolsep}% \begin{multicols}{2}[\parskip\z@skip%\raggedcolumns \setlength{\columnsep}{\leftmarginii}% \setlength{\columnseprule}{0pt}% \etocoldpar %\addvspace{\etocinnertopsep} \addvspace{\etocabovetocskip}]% }% {\end{multicols} }% % this macro is defined by etoc for use in its own display styles % like the one from \etocmulticolstyle. We use it manually above. \renewcommand*\etocabovetocskip{\bigskipamount} \makeatother \etocsettagdepth {part1A}{none} \etocsettagdepth {part1B}{none} \etocsettagdepth {macros} {section} \ifnum\doxintsource=1 % xintsource.pdf \etocsettagdepth {implementation}{section} \else \ifnum\NoSourceCode=1 % xint.pdf \etocsettagdepth {implementation}{part} \else % xint-all.pdf \etocsettagdepth {implementation}{section} \fi \fi % THIS IS THE SECOND HALF OF THE TOC ON PAGE 1, WITH PARTS II AND III \etocglobaldefs \tableofcontents \etoclocaldefs \etocignoredepthtags % 30 juillet 2025, simplification du contrôle espacement après TOCs \makeatletter \def\etocabovetocskip{\z@skip} \makeatother \def\etocbelowtocskip{\bigskipamount} \etocmulticolstyle [1]{% \phantomsection% \section* {Contents} \etoctoccontentsline*{toctobookmark}{Contents}{2}% } \inmanualmaintocfalse \clearpage % ---- % Fibonacci code % December 7, 2013. Expandably computing a big Fibonacci number % with the help of TeX+\numexpr+\xintexpr, © Jean-François Burnol \catcode`_ 11 % % ajouté 7 janvier 2014 au xint.dtx pour 1.07j. % % Le 17 janvier je me décide de simplifier l'algorithme car l'original ne tenait % pas compte de la relation toujours vraie A=B+C dans les matrices symétriques % utilisées en sous-main [[A,B],[B,C]]. % % la version ici est celle avec les * omis: car multiplication tacite devant les % sous-expressions depuis 1.09j, et aussi devant les parenthèses depuis 1.09k. \def\Fibonacci #1{% \expandafter\Fibonacci_a\expandafter {\the\numexpr #1\expandafter}\expandafter {\romannumeral0\xintiiexpro 1\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro 1\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro 1\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro 0\relax}} % \def\Fibonacci_a #1{% \ifcase #1 \expandafter\Fibonacci_end_i \or \expandafter\Fibonacci_end_ii \else \ifodd #1 \expandafter\expandafter\expandafter\Fibonacci_b_ii \else \expandafter\expandafter\expandafter\Fibonacci_b_i \fi \fi {#1}% }% \def\Fibonacci_b_i #1#2#3{\expandafter\Fibonacci_a\expandafter {\the\numexpr #1/2\expandafter}\expandafter {\romannumeral0\xintiiexpro sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro (2#2-#3)#3\relax}% }% end of Fibonacci_b_i \def\Fibonacci_b_ii #1#2#3#4#5{\expandafter\Fibonacci_a\expandafter {\the\numexpr (#1-1)/2\expandafter}\expandafter {\romannumeral0\xintiiexpro sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro (2#2-#3)#3\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro #2#4+#3#5\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro #2#5+#3(#4-#5)\relax}% }% end of Fibonacci_b_ii \def\Fibonacci_end_i #1#2#3#4#5{\xintthe#5} \def\Fibonacci_end_ii #1#2#3#4#5{\xinttheiiexpr #2#5+#3(#4-#5)\relax} \catcode`_ 8 \def\Fibo #1.{\Fibonacci {#1}} \def\specialprintone #1% {% \ifx #1\relax \else \makebox[877496sp]{#1}\hskip 0pt plus 2sp\relax \expandafter\specialprintone\fi }% \def\specialprintnumber #1% first ``fully'' expands its argument. {\expandafter\specialprintone \romannumeral-`0#1\relax }% \AddToShipoutPicture*{% \put(10.5cm,14.85cm) {\makebox(0,0) {\resizebox{17cm}{!}{\vbox {\hsize 8cm\Huge\baselineskip.8\baselineskip\color{black!5}% \specialprintnumber{F(1250)=}% \specialprintnumber{\Fibonacci{1250}}}\par}% }% }% } \pdfbookmark[1]{Dependency graph}{DependencyGraph} \tikzstyle{block} = [rectangle, draw, fill=yellow!10, % fill opacity=0.5, draw=black!30, line width=2pt, text width=6em, text centered, rounded corners, minimum height=4em] \tikzstyle{line} = [draw, line width=1pt, color=black!30] %\vspace*{\stretch{0.1666}} \begin{figure}[ht!] \phantomsection\label{dependencygraph} \centeredline{% \begin{tikzpicture}[node distance = 2.5cm] % Place nodes \node [block] (kernel) {\xintkernelname}; % \node [left of=kernel] (A) {}; % \node [right of=kernel] (B) {}; \node [block, below of=kernel] (core) {\xintcorename}; \node [block, right of=core, xshift=1cm] (binhex) {\xintbinhexname}; \node [block, left of=core, xshift=-2.5cm] (tools) {\xinttoolsname}; \node [block, below of=core] (xint) {\xintname}; \node [block, right of=xint, xshift=1cm] (bnumexpr) {\ctanpackage{bnumexpr}}; \node [block, left of=xint, xshift=-0.5cm] (gcd) {\xintgcdname}; \node [block, below of=xint] (frac) {\xintfracname}; \node [block, below of=frac, yshift=-.5cm] (expr) {\xintexprname}; \node [block, below right of=expr, yshift=-.5cm, xshift=2.25cm] (polexpr) {\ctanpackage{polexpr}}; \node [block, below of=polexpr] (session) {rlwrap etex \ctanpackage{xintsession}}; \node [block, below of=expr, yshift=-.5cm] (trig) {\xinttrigname}; \node [block, left of=trig] (log) {\xintlogname}; \node [block, left of=log, xshift=-1cm] (poormanlog) {\ctanpackage{poormanlog}}; \node [block, below of=gcd, yshift=1cm] (cfrac) {\xintcfracname}; \node [block, below of=cfrac, yshift=1cm] (series) {\xintseriesname}; % Draw edges \path [line,-{Stealth[length=5mm]}] (kernel) -- (core); \path [line,-{Stealth[length=5mm]}] (kernel) -- (tools); \path [line,-{Stealth[length=5mm]}] (kernel) -- (binhex); \path [line,-{Stealth[length=5mm]}] (core) -- (bnumexpr); \path [line,-{Stealth[length=5mm]}] (binhex) -- (bnumexpr); \path [line,-{Stealth[length=5mm]}] (core) -- (xint); \path [line,-{Stealth[length=5mm]}] (xint) -- (frac); \path [line,-{Stealth[length=5mm]}] (xint) -- (gcd); \path [line,-{Stealth[length=5mm]}] (frac) -- (expr); \path [line,-{Stealth[length=5mm]}] (frac) -- (series); \path [line,-{Stealth[length=5mm]}] (frac) -- (cfrac); \path [line,-{Stealth[length=5mm]}] (expr) -- (polexpr); \path [line,{Stealth[length=5mm]}-{Stealth[length=5mm]}] (expr) -- (trig); \path [line,{Stealth[length=5mm]}-{Stealth[length=5mm]}] (expr) -- (log); \path [line,-{Stealth[length=5mm]}] (poormanlog) -- (log); \path [line,-{Stealth[length=5mm]}] (expr) -- (polexpr); \path [line,-{Stealth[length=5mm]}] (expr) -- (session); \path [line,-{Stealth[length=5mm]}] (polexpr) -- (session); \path [line,-{Stealth[length=5mm]}] (trig.south) to [out=-90,in=180] (session.west); \path [line,-{Stealth[length=5mm]}] (log.south) to [out=-90,in=180] (session.west); % at 1.4n, xintbinhex is automatically loaded by xintexpr, no more "dashed" \path [line,-{Stealth[length=5mm]}] (binhex.south east) to [out=-45,in=0] (expr); % at 1.4 xintgcd loads xinttools \path [line,-{Stealth[length=5mm]}] (tools.south west) to [out=-90,in=180](gcd.west); % at 1.4n, xintcfrac loads xinttools automatically \path [line,-{Stealth[length=5mm]}] (tools.south west) to [out=-90,in=180](cfrac.west); \path [line,-{Stealth[length=5mm]}] (tools.south west) to [out=-90,in=180] (expr.west); \end{tikzpicture}}\bigskip \end{figure} \vspace{\baselineskip} \begin{addmargin}{1.5cm} \normalfont\footnotesize Dependency graph for the \xintbundlename components. % Modules pointed to by arrows \textbf{automatically} import the module from which the arrow originates. \ctanpackage{bnumexpr} is a \LaTeX{} package by the author which uses (by default) \xintcorename as its mathematical engine. To use it under Plain e\TeX{} issue first |\input miniltx.tex| then |\input bnumexpr.sty|. \ctanpackage{polexpr} handles definitions and algebraic operatione on one-variable polynomials, as well as root localization to arbitrary precision. It works both with Plain \TeX\ and with \LaTeX. \xinttrigname and \xintlogname are loaded automatically by \xintexprname; they should not be loaded directly via a separate |\usepackage| (in \LaTeX). \ctanpackage{poormanlog} is a \TeX{} and \LaTeX{} package by the author which is loaded automatically by \xintlogname. \ctanpackage{xintsession} is invoked on the command line as |etex xintsession| (or, much better if available: |rlwrap etex xintsession|). \par \end{addmargin} \vfill \clearpage \etocdepthtag.toc {part1A} \csname Start herenameUp\endcsname \part{The \xintexprname package} \RaisedLabel[12]{part:1} \etocsetnexttocdepth{section} \localtableofcontents \section {Introduction} \localtableofcontents \begin{framed} \textsc{Jürgen Gilg}'s interest into what he called {|"XINT"|} was instrumental in keeping the author motivated over the years. % We exchanged on many topics extending beyond \TeX{} and often reacted similarly to private and public events. I knew he was a very kind and devoted person, who took care of the needs of others prior to his own, although he never mentioned it. % Jürgen suffered a sudden, unexpected, and deadly stroke in May 2022. I will miss his friendship profoundly. \end{framed} \subsection{Compatible engines and formats} The components of the \xintbundlename can be used indifferently with Plain \TeX{} (and other formats, as mentioned next) or with \LaTeX{}. The sole difference being that with the latter the loading must be done by \cs{usepackage} whereas with any non-\LaTeX{} format it has to be via \cs{input} (using |.sty| filename extension, not |.tex|). The engine can be PDF\TeX, Xe\TeX, or Lua\TeX. With release |1.4n| you can also use the packages with Con\TeX t (only latest one, with LuaMeta\TeX{} engine), and Op\TeX. You can't use the \xintbundlename with Knuth's original |tex| binary, because its functionalities require \cs{numexpr} and other e-\TeX{} extensions as well as the more recent \cs{expanded} engine primitive (and \cs{pdfstrcomp} or \cs{strcmp}). \xintexprname will be probably the main entry point, and it actually automatically loads most other components. The aim of \xintexprname is to provide expandable parsers of numerical expressions, either floating point numbers or fractions. \subsection{Usage} Here is an example: \begin{everbatim*} \xintfloateval{cos(3Pi/17)*sin(1)^0.123 + log(3.42e5)} \end{everbatim*} You can get the result with more digits: \begingroup \begin{everbatim*} \xintSetDigits*{32} \xintfloateval{cos(3Pi/17)*sin(1)^0.123 + log(3.42e5)} \end{everbatim*} \endgroup And with still more digits (the |[-2]| rounds away the two least significant digits of the result): \begingroup \begin{everbatim*} \xintSetDigits*{62} \xintfloateval[-2]{cos(3Pi/17)*sin(1)^0.123 + log(3.42e5)} \end{everbatim*} \endgroup Here is now an example with fractions: \begin{everbatim*} \xinteval{reduce(add(1/i^3, i=1..25))} \end{everbatim*} And two examples with large integers: \begin{everbatim*} $2^{1000}=\printnumber{\xinteval{2^1000}}$.\newline $100!^3=\printnumber{\xintiieval{100!^3}}$. \end{everbatim*} The \hyperref[ssec:printnumber]{\string\printnumber} utility to wrap very long output is not part of the package. It is documented in \autoref{ssec:printnumber} next. The table of \hyperref[tab:functions]{built-in functions} and the one of \hyperref[tab:precedences]{built-in operators} will give a quick overview of the available syntax. \subsection{\ctanpackage{xintsession}} The simplest way\footnote{I am assuming here in the displayed example a Unixen system, i.e. Mac OS or Linux, adapt to your environment.} to test the syntax is to work interactively on the command line (this feature is available since April 2021, the version of \ctanpackage{xintsession} used here is |1.3a|). Beware though that ill-formed inputs will trigger \TeX{} famously antiquated error handling, from which it is hard to recover, altough hitting |S| may sometimes miraculously bring you back to the \ctanpackage{xintsession} prompt. \begin{everbatim} rlwrap etex xintsession [...welcome banner...] Magic words: `&pause' (or `;'), `&help', `&bye', `&exact', `&fp', `&int', `&pol'. \jobname is xintsession Transcript will go to log and to xintsession-210609_12h00.tex Starting in exact mode (floating point evaluations use 16 digits) >>> 2^100; @_1 1267650600228229401496703205376 >>> cos(1); @_2 0.5403023058681397 >>> &fp=32 (/usr/local/texlive/2021/texmf-dist/tex/generic/xint/xintlog.sty) (/usr/local/texlive/2021/texmf-dist/tex/generic/xint/xinttrig.sty) fp mode (log and trig reloaded at Digits=32) >>> cos(1); @_3 0.54030230586813971740093660744298 >>> 3^1000; @_4 1.3220708194808066368904552597521e477 >>> &exact exact mode (floating point evaluations use 32 digits) >>> 3^1000; @_5 13220708194808066368904552597521443659654220327521481676649203682268285 9734670489954077831385060806196390977769687258235595095458210061891186534272525 7953674027620225198320803878014774228964841274390400117588618041128947815623094 4380615661730540866744905061781254803444055470543970388958174653682549161362208 3026856377858229022841639830788789691855640408489893760937324217184635993869551 6765018940588109060426089671438864102814350385648747165832010614366132173102768 902855220001 >>> &bye Did I say something wrong? Session transcript written on xintsession-210609_12h00.tex ) No pages of output. Transcript written on xintsession.log. \end{everbatim} \subsection{\ctanpackage{polexpr}} The package \ctanpackage{polexpr} enriches the \csbxint{eval} syntax (but not the one of \csbxint{floateval}) with a polynomial type with associated constructor |pol([c0,c1,...])|, and polynomial specific functions such as |polgcd(pol1, pol2, ...)|. Full usage of polynomials (and algebraic notations |c_0 + c_1 x + c_2 x^2 + ...| for input and also output) goes through a dedicated |\poldef| parser which is based upon \csbxint{defvar}/\csbxint{deffunc} and is a necessary step to then access via a dedicated macro interface operations such as identifying all rational roots and isolating all real roots to arbitrary precision. The simplest manner to experiment with \ctanpackage{polexpr} is via the |&pol| mode of \ctanpackage{xintsession}. \subsection{\ctanpackage{bnumexpr}} This \LaTeX{} package loads \xintcorename and \xintbinhexname and provides \cs{bnumeval} which is a scaled-down \csbxint{iieval} (omitting support for nested structures, functions, variables, boolean branching, etc...). It can be used with Plain e\TeX, thanks to \ctanpackage{miniltx}. For this, use |\input miniltx.tex| followed by |\input bnumexpr.sty| (remark: \ctanpackage{miniltx} is not needed for \xintexprname). \cs{bnumeval} is thus a boosted \cs{inteval} which addition of support for arbitrarily large integers, powers with |**| and |^|, rounded division with |/|, floored division with |//| and associated modulo |/:|, factorials via |!| postfix operator, comma separated multi-item expressions. It also supports as \csbxint{iieval} does the |'|, |"|, |0b|, |0o| and |0x| input prefixes and the optional arguments |[b]|, |[o]|, or |[h]|. Further, it provides an interface (which does not exist with \xintexprname) to let all operations be done by macros of one's own choosing, as replacement for some or all of the operations by default implemented via the help of \xintcorename and \xintbinhexname. It even makes it possible to add to the syntax extra infix or postfix operators and to modify the precedence levels of those already defined. \subsection{Printing big numbers on the page}\label{ssec:printnumber} When producing very long numbers there is the question of printing them on the page, without going beyond the page limits. In this document, I have most of the time made use of a ``|\printnumber|'' macro, which is not provided by the package. A primitive form would be: \everb|@ \def\allowsplits #1{\ifx #1\relax \else #1\hskip 0pt plus 1pt\relax \expandafter\allowsplits\fi}% \def\printnumber #1{\expandafter\allowsplits \romannumeral-`0#1\relax }% | This macro triggers ``\fexpan sion'' of its argument (and indeed \csbxint{eval} and friends expand completely under such trigger), then it goes through the computation result character by character inserting \TeX\ potential break points in-between them. It is ineffective in math mode, one would need to add some |\allowbreak|'s. The |\printnumber| used for building this documentation uses slightly different and more sophisticated mechanisms and can be found in the source file |xint.dtx|. \subsection{Repository} It is at \url{https://github.com/jfbu/xint}. At this stage, it does not recored real-time development status but only actual successive \href{https://ctan.org}{CTAN} releases since 2013. Use it to report issues. Don't forget to include |@jfbu| in the ticket else I will not be pinged. A front page at \url{https://jfbu.github.io/xint} provides, in addition to the present |xint.pdf| and to |README.md| a file |CHANGES.html|, which contains the complete list of changes relevant to user level since the initial release of the package: % \centeredline{\url{https://jfbu.github.io/xint/CHANGES.html}} Its version |xintchanges.md| in Markdown format is included in the \href{https://ctan.org/pkg/xint}{CTAN} upload, % \centeredline{|texdoc xintchanges.md|} Warning: I don't have the time to maintain perfectly such large documentation. It combines old documentation which never really got updated and may be locally obsolete with more recent stuff mostly written on occasion of the |1.4| release of January 2020 and the |1.4e| one of May 2021, and the intervening changes might also have made some of it not completely accurate, despite my best efforts. \subsection{License and installation instructions} \label{ssec:install} The \xintbundlename components are made available under the \href{http://www.latex-project.org/lppl/lppl-1-3c.txt}{LaTeX Project Public License 1.3c}. They are included in all major \TeX\ distributions, thus there is probably no need for a custom install: just use the package manager to update if necessary the \xintbundlename components to the latest version available. Else, \href{https://ctan.org/pkg/xint}{CTAN} access provides |xint.tds.zip| which has all source code and documentation in a TDS-compliant archive, only waiting to be |unzip -d | into some suitable hierarchical structure. See \url{https://jfbu.github.io/xint} for how to build from the \href{https://ctan.org/tex-archive/macros/generic/xint}{CTAN xint}.dtx source file. \clearpage \expandafter\let\csname Start herenameUp\endcsname\undefined \csname xintexprnameUp\endcsname \section{Syntax reference and user guide} \RaisedLabel{sec:expr} \localtableofcontents \begin{framed} \textbf{WARNING:} this documentation goes sometimes into too much details, and does need some improvements. But there is no time for that at |1.4n|. Although people do not believe me when I say that, there is ample intellectual reward in actually reading the documentation, and it would be nice if at least, at last someone on Earth did, once (as \textsc{Jürgen Gilg} some years back). \end{framed} \subsection{The three parsers} \xintexprname provides three numerical expression parsers corresponding to these three respective tasks: \begin{description}[noitemsep] \item[\csa{xintfloateval}:] evaluations with floating point numbers; the default precision is with 16 digits, it can be set via \csbxint{SetDigits*}, \item[\csa{xinteval}:] exact evaluations with fractions, decimal fixed point numbers, numbers in scientific notation, with no size limitation, \item[\csa{xintiieval}:] evaluations allowing only integers with no size limitation, \end{description} and two secondary ones which act like the exact evaluator then round the output to a given number of fractional digits, or convert them to |false| or |true|\CHANGED{1.4m} according to whether they vanish or do not vanish. \begin{framed} Please note the following: \begin{itemize}[noitemsep] \item If you find that \csbxint{floateval} is too much of a mouthful, you create an alias named, for example, |\fpeval|. Oops, no, that is \LaTeX3 very efficient floating point engine. It is faster at its (unchangeable) precision of 16 decimal digits than \csbxint{floateval} due to various reasons, one of them being that \xintexprname birth was related to big integers only, and floating point support in arbitrary precision was added on top of that, via some expedients which have never been refactored, in view of the massive work that this would entail by now. But for example you could do |\let\evalfp\xintfloateval| if you want a shorter name. By the way |\xintfloateval| could very well have been christened |\xintfpeval| but when the author wrote the first release in 2013 he was barely if at all aware of existence of \LaTeX3, and of its |l3fp| component. \item Although \csbxint{eval} manipulates arbitrarily long integers or fractions it also accepts scientific notation on input, as well as all the mathematical functions (evaluated using the prevailing digits precision), and (depending on customization) can thus produce also scientific notation on output. \item So far, individual operations and the printing routine of \csbxint{eval} do not automatically reduce fractions to their lowest terms. \end{itemize} \end{framed} % They are designed to be compatible with expansion only context. All % computations ultimately rely on (and reduce to) usage of the |\numexpr| % primitive from \eTeX{}% % % % \footnote{It can handle only integers, and they must be at most % $2^{31}-1={}$\dtt{\the\numexpr"7FFFFFFF\relax}. Thus some work has to be done % to handle arbitrarily big integers or arbitrary float precision.}. % % % These \eTeX{} extensions date % back to 1999 and are by default incorporated into the |pdftex| % etc...\@{} executables from major modern \TeX{} installations for more than % fifteen years now. The interface is: \begin{itemize} \item \csbxint{eval}\marg{expression} handles integers, decimal numbers, numbers in scientific notation and fractions. The algebraic computations are done \emph{exactly}, and in particular \oper{/} simply constructs fractions. Use \oper{//} for floored division. \begin{everbatim*} \xinteval{add(x/(x+1), x = 1000..1014)}\par \end{everbatim*} The output in this specific example came out irreducible. In general one needs a \func{reduce} wrapper for an irreducible output: \begin{everbatim*} \[\xinteval{subs((y,reduce(y)), y = mul(x/1000, x = 10..[10]..90))}\] \end{everbatim*} Arbitrarily long numbers are allowed in the input. The space character (contrarily to the situation inside |\numexpr|) and also the underscore character (as allowed in Python too) can serve to separate groups of digits for better readability. But the package currently provides no macros to let the output be formatted with such separators. \begin{everbatim*} \xinteval{123_456_789_012^5} \end{everbatim*} Hexadecimal,\NewWith{1.4n} octal and binary (with fractional part allowed) can be input using suitable prefixes: respectively |"| or |0x|, |'| or |0o|, and |0b|: \begin{everbatim*} \xinteval{0b111111111111.111111111111} \end{everbatim*} \item \csbxint{ieval}\oarg{D}\marg{expression} is the same parser as \csbxint{eval}, i.e. accepts the same inputs and does all computations exactly in the same manner, but it then rounds its final result to the nearest integer, or, in case there is an optional argument |[D]|, to: \begin{itemize} \item if |D>0|: the nearest fixed point number with |D| digits after the decimal mark, \item if |D=0|: the nearest integer (as for \csbxint{ieval} with no optional argument), \item if |D<0|: the rounded quotient by |10^(-D)|. \end{itemize} The optional argument \oarg{D} can also be located \emph{within} the braces at the start of the expression (this was actually the legacy syntax until |1.4k|). \item \csbxint{iieval}\marg{expression} executes computations \emph{on (big) integers only.} It is (only slightly) faster than \csbxint{eval} for the same expression. Attention: the forward slash \oper{/} does the \emph{rounded} integer division to match behaviour of |\numexpr|. The \oper{//} operator does floored division as in \csbxint{eval}. The \oper{/:} is the associated modulo operator (we could easily let the catcode 12 |%| character be an alias, but using such an unusual percent character would be a bit cumbersome in a \TeX{} workflow, if only for matters of syntax highlighting in \TeX-aware text editors). \begin{everbatim*} % add the i^5 only if i is a multiple of 7 \xintiieval{add((i/:7)?{omit}{i^5}, i=1000..1020)} \end{everbatim*} An\NewWith{1.4n} optional argument |[h]|, |[o]|, or |[b]| says to convert the output to hexadecimal, octal or binary: \begin{everbatim*} \xintiieval[h]{3^100} \end{everbatim*} \item \csbxint{floateval}\oarg{Q}\marg{expression} does floating point computations with a given precision, which defaults to |16|. The precision |P| can be set using \csbxint{Digits*}|:=P\relax| or \csbxint{SetDigits*}|{P}| syntaxes. Its optional argument |[Q]|, if present, means to do a \emph{final} float rounding to a mantissa of |Q| digits (this thus makes sense only if |Q}, \oper{==}, \oper{<=}, \oper{>=}, \oper{!=} (they can be chained)\strut\\\hline % \prec{8}& Boolean conjunction \oper{\Ampersand\Ampersand} and its alias \oper{'and'}\strut\\\hline % \prec{6}& Boolean disjunction \oper{\string|\string|} and its alias \oper{'or'}. Also \oper{'xor'} and \oper{\strut..}, \oper{..[}, \oper{{]..}}, and \oper{:} have this precedence\strut\\\hline % \prec{4}& the brackets for slicers and extractors \oper{\empty[}, \oper{\empty]}\strut\\\hline % \prec{3}& the comma \oper{,}\strut\\\hline % \prec{2}& the bracketers \oper{[}, \oper{]} construct nestable \myenquote{arrays}\strut\\\hline % \prec{1}& the parentheses \oper{(}, \oper{)}, and the semi-colon \oper{;} in \func{iter}, \func{rseq}, and further structures\strut\\\hline % \hline % \multicolumn{2}{|p{.6\textwidth}|}{% \begin{itemize}[nosep] \item Binary operators have a left and a right precedence, which for most coincide. The right precedence is indicated within parentheses. \item \hyperref[ssec:tacit multiplication]{Tacit multiplication} has an elevated left precedence level: |(1+2)/(3+4)5| is computed as |(1+2)/((3+4)*5)| and |x/2y| is interpreted as |x/(2*y)| when using variables. \end{itemize} }\\\hline \end{tabular} \caption{Precedence levels} \label{tab:precedences} \etoctoccontentsline {xinttable}{\protect\emph{Table of precedence levels of operators}} \restorehtdpstrutbox \end{table} The entries of \autoref{tab:precedences} are hyperlinked to the more detailed discussion at each level. In these entries the number within parentheses indicates the right-\hskip0pt precedence, if it differs from the left. \begin{description} %[parsep=0pt, listparindent=\leftmarginiii] % [parsep=0pt,align=left,itemindent=0pt, % leftmargin=\leftmarginii, labelwidth=\leftmarginii, labelsep=0pt, % labelindent=0pt, listparindent=\leftmarginiii] \edef\Ampersand{\string&}% \precdesc{$\infty$} At this highest level of precedence, one finds: \begin{description} \item[{\hyperref[ssec:builtinfunctions]{functions} and \hyperref[ssec:uservariables]{variables}}] Functions (even the logic functions \func{!} and \func{?} whose names consist of a single non-letter character) must be used with parentheses. These parentheses may arise from expansion after the function name is parsed (there are exceptions which are documented at the relevant locations.) \operdesc{\empty\lowast} Python-like \myenquote{unpacking} prefix operator. Sometimes one needs to use it as function |*()| (but I can't find an example right now) but most of the time parentheses are unneeded. \operdesc{\strut.} is decimal mark; the number scanner treats it as an inherent, optional and unique component of a being formed number. |\xintexpr 0.^2+2^.0\relax| is interpreted as |0^2+2^0| and thus produces \dtt{\xintexpr 0.^2+2^.0\relax}. Since release |1.2| an isolated decimal mark is illegal input in the \xintexprname parsers (it remains legal as argument to the macros of \xintfracname). \operdesc{e} scientific notation. \operdesc{E} scientific notation. For output, see \csbxint{PFloatE}. \operdesc{"} prefix for hexadecimal input. Only uppercase letters, and one optional |.| separating integer and fractional hexadecimal parts. \begin{everbatim*} \xintexpr "FEDCBA9876543210\relax\newline \xintexpr ".FEDCBA9876543210\relax\newline \xintexpr 16^5-("F75DE.0A8B9+"8A21.F5746+16^-5)\relax \end{everbatim*} It is possible that in future the |"| prefix could be dropped in favour of |0x| prefix. This would free |"| to be used for input of \myenquote{string}-like entities. \end{description} \precdesc{20} The postfix operators |!| and the branching conditionals |?|, |??|. \begin{description} \operdesc{!} computes the factorial of an integer. \operdesc{?} is used as |(stuff)?{yes}{no}|. It evaluates |stuff| and chooses the |yes| branch if the result is non-zero, else it executes |no|. After evaluation of |stuff| it acts as a macro with two mandatory arguments within braces, chooses the correct branch \emph{without evaluating the wrong one}. Once the braces are removed, the parser scans and expands the uncovered material. % so for % example % % % \leftedline{|\xinttheiexpr (3>2)?{5+6}{7-1}2^3\relax|} % % % is legal and computes % |5+62^3=|\dtt{\xinttheiexpr(3>2)?{5+(6}{7-(1}2^3)\relax}. It would be % better practice to include here the |2^3| inside the branches. The % contents of the branches may be arbitrary as long as once glued to what is % next the syntax is respected: {|\xintexpr (3>2)?{5+(6}{7-(1}2^3)\relax| % also works.} \operdesc{??} is used as |(stuff)??{<0}{=0}{>0}|, where |stuff| is anything, its sign is evaluated and depending on the sign the correct branch is un-braced, the two others are discarded with no evaluation of their contents. % The un-braced branch will then be parsed as % usual. % % % \leftedline{|\def\x{0.33}\def\y{1/3}|} % % % \leftedline{|\xinttheexpr (\x-\y)??{sqrt}{0}{1/}(\y-\x)\relax|% % \dtt{=\def\x{0.33}\def\y{1/3}% % \xinttheexpr (\x-\y)??{sqrt}{0}{1/}(\y-\x)\relax }} % % \end{description} \precdesc{-} As unary operator, the minus sign inherits as precedence the minimum of |12| (which is the precedence for addition and subtraction) and of the (right-) precedence of the operators preceding it (if any). \begin{everbatim*} \xintexpr -3-4*-5^-7, (-3)-(4*(-(5^(-7))))\relax\newline \xintexpr -3^-4*-5-7, (-((3^(-4))*(-5)))-7\relax\newline |2^-10| gives \xintexpr 2^-10\relax\space \end{everbatim*}and is thus perfectly legal, no need for parentheses. The |+| character as prefix unary operator is simply ignored during input parsing. \precdesc{18} \begin{description} \operdesc{\string^} \operdesc{\lowast\lowast} Both compute powers. They act in a right associative way. \begin{everbatim*} \xintiiexpr 2^3^4\relax \end{everbatim*} \end{description} % et: % *2^-3^-4; % (@_1) 0.991479137495678 % *2**-3**-4; % (@_2) 0.991479137495678 % Python: % >>> 2**-3**-4; % 0.9914791374956781 \precdesc{16} see \hyperref[ssec:tacit multiplication]{Tacit multiplication}. \precdesc{14} \begin{description} \operdesc{\lowast} multiplication \operdesc{/} division: \begin{itemize} \item in \csbxint{eval}: exact division in the field of rational numbers (not automatically reduced to lowest terms), \item in \csbxint{floateval}: correct rounding of the exact division; the two operands are, if necessary, float-rounded before the fraction is evaluated and rounded (to obtain the correcty rounded |A/B| without prior rounding of |A| and |B| see \func{qfloat}), \item in \csbxint{iieval}: for compatibility with the legacy behaviour of |/| in |\numexpr|, it rounds the exact fraction \emph{with half-integers going towards the infinity of the same sign}. \end{itemize} The division is left-associative. Example: \begin{everbatim*} \xintexpr reduce(100/50/2)\relax \end{everbatim*} \operdesc{//} floored division (and thus produces an integer, see \func{divmod} for details) \operdesc{/:} the associated modulo (see \func{divmod} and \func{mod}) Left-associativity applies to the division operators: \begin{everbatim*} \xintexpr 100000/:13, 100000 'mod' 13\relax, \xintexpr 100000/:13/13\relax \end{everbatim*} Nothing special needs to be done in contexts such as \LaTeX3 |\ExplSyntaxOn| where |:| is of catcode letter, but if |:| is an active character one needs to use input such as |/\string :| (or replace it with usage of the function \func{mod}). Bulky workarounds such as |/\string :| are \fbox{\emph{unneeded}} if activation is due to Babel.\NewWith{1.4n} See also \csbxint{exprSafeCatcodes} and a framed note found in \autoref{xintexpr}. \operdesc{'mod'} is same as \oper{/:}. \fbox{Attention:}\IMPORTANTf{} with \ctanpackage{polexpr} loaded, which allows |'| in variable and function names, |'mod'| can not follow a variable name. Add parentheses around the variable, or use |/:|. \end{description} \precdesc{12} \begin{description} \operdesc{+} addition \operdesc{-} subtraction. According to the general left-associativity rule in case of equal precedence, it is left associative: \begin{everbatim*} \xintiiexpr 100-50-2\relax \end{everbatim*} \end{description} \precdesc{10} Comparison operators are (as in Python) all at the same level of precedence, use parentheses for disambiguation. \begin{description} \operdesc{<} |a} |a>b| evaluates to \dtt{1} if the strict inequality holds to \dtt{0} if not. \operdesc{==} |a==b| evaluates to \dtt{1} if equality holds to \dtt{0} if not. \operdesc{<=} |a<=b| evaluates to \dtt{1} if left hand side is at most equal to right hand side, to \dtt{0} if not. \operdesc{>=} |a>=b| evaluates to \dtt{1} if left hand side is at least equal to right hand side, to \dtt{0} if not. \operdesc{!=} |a!=b| evaluates to \dtt{1} if they differ, to \dtt{0} if not. \end{description} Comparisons can be chained arbitrarily, e.g., |x < y <= z != t| is equivalent to |x < y 'and' y <= z 'and' z != t| (and also to |all(x1}{true}{\error}, \xintifboolexpr{1<=2>=3<4>1}{\error}{false}, \xintifboolexpr{3 != 3! == 6 != 4! == 24}{true}{\error} \end{everbatim*} \precdesc{8} \begin{description} \operdesc{\Ampersand\Ampersand} logical conjunction. Evaluates to \dtt{1} if both sides are non-zero, to \dtt{0} if not. \operdesc{'and'} same as \verb+&&+. See also the \func{all} multi-arguments function. \fbox{Attention:}\IMPORTANTf{} with \ctanpackage{polexpr} loaded, which allows |'| in variable and function names, |'and'| can not follow a variable name. Add parentheses around the variable, or use |&&|. \end{description} \precdesc{6} \begin{description} \operdesc{\string|\string|} logical (inclusive) disjunction. Evaluates to \dtt{1} if one or both sides are non-zero, to \dtt{0} if not. \operdesc{'or'} same as as \verb+||+. See also the \func{any} multi-arguments function. \fbox{Attention:}\IMPORTANTf{} with \ctanpackage{polexpr} loaded, which allows |'| in variable and function names, |'or'| can not follow a variable name. Add parentheses around the variable, or use \verb=||=. \operdesc{'xor'} logical (exclusive) disjunction. \fbox{Attention:}\IMPORTANTf{} with \ctanpackage{polexpr} loaded, which allows |'| in variable and function names, |'xor'| can not follow a variable name. Add parentheses around the variable, or use the \func{xor} function syntax. \operdesc{\strut..} \operdesc{..[} \operdesc{{]..}} Syntax for arithmetic progressions. See \autoref{ssec:arithseq}. \operdesc{:} This is a separator involved in |[a:b]| Python-like slicing syntax. \end{description} \precdesc{4} \begin{description} \operdesc{\empty[} \operdesc{\empty]} Involved in Python-like slicing |[a:b]| and extracting |[N]| syntax. And its extension à la NumPy |[a:b,N,c:d,...,:]|. Ellipsis |...| is not yet implemented. The \myenquote{step} parameter as in |[a:b:step]| is not yet implemented. \end{description} \precdesc{3} \begin{description} \operdesc{,} The comma separates expressions (or function arguments).% % \footnote{The comma is really like a binary operator, which may be called ``join''. It has lowest precedence of all (apart the parentheses) because when it is encountered all postponed operations are executed in order to finalize its \emph{first} operand; only a new comma or a closing parenthesis or the end of the expression will finalize its \emph{second} operand.} % \begin{everbatim*} \xintiiexpr 2^3,3^4,5^6\relax \end{everbatim*} \end{description} \precdesc{2} \begin{description} \operdesc{[} \operdesc{]} The bracketers construct nestable \myenquote{array-like} structures. Arbitrary (heterogeneous) nesting is allowed. For output related matters see \csbxint{thealign} (its usage is optional, without it rendering is \myenquote{one-dimensional}). Output shape of non-homogeneous arrays is to be considered unstable at this time. \end{description} \precdesc{1} \begin{description} \operdesc{(} \operdesc{)} The parentheses serve as mandatory part of the syntax for functions, and to disambiguate precedences.% % \footnote{It is not apt to describle the opening parenthesis as an operator, but the closing parenthesis is analogous to a postfix unary operator. It has lowest precedence which means that when it is encountered all postponed operations are executed to finalize its operand. The start of this operand was decided by the opening parenthesis.} % They do not construct any nested structure. \operdesc{;} The semi-colon as involved as part of the syntax of \func{iter}, \func{rseq}, \func{ndseq}, \func{ndmap} has the same precedence as a closing parenthesis. \end{description} \item[|\relax|] This is the expression terminator for \csbxint{expr} et al. It may arise from expansion during the parsing itself. As alternative to \csbxint{expr} (et al.) use \csbxint{eval} (et al.) which have the usual macro interface (with one mandatory argument). \end{description} The |;| also serves as syntax terminator for \csbxint{defvar} and \csbxint{deffunc}. It can in this rôle not arise from expansion as the expression body up to it is fetched by a delimited macro. But this is done in a way which does not require any specific hiding for inner semi-colons as involved in the syntax of \func{iter}, etc... \subsection{Built-in functions}\label{ssec:builtinfunctions} See \autoref{tab:functions} whose elements are hyperlinked to the corresponding definitions. Functions are at the same top level of priority. All functions even \func{?} and \func{!} require parentheses around their arguments. % Table of functions \begin{table}[htbp] \capstart \centering \xintAssignArray\xintCSVtoList{!, ?, \textasciigrave\lowast\textasciigrave, \textasciigrave+\textasciigrave, abs, add, all, any, acos, acosd, Arg, Argd, asin, asind, atan, atand, atan2, atan2d, binomial, bool, ceil, cos, cosd, cot, cotd, cotg, csc, cscd, divmod, even, exp, factorial, first, flat, float, float\string_dgt, floor, frac, gcd, if, ifint, ifone, ifsgn, ilog10, iquo, irem, isint, isone, iter, iterr, inv, last, lcm, len, log, log10, max, min, mod, mul, ndmap, ndseq, ndfillraw, not, num, nuple, odd, pArg, pArgd, pfactorial, pow, pow10, preduce, qfloat, qfrac, qint, qrand, qraw, random, randrange, rbit, reduce, reversed, round, rrseq, rseq, sec, secd, seq, sgn, sin, sinc, sind, sqr, sqrt, sqrtr, subs, subsm, subsn, tan, tand, tg, togl, trunc, unpack, xor, zip} \to\Functions \cnta\Functions{0} \cntb\xinttheexpr ceil(\cnta/7)\relax\space \newcommand\builtinfunction[1]{\expandafter\expandafter\expandafter\func \expandafter\expandafter\expandafter{\Functions{#1}}}% \centeredline{\begin{tabular}{|*{7}{p{2cm}|}} \hline \xintFor* #1 in {\xintSeq{1}{\cntb}}\do {\builtinfunction{#1}& \builtinfunction{#1+\cntb}&% \builtinfunction{#1+2*\cntb}&% \builtinfunction{#1+3*\cntb}&% \builtinfunction{#1+4*\cntb}&% \builtinfunction{#1+5*\cntb}&% \ifnumgreater{#1+6*\cntb}{\cnta} {} {\builtinfunction{#1+6*\cntb}}% \\\hline}% \end{tabular}} \caption{Functions (click on names)}\label{tab:functions} \etoctoccontentsline {xinttable}{\protect\emph{Table of functions in expressions}} \etocsetnexttocdepth{subsubsection} \localtableofcontents \end{table} Miscellaneous notes: \begin{itemize}[nosep] \item since release |1.3d| \func{gcd} and \func{lcm} are extended to apply to fractions too, and do NOT require the loading of \xintgcdname, \item The randomness related functions \func{random}, \func{qrand} and \func{randrange} require that the \TeX\ engine provides the \csa{uniformdeviate} or \csa{pdfuniformdeviate} primitive. This is currently the case for |pdftex|, |(u)ptex|, |luatex|, and also for |xetex| since \TeX Live 2019.\IMPORTANT \item \func{togl} is provided for the case |etoolbox| package is loaded, \item \func{bool}, \func{togl} use delimited macros to fetch their argument and the closing parenthesis must be explicit, it can not arise from on the spot expansion. The same holds for \func{qint}, \func{qfrac}, \func{qfloat}, \func{qraw}, \func{random} and \func{qrand}. \item Also \hyperlink{ssec:dummies}{functions with dummy variables} use delimited macros for some tasks. See the relevant explanations there. \item Functions may be called with \emph{oples} as arguments as long as the total length is the number of arguments the function expects. \end{itemize} \subsubsection{Functions with no argument} \begin{description} % [parsep=0pt,align=left, % leftmargin=0pt, itemindent=0pt, % labelwidth=-\fontdimen2\font, labelsep=\fontdimen2\font, labelindent=0pt, % listparindent=\leftmarginiii] \funcdesc[]{random} returns a random float |x| verifying |0 <= x < 1|. It obeys the prevailing precision as set by \csbxint{Digits}: i.e.\@{} with |P| being the precision the random float multiplied by |10^P| is an integer, uniformly distributed in the |0..10^P-1| range. This description implies that if |x| turns out to be |<0.1| then its (normalized) mantissa has |P-1| digits and a trailing zero, if |x<0.01| it has |P-2| digits and two trailing zeros, etc... This is what is observed also with Python's |random()|, of course with |10| replaced there by radix |2|.% \begin{everbatim*} \pdfsetrandomseed 12345 \xintDigits:=37\relax \xintthefloatexpr random()\relax\newline \xintthefloatexpr random()\relax\par \end{everbatim*} \funcdesc[]{qrand} returns a random float |0 <= x < 1| using \dtt{16} digits of precision (i.e.\@{} |10^{16}x| is an integer). This is provided when speed is a at premium as it is optimized for precision being precisely \dtt{16}.% \begin{everbatim*} % still with 37 digits as prevailing float precision \xintthefloatexpr qrand(), random()\relax\newline \xintDigits:=16\relax \xintthefloatexpr qrand(), random()\relax\par \end{everbatim*} One can use both |qrand()| and |random()| inside the |\xintexpr| parser too. But inside the integer only |\xintiiexpr| parser they will cause some low-level error as soon as they get involved in any kind of computation as they use an internal format not recognized by the integer-only parser. See further \func{randrange}, which generates random integers. Currently there is no |uniform()| function% % \footnote{Because I am not sure how to handle rounding issues: should the computation proceed exactly and a rounding be done only at very end?} % but it can be created by user: \begin{everbatim*} \xintdeffloatfunc uniform(a, b):= a + (b-a)*random(); \romannumeral\xintreplicate{10}% {% \xintthefloatexpr uniform(123.45678, 123.45679)\relax\newline }% \end{everbatim*} \funcdesc[]{rbit} returns a random |0| or |1|. \end{description} \subsubsection{Functions with one argument} \begin{description} % [parsep=0pt,align=left, % leftmargin=0pt, itemindent=0pt, % labelwidth=-\fontdimen2\font, labelsep=\fontdimen2\font, labelindent=0pt, % listparindent=\leftmarginiii] \funcdesc{num} truncates to the nearest integer (truncation towards zero). It has the same sign as |x|, except of course with |-1