% -*- coding: utf-8; time-stamp-format: "%02d-%02m-%:y at %02H:%02M:%02S %Z" -*- % This file: xint.dtx. Proudly produced by xint-dtxbuild.sh. % Extract all files via "etex xint.dtx" and do "make help" % or follow instructions from extracted README.md. %<*dtx> \def\xintdtxtimestamp {Time-stamp: <11-06-2022 at 19:36:36 CEST>} % %<*xintdrv|sourcedrv|alldrv> %% --------------------------------------------------------------- \def\xintdocdate {2022/06/11} \def\xintbndldate{2022/06/10} \def\xintbndlversion {1.4m} % %% README %% CHANGE LOG %% xint 1.4m %% 2022/06/10 % % Source: xint.dtx 1.4m 2022/06/10 (doc 2022/06/11) % Author: Jean-Francois Burnol % Info: Expandable operations on big integers, decimals, fractions % License: LPPL 1.3c % %<*!readme&!changes&!dohtmlsh&!makefile> %% --------------------------------------------------------------- %% The xint bundle 1.4m 2022/06/10 %% Copyright (C) 2013-2022 by 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 binary and hexadecimal conversions %%% 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 =========== It is possible to use the package both with Plain (`\input xintexpr.sty`) or with the LaTeX macro format (`\usepackage{xintexpr}`). The basic aim is provide *expandable* computations on (arbitrarily big) integers, fractions, and floating point numbers (at a user chosen precision). The four operations and the square-root extraction achieve the *correct rounding* for the given arbitrary precision. Exponential (natural and to the base ten), logarithm (also to the base 10), fractional powers, direct and inverse trigonometrical functions are available up to 62 digits of precision. The syntax supports dummy variables (to generate sequences of values) and nested structures. Support for user-declared functions and variables is implemented. Here is an example of everyday typical calculation by `xintexpr` users: \xinteval{reduce(add(1/i^3, i=1..25))} It expands to: 2560976152652211536408111110189/2131858131361319942957376000000 Usage on the command line ========================= One can use `xintexpr` as an interactive calculator on the command line. See the [xintsession](http://ctan.org/pkg/xintsession) package. >>> 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 132207081948080663689045525975... (trimmed for this README) Installation ============ `xint` is included in [TeXLive](http://tug.org/texlive/) (hence [MacTeX](http://tug.org/mactex/) also) and in [MikTeX](http://www.miktex.org/). Thus, use the package manager to update your distribution. Direct installation of both the macro files and the documentation into a TDS-compliant hierarchy is available via [`xint.tds.zip`](http://mirror.ctan.org/install/macros/generic/xint.tds.zip) and usage of `unzip`. For example, on a macOS system, installation in user repertory: unzip xint.tds.zip -d ~/Library/texmf Admin privileges may be needed if the target repertory requires it. Else, one can download `xint.dtx` from https://www.ctan.org/tex-archive/macros/generic/xint and execute `etex xint.dtx` which will extract all macro files (those with extension `.sty`). One then only needs to move them to a location where `TeX` can find them. To build the documentation one can execute `latex` directly on `xint.dtx` (at least three times, perhaps more, so `latexmk` is recommended) then `dvipdfmx` or directly `pdflatex`. The resulting `xint.pdf` includes both the user manual and the commented source code, with hyperlinks. For those on Unix-like systems the recommended way is to fetch also `Makefile` from the location above (or to rename the extracted `Makefile.mk` into `Makefile`), then one can execute `make xint.pdf` (user manual only), or `make sourcexint.pdf` or `make xint-all.pdf`. These targets will require `latexmk`. Further help can be obtained via `make help` or from the comments in extracted files `xint.tex`, `sourcexint.tex`, and `xint-all.tex`. Documentation ============= `README.md`: this file `CHANGES.html`: change log as relevant to end users (`texdoc --list xint`) `xint.pdf`: user manual `sourcexint.pdf`: commented source code (`texdoc --list xint` or `texdoc sourcexint`) License ======= Copyright (C) 2013-2022 by Jean-Francois 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-Francois Burnol`. This Work consists of the files `xint.dtx` and `Makefile` and extracted files inclusive of the macro files `xint*sty` as well as derived documentation files such as `xint.pdf`, `sourcexint.pdf` and `CHANGES.html` See `xint.pdf` for contact information. %-------------------------------------------------------- %<*changes>------------------------------------------------------- `1.4m (2022/06/10)` ---- The fix of a compatibility bug with `miniltx` and the already in place documentation improvements (in particular, hyperlinked macro names in code lines) motivated release `1.4m`. With some hesitation I decided to not revert the removals and breaking changes listed here and which had been already acted in preparation of an hypothetic future `1.5`. ### Removed - **xintexpr**: `\xintdefefunc` et al., deprecated at `1.4` have been removed. - **xintexpr**: `\thexintexpr` et al., deprecated at `1.4b` have been removed. Use `\xinttheexpr` et al. - **xintlog**: `\poormanloghack` which was a no-op since `1.4e` has been removed. - **xintfrac**: `\xintFrac`, `\xintFwOver`, `\xintSignedFrac`, `\xintSignedFwOver` now raise errors. They were deprecated at `1.4g`, check the documentation for the new names `\xintTeXFrac` et al. ### Breaking changes - **xintexpr**: `\xinttheboolexpr` now outputs `true` or `false` (to match TeX conventions) and not the `True` or `False` employed since `1.4` (inside expressions `true`, `false`, `True` and `False` are all recognized keywords anyhow). - The `\pdfstrcmp/\strcmp` engine primitive is required. With `LuaTeX` it is emulated via `Lua` code basically copied over from `LaTeX3`. Not sure if this is breaking as the package already requires the `\expanded` primitive. Only used so far by (as expected) `\xintiiCmp`, and macros which will end up calling it. ### Bug fixes - **xintexpr**: with `\input xintexpr.sty\relax` in `(pdf)eTeX` plus `miniltx` (naturally, if `miniltx` was already loaded), and with versions up to `1.4k` the `xinttrig` and `xintlog` aborted their own `xintexpr`-triggered input erroneously thinking the latter had not yet been loaded, and emitted only a very discrete message to the log file. With `1.4l` it became worse as `\input xintexpr\relax` auto-repeated itself about six times until `TeX` called it quits. ### Improvements - Documentation: most macros are hyperlinked in the source code to the code line of their definitions. Furthermore, from the place of the definition the main macros will link to either their descriptions in the user manual (in `xint-all.pdf`) or in the implementation part (`sourcexint.pdf`). Conversely inside `xint-all.pdf` the macro descriptions are linked towards their implementation. You may notice some time lag with some pdf viewers on opening the heavily hyperlinked `sourcexint.pdf` compared to previous releases. - Not sure if that counts as an improvement, but I have shortened the wording of the expandable error messages, which had been last modified at `1.4g`. `1.4l (2022/05/29)` ---- ### Bug fixes - **xintkernel**: ever since `1.4`, loading anyone of the `xint*sty` packages left the catcode of the character of ascii code `1` to the internal custom value `3`. - **xintfrac**: the `\xintPFloat` checks for an output being an integer in decimal notation or a number with a one-digit trimmed mantissa could fail if `\xintPFloatMinTrimmed` (added at `1.4k`) was large enough, e.g. equal to the target precision. Then, the outputs always kept trailing zeros, as expected in general but not for those special cases. - **xintlog**, **xinttrig**: since `1.4e` the message emitted if `\usepackage{xintlog}` or `\usepackage{xinttrig}` was encountered in place of the correct `\usepackage{xintexpr}` was wrong. It advised to use `\input xintexpr.sty\relax`, which would have failed with LaTeX. The warning is corrected and now the macro file in place of aborting will (be it with or without LaTeX) trigger the loading of `xintexpr` (hence of itself after it). - The possibility to run `latex` directly on `xint.dtx` had been broken since `1.4i`. ### New features - **xintfrac**: `\xintRawBraced` as a public alias to an **xintfrac** entry point to its core input handler. Experimental additions `\xintSignBit` and `\xintFloatBraced`. Deprecate `\xintTeXfromSci` in favor of new name `\xintTeXFromSci`, and remove its `\expanded` wrapper (so it is not f-expandable anymore). Add `\xintTeXFromScifracmacro`. - **xintfrac**, **xintexpr**: `\xintFracToSci` and `\xintFracToDecimal` now behave like all other **xintfrac** macros in terms of allowed arguments and f-expandability and have been moved back to **xintfrac**. ### Documentation - Renewed random shuffling of large parts of the documentation has greatly improved it. - Simpler build flow to produce a `pdf` containing both user manual and source code. Removal of dependency on `grep` binary for such builds or the one of `sourcexint.pdf`. Fix of various obsoleted comments in extracted files involved in the documentation build process. `1.4k (2022/05/18)` ---- ### Breaking changes - **xintfrac**: the longstanding (but documented as undecided and unstable) way of `\xintFloat` to output the zero value was `0.e0` and it has now been modified into `0.0e0`. Now customizable via `\xintFloatZero`. - **xintfrac**/**xintexpr**: the behaviour of `\xintPFloat` (hence of `\xintfloateval`) has again changed: when the output is an integer (not using scientific notation) it does not get postfixed by `.0`. This applies in particular for the zero value, now printed `0`. Similarly, in the case of scientific notation with a single-digit (trimmed) mantissa, no `.0` is used. Customizable via `\xintPFloatIntSuffix`, `\xintPFloatLengthOneSuffix`, and `\xintPFloatZero`. Also, `\xintPFloat` trims trailing zeros from the full significand only if there are, by default, at least `4` of them, see `\xintPFloatMinTrimmed`. - **xintfrac**/**xintexpr**: macro definition of `\xintFracToSci` migrated from the former to the latter (see `1.4l` for update). - **xintexpr**: `\xintexpr{Safe,Restore}Catcodes` pairs now behave like a "last in first out" stack. Check the `pdf` documentation for details. ### Bug fixes - **xintexpr**: the `\xintexpr{Safe,Restore}Catcodes` were documented at user level, but also used by the package `\xintdefvar` or `\xintdeffunc`. This could result in some bad interaction due to the somewhat strange (but documented) behaviour of nested `\xintexpr{Safe,Restore}Catcodes` (which has now been modified). - **xintexpr**: ever since `1.4`, `\xintdefufunc` (but not `\xintdeffunc`) forgot to reset the catcodes to their status prior to the sanitization done by the macro at the start of its execution. ### New features - **xintfrac**: `\xintPFloatZero`, `\xintPFloatIntSuffix`, `\xintPFloatLengthOneSuffix`, `\xintPFloatNoSciEmax`, `\xintPFloatNoSciEmin` and `\xintPFloatMinTrimmed` customize the output of `\xintPFloat`, hence also of `\xintfloateval` (and of `\xinteval` when scientific notation was used in the expression). Also added `\xintFloatZero`. - **xintfrac**: `\xintFloatToDecimal`. - **xintexpr**: `\xintFracToDecimal`, an alternative to the default `\xintFracToSci` configuration of `\xintexprPrintOne`. - **xintexpr**: long awaited syntax `\xintieval[D]{...}` and `\xintfloateval[Q]{...}` now implemented. The legacy syntax with `\xintieval{[D]...}` and `\xintfloateval{[Q]...}` is kept for backwards compatibility. `1.4j (2021/07/13)` ---- ### Bug fixes - **xinttools**: a brace removal bug affected the venerable `\xintSeq` if producing a single number (e.g. `\xintSeq{10}{10}` expanded to `10` not `{10}`). Thanks to Christophe Poulain for report. `1.4i (2021/06/11)` ---- ### New features - **xintexpr**: the concept of simultaneous assignments is extended: in case of more variables than values the extraneous variables do not cause an error message but are simply set to the `nil` value; in case of more values than variables, the last variable is defined to be the ople concatenating all the extra values. - **xintexpr**: built-in functions usable with arbitrarily many arguments such as `max()`, `gcd()`, or `len()` are now again usable with a single numeric argument: since `1.4` a lone argument had to be a `nutple` (which was automatically unpacked). It can now again be a number. ### Bug fixes - **xintexpr**: simultaneous assignments via `\xintdefvar` to 10 or more variables was broken if the right hand side was an ople (of length at least 10, as it had prior to this release to match the number of variables). - **xintexpr**: the mechanism which allows to define variables with names already in use for pre-existing functions was broken for some built-in functions: those handling syntax with dummy variables (currently `subs()`, `subsm()`, `subsn()`, `seq()`, `add()`, `mul()`, `ndseq()`, `ndmap()`, `ndfillraw()`) and the so-called "pseudo" functions (currently `bool()`, `togl()`, `protect()`, `qint()`, `qfrac()`, `qfloat()`, `qraw()`, `random()`, `qrand()`, `rbit()`). For example the function `seq()` was broken if the user had defined a variable `seq`. `1.4h (2021/05/27)` ---- ### Bug fixes - **xintexpr**: the recent `1.4g` introduced a bug breaking input of the type ``. - **xintexpr**: since `1.4` (`2020/01/31`) the `omit` and `abort` keywords were broken if used inside a substitution, itself nested in a `seq()` or similar construct. - **xintexpr**: since `1.4c` the `\xintthespaceseparated` (added at `1.4a`) inserted two, not one, spaces at one specific location near the end of its output. A bit cosmetic problem, fixed nevertheless. `1.4g (2021/05/25)` ---- ### Breaking changes - **xintexpr**: the parsing of power operators `**` and `^` now proceeds in a right associative way: `2^3^4==2^(3^4)`. - **xintexpr**: single-character operators `&`, `|`, and `=` (deprecated since `1.1`) have been removed. Use `&&`, `||` and `==` respectively. ### Deprecated - **xintfrac**: old typesetting macros dating back to `1.03` and `1.04` releases `\xintFrac`, `\xintSignedFrac`, `\xintFwOver`, `\xintSignedFwOver` are deprecated. Please use the new names `\xintTeXFrac`, `\xintTeXsignedFrac`, `\xintTeXOver`, `\xintTeXsignedOver`. The old names will emit warnings. ### New features - Messages written to the terminal and log file during the handling of recovery from exceptions use a new mechanism; when in interactive mode, the user is prompted only once, not thrice, to enter `` for recovery and continued processing. - **xintfrac**: `\xintTeXfromSci` (added about 7 or 8 years too late) to help typesetting values output by `\xintfloateval` in a more useful way than `\xintTeXFrac` (formerly `\xintFrac`). ### Bug fixes - **xintexpr**: with **xintbinhex** loaded, `"` is recognized as prefix for hexadecimal input; but a bug (present ever since this support for hexadecimal input was added) caused syntax such as `"\macro` to break the parser. Also, leading zeros such as in `"0000A` where not properly trimmed since `1.2m`. - **xintexpr**: authorize `x! == y` without parentheses. Formerly the parser mis-interpreted `!` as first character of the `!=` not-equal-to comparison operator, subsequently causing breakage when finding the second `=`. - **xintexpr**: various error situations were badly handled. - `\xinteval{1/0}` did not recover gracefully due to longstanding bug in **xintfrac**. - `\xintfloateval{1/0}` did not recover gracefully either... due to some other reason. - recovery from encountering an unknown variable name was broken since `1.4`; also, with an unknown function name if in `\xintfloatexpr`. - `\xinteval{_4}` caused an infinite loop (with underscore `_` having its normal catcode). This was unexpected, as the `_` is documented to be ignored if in-between digits (and is ignored if last after some digits). It will be now ignored also if encountered upfront. A similar problem existed with variable names starting with a `_` (of normal catcode), which however are clearly not legal. The (normal catcode) `_` will then be ignored as well if encountered in front of a variable or function name (but not inside of course). - ``\xinteval{\catcode`@}`` crashed (one had to use an added `\the` or `\number`). - illegal ``\xinteval{/3}`` was not intercepted and ultimately caused low-level errors (same with `^`). Surely, further situations remain where bad input will crash parser. `1.4f (2021/05/10)` ---- ### Breaking changes - **xintexpr**: `\xintieval{[-D]...}`, which rounds to a multiple of `1eD` for `D` positive now *does not insert the trailing zeros* (as done at `1.4e`) *nor a scientific part* `eD` (as prior to `1.4e`). The use case envisioned is for the quantized value to be used with an appropriate unit, for example `k` for `D=3` or `M` for `D=6` etc... Sorry for the very long process which was needed to reach this final decision. - **xintexpr**: for Digits beyond the officially supported range for accurate math functions, i.e. for `D>62`, computations were still done and printed with full number of digits, but the extra digits were meaningless; they now operate on and output mantissas limited to `min(D,64)` digits. - **xintexpr**: for powers `a^b` with Digits at most `8`, the number `a` is now float-rounded to Digits before computation, as is done for `Digits>8`; previously `9` significant digits were kept. - **xintexpr**: further changes in the computation of powers, see the bug fixes below. - **xintexpr**: the `float_()` function got renamed into `float_dgt()`. ### Bug fixes - **xintexpr**: the documentation said `float_()` function had been renamed `float_dgt()` but actually that was not yet the case. - **xintexpr**: powers `a^b` (with exponent `b` neither integer nor half-integer) stopped being accurate regarding the last digits for `|b|` about `1000` and beyond. Except for `0.81` and the scientific part is dropped if the exponent vanishes. In this way the output of `\xinteval` can be pasted to alternative software. - The output format of `\xinthe\xintboolexpr` also has changed. It uses `True` and `False` (which are accepted on input), and this can easily be configured otherwise (also `true` and `false` are accepted on input). - The "broadcasting" (as it turned out, à la `NumPy`) of scalar operations on one-dimensional "lists", e.g `3*[1,3,5,7]+10` acting itemwise is **dropped**. It is hoped to implement such operations again in stronger form in future releases. Pre-existing alternative syntax is available, also to produce the bracketed (cf. next item) `[13,19,25,31]` which will be the output in future. - The `divmod()` function now produces on output such a bracketed pair, but simultaneous assignment such as `\xintdefvar xq, xr = divmod(a,b);` will work transparently. - The syntax for using conditionals in function declarations has changed. Now, one *must* use the `?` and `??` short-circuit boolean branching operators whereas in the past it was explained that the syntax had to use the `if()` and `ifsgn()` functions. - Macros `\xintGCD`, `\xintLCM`, `\xintGCDof` and `\xintLCMof` formerly provided by **xintgcd** got moved to **xintfrac** (which is not loaded by **xintgcd**). Moreover, they were extended to handle general fractions on input but this also means that their output is now obiding by the raw **xintfrac** format. The integer only `\xintiiGCD`, `\xintiiLCM` also got moved out of **xintgcd**, but to **xint** which is now loaded automatically by **xintgcd**. The few remaining macros of **xintgcd** at least do not need other imports as **xintgcd** now loads also automatically **xinttools** which is a dependency for two of them. ### Improvements and new features Please note that this list is currently incomplete. For more information look at the user manual and the documented source code `sourcexint.pdf`. Unless otherwise specified all changes commented upon here regard **xintexpr**. Important: all the new syntax is to be considered experimental. The author may change some names in future release, or even the interface (whether to use semi-colons or colons etc...). - The `\csname` encapsulation technique used since **xintexpr** initial release (`1.07 2013/05/25`) to move around possibly large data during expansion-only operations is replaced with methods based on the `\expanded` engine primitive. The latter is available in all major engines since TeXLive 2019. Formerly, and with default memory settings, one would typically saturate the string pool memory after about of the order of 50,000 independent floating point evaluations of expressions of average complexity on 16-digits numbers. There is thus no string pool memory impact at all but one can now hit TeX's main memory limit (which typically stands at 5,000,000 words) from defining large variables or generating on the fly large data. TeX distributions have a configuration file allowing to enlarge TeX memory parameters and regenerate the (eTeX based) formats. - The package supports input and output of arbitrarily *nested lists*, a.k.a. *oples* or *nlists*, with `[...]` as the constructor of *bracketed lists*, a.k.a *nut-ples*. Operations on these objects (as briefly surveyed in later items) are inspired from syntax and functionalities of `NumPy`'s *ndarrays*. Our *oples* (hence also their packaged form *nut-ples*) may have *leaves* at varying depths rather than obeying an N-dimensional hyperrectangular shape. But the syntax does provide specific constructors for *ndlists* (i.e. hyperrectangular *oples* or *nut-ples*). In a (distant?) future, perhaps **xintexpr** itself or a third-party package will provide an interface, say `\xintstorearray`, `\xintgetarray`, to store (which can not be expandable) and retrieve (which can be expandable and thus be embedded inside expressions parsed by `\xintexpr`, `\xintiiexpr` or `\xintfloatexpr`) such *ndlists* from TeX memory. This is why the package does not use the word *ndarray* and reserves it for such memory stored objects. - The `*` serves as *unpacking* operator on *nut-ples*, i.e. reversing the `[]` bracketing of an *ople*. - *oples* have no exact equivalent in `Python`. For example **xintexpr** allows `foo(Var1, x)` if `foo` is a function of 4 variables and `Var1` is a variable producing a length 3 *ople*, or `foo(Var2)` if `Var2` is a variable producing a length 4 *ople*. Python would require here to use explicitly the `*`-unpacking notation on some "packed" objects. Variable and function values may be *oples* (even *nil*), but in function declarations variables must stand for *one-ples*, i.e. either *numbers* or *nut-ples* (as there is no non-ambiguous way to split e.g. 5 arguments into two separate *oples*). - Simultaneous assignment to at least two variables via `\xintdefvar` et al. automatically unpacks the assigned value if it is a *one-ple*. If this value was in fact a *number*, low-level errors will result shortly afterwards as no check is done if the unpacking was illicit. (update: this last remark does not apply since the `1.4i` extension to the concept of simultaneous assignments) - The `NumPy` concept and syntax for nested slicing and item selection are implemented. Currently *stepping* and the *Ellipsis object* are not yet available. Only so-called basic slicing is currently supported. (The author has not yet read the section of `NumPy` documentation on so-called *advanced indexing*). - The *broadcasting* of scalar operations, such as itemwise addition or multiplication of *nut-ples* of the same shape is **not yet implemented**. - Slicing and indexing apply also at top level to the *oples* with behaviour conforming to intuitive expectations (see user manual); if it turns out the *ople* is in fact a *nut-ple*, the top-level slicing/indexing switches to the `Python/NumPy` conventions, i.e. it operates inside the brackets for slicing and removes brackets if indexing. - The syntax `ndseq(expression in x, y, ..., x = values; y = values; ...)` constructs a (bracketed) *ndlist* by evaluation the expression on all possible Cartesian n-uples, where the first variable indexes the first axis, the second the next, etc... - The `ndmap(foo, values1; values2; ...; valuesN)` syntax constructs a (bracketed) *ndlist* by evaluating the function `foo` on all elements of the cartesian product of the given (one-dimensional) value lists. - The two concepts of `\xintdeffunc` (for recursive definitions) and `\xintdefefunc` (for functions which expand immediately in other function declarations) have been merged. The `\xintdefefunc` et al. are deprecated and kept as aliases for `\xintdeffunc` et al. - `\xintdefufunc` allows to define so-called *universal functions*, i.e. functions `foo` such that `foo(myople)` will apply itemwise at arbitrary depth in the nested structure. The function `foo` is allowed to produce from a scalar an *ople*... - The variables in function declarations can now be multi-letter words. - The last positional variable in a function declaration can be prefixed with a `*` meaning exactly as in Python (*variadic* function argument) that it stands for a one-dimensional *nut-ple* receiving all remaining arguments from the function call beyond the first positional ones. It is thus an optional argument, but syntax for named optional arguments with default values is not yet implemented. - Dummy variables used in constructors can also be multi-letter words, if they have been declared as such. - In variable and function declarations, if the expression contains inner semi-colons, it is not needed anymore to brace them to avoid mis-interpretation as the final semi-colon which is mandated by the syntax to serve as expression terminator. - `subsm(expression, var1 = value1; var2 = value2; ...)` provides a leaner syntax for multiple substitutions; they must be independent, though. - `subsn(expression, var1 = value1; var2 = value2; ...)` provides a leaner syntax for nested substitutions, i.e., each `valueJ` may be an expression using the dummy variables `varK` with `K>J`. And finally of course the evaluated expression can refer to all variables. - `\xintthealign\xintexpr...\relax` (or with `\xintfloatexpr` or `\xintiiexpr` or `\xintboolexpr`...) will use a TeX alignment to display *oples*. The output (for regular N-dimensional lists) looks very similar to what `Python/NumPy` produces in interactive session. This is entirely configurable and can also be set-up to be used for writing into external files. Attention that `\xintthealign` only works if followed by `\xintexpr` et al., not by `\xinteval{}`. - It is now possible to use `\xintexpr...\relax` directly for typesetting. The syntax `\xinteval{...}` or `\xintthe\xintexpr...\relax` is needed only if one wants the expansion to give the explicit digits, but `\xintexpr...\relax` by itself will typeset as would have the other ones. Further it can be used in so-called moving arguments, because when output to an external file it uses only characters with standard catcodes (and produces the same protected and re-tokenizable result it would in an `\edef`.) As formerly, `\xintexpr...\relax` is the preferred way to include an expression into another one. Using `\xinteval` is a waste because it forces the outer parser to re-digest all the digits (or now also the square brackets). - The output format of `\xintfloateval` with scientific notation has not changed (apart from possible presence of bracketed lists), but the author hesitates because the *prettifying* it does by default is not really adapted to display of arrays (see `\xintthealign`). Anyway, this is configurable by the user. It is possible to specify whether to use `e` or `E`. - Function declarations are able to parse a much wider part of the syntax, but some severe limitations remain. Refer to the user manual for related information. - We have made an effort on some error messages, and when working interactively in a shell it may even be sometimes possible to insert for example a correct variable or function name in place of the not recognized one. But don't expect miracles when trying to intervene in the midst of a purely expandable expansion... ### Bug fixes Bugs? Those identified in `1.3f` were almost features. As per `1.4` the code base of **xintexpr** received multiple successive core refactorings and added numerous new features, and our test suite although significantly enlarged is not yet extensive enough. Please report bugs by mail. ### TODO - The long delayed overhaul of how floating point numbers are handled is delayed again. It has remained basically identical to its initial provisory version from `1.07 2013/05/25` (which was based upon what was originally only a set of expandable macros for computations with big integers), and suffers from the author lack of knowledge of the notion of "data type" in modern programming. Indeed, he never took a CS class, and disables JavaScript in his browser (or allows only select non-tracking scripts, a rare beast in modern days). - Prior to integrating all of `NumPy`, it is envisioned to start with matrix algebra first. `1.3f (2019/09/10)` ---- ### Improvements and new features - **xintfrac**: `\xintDigits = P;` syntax (i.e. without a colon) is now accepted in addition to `\xintDigits := P;`. Document that the ending semi-colon can not be an active character and that it has always been allowed to use in its place a non-expanding token e.g. `\xintDigits := 32\relax`. Add `\xintSetDigits`. - **xintexpr**: add starred variants `\xintDigits*` and `\xintSetDigits*` which execute `\xintreloadxinttrig`. Revert 1.3e ban on usage of `\xinteval` et al. inside expressions by `\xintdeffunc`. And make them usable also inside macro definitions via `\xintNewExpr`. ### Bug fixes - **xintexpr**: fix bug preventing usage of `\xintdefefunc` to define a function without variables. Fix some issue with `\xintfloatexpr[D]..\relax` if used inside an expression parsed by `\xintdeffunc` et al. `1.3e (2019/04/05)` ---- ### Breaking changes - (_reverted at 1.3f_) When defining functions, sub-expressions can only use the `\xint(float)expr...\relax` syntax. One can not use there the `\xint(float)eval` wrappers. ### Improvements and new features - The **xinttrig** library is automatically loaded by **xintexpr**. It provides direct and inverse trigonometrical functions using either degrees or radians with a precision of up to (a bit less than) 60 digits. It is for the most part implemented using high level user interface, but will probably get some optimizations in future (and perhaps extension to more digits). - The **xintlog** library is automatically loaded by **xintexpr**. It uses [poormanlog](http://ctan.org/pkg/poormanlog) to provide logarithms and exponentials with almost 9 digits of precision. Extended precision is for a future release. - **xintexpr**: `\xintdefefunc`, `\xintdeffloatefunc`, `\xintdefiiefunc` define functions which are not protected against expansion in the definition of other functions; refer to `xint.pdf` for the related explanations. Notice that whole area of `\xintdef(e)func`, `\xintNewExpr`, `\xintNewFunction` is complex and to be considered still as work in progress as it has a number of shortcomings. - **xintexpr**: `inv()`, `ilog10()`, `sfloat()`, behaviour of `qfloat()` slightly modified. - **xintexpr**: `\xintensuredummy`, `\xintrestorelettervar`. - The optional argument of `\xintfloatexpr` or `\xintfloateval` (it must be at start of braced argument) can be negative; it then means to trim (and round) from the output at float precision that many least significant digits. ### Bug fixes - Some bugfixes related to user functions with no variables at all; they were dysfunctional. `1.3d (2019/01/06)` ---- ### Breaking changes - **xintexpr**: the `gcd()` and `lcm()` functions formerly converted their arguments to integers via `\xintNum`. They now handle general input with no such modification. - **xintexpr**: former `\xinteval`, `\xintieval`, `\xintiieval`, and `\xintfloateval` renamed to `\xintexpro`, `\xintiexpro`, `\xintiiexpro`, and `\xintfloatexpro`. ### Improvements and new features - **xintexpr**: the `gcd()` and `lcm()` multi-arguments functions have been refactored to handle general fractions. The dependency on **xintgcd** is removed. - **xintexpr**: three-way branching `\xintifsgnexpr`, `\xintifsgnfloatexpr`, `\xintifsgniiexpr` conditional macros. - **xintexpr**: `\xintunassignexprfunc`, `\xintunassigniiexprfunc`, `\xintunassignfloatexprfunc` to "undefine" functions. - **xintexpr**: `\xintunassignvar` really makes the (multi-letter) variable unknown (formerly, it only gave it value zero), - **xintexpr**: functions `isone()` and `isint()`. - **xintexpr**: `\xinteval`, `\xintieval`, `\xintiieval`, and `\xintfloateval` as synonyms to `\xinttheexpr...\relax` etc..., but with the (comma-separated) expression as a usual braced macro argument. ### Bug fixes - **xintcore**, **xintexpr** : division in `\xintiiexpr` was broken for a zero dividend and a one-digit divisor (e.g. ``0//7``) since `1.2p` due to a bug in `\xintiiDivMod` for such arguments. The bug was signaled (thanks to Kpym for report) and fixed shortly after `1.3c` release but I then completely forgot to upload a bugfix release to CTAN at that time, apologies for that. `1.3c (2018/06/17)` ---- ### Improvements and new features - **xintexpr**: with `\xintglobaldefstrue`, `\xintdefvar`, `\xintdeffunc`, `\xintNewExpr` et al. make definitions with global scope. - **xintexpr**: `qraw()` for fast input of (very many) comma separated numbers (in suitable raw format). - **xintexpr**: the colon in the `:=` part of the syntax for `\xintdefvar` and variants is now optional; and if present it may be an active character or have any (reasonable) catcode. - **xintexpr**: `\xintdefvar`, `\xintdeffunc` and their variants try to set the catcode of the semi-colon which delimits their arguments; of course this will not work if that catcode is already frozen. - `\xintUniformDeviate` is better documented and `sourcexint.pdf` is better hyperlinked and includes indices for the macros defined by each package. ### Bug fixes - **xintfrac**: since `1.3` release, it loaded **xintgcd** in contradiction to what the documentation says (hence also **xintexpr** loaded **xintgcd** automatically). There is no actual dependency so the loading is removed for now. `1.3b (2018/05/18)` ---- ### Improvements and new features All additions related to randomness are marked as work-in-progress. They require an engine providing the `\(pdf)uniformdeviate` primitive. - **xintkernel**: `\xintUniformDeviate`. - **xint**: `\xintRandomDigits`, `\xintXRandomDigits`, `\xintiiRandRange`, `\xintiiRandRangeAtoB`. - **xintfrac**: support macros (not public, mainly because internal format for floats is surely not final) for `random()` and `qrand()`. - **xintexpr**: `random()`, `qrand()`, and `randrange(A[, B])`. - **xintexpr**: when a function `foo()` is declared via `\xintdeffunc` (et al.) to be parameter-less, it can be used as `foo()`; formerly `foo(nil)` syntax was required. - The usual provision of user manual "improvements". `1.3a (2018/03/07)` ---- ### Removed - **xintcore**, **xint**, **xintfrac**: removal of the internal macros which were used at `1.2o` to add a deprecation mechanism; all deprecated macros have been removed at `1.3` so there was no reason to keep the code used for deprecating them. ### Improvements and new features - **xintexpr**: new conditionals `ifone()` and `ifint()`. - **xintfrac**: `\xintREZ` is faster on inputs having one hundred digits or more. - Added to the user manual mention of macros such as `\xintDivFloor`, `\xintMod`, `\xintModTrunc`, which had been left out so far. ### Bug fixes - **xintexpr**: the mechanism for adjunction to the expression parsers of user defined functions was refactored and improved at previous release `1.3`: in particular recursive definitions became possible. But an oversight made these recursive functions quite inefficient (to remain polite.) This release fixes the problem. `1.3 (2018/03/01)` ---- ### Breaking changes - **xintcore**, **xint**, **xintfrac**: all macros deprecated at `1.2o` got removed. - **xintfrac**: addition and subtraction of `a/b` and `c/d` now use the l.c.m. of the denominators. Similarly the macro supporting the modulo operator `/:` uses a l.c.m. for the denominator of the result. - **xintexpr**: the addition, subtraction, modulo `/:`, and the `mod()` and `divmod()` functions produce generally smaller denominators (see previous item). - **xintexpr**: formerly, the internal macros which are internally associated to user-declared functions were using comma separated parameter texts. They now do not use such commas (their meanings, which may again change in future, are written for information to the log under `\xintverbosetrue`). ### Improvements and new features - **xintexpr**: user-defined functions may now be of a recursive nature. This was made possible by a refactoring of the `\xintNewExpr` mechanism. It became both leaner and more extensive than formerly. - **xintfrac**: new macros `\xintPIrr` and `\xintDecToString`. The latter is a backport of a `polexpr 0.4` utility, and it is to be considered unstable. - **xintexpr**: new function `preduce()` associated with `\xintPIrr`. `1.2q (2018/02/06)` ---- ### Improvements and new features - **xintexpr**: tacit multiplication extended to cases such as `3!4!5!` or `(1+2)3`. ### Bug fixes - **xintcore**: sadly, refactoring at `1.2l` of subtraction left an extra character in an inner macro causing breakage in some rare circumstances. This should not have escaped our test suite! `1.2p (2017/12/05)` ---- ### Breaking changes - **xintgcd**: `\xintBezout{a}{b}`'s output consists of `{u}{v}{d}` with `u*a+v*b==d`, with `d` the GCD. Formerly it was `{a}{b}{u}{v}{d}`, and with `u*a-v*b==d`. - **xintgcd**: `\xintBezout{0}{0}` expands to `{0}{0}{0}`. Formerly (since `1.2l`) it raised `InvalidOperation`. - **xintcore**: `\xintiiMod` is now associated with floored division. The former meaning (associated with truncated division) is available as `\xintiiModTrunc`. - **xintfrac**: `\xintMod` is now associated with floored division. The former meaning is available as `\xintModTrunc`. - **xintexpr**: the ``//`` operator and its associated modulo ``'mod'`` (or ``/:``) now correspond to floored division, like the Python language `//`, `%`, and `divmod(x, y)`. Formerly they had been associated to truncated division. This is breaking change for operands of opposite signs. ### Improvements and new features - **xinttools**: `\xintListWithSep`, which had remained unchanged since its introduction at `1.04 (2013/04/25)`, was rewritten for increased speed. - **xintexpr**: `\xintdefvar`'s syntax is extended to allow simultaneous assignments. Examples: `\xintdefvar x1, x2, x3 := 1, 3**10, 3**20;` or `\xintdefiivar A, B := B, A 'mod' B;` for already defined variables `A` and `B`. - **xintexpr**: added `divmod()` to the built-in functions. It is associated with floored division, like the Python language `divmod()`. Related support macros added to **xintcore**, and **xintfrac**. ### Bug fixes - **xintgcd**: `\xintBezout{6}{3}` (for example) expanded to `{6}{3}{-0}{-1}{3}`, but the `-0` should have been `0`. - **xintgcd**: it still used macro `\xintiAbs` although the latter had been deprecated from **xintcore**. - **xintexpr**: in float expressions the `//` and `/:` (aka `'mod'`) operators did not round their operands to the float precision prior to computing with them, contrarily to other infix arithmetic operators and to the `mod(f,g)` function; thus, `mod(f,g)` and `f 'mod' g` were not completely equivalent. - various documentation fixes; in particular, the partial dependency of **xintcfrac** on **xinttools** had not been mentioned. `1.2o (2017/08/29)` ---- ### Breaking changes - **xint**: `\xintAND`, `\xintOR`, ... and similar Boolean logic macros do not apply anymore `\xintNum` (or `\xintRaw` if **xintfrac** is loaded), to their arguments (often, from internal usage of `\xintSgn`), but only f-expand them (using e.g. `\xintiiSgn`). This is kept un-modified even if loading **xintfrac**. ### Deprecated Deprecated macros raise an error but, generally, then expand as in former releases. They will all get removed at some future release. - **xintcore**: `\xintiOpp`, `\xintiAbs`, `\xintiAdd`, `\xintiSub`, `\xintiMul`, `\xintiDivision`, `\xintiQuo`, `\xintiRem`, `\xintiDivRound`, `\xintiDivTrunc`, `\xintiMod`, `\xintiSqr`, `\xintiPow`, and `\xintiFac` are deprecated. Only the `ii`-named variants get defined. - **xintcore**: `\xintCmp` and `\xintSgn` are deprecated from **xintcore** (which only defines `\xintiiCmp` and `\xintiiSgn`) as they actually belong to **xintfrac**. - **xintcore**: `\xintiiFDg`, resp. `\xintiiLDg`, are renamed `\xintFDg`, resp. `\xintLDg`. Former denominations are deprecated. - **xint**: `\xintMON`, `\xintMMON`, `\xintiMax`, `\xintiMin`, `\xintiMaxof`, `\xintiMinof`, `\xintiSquareRoot`, `\xintiSqrt`, `\xintiSqrtR`, `\xintiBinomial`, and `\xintiPFactorial` are deprecated. Only `ii`-named variants get defined. - **xint**: `\xintEq`, `\xintGeq`, `\xintGt`, `\xintLt`, `\xintGtorEq`, `\xintLtorEq`, `\xintIsZero`, `\xintIsNotZero`, `\xintIsOne`, `\xintOdd`, `\xintEven`, `\xintifSgn`, `\xintifCmp`, `\xintifEq`, `\xintifGt`, `\xintifLt`, `\xintifZero`, `\xintifNotZero`, `\xintifOne`, `\xintifOdd`, are deprecated. These macros belong to **xintfrac**. Package **xint** defines only the `ii`-named variants. - **xint**: `\xintNeq` was renamed to `\xintNotEq` which however is only provided by **xintfrac**. Package **xint** defines `\xintiiNotEq`, and `\xintNeq` is deprecated. - **xint**: `\xintNot` was renamed to `\xintNOT`, former denomination is deprecated. See also item about Boolean logic macros in the *Incompatible Changes* section. `1.2n (2017/08/06)` ---- ### Breaking changes - **xintbinhex** does not load package **xintcore** anymore, but only **xintkernel**. ### Improvements and new features - **xintbinhex** has only **xintkernel** as dependency. - Macros of **xintbinhex** have been improved for speed and increased maximal sizes of allowable inputs. `1.2m (2017/07/31)` ---- ### Breaking changes - **xintbinhex**: the length of the input is now limited. The maximum size depends on the macro and ranges from about `4000` to about `19900` digits. - **xintbinhex**: `\xintCHexToBin` is now the variant of `\xintHexToBin` which does not remove leading binary zeroes: `N` hex-digits give on output exactly `4N` binary digits. ### Improvements and new features - **xintbinhex**: all macros have been rewritten using techniques from the 1.2 release (they had remained unmodified since `1.08` of `2013/06/07`.) The new macros are faster but limited to a few thousand digits. The `1.08` routines could handle tens of thousands of digits, but not in a reasonable time. ### Bug fixes - user manual: the `Changes` section wrongly stated at `1.2l` that the macros of **xintbinhex** had been made robust against non terminated input such as ``\number\mathcode`\-``. Unfortunately the author fell into the trap of believing his own documentation and he forgot to actually implement the change. Now done. - user manual: the PDF bookmarks were messed up. - **xint**, **xintfrac**: `\xintGeq`, `\xintMax`, `\xintMin`, suffered from some extra overhead. This was caused by use of some auxiliaries from the very early days which got redefined at some stage. This is fixed here with some additional efficiency improvements and pruning of old code. `1.2l (2017/07/26)` ---- ### Removed - `\xintiiSumExpr`, `\xintiiPrdExpr` (**xint**) and `\xintSumExpr`, `\xintPrdExpr` (**xintfrac**). They had not been formally deprecated, but had been left un-documented since `1.09d (2013/10/22)`. - internal macro `\xint_gob_til_xint_relax` removed. ### Improvements and new features - the underscore character `_` is accepted by the **xintexpr** parsers as a digit separator (the space character already could be used for improved readability of big numbers). It is not allowed as *first* character of a number, as it would then be mis-interpreted as the start of a possible variable name. - some refactoring in **xintcore** auxiliary routines and in `\xintiiSub` and `\xintiiCmp` for some small efficiency gains. - code comments in **xintcore** are better formatted, but remain sparse. - **xintcore**, **xint**, **xintfrac**, ... : some macros were not robust against arguments whose expansion looks forward for some termination (e.g. ``\number\mathcode`\-``), and particularly, most were fragile against inputs using non-terminated ``\numexpr`` (such as `\xintiiAdd{\the\numexpr1}{2}` or `\xintRaw{\numexpr1}`). This was not a bug per se, as the user manual did not claim such inputs were legal, but it was slightly inconvenient. Most macros (particularly those of **xintfrac**) have now been made robust against such inputs. Some macros from **xintcore** primarily destined to internal usage still accept only properly terminated arguments such as ``\the\mathcode`\-`` or ``\the\numexpr1\relax``. The situation with expressions is unchanged: syntax such as `\xintexpr \numexpr1+2\relax` is illegal as the ending `\relax` token will get swallowed by the `\numexpr`; but it is needed by the ``xintexpr``-ession parser, hence the parser will expand forward and presumably end with in an "illegal token" error, or provoke some low-level TeX error (N.B.: a closing brace `}` for example can not terminate an ``xintexpr``-ession, the parser must find a `\relax` token at some point). Thus there must be in this example a second `\relax`. - experimental code for error conditions; there is no complete user interface yet, it is done in preparation for next major release and is completely unstable and undocumented. ### Bug fixes - **xintbinhex**: since `1.2 (2015/10/10)`, `\xintHexToDec` was broken due to an undefined macro (it was in `xint.sty`, but the module by itself is supposedly dependent only upon `xintcore.sty`). - **xintgcd**: macro `\xintBezout` produced partially wrong output if one of its two arguments was zero. - **xintfrac**: the manual said one could use directly `\numexpr` compatible expressions in arithmetic macros (without even a `\numexpr` encapsulation) if they were expressed with up to 8 tokens. There was a bug if these 8 tokens evaluated to zero. The bug has been fixed, and up to 9 tokens are now accepted. But it is simpler to use `\the\numexpr` prefix and not to worry about the token count... The ending `\relax` is now un-needed. `1.2k (2017/01/06)` ---- ### Breaking changes - macro `\xintFloat` which rounds its input to a floating point number does _not_ print anymore `10.0...0eN` to signal an upwards rounding to the next power of ten. The mantissa has in all cases except the zero input exactly one digit before the decimal mark. - some floating point computations may differ in the least significant digits, due to a change in the rounding algorithm applied to macro arguments expressed as fractions and to an improvement in precision regarding half-integer powers in expressions. See next. ### Improvements and new features - the initial rounding to the target precision `P` which is applied by the floating point macros from **xintfrac** to their arguments achieves the _exact (aka correct) rounding_ even for inputs which are fractions with more than `P+2` digits in their numerators and denominators (`>1`.) Hence the computed values depend only on the arguments as rational numbers and not upon their representatives. This is not relevant to _expressions_ (**xintexpr**), because the `\xintfloatexpr` parser sees there `/` as an operator and does not (apart from special constructs) get to manipulate fractions as such. - `\xintnewdummy` is public interface to a `1.2e` macro which serves to declare any given catcode 11 character as a dummy variable for expressions (**xintexpr**). This is useful for Unicode engines (the Latin letters being already all pre-declared as dummy variables.) - added `\xintiSqrtR`, there was only `\xintiiSqrtR` alongside `\xintiSqrt` and `\xintiiSqrt` (**xint**). - added non public `\xintLastItem:f:csv` to **xinttools** for faster `last()` function, and improved `\xintNewExpr` compatibility. Also `\xintFirstItem:f:csv`. ### Bug fixes - the `1.2f` half-integer powers computed within `\xintfloatexpr` had a silly rounding to the target precision just _before_ the final square-root extraction, thus possibly losing some precision. The `1.2k` implementation keeps guard digits for this final square root extraction. As for integer exponents, it is guaranteed that the computed value differs from the exact one by less than `0.52 ulp` (for inputs having at most `\xinttheDigits` digits.) - more regressions from `1.2i` were fixed: `\xintLen` (**xint**, **xintfrac**) and `\xintDouble` (**xintcore**) had forgotten that their argument was allowed to be negative. A regression test suite is now in place and is being slowly expanded to cover more macros. - `\xintiiSquareRoot{0}` now produces `{1}{1}`, which fits better the general documented behaviour of this macro than `11`. `1.2j (2016/12/22)` ---- ### Improvements and new features - **xinttools** and **xintexpr**: 1. slightly improves the speed of `\xintTrim`. 2. speed gains for the handlers of comma separated lists implementing Python-like slicing and item extraction. Relevant non (user) documented macros better documented in `sourcexint.pdf`. - significant documentations tweaks (inclusive of suppressing things!), and among them two beautiful hyperlinked tables with both horizontal and vertical rules which bring the documentation of the **xintexpr** syntax to a kind of awe-inspiring perfection... except that implementation of some math functions is still lacking. ### Bug fixes - fix two `1.2i` regressions caused by undefined macros (`\xintNthElt` in certain branches and `[list][N]` item extraction in certain cases.) The test files existed but were not executed prior to release. Automation in progress. `1.2i (2016/12/13)` ---- ### Breaking changes - `\xintDecSplit` second argument must have no sign (former code replaced it with its absolute value, a sign now may cause an error.) ### Removed - deprecated macros `\xintifTrue`, `\xintifTrueFalse`, `\xintQuo`, `\xintRem`, `\xintquo`, `\xintrem`. ### Improvements and new features - **xintkernel**: `\xintLength` is faster. New macros: - `\xintLastItem` to fetch the last item from its argument, - `\romannumeral\xintgobble` for gobbling many (up to 531440) upstream braced items or tokens. - `\romannumeral\xintreplicate` which is copied over from the expl3 `\prg_replicate:nn` with some minor changes. - **xinttools**: general token list handling routines `\xintKeep`, `\xintTrim` and `\xintNthElt` are faster; but the novel `\xintTrim` can only remove up to a maximum of 531440 items. Also, `\xintFor` partially improves on some issues which are reported upon in the documentation. - some old macros have been rewritten entirely or partially using techniques which **xint** started using in release `1.2`: - **xintcore**: `\xintDouble`, `\xintHalf`, `\xintInc`, `\xintDec`, `\xintiiLDg`, `\xintDSR` (originally from **xint**), a novel `\xintDSRr`. - **xint**: `\xintDSH`, `\xintDSx`, `\xintDecSplit`, `\xintiiE`. - **xintfrac**: as a result of the above `\xintTrunc`, `\xintRound` and `\xintXTrunc` got faster. But the main improvement for them is with decimal inputs which formerly had not been treated separately from the general fraction case. Also, `\xintXTrunc` does not anymore create a dependency of **xintfrac** on **xinttools**. - the documentation has again been (slightly) re-organized; it has a new sub-section on the Miller-Rabin primality test, to illustrate some use of `\xintNewFunction` for recursive definitions. - the documentation has dropped the LaTeX "command" terminology (which had been used initially in 2013 for some forgotten reasons and should have been removed long ago) and uses only the more apt "macro", as after all, all of **xint** is about expansion of macros (plus the use of `\numexpr`). ### Bug fixes - `\xintDecSplitL` and `\xintDecSplitR` from **xint** produced their output in a spurious brace pair (bug introduced in `1.2f`). `1.2h (2016/11/20)` ---- ### Improvements and new features - new macro `\xintNewFunction` in **xintexpr** which allows to extend the parser syntax with functions in situations where `\xintdeffunc` is not usable (typically, because dummy variables are used over a not yet determined range of values because it depends on the variables). - after three years of strict obedience to `xint` prefix, now `\thexintexpr`, `\thexintiexpr`, `\thexintfloatexpr`, and `\thexintiiexpr` are provided as synonyms to `\xinttheexpr`, etc... ### Bug fixes - the `(cond)?{foo}{bar}` operator from **xintexpr** mis-behaved in certain circumstances (such as an empty `foo`). - the **xintexpr** `1.2f` `binomial` function (which uses `\xintiiBinomial` from **xint.sty** or `\xintFloatBinomial` from **xintfrac.sty**) deliberately raised an error for `binomial(x,y)` with `y<0` or `x:= expression ;` is now accepted. - documentation enhancements: the _Quick Sort_ section with its included code samples has been entirely re-written; the _Commands of the xintexpr package_ section has been extended and reviewed entirely. ### Bug fixes - in **xintfrac**: the `\xintFloatFac` from release `1.2` parsed its argument only through `\numexpr` but it should have used `\xintNum`. - in **xintexpr**: release `1.2d` had broken the recognition of sub-expressions immediately after variable names (with tacit multiplication). - in **xintexpr**: contrarily to what `1.2d` documentation said, tacit multiplication was not yet always done with enhanced precedence. Now yes. `1.2d (2015/11/18)` ---- ### Improvements and new features - the function definitions done by `\xintdeffunc` et al., as well as the macro declarations by `\xintNewExpr` et al. now have only local scope. - tacit multiplication applies to more cases, for example (x+y)z, and always ties more than standard * infix operator, e.g. x/2y is like x/(2*y). - some documentation enhancements, particularly in the chapter on xintexpr.sty, and also in the code source comments. ### Bug fixes - in **xintcore**: release `1.2c` had inadvertently broken the `\xintiiDivRound` macro. `1.2c (2015/11/16)` ---- ### Improvements and new features - macros `\xintdeffunc`, `\xintdefiifunc`, `\xintdeffloatfunc` and boolean `\ifxintverbose`. - on-going code improvements and documentation enhancements, but stopped in order to issue this bugfix release. ### Bug fixes - in **xintcore**: recent release `1.2` introduced a bug in the subtraction (happened when 00000001 was found under certain circumstances at certain mod 8 locations). `1.2b (2015/10/29)` ---- ### Bug fixes - in **xintcore**: recent release `1.2` introduced a bug in the division macros, causing a crash when the divisor started with 99999999 (it was attempted to use with 1+99999999 a subroutine expecting only 8-digits numbers). `1.2a (2015/10/19)` ---- ### Improvements and new features - added `\xintKeepUnbraced`, `\xintTrimUnbraced` (**xinttools**) and fixed documentation of `\xintKeep` and `\xintTrim` regarding brace stripping. - added `\xintiiMaxof/\xintiiMinof` (**xint**). - TeX hackers only: replaced all code uses of ``\romannumeral-`0`` by the quicker ``\romannumeral`&&@`` (`^` being used as letter, had to find another character usable with catcode 7). ### Bug fixes - in **xintexpr**: recent release `1.2` introduced a bad bug in the parsing of decimal numbers and as a result `\xinttheexpr 0.01\relax` expanded to `0` ! (sigh...) `1.2 (2015/10/10)` ---- ### Removed - the macros `\xintAdd`, `\xintSub`, `\xintMul`, `\xintMax`, `\xintMin`, `\xintMaxof`, `\xintMinof` are removed from package **xint**, and only exist in the versions from **xintfrac**. With only **xintcore** or **xint** loaded, one _must_ use `\xintiiAdd`, `\xintiiSub`, ..., or `\xintiAdd`, `\xintiSub`, etc... ### Improvements and new features - the basic arithmetic implemented in **xintcore** has been entirely rewritten. The mathematics remains the elementary school one, but the `TeX` implementation achieves higher speed (except, regarding addition/subtraction, for numbers up to about thirty digits), the gains becoming quite significant for numbers with hundreds of digits. - the inputs must have less than 19959 digits. But computations with thousands of digits take time. - a previously standing limitation of `\xintexpr`, `\xintiiexpr`, and of `\xintfloatexpr` to numbers of less than 5000 digits has been lifted. - a *qint* function is provided to help the parser gather huge integers in one-go, as an exception to its normal mode of operation which expands token by token. - `\xintFloatFac` macro for computing the factorials of integers as floating point numbers to a given precision. The `!` postfix operator inside `\xintfloatexpr` maps to this new macro rather than to the exact factorial as used by `\xintexpr` and `\xintiiexpr`. - there is more flexibility in the parsing done by the macros from **xintfrac** on fractional input: the decimal parts of both the numerator and the denominator may arise from a separate expansion via ``\romannumeral-`0``. Also the strict `A/B[N]` format is a bit relaxed: `N` may be anything understood by `\numexpr` (it could even be empty but that possibility has been removed by later `1.2f` release.) - on the other hand an isolated dot `.` is not legal syntax anymore inside the expression parsers: there must be digits either before or after. It remains legal input for the macros of **xintfrac**. - added `\ht`, `\dp`, `\wd`, `\fontcharht`, etc... to the tokens recognized by the parsers and expanded by `\number`. - an obscure bug in package **xintkernel** has been fixed, regarding the sanitization of catcodes: under certain circumstances (which could not occur in a normal `LaTeX` context), unusual catcodes could end up being propagated to the external world. - an effort at randomly shuffling around various pieces of the documentation has been done. `1.1c (2015/09/12)` ---- - bugfix regarding macro `\xintAssign` from **xinttools** which did not behave correctly in some circumstances (if there was a space before `\to`, in particular). - very minor code improvements, and correction of some issues regarding the source code formatting in `sourcexint.pdf`, and minor issues in `Makefile.mk`. `1.1b (2015/08/31)` ---- - bugfix: some macros needed by the integer division routine from **xintcore** had been left in **xint.sty** since release `1.1`. This for example broke the `\xintGCD` from **xintgcd** if package **xint** was not loaded. - Slight enhancements to the documentation, particularly in the `Read this first` section. `1.1a (2014/11/07)` ---- - fixed a bug which prevented `\xintNewExpr` from producing correctly working macros from a comma separated replacement text. - `\xintiiSqrtR` for rounded integer square root; former `\xintiiSqrt` already produced truncated integer square root; corresponding function `sqrtr` added to `\xintiiexpr..\relax` syntax. - use of straight quotes in the documentation for better legibility. - added `\xintiiIsOne`, `\xintiiifOne`, `\xintiiifCmp`, `\xintiiifEq`, `\xintiiifGt`, `\xintiiifLt`, `\xintiiifOdd`, `\xintiiCmp`, `\xintiiEq`, `\xintiiGt`, `\xintiiLt`, `\xintiiLtorEq`, `\xintiiGtorEq`, `\xintiiNeq`, mainly for efficiency of `\xintiiexpr`. - for the same reason, added `\xintiiGCD` and `\xintiiLCM`. - added the previously mentioned `ii` macros, and some others from `1.1`, to the user manual. But their main usage is internal to `\xintiiexpr`, to skip unnecessary overheads. - various typographical fixes throughout the documentation, and a bit of clean up of the code comments. Improved `\Factors` example of nested `subs`, `rseq`, `iter` in `\xintiiexpr`. `1.1 (2014/10/28)` ---- ### Breaking changes - in `\xintiiexpr`, `/` does _rounded_ division, rather than the Euclidean division (for positive arguments, this is truncated division). The `//` operator does truncated division, - the `:` operator for three-way branching is gone, replaced with `??`, - `1e(3+5)` is now illegal. The number parser identifies `e` and `E` in the same way it does for the decimal mark, earlier versions treated `e` as `E` rather as infix operators of highest precedence, - the `add` and `mul` have a new syntax, old syntax is with `` `+` `` and `` `*` `` (left quotes mandatory), `sum` and `prd` are gone, - no more special treatment for encountered brace pairs `{..}` by the number scanner, `a/b[N]` notation can be used without use of braces (the `N` will end up as is in a `\numexpr`, it is not parsed by the `\xintexpr`-ession scanner), - in earlier releases, place holders for `\xintNewExpr` could either be denoted `#1`, `#2`, ... or also `$1`, `$2`, ... Only the usual `#` form is now accepted and the special cases previously treated via the second form are now managed via a `protect(...)` function. - **xintfrac**: `\xintFloor` and `\xintCeil` add a trailing `/1[0]` to their (integer) output. New `\xintiFloor` and `\xintiCeil` do not. ### Removed - `\xintnumexpr`, `\xintthenumexpr`, `\xintNewNumExpr`: use `\xintiexpr`, `\xinttheiexpr`, `\xintNewIExpr`. ### Deprecated - `\xintDivision`, `\xintQuo`, `\xintRem`: use `\xintiDivision`, `\xintiQuo`, `\xintiRem`. - `\xintMax`, `\xintMin`, `\xintAdd`, `\xintSub`, `\xintMul` (**xint**): their usage without **xintfrac** is deprecated; use `\xintiMax`, `\xintiMin`, `\xintiAdd`, `\xintiSub`, `\xintiMul`. - the `&` and `|` as Boolean operators in `xintexpr`-essions are deprecated in favour of `&&` and `||`. The single letter operators might be assigned some other meaning in some later release (bitwise operations, perhaps). Do not use them. ### Improvements and new features * new package **xintcore** has been split off **xint**. It contains the core arithmetic macros (it is loaded by LaTeX package **bnumexpr**), * neither **xint** nor **xintfrac** load **xinttools**. Only **xintexpr** does, * whenever some portion of code has been revised, often use has been made of the `\xint_dothis` and `\xint_orthat` pair of macros for expandably branching, * these tiny helpful macros, and a few others are in package **xintkernel** which contains also the catcode and loading order management code, initially inspired by code found in Heiko Oberdiek's packages, * the source code, which was suppressed from `xint.pdf` in release `1.09n`, is now compiled into a separate file `sourcexint.pdf`, * faster handling by `\xintAdd`, `\xintSub`, `\xintMul`, ... of the case where one of the arguments is zero, * the `\xintAdd` and `\xintSub` macros from package **xintfrac** check if one of the denominators is a multiple of the other, and only if this is not the case do they multiply the denominators. But systematic reduction would be too costly, * this naturally will be also the case for the `+` and `-` operations in `\xintexpr`, * **xint** added `\xintiiDivRound`, `\xintiiDivTrunc`, `\xintiiMod` for rounded and truncated division of big integers (next to `\xintiiQuo` and `\xintiiRem`), * with **xintfrac** loaded, the `\xintNum` macro does `\xintTTrunc` (which is truncation to an integer, same as `\xintiTrunc {0}`), * added `\xintMod` to **xintfrac** for modulo operation with fractional numbers, * added `\xintiFloor` and `\xintiCeil` to **xintfrac**, * `\xintiexpr`, `\xinttheiexpr` admit an optional argument within brackets `[d]`, they round the computation result (or results, if comma separated) to `d` digits after decimal mark, (the whole computation is done exactly, as in `xintexpr`), * `\xintfloatexpr`, `\xintthefloatexpr` similarly admit an optional argument which serves to keep only `d` digits of precision, getting rid of cumulated uncertainties in the last digits (the whole computation is done according to the precision set via `\xintDigits`), * `\xinttheexpr` and `\xintthefloatexpr` _pretty-print_ if possible, the former removing unit denominator or `[0]` brackets, the latter avoiding scientific notation if decimal notation is practical, * the `//` does truncated division and `/:` is the associated modulo, * multi-character operators `&&`, `||`, `==`, `<=`, `>=`, `!=`, `**`, * multi-letter infix binary words `'and'`, `'or'`, `'xor'`, `'mod'` (straight quotes mandatory), * functions `even`, `odd`, * `\xintdefvar A3:=3.1415;` for variable definitions (non expandable, naturally), usable in subsequent expressions; variable names may contain letters, digits, underscores. They should not start with a digit, the `@` is reserved, and single lowercase and uppercase Latin letters are predefined to work as dummy variables (see next), * generation of comma separated lists `a..b`, `a..[d]..b`, * Python syntax-like list extractors `[list][n:]`, `[list][:n]`, `[list][a:b]` allowing negative indices, but no optional step argument, and `[list][n]` (`n=0` for the number of items in the list), * functions `first`, `last`, `reversed`, * itemwise operations on comma separated lists `a*[list]`, etc.., possible on both sides `a*[list]^b`, and obeying the same precedence rules as with numbers, * `add` and `mul` must use a dummy variable: `add(x(x+1)(x-1), x=-10..10)`, * variable substitutions with `subs`: `subs(subs(add(x^2+y^2,x=1..y),y=t),t=20)`, * sequence generation using `seq` with a dummy variable: `seq(x^3, x=-10..10)`, * simple recursive lists with `rseq`, with `@` given the last value, `rseq(1;2@+1,i=1..10)`, * higher recursion with `rrseq`, `@1`, `@2`, `@3`, `@4`, and `@@(n)` for earlier values, up to `n=K` where `K` is the number of terms of the initial stretch `rrseq(0,1;@1+@2,i=2..100)`, * iteration with `iter` which is like `rrseq` but outputs only the last `K` terms, where `K` was the number of initial terms, * inside `seq`, `rseq`, `rrseq`, `iter`, possibility to use `omit`, `abort` and `break` to control termination, * `n++` potentially infinite index generation for `seq`, `rseq`, `rrseq`, and `iter`, it is advised to use `abort` or `break(..)` at some point, * the `add`, `mul`, `seq`, ... are nestable, * `\xintthecoords` converts a comma separated list of an even number of items to the format expected by the `TikZ` `coordinates` syntax, * completely new version `\xintNewExpr`, `protect` function to handle external macros. The dollar sign `$` for place holders is not accepted anymore, only the standard macro parameter `#`. Not all constructs are compatible with `\xintNewExpr`. % $ this docstripped line for emacs buffer fontification issues in doctex-mode ### Bug fixes - `\xintZapFirstSpaces` hence also `\xintZapSpaces` from package **xinttools** were buggy when used with an argument either empty or containing only space tokens. - `\xintiiexpr` did not strip leading zeroes, hence `\xinttheiiexpr 001+1\relax` did not obtain the expected result ... - `\xinttheexpr \xintiexpr 1.23\relax\relax` should have produced `1`, but it produced `1.23` - the catcode of `;` was not set at package launching time. - the `\XINTinFloatPrd:csv` macro name had a typo, hence `prd` was non-functional in `\xintfloatexpr`. `1.09n (2014/04/01)` ---- * the user manual does not include by default the source code anymore: the `\NoSourceCode` toggle in file `xint.tex` has to be set to 0 before compilation to get source code inclusion (later release `1.1` made source code available as `sourcexint.pdf`). * bug fix (**xinttools**) in `\XINT_nthelt_finish` (this bug was introduced in `1.09i` of `2013/12/18` and showed up when the index `N` was larger than the number of elements of the list). `1.09m (2014/02/26)` ---- * new in **xinttools**: `\xintKeep` keeps the first `N` or last `N` elements of a list (sequence of braced items); `\xintTrim` cuts out either the first `N` or the last `N` elements from a list. * new in **xintcfrac**: `\xintFGtoC` finds the initial partial quotients common to two numbers or fractions `f` and `g`; `\xintGGCFrac` is a clone of `\xintGCFrac` which however does not assume that the coefficients of the generalized continued fraction are numeric quantities. Some other minor changes. `1.09kb (2014/02/13)` ---- * bug fix (**xintexpr**): an aloof modification done by `1.09i` to `\xintNewExpr` had resulted in a spurious trailing space present in the outputs of all macros created by `\xintNewExpr`, making nesting of such macros impossible. * bug fix (**xinttools**): `\xintBreakFor` and `\xintBreakForAndDo` were buggy when used in the last iteration of an `\xintFor` loop. * bug fix (**xinttools**): `\xintSeq` from `1.09k` needed a `\chardef` which was missing from `xinttools.sty`, it was in `xint.sty`. `1.09k (2014/01/21)` ---- * inside `\xintexpr..\relax` (and its variants) tacit multiplication is implied when a number or operand is followed directly with an opening parenthesis, * the `"` for denoting (arbitrarily big) hexadecimal numbers is recognized by `\xintexpr` and its variants (package **xintbinhex** is required); a fractional hexadecimal part introduced by a dot `.` is allowed. * re-organization of the first sections of the user manual. * bug fix (**xinttools**, **xint**, ...): forgotten catcode check of `"` at loading time has been added. `1.09j (2014/01/09)` ---- * (**xint**) the core division routines have been re-written for some (limited) efficiency gain, more pronounced for small divisors. As a result the *computation of one thousand digits of $\pi$* is close to three times faster than with earlier releases. * some various other small improvements, particularly in the power routines. * (**xintfrac**) a macro `\xintXTrunc` is designed to produce thousands or even tens of thousands of digits of the decimal expansion of a fraction. Although completely expandable it has its use limited to inside an `\edef`, `\write`, `\message`, \dots. It can thus not be nested as argument to another package macro. * (**xintexpr**) the tacit multiplication done in `\xintexpr..\relax` on encountering a count register or variable, or a `\numexpr`, while scanning a (decimal) number, is extended to the case of a sub `\xintexpr`-ession. * `\xintexpr` can now be used in an `\edef` with no `\xintthe` prefix; it will execute completely the computation, and the error message about a missing `\xintthe` will be inhibited. Previously, in the absence of `\xintthe`, expansion could only be a full one (with ``\romannumeral-`0``), not a complete one (with `\edef`). Note that this differs from the behavior of the non-expandable `\numexpr`: `\the` or `\number` (or `\romannumeral`) are needed not only to print but also to trigger the computation, whereas `\xintthe` is mandatory only for the printing step. * the default behavior of `\xintAssign` is changed, it now does not do any further expansion beyond the initial full-expansion which provided the list of items to be assigned to macros. * bug fix (**xintfrac**): `1.09i` did an unexplainable change to `\XINT_infloat_zero` which broke the floating point routines for vanishing operands =:((( * bug fix: the `1.09i` `xint.ins` file produced a buggy `xint.tex` file. `1.09i (2013/12/18)` ---- * (**xintexpr**) `\xintiiexpr` is a variant of `\xintexpr` which is optimized to deal only with (long) integers, `/` does a euclidean quotient. * *deprecated*: `\xintnumexpr`, `\xintthenumexpr`, `\xintNewNumExpr` are renamed, respectively, `\xintiexpr`, `\xinttheiexpr`, `\xintNewIExpr`. The earlier denominations are kept but are to be removed at some point. * it is now possible within `\xintexpr...\relax` and its variants to use count, dimen, and skip registers or variables without explicit `\the/\number`: the parser inserts automatically `\number` and a tacit multiplication is implied when a register or variable immediately follows a number or fraction. Regarding dimensions and `\number`, see the further discussion in *Dimensions*. * (**xintfrac**) conditional `\xintifOne`; `\xintifTrueFalse` renamed to `\xintifTrueAelseB`; macros `\xintTFrac` (`fractional part`, mapped to function `frac` in `\xintexpr`-essions), `\xintFloatE`. * (**xinttools**) `\xintAssign` admits an optional argument to specify the expansion type to be used: `[]` (none, default), `[o]` (once), `[oo]` (twice), `[f]` (full), `[e]` (`\edef`),... to define the macros * **xinttools** defines `\odef`, `\oodef`, `\fdef` (if the names have already been assigned, it uses `\xintoodef` etc...). These tools are provided for the case one uses the package macros in a non-expandable context. `\oodef` expands twice the macro replacement text, and `\fdef` applies full expansion. They are useful in situations where one does not want a full `\edef`. `\fdef` appears to be faster than `\oodef` in almost all cases (with less than thousand digits in the result), and even faster than `\edef` for expanding the package macros when the result has a few dozens of digits. `\oodef` needs that expansion ends up in thousands of digits to become competitive with the other two. * some across the board slight efficiency improvement as a result of modifications of various types to *fork macros* and *branching conditionals* which are used internally. * bug fix (**xint**): `\xintAND` and `\xintOR` inserted a space token in some cases and did not expand as promised in two steps `:-((` (bug dating back to `1.09a` I think; this bug was without consequences when using `&` and `|` in `\xintexpr-essions`, it affected only the macro form). * bug fix (**xintcfrac**): `\xintFtoCCv` still ended fractions with the `[0]`'s which were supposed to have been removed since release `1.09b`. * *deprecated*: `\xintifTrueFalse`, `\xintifTrue`; use `\xintifTrueAelseB`. `1.09h (2013/11/28)` ---- * parts of the documentation have been re-written or re-organized, particularly the discussion of expansion issues and of input and output formats. * the expansion types of macro arguments are documented in the margin of the macro descriptions, with conventions mainly taken over from those in the `LaTeX3` documentation. * a dependency of **xinttools** on **xint** (inside `\xintSeq`) has been removed. * (**xintgcd**) `\xintTypesetEuclideAlgorithm` and `\xintTypesetBezoutAlgorithm` have been slightly modified (regarding indentation). * (**xint**) macros `xintiSum` and `xintiPrd` are renamed to `\xintiiSum` and `\xintiiPrd`. * (**xinttools**) a count register used in `1.09g` in the `\xintFor` loops for parsing purposes has been removed and replaced by use of a `\numexpr`. * the few uses of `\loop` have been replaced by `\xintloop/\xintiloop`. * all macros of **xinttools** for which it makes sense are now declared `\long`. `1.09g (2013/11/22)` ---- * a package **xinttools** is detached from **xint**, to make tools such as `\xintFor`, `\xintApplyUnbraced`, and `\xintiloop` available without the **xint** overhead. * expandable nestable loops `\xintloop` and `\xintiloop`. * bugfix: `\xintFor` and `\xintFor*` do not modify anymore the value of `\count 255`. `1.09f (2013/11/04)` ---- * (**xint**) `\xintZapFirstSpaces`, `\xintZapLastSpaces`, `\xintZapSpaces`, `\xintZapSpacesB`, for expandably stripping away leading and/or ending spaces. * `\xintCSVtoList` by default uses `\xintZapSpacesB` to strip away spaces around commas (or at the start and end of the comma separated list). * also the `\xintFor` loop will strip out all spaces around commas and at the start and the end of its list argument; and similarly for `\xintForpair`, `\xintForthree`, `\xintForfour`. * `\xintFor` *et al.* accept all macro parameters from `#1` to `#9`. * for reasons of inner coherence some macros previously with one extra `i` in their names (e.g. `\xintiMON`) now have a doubled `ii` (`\xintiiMON`) to indicate that they skip the overhead of parsing their inputs via `\xintNum`. Macros with a *single* `i` such as `\xintiAdd` are those which maintain the non-**xintfrac** output format for big integers, but do parse their inputs via `\xintNum` (since release `1.09a`). They too may have doubled-`i` variants for matters of programming optimization when working only with (big) integers and not fractions or decimal numbers. `1.09e (2013/10/29)` ---- * (**xint**) `\xintintegers`, `\xintdimensions`, `\xintrationals` for infinite `\xintFor` loops, interrupted with `\xintBreakFor` and `\xintBreakForAndDo`. * `\xintifForFirst`, `\xintifForLast` for the `\xintFor` and `\xintFor*` loops, * the `\xintFor` and `xintFor*` loops are now `\long`, the replacement text and the items may contain explicit `\par`'s. * conditionals `\xintifCmp`, `\xintifInt`, `\xintifOdd`. * bug fix (**xint**): the `\xintFor` loop (not `\xintFor*`) did not correctly detect an empty list. * bug fix (**xint**): `\xintiSqrt {0}` crashed. `:-((` * the documentation has been enriched with various additional examples, such as the *the quick sort algorithm illustrated* or the various ways of *computing prime numbers*. * the documentation explains with more details various expansion related issues, particularly in relation to conditionals. `1.09d (2013/10/22)` ---- * bug fix (**xint**): `\xintFor*` is modified to gracefully handle a space token (or more than one) located at the very end of its list argument (as the space before `\do` in `\xintFor* #1 in {{a}{b}{c}} \do {stuff}`; spaces at other locations were already harmless). Furthermore this new version _f-expands_ the un-braced list items. After `\def\x{{1}{2}}` and `\def\y{{a}\x {b}{c}\x }`, `\y` will appear to `\xintFor*` exactly as if it had been defined as `\def\y{{a}{1}{2}{b}{c}{1}{2}}`. * same bug fix for `\xintApplyInline`. `1.09c (2013/10/09)` ---- * (**xintexpr**) added `bool` and `togl` to the `\xintexpr` syntax; also added `\xintboolexpr` and `\xintifboolexpr`. * added `\xintNewNumExpr`. * the factorial `!` and branching `?`, `:`, operators (in `\xintexpr...\relax`) have now less precedence than a function name located just before, * (**xint**) `\xintFor` is a new type of loop, whose replacement text inserts the comma separated values or list items via macro parameters, rather than encapsulated in macros; the loops are nestable up to four levels (nine levels since `1.09f`) and their replacement texts are allowed to close groups as happens with the tabulation in alignments, * `\xintForpair`, `\xintForthree`, `\xintForfour` are experimental variants of `\xintFor`, * `\xintApplyInline` has been enhanced in order to be usable for generating rows (partially or completely) in an alignment, * command `\xintSeq` to generate (expandably) arithmetic sequences of (short) integers, * again various improvements and changes in the documentation. `1.09b (2013/10/03)` ---- * various improvements in the documentation, * more economical catcode management and re-loading handling, * removal of all those `[0]`'s previously forcefully added at the end of fractions by various macros of **xintcfrac**, * `\xintNthElt` with a negative index returns from the tail of the list, * macro `\xintPRaw` to have something like what `\xintFrac` does in math mode; i.e. a `\xintRaw` which does not print the denominator if it is one. `1.09a (2013/09/24)` ---- * (**xintexpr**) `\xintexpr..\relax` and `\xintfloatexpr..\relax` admit functions in their syntax, with comma separated values as arguments, among them `reduce, sqr, sqrt, abs, sgn, floor, ceil, quo, rem, round, trunc, float, gcd, lcm, max, min, sum, prd, add, mul, not, all, any, xor`. * comparison (`<`, `>`, `=`) and logical (`|`, `&`) operators. * the command `\xintthe` which converts `\xintexpr`essions into printable format (like `\the` with `\numexpr`) is more efficient, for example one can do `\xintthe\x` if `\x` was defined to be an `\xintexpr..\relax`: \def\x{\xintexpr 3^57\relax} \def\y{\xintexpr \x^(-2)\relax} \def\z{\xintexpr \y-3^-114\relax} \xintthe\z * `\xintnumexpr .. \relax` (now renamed `\xintiexpr`) is `\xintexpr round( .. ) \relax`. * `\xintNewExpr` now works with the standard macro parameter character `#`. * both regular `\xintexpr`-essions and commands defined by `\xintNewExpr` will work with comma separated lists of expressions, * commands `\xintFloor`, `\xintCeil`, `\xintMaxof`, `\xintMinof` (package **xintfrac**), `\xintGCDof`, `\xintLCM`, `\xintLCMof` (package **xintgcd**), `\xintifLt`, `\xintifGt`, `\xintifSgn`, `\xintANDof`, ... * The arithmetic macros from package **xint** now filter their operands via `\xintNum` which means that they may use directly count registers and `\numexpr`-essions without having to prefix them by `\the`. This is thus similar to the situation holding previously already when **xintfrac** was loaded. * a bug (**xintfrac**) introduced in `1.08b` made `\xintCmp` crash when one of its arguments was zero. `:-((` `1.08b (2013/06/14)` ---- * (**xintexpr**) Correction of a problem with spaces inside `\xintexpr`-essions. * (**xintfrac**) Additional improvements to the handling of floating point numbers. * section *Use of count registers* documenting how count registers may be directly used in arguments to the macros of **xintfrac**. `1.08a (2013/06/11)` ---- * (**xintfrac**) Improved efficiency of the basic conversion from exact fractions to floating point numbers, with ensuing speed gains especially for the power function macros `\xintFloatPow` and `\xintFloatPower`, * Better management by `\xintCmp`, `\xintMax`, `\xintMin` and `\xintGeq` of inputs having big powers of ten in them. * Macros for floating point numbers added to the **xintseries** package. `1.08 (2013/06/07)` ---- * (**xint** and **xintfrac**) Macros for extraction of square roots, for floating point numbers (`\xintFloatSqrt`), and integers (`\xintiSqrt`). * new package **xintbinhex** providing *conversion routines* to and from binary and hexadecimal bases. `1.07 (2013/05/25)` ---- * The **xintexpr** package is a new core constituent (which loads automatically **xintfrac** and **xint**) and implements the expandable expanding parser \xintexpr . . . \relax, and its variant \xintfloatexpr . . . \relax allowing on input formulas using the infix operators `+`, `-`, `*`, `/`, and `^`, and arbitrary levels of parenthesizing. Within a float expression the operations are executed according to the current value set by `\xintDigits`. Within an `\xintexpr`-ession the binary operators are computed exactly. To write the `\xintexpr` parser I benefited from the commented source of the `l3fp` parser; the `\xintexpr` parser has its own features and peculiarities. *See its documentation*. * The floating point precision `D` is set (this is a local assignment to a `\mathchar` variable) with `\xintDigits := D;` and queried with `\xinttheDigits`. It may be set to anything up to `32767`.[^1] The macro incarnations of the binary operations admit an optional argument which will replace pointwise `D`; this argument may exceed the `32767` bound. * The **xintfrac** macros now accept numbers written in scientific notation, the `\xintFloat` command serves to output its argument with a given number `D` of significant figures. The value of `D` is either given as optional argument to `\xintFloat` or set with `\xintDigits := D;`. The default value is `16`. [^1]: but values higher than 100 or 200 will presumably give too slow evaluations. `1.06b (2013/05/14)` ---- * Minor code and documentation improvements. Everywhere in the source code, a more modern underscore has replaced the @ sign. `1.06 (2013/05/07)` ---- * Some code improvements, particularly for macros of **xint** doing loops. * New utilities in **xint** for expandable manipulations of lists: \xintNthElt, \xintCSVtoList, \xintRevWithBraces * The macros did only a double expansion of their arguments. They now fully expand them (using ``\romannumeral-`0``). Furthermore, in the case of arguments constrained to obey the TeX bounds they will be inserted inside a `\numexpr..\relax`, hence completely expanded, one may use count registers, even infix arithmetic operations, etc... `1.05 (2013/05/01)` ---- Minor changes and additions to **xintfrac** and **xintcfrac**. `1.04 (2013/04/25)` ---- * New component **xintcfrac** devoted to continued fractions. * **xint**: faster division. * **xint**: added expandable macros `\xintListWithSep` and `\xintApply` to handle token lists. * **xintfrac**: added `\xintRound`. * **xintseries** has a new implementation of `\xintPowerSeries` based on a Horner scheme, and new macro `\xintRationalSeries`. Both to help deal with the *denominator buildup* plague. * `tex xint.dtx` extracts style files (no need for a `xint.ins`). * Bug fix (**xintfrac**): `\xintIrr {0}` crashed. `1.03 (2013/04/14)` ---- * New modules **xintfrac** (expandable operations on fractions) and **xintseries** (expandable partial sums with xint package). * Slightly improved division and faster multiplication (the best ordering of the arguments is chosen automatically). * Added illustration of Machin algorithm to the documentation. `1.0 (2013/03/28)` ---- Initial announcement: > The **xint** package implements with expandable TeX macros the basic arithmetic operations of addition, subtraction, multiplication and division, as applied to arbitrarily long numbers represented as chains of digits with an optional minus sign. > The **xintgcd** package provides implementations of the Euclidean algorithm and of its typesetting. > The packages may be used with Plain and with LaTeX. %------------------------------------------------------ %<*dates>------------------------------------------------------- `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" # 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 displays this help using the more pager. make helpless displays this help using the less pager. make doc produces all documentation, requires Latexmk and Pandoc. make all produces all documentation, then creates xint.tds.zip. make xint.tds.zip same as "make all" make xint.pdf extracts files and produces xint.pdf (user manual), using latex and dvipdfmx. Requires Latexmk. make sourcexint.pdf extracts files and produces sourcexint.pdf (source code), using latex and dvipdfmx. Requires Latexmk. make xint-all.pdf extracts files and produces xint-all.pdf (manual + code), using latex and dvipdfmx. Requires Latexmk. make CHANGES.html requires Pandoc. make clean removes auxiliary files and repertories. make cleanall removes all files, leaving only xint.dtx (and Makefile). ==== INSTALLING The following has been tested on a TeXLive installation: make installhome creates xint.tds.zip, and unzips it in make installlocal creates xint.tds.zip, unzips 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 removes all xint files and repertories from make uninstalllocal removes all xint files and repertories from and then does texhash Might need "sudo". endef .PHONY: help helpless all doc clean cleanall\ 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 is not included in $(extracted). Its extraction rule is in # master Makefile file. We can not extract Makefile from xint.dtx via # docstrip, as .tex is always appended if a filename with no extension is # specified. Notice that if "make -f Makefile.mk" is executed, this will # actually extract again Makefile.mk which will be overwritten but this # does not seem to be problematic. extracted = $(packages) xint.tex sourcexint.tex xint-all.tex\ README.md CHANGES.md xint-dates.txt doHTMLs.sh filesfortex = $(packages) filesforsource = xint.dtx Makefile filesfordoc = xint.pdf sourcexint.pdf README.md CHANGES.html auxiliaryfiles = xint.dvi xint.aux xint.toc xint.log\ sourcexint.dvi sourcexint.aux sourcexint.toc sourcexint.log\ xint-all.dvi xint-all.aux xint-all.toc xint-all.log all: $(extracted) doc xint.tds.zip @echo 'make all done.' $(extracted): xint.dtx etex xint.dtx doc: xint.pdf sourcexint.pdf CHANGES.html @echo 'make doc done.' xint.pdf: xint.dtx xint.tex latexmk xint.tex dvipdfmx xint.dvi sourcexint.pdf: xint.dtx sourcexint.tex latexmk sourcexint.tex dvipdfmx sourcexint.dvi xint-all.pdf: xint.dtx xint-all.tex latexmk xint-all.tex dvipdfmx xint-all.dvi CHANGES.html: CHANGES.md doHTMLs.sh chmod u+x doHTMLs.sh && ./doHTMLs.sh 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/ TEMP*/ rm -f $(auxiliaryfiles)\ xint-all.fls xint-all.fdb_latexmk\ sourcexint.fls sourcexint.fdb_latexmk\ xint.fls xint.fdb_latexmk cleanall: clean rm -f $(extracted) CHANGES.html xint-dates.txt \ xint.pdf sourcexint.pdf xint-all.pdf xint.tds.zip xint.zip Makefile.mk %$----------------------------------------------------- %<*dohtmlsh>------------------------------------------------------ #! /bin/sh # README.html and CHANGES.html from README.md and CHANGES.md # tested with pandoc 1.13.1 # updated 2022 for usage with pandoc 2.18 and its strange CSS obsessed by mobile devices # pandoc -o README.html -s --toc -V highlighting-css=' body{margin-left : 10%; margin-right : 15%; margin-top: 4ex; font-size: 12pt;} # pre {white-space: pre-wrap; } # code {white-space: pre-wrap; } # .mono {font-family: monospace;}' README.md pandoc -o CHANGES.html -s --toc -V 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;}' CHANGES.md %------------------------------------------------------ %<*xintdrv>----------------------------------------------------------- %% To extract files: %% (but this is probably already done as you read this one) %% etex xint.dtx %% %% Then execute: %% make --file=Makefile.mk xint.pdf %% %% Alternative for build without `make': %% latexmk xint.tex %% dvipdfmx xint.dvi %% %% One can also tell latexmk to use xelatex or pdflatex. %% Or use one of them directly enough times on xint.tex. %% %% To produce the documented source code sourcexint.pdf: %% make --file=Makefile.mk sourcexint.pdf %% (check sourcexint.tex for alternatives to `make') %% %% To produce xint-all.pdf with both user doc and source code: %% make --file=Makefile.mk xint-all.pdf %% (check xint-all.tex for alternatives to `make') \NeedsTeXFormat{LaTeX2e} \ProvidesFile{xint.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: %----------------------------------------------------------- %<*sourcedrv>----------------------------------------------------------- %% To extract files: %% (but this is probably already done as you read this one) %% etex xint.dtx %% %% Then execute: %% make --file=Makefile.mk sourcexint.pdf %% %% Alternative for build without `make': %% latexmk sourcexint.tex %% dvipdfmx sourcexint.dvi %% %% One can intruct latexmk (see its documentation) to use xelatex %% or pdflatex, or use them directly on sourcexint.tex. \NeedsTeXFormat{LaTeX2e} \ProvidesFile{sourcexint.tex}% [\xintbndldate\space v\xintbndlversion\space xint commented code (JFB)]% \PassOptionsToClass{a4paper,fontsize=10pt}{scrartcl} \chardef\NoSourceCode=0\chardef\dosourcexint=1 \input xint.dtx %%% Local Variables: %%% mode: latex %%% TeX-PDF-from-DVI: "Dvipdfmx" %%% End: %----------------------------------------------------------- %<*alldrv>----------------------------------------------------------- %% To extract files: %% (but this is probably already done as you read this one) %% etex xint.dtx %% %% Then execute: %% make --file=Makefile.mk xint-all.pdf %% %% Alternative for build without `make': %% latexmk xint-all.tex %% dvipdfmx xint-all.dvi %% %% One can intruct latexmk (see its documentation) to use xelatex %% or pdflatex, or use them directly on xint-all.tex. %% %% Another way is to run latex (enough times, then dvipdfmx) or %% pdflatex directly on source file xint.dtx. The produced xint.pdf %% will then combine user manual and commented source code. \NeedsTeXFormat{LaTeX2e} \ProvidesFile{xint-all.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 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 on xint.tex or sourcexint.tex or xint-all.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 help" will provide information.^^J}% \Msg{* In particular:^^J}% \Msg{* - the "doc" target builds xint.pdf and sourcexint.pdf,^^J}% \Msg{* - the "xint.tds.zip" target additionally prepares a TDS-compliant^^J}% \Msg{*\space\space\space archive.^^J}% \Msg{* Building with "make" requires "Latexmk".^^J}% \Msg{* The target "CHANGES.html" requires "Pandoc".^^J}% \Msg{*^^J}% \Msg{* Instructions for builds 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}} \file{CHANGES.md}{\from{xint.dtx}{changes}} \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}} \file{doHTMLs.sh}{\from{xint.dtx}{dohtmlsh}} \usepreamble\defaultpreamble \usepostamble\defaultpostamble \file{xint.tex}{\from{xint.dtx}{xintdrv}} \file{sourcexint.tex}{\from{xint.dtx}{sourcedrv}} \file{xint-all.tex}{\from{xint.dtx}{alldrv}} \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% (if with xetex, 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\dosourcexint \chardef\NoSourceCode 0 \else \chardef\dosourcexint 0 \fi % \dosourcexint=1 means producing only source code. % It is set in sourcexint.tex. Prior to 1.4l it was % set in the call with latexmk + \input syntax. % % \dosourcexint=0 and \NoSourceCode=1 : include only user doc % \dosourcexint=0 and \NoSourceCode=0 : combine user doc and source code % \dosourcexint=1 and \NoSourceCode=1 : never happens but would mean to do % nothing! % default is to assume latex + dvipdfmx \chardef\Withdvipdfmx 1 \RequirePackage{ifpdf} \RequirePackage{ifxetex} \ifpdf \chardef\Withdvipdfmx 0 \fi \ifxetex\chardef\Withdvipdfmx 0 % they are used at some locations in this doc \let\pdfsetrandomseed\setrandomseed \let\pdfuniformdeviate\uniformdeviate \let\pdfresettimer\resettimer \let\pdfelapsedtime\elapsedtime \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, dvipdfmx-outline-open]{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 sourcexint.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 % Let's now reenact the doc.sty default for \theCodeLineNo \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} \ifxetex \else \usepackage[T1]{fontenc} % je suis passé à utf8 le 28 février 2016 \usepackage[utf8]{inputenc} % (2016/12/08): utilisé où ? % (2018/05/22): utilisé dans les commentaires de la division de xint.sty \DeclareUnicodeCharacter{03B4}{\ensuremath{\delta}}%δ % pour exemple de \xintnewdummy \DeclareUnicodeCharacter{03BE}{\ensuremath{\xi}}%ξ % (2019/03/31): utilisé dans mes commentaires de xinttrig.sty \DeclareUnicodeCharacter{03C0}{\ensuremath{\pi}}%π % (2019/04/24): utilisé dans un commentaire de xintlog.sty \DeclareUnicodeCharacter{2260}{\ensuremath{\neq}}%≠ \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\dosourcexint=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 sourcexint.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\dosourcexint=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\dosourcexint=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=a,straightquotes,scaled=0.95]{newtxtt} \usepackage{newtxmath} \ifnum\dosourcexint=1 \else \renewcommand\familydefault\ttdefault \usepackage[noendash]{mathastext}% pas de endash dans newtxtt \fi \frenchspacing % sans-serif in footnotes, TOC, titles, etc... \renewcommand\familydefault\sfdefault % TABLES OF CONTENTS % ================== \usepackage{tocloft} \usepackage{etoc} \def\gobbletodot #1.{} \newif\ifinmanualmaintoc \ifnum\dosourcexint=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{table}{6} \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 % 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 \edef\everbatimxprehook {\pdfcolorstack\noexpand\@pdfcolorstack push{\@tempa}\relax} \def\everbatimxposthook{\pdfcolorstack\@pdfcolorstack pop\relax} \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\dosourcexint=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 {(\space bundle,bundle), (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\DOCxintfrontpage {\perhapshyperref[frontpage]{{\color{xintnamecolor}TOC}}}% \ifnum\dosourcexint=1 % sourcexint.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\dosourcexint=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\dosourcexint=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, \csname xint bundlename\endcsname}} \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\dosourcexint=1 \catcode`+ 0 \catcode0 9 % n'importe quoi sauf 15 (car ^^@) \catcode`\\ 12 +expandafter+iffalse+fi \fi % \makeatletter \etocsetlevel{toctobookmark}{6} \etocsetlevel{table}{2}% subsection \let\orig@etocbelowtocskip\etocbelowtocskip \let\orig@etocinnertopsep\etocinnertopsep \let\orig@etoctoclineleaders\etoctoclineleaders \renewcommand*{\etocbelowtocskip}{0pt} \renewcommand*{\etocinnertopsep}{0pt} \renewcommand*{\etoctoclineleaders} {\hbox{\normalfont\normalsize\hbox to 1ex {\hss.\hss}}} \etocsettocstyle{}{} \etocsettagdepth {part1A}{subsection} \etocsettagdepth {part1B}{section} \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\dosourcexint=0 \ifnum\NoSourceCode=0 % both true only for xint-all.pdf \def\etocbelowtocskip{\z@skip}% \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\dosourcexint=1 0\fi\ifnum\NoSourceCode=1 0\fi1% xint-all.pdf \def\etocbelowtocskip{\z@skip}% \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\addvspace{\etocbelowtocskip}% } {% % \kern and not \vskip to avoid multicolumn balncing columns \def\tocstylesectionVSKIP{\kern\smallskipamount}% \if1\ifnum\dosourcexint=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}\addvspace{\etocbelowtocskip}}% % 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 \etocsettocstyle{}{} \etocsettagdepth {part1A}{none} \etocsettagdepth {part1B}{none} \etocsettagdepth {macros} {section} \ifnum\dosourcexint=1 % sourcexint.pdf \etocsettagdepth {implementation}{section} \else \ifnum\NoSourceCode=1 % xint.pdf \etocsettagdepth {implementation}{part} \else % xint-all.pdf \etocsettagdepth {implementation}{section} \fi \fi % seems unneeded now %\vspace*{2\baselineskip} % THIS IS THE SECOND HALF OF THE TOC ON PAGE 1, WITH PARTS II AND III \etocglobaldefs \tableofcontents \etoclocaldefs \etocignoredepthtags \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, (c) 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 right of=B] (core) {\xintcorename}; \node [block, below left of=A] (tools) {\xinttoolsname}; \node [block, right of=core, xshift=1cm] (bnumexpr) {\ctanpackage{bnumexpr}}; \node [block, below of=core] (xint) {\xintname}; \node [block, left of=xint, xshift=-1cm] (gcd) {\xintgcdname}; \node [block, left of=gcd] (binhex) {\xintbinhexname}; \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 right of=frac, xshift=1cm] (series) {\xintseriesname}; \node [block, right of=series] (cfrac) {\xintcfracname}; % Draw edges \path [line,-{Stealth[length=5mm]}] (kernel) -- (core); \path [line,-{Stealth[length=5mm]}] (kernel) -- (tools); \path [line,-{Stealth[length=5mm]}] (core) -- (bnumexpr); % \path [line,-{Stealth[length=5mm]}] (core) to [out=180,in=90] (gcd.north); \path [line,-{Stealth[length=5mm]}] (kernel) -- (binhex); \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]}] (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); \path [line,-{Stealth[length=5mm]}] (frac) to [out=0,in=90] (series.north); \path [line,-{Stealth[length=5mm]}] (frac) to [out=0,in=90] (cfrac.north); \path [line,dashed,-{Stealth[length=5mm]}] (binhex.south) -- (expr); % at 1.3d gcd() and lcm() needs no support from xintgcd % \path [line,dashed,-{Stealth[length=5mm]}] (gcd.south) -- (expr); % at 1.4 xintgcd loads xinttools \path [line,-{Stealth[length=5mm]}] (tools) to [out=0, in=90] (gcd.north);% je dois positionner mieux mais pas le temps de lire 700 pages \path [line,dashed,-{Stealth[length=5mm]}] (tools.south west) to [out=270, in=225] (cfrac.south west);% je dois positionner mieux mais pas le temps de lire 700 pages \path [line,-{Stealth[length=5mm]}] (tools) to [out=270,in=180] (expr); \end{tikzpicture}}\bigskip \end{figure} \vspace{\baselineskip} \begin{addmargin}{2cm} \normalfont\footnotesize Dependency graph for the \xintname bundle components: modules pointed to by arrows \textbf{automatically} import the modules originating the continuous line ended by an arrow. Dashed lines indicate a partial dependency, and to enable the corresponding functionalities of the lower module it is thus necessary to use a suitable |\usepackage| (\LaTeX) or |\input| (Plain \TeX.)\par \ctanpackage{bnumexpr} is a separate (\LaTeX{} only) package by the author which uses (by default) \xintcorename as its mathematical engine. \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, if available, |rlwrap etex xintsession|). It loads \xintbinhexname automatically (but this is not indicated above graphically). \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} \emph{\emph{\textsc{Jürgen Gilg}}'s interest into what he called \emph{|"XINT"|} was instrumental in keeping the author motivated over the years. % \emph pas compatible avec plusieurs paragraphes ! 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{Basic usage and purpose} \begin{itemize} \item To use with |etex|, |pdftex|, ..., i.e.\@ with \TeX{} engines activating the e\TeX{} extensions: \begin{everbatim} \input xintexpr.sty \end{everbatim} \item To use with the \LaTeX{} macro layer (|latex|, |pdflatex|, ...): \begin{everbatim} \usepackage{xintexpr} \end{everbatim} \end{itemize} Some random examples: \begin{everbatim*} $\sqrt{13}, \cos(1), \exp(13.3) = \xintfloateval{sqrt(13), cos(1), exp(13.3)}$\par \end{everbatim*} \begin{everbatim*} \begin{center} \xintDigits*:=32;% this sets the precision to 32 digits for the math functions \begin{minipage}{34\fontcharwd\font`0} \xintfloateval{sqrt(13), cos(1), exp(13.3)}\par \end{minipage}% \end{center} \end{everbatim*} \begin{everbatim*} $2^{1000}=\printnumber{\xinteval{2^1000}}$\par% exact computations \end{everbatim*} \begin{everbatim*} % dummy variables \[\sum_{i=1}^{50}\frac1i=\xintTeXFrac{\xinteval{reduce(add(1/i, i=1..50))}}\] \end{everbatim*} \begin{everbatim*} \[\sum_{i=1}^{50}\frac1{i^2}=\xintTeXFrac{\xinteval{reduce(add(1/i^2, i=1..50))}}\] \end{everbatim*} Computations are done expandably. This means that for example \begin{everbatim} \typeout{\xinteval{sqrt(13, 70)}} \end{everbatim} will compute on the fly while writing out to the log file (|\typeout| is the \LaTeX\ idiom), here the square root of \dtt{13} correctly rounded to \dtt{70} significant digits. Indeed, \xintexprname is a package to do expandable computations, either exactly with arbitrarily big inputs (fractions, arbitrarily long decimal expansions, ...), or in the sense of floating point numbers (logarithm, exponential, sine, cosine, ...). The math functions are implemented up to \dtt{62} digits of precision. The square root (as well of course as the four operations) achieve correct rounding in arbitrary precision (i.e.\@ even with more than \dtt{62} digits, and may even handle thousands of digits but reasonable range is not beyond a few hundreds). The syntax to modify the precision used for floating point evaluations is \begin{everbatim} \xintDigits*:= ; \end{everbatim}\smallskip \begin{footnotesize} For reasons of the history of the package, one usually will want to use indeed the |*| (see \csbxint{Digits}), as the more lightweight variant without it does let the four operations and the square root obey the new setting but it does not recalibrate the \xinttrigname and \xintlogname libraries and their built-in constants.\par \end{footnotesize} The current precision is available as \csbxint{theDigits}, and defaults to \dtt{16}, but in this documentation I might be using simply |Digits| to refer to it. The table of \hyperref[tab:precedences]{built-in operators} and the one of \hyperref[tab:functions]{built-in functions} 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|): \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 small package loads \xintcorename and provides the functionality of the integer-only \csbxint{iiexpr}/\csbxint{iieval} parser, but dropping support for nested structures, functions, variables, boolean branching, etc...\@ It includes by default support for hexadecimal input (with |"| prefix) and output based upon \xintbinhexname. Compared to |\the\numexpr| it adds support for arbitrarily large integers, powers with |**| and |^|, factorials via |!| postfix operator, floored division and associated modulo, and comma separated multi-item expressions. It also offers a user-level interface to add extra infix or postfix operators. \subsection{License and installation instructions} \label{ssec:install} \xintname is made available under the \href{http://www.latex-project.org/lppl/lppl-1-3c.txt}{LaTeX Project Public License 1.3c} and is included in the major \TeX\ distributions, thus there is probably no need for a custom install: just use the package manager to update if necessary \xintname 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. The |README.md| at \href{https://ctan.org/pkg/xint}{CTAN} lists some alternatives. \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|'' macros, not provided by the package, and which is coded like this (with some extra decorations): \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 triggering), then it goes through the computation result character by character inserting \TeX\ potential break points in-between them. % \begin{everbatim*} \printnumber{\xintiieval{100!^3}}\newline \end{everbatim*}% \subsection{The package documentation} With \TeX\ distributions providing a |"texdoc"| or similar utility, \centeredline{|texdoc --list xint|} will offer the choice to visualize one of those files: \begin{enumerate}[nosep] \item |xint.pdf| (this file) \item |sourcexint.pdf| (commented (hmm...) source code) \item |CHANGES.html| \item |README.md| \end{enumerate} Warning: I don't have the time to maintain perfectly such large documentation. It currently 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. Bug reports and feature requests are most welcome. The section formerly included with this documentation and documenting the changes since the |1.4| release has been removed as it was too time-consuming to maintain it here. Please refer to |CHANGES.html| for the detailed listing: \centeredline{|texdoc --list xint| then select |CHANGES.html|} On the internet: \centeredline{\url{http://mirrors.ctan.org/macros/generic/xint/CHANGES.html}} % A one-page condensed ``timeline'' is to be found at the start of |sourcexint.pdf|. \clearpage \expandafter\let\csname Start herenameUp\endcsname\undefined \csname xintexprnameUp\endcsname \section{Syntax reference and user guide} \RaisedLabel{sec:expr} \localtableofcontents \subsection{The three parsers} \xintexprname provides three numerical expression parsers corresponding to these three respective tasks: \begin{description}[noitemsep] \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, \item[\csa{xintfloateval}:] evaluations with floating points numbers according to the prevailing precision (see \csbxint{Digits*}), \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 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*} In this example, the fraction obtained by addition is already irreducible, but this is not always the case, as pointed above 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*} \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} Prior to |1.4k| the optional argument \oarg{D} had to be located \emph{within} the braces at the start of the expression. The legacy syntax is and will keep being allowed. \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*} \item \csbxint{floateval}\oarg{Q}\marg{expression} does floating point computations with a given precision |P|, as specified via a prior assignment |\xintDigits:=P\relax | (the value |P| can be recovered via \csbxint{theDigits}). 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 {table}{\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. This functionality \centeredline{\fbox{requires to load explicitly package \xintbinhexname.}}% \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 (for example in \LaTeX\ with babel+french) one needs to use input such as |/\string :| (or replace it with usage of the function \func{mod}). \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 {table}{\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