summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/optex/base
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/optex/base')
-rw-r--r--Master/texmf-dist/tex/optex/base/alloc.opm6
-rw-r--r--Master/texmf-dist/tex/optex/base/basic-macros.opm5
-rw-r--r--Master/texmf-dist/tex/optex/base/doc.opm20
-rw-r--r--Master/texmf-dist/tex/optex/base/f-heros.opm8
-rw-r--r--Master/texmf-dist/tex/optex/base/fonts-resize.opm2
-rw-r--r--Master/texmf-dist/tex/optex/base/fonts-select.opm6
-rw-r--r--Master/texmf-dist/tex/optex/base/hisyntax-c.opm2
-rw-r--r--Master/texmf-dist/tex/optex/base/if-macros.opm20
-rw-r--r--Master/texmf-dist/tex/optex/base/keyval.opm99
-rw-r--r--Master/texmf-dist/tex/optex/base/lists.opm8
-rw-r--r--Master/texmf-dist/tex/optex/base/math-macros.opm4
-rw-r--r--Master/texmf-dist/tex/optex/base/more-macros.opm28
-rw-r--r--Master/texmf-dist/tex/optex/base/optex.ini2
-rw-r--r--Master/texmf-dist/tex/optex/base/others.opm6
-rw-r--r--Master/texmf-dist/tex/optex/base/parameters.opm12
-rw-r--r--Master/texmf-dist/tex/optex/base/prefixed.opm153
-rw-r--r--Master/texmf-dist/tex/optex/base/references.opm3
-rw-r--r--Master/texmf-dist/tex/optex/base/sections.opm2
-rw-r--r--Master/texmf-dist/tex/optex/base/slides.opm2
-rw-r--r--Master/texmf-dist/tex/optex/base/table.opm9
-rw-r--r--Master/texmf-dist/tex/optex/base/unimath-codes.opm265
-rw-r--r--Master/texmf-dist/tex/optex/base/unimath-macros.opm123
22 files changed, 473 insertions, 312 deletions
diff --git a/Master/texmf-dist/tex/optex/base/alloc.opm b/Master/texmf-dist/tex/optex/base/alloc.opm
index d4f823fec4a..fae88d286ed 100644
--- a/Master/texmf-dist/tex/optex/base/alloc.opm
+++ b/Master/texmf-dist/tex/optex/base/alloc.opm
@@ -1,6 +1,6 @@
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \newdimen {Allocators for registers <2022-06-10>} % preloaded in format
+\_codedecl \newdimen {Allocators for registers <2023-02-03>} % preloaded in format
\_doc -----------------------------
The limits are set first.
@@ -46,9 +46,10 @@
\_errmessage{No room for a new \_ea\_string\_csname #2\_endcsname}%
\_else
\_global#3#1=\_cs{_#2alloc}%
- \_wlog{\_string#1=\_ea\_string\_csname #2\_endcsname\_the\_cs{_#2alloc}}%
+ \_wloga{\_string#1=\_ea\_string\_csname #2\_endcsname\_the\_cs{_#2alloc}}%
\_fi
}
+\_let\_wloga=\_wlog % you can suppress the logging by \_let\_wloga=\_ignoreit
\_doc -----------------------------
The allocation macros
@@ -177,6 +178,7 @@ the array-like declarator of counters.
\_endinput
+2023-02-03 \_wloga introduced
2022-06-10 \_famalloc set to 42 (answer to the biggest fundamental question)
2022-03-07 \_noattr allocated
2022-02-19 \_newlanguage introduced
diff --git a/Master/texmf-dist/tex/optex/base/basic-macros.opm b/Master/texmf-dist/tex/optex/base/basic-macros.opm
index ae5c833140d..92275056787 100644
--- a/Master/texmf-dist/tex/optex/base/basic-macros.opm
+++ b/Master/texmf-dist/tex/optex/base/basic-macros.opm
@@ -1,6 +1,6 @@
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \sdef {Basic macros for OpTeX <2022-11-22>} % preloaded in format
+\_codedecl \sdef {Basic macros for OpTeX <2023-01-22>} % preloaded in format
\_doc ------------------------------
\`\bgroup`, \`\egroup`, \`\empty`, \`\space`, and \`\null`
@@ -73,7 +73,7 @@
\_cod ------------------------------
\_def \_cs #1{\_csname#1\_endcsname}
-\_def \_trycs#1#2{\_ifcsname #1\_endcsname \_csname #1\_ea\_endcsname \_else #2\_fi}
+\_def \_trycs#1#2{\_ifcsname #1\_endcsname \_csname #1\_ea\_endcsname \_else \_afterfi{#2}\_fi}
\_public \cs \trycs ;
\_doc ------------------------------
@@ -142,6 +142,7 @@
\_endcode % -------------------------------------
+2023-01-22: \trycs: afterfi used for second parameter
2022-11-22: \_banner definition moved here
2022-11-18: \ahead introduced
2022-10-29: \_fin introduced
diff --git a/Master/texmf-dist/tex/optex/base/doc.opm b/Master/texmf-dist/tex/optex/base/doc.opm
index dc5d037e72d..fb96d35007e 100644
--- a/Master/texmf-dist/tex/optex/base/doc.opm
+++ b/Master/texmf-dist/tex/optex/base/doc.opm
@@ -1,6 +1,6 @@
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \printdoc {Macros for documentation printing <2022-11-21>} % loaded on demand by \load[doc]
+\_codedecl \printdoc {Macros for documentation printing <2022-12-11>} % loaded on demand by \load[doc]
\_doc -----------------------------
General decalarations.
@@ -204,7 +204,7 @@
\_doc -----------------------------
If this macro is loaded by \^`\load` then we need to initialize
- catcodes using the `\_afteroad` macro.
+ catcodes using the `\_afterload` macro.
\_cod -----------------------------
\_def\_afterload{\_catcode`\<=13 \_catcode`\`=13
@@ -229,26 +229,32 @@
Link to user documentation point: \code{\\~`\\foo}.
\_cod -----------------------------
+\_def\_docrefcodes{\_catcode`\.=11\_relax}
+
\_verbchar`
-\_def\`#1`{\_leavevmode\_edef\_tmp{\_csstring#1}\_iindex{\_tmp}%
- \_ifcsname cs:\_tmp\_endcsname\_else \_dest[cs:\_tmp]\_fi
+\_def\`{\_bgroup \_docrefcodes \_mainpoint}
+\_def\_mainpoint #1`{\_egroup\_leavevmode\_edef\_tmp{\_csstring#1}\_iindex{\_tmp}%
+ \_ifcsname cs:\_tmp\_endcsname \_moremainpoints \_else \_dest[cs:\_tmp]\_fi
\_sxdef{cs:\_tmp}{}%
\_hbox{\_ifcsname cs:^\_tmp\_endcsname
\_link[cs:^\_tmp]{\mlinkcolor}{\_tt\_csstring\\\_tmp}\_else
{\_tt\mlinkcolor\_csstring\\\_tmp}\_fi}%
}
-\_def\^`#1{\_leavevmode\_edef\_tmp{\_csstring#1}\_iindex{\_tmp}%
+\_def\^`{\_bgroup \_docrefcodes \_docpoint}
+\_def\_docpoint #1{\_egroup\_leavevmode\_edef\_tmp{\_csstring#1}\_iindex{\_tmp}%
\_hbox{\_ifcsname cs:^\_tmp\_endcsname \_else \_dest[cs:^\_tmp]\_sxdef{cs:^\_tmp}{}\_fi
\_link[cs:\_tmp]{\ulinkcolor}{\_tt\_string#1}}%
\_futurelet\_next\_cslinkA
}
\_def\_cslinkA{\_ifx\_next`\_ea\_ignoreit \_else \_ea\_ea\_ea`\_ea\_string\_fi}
-\_def\~`#1{\_leavevmode\_edef\_tmp{\_csstring#1}\_iindex{\_tmp}%
+\_def\~`{\_bgroup \_docrefcodes \_doctpoint}
+\_def\_doctpoint #1{\_egroup\_leavevmode\_edef\_tmp{\_csstring#1}\_iindex{\_tmp}%
\_hbox{\_link[cs:^\_tmp]{\ulinkcolor}{\_tt\_string#1}}%
\_futurelet\_next\_cslinkA
}
+\_def\_moremainpoints{\_opwarning{Second main documentation point \_bslash\_tmp}}
\_doc -----------------------------
The \`\fw` macro for forward links to user documentation point (given later)
@@ -357,6 +363,8 @@ have the same meaning: `\optexdoclink` in this example. And
\endinput
+2022-12-11 \_opwaning "Second main documentation point" introduced.
+2022-12-11 \_docrefcodes added (bug due to 2022-11-13 fixed).
2022-11-21 magenta color for internal links instead green.
2022-11-13 \catcode`.=11: only local settings
2022-07-01 \_printii improved, colors declaration part added.
diff --git a/Master/texmf-dist/tex/optex/base/f-heros.opm b/Master/texmf-dist/tex/optex/base/f-heros.opm
index 2531573ca4b..d7495538826 100644
--- a/Master/texmf-dist/tex/optex/base/f-heros.opm
+++ b/Master/texmf-dist/tex/optex/base/f-heros.opm
@@ -193,12 +193,16 @@ so the first font from the new family is loaded and it is ready to use it.
\seccc Name conventions
-Create font modifiers, new variants, and the `\<Familyselector>` only as public, i.e.
-in user namespace without `_` prefix. We assume that if a user re-defines them then he/she needs
+Create font modifiers, new variants, and the `\<Familyselector>` only in
+public namespace without `_` prefix. We assume that if a user re-defines them then he/she needs
not them, so we have no problems. If the user's definition was done before loading
the font family file then it is re-defined and \OpTeX/ warns about it. See the end of
section~\ref[fontcommands].
+If you need to use an internal control sequence declared in your fontfile,
+use the reserved name space with names starting with two `_` followed by family
+indentifier or by `vf` if it relates to variable fonts.
+
The name of `\<Familyselector>` should begin with an uppercase letter.
Please, look at
diff --git a/Master/texmf-dist/tex/optex/base/fonts-resize.opm b/Master/texmf-dist/tex/optex/base/fonts-resize.opm
index 34885d44bd7..e76596611b4 100644
--- a/Master/texmf-dist/tex/optex/base/fonts-resize.opm
+++ b/Master/texmf-dist/tex/optex/base/fonts-resize.opm
@@ -107,7 +107,7 @@
The \`\_regtfm` `<font id> <optical size data>`
registers optical sizes data directly by the font file names.
This can be used for `tfm` files or OpenType files without
- various font features. See also \`\_regoptsizes` in section~\ref[optsizes].
+ various font features. See also \^`\_regoptsizes` in section~\ref[optsizes].
The `\_regtfm` command saves the <optical size data> concerned to the `<font id>`.
The `<optical size data>` is in the form as shown below in the code where
`\_regtfm` is used.
diff --git a/Master/texmf-dist/tex/optex/base/fonts-select.opm b/Master/texmf-dist/tex/optex/base/fonts-select.opm
index 7e00c9baea1..6b10f75aff0 100644
--- a/Master/texmf-dist/tex/optex/base/fonts-select.opm
+++ b/Master/texmf-dist/tex/optex/base/fonts-select.opm
@@ -733,10 +733,10 @@ Compare ex-height of Termes \rmsans with Heros \rm and Termes.
\endtt
The variant selectors (declared by \~`\famvardef`) or font
-modifiers (declared by \~`\moddef`) are (typically) control sequences in user name
-space (`\mf`, `\caps`). They are most often declared in font family files and
+modifiers (declared by \~`\moddef`) are (typically) control sequences in the public
+namespace (`\mf`, `\caps`). They are most often declared in font family files and
they are loaded by \^`\fontfam`. A conflict with such names in
-user namespace can be here. For example: if `\mf` is defined by a user and then
+the public namespace can be here. For example: if `\mf` is defined by a user and then
`\fontfam[Roboto]` is used then `\famvardef\mf` is performed for Roboto
family and the original meaning of `\mf` is lost. But \OpTeX/ prints warning
about it. There are two cases:
diff --git a/Master/texmf-dist/tex/optex/base/hisyntax-c.opm b/Master/texmf-dist/tex/optex/base/hisyntax-c.opm
index 3c1f228f88c..d0a4217b31e 100644
--- a/Master/texmf-dist/tex/optex/base/hisyntax-c.opm
+++ b/Master/texmf-dist/tex/optex/base/hisyntax-c.opm
@@ -52,7 +52,7 @@ User can re-declare his/her own colors by `\hicolors` which has precedence
before `\_hicolors<name>`.
The public variants can be declared if you want to give these token lists to
-the user namespace. But it is not explicitly needed.
+the public namespace. But it is not explicitly needed.
All settings must be global here because the file is typically read inside
a group and we need not read it repeatedly before each code chunk
diff --git a/Master/texmf-dist/tex/optex/base/if-macros.opm b/Master/texmf-dist/tex/optex/base/if-macros.opm
index 9113b5f8beb..148c8559413 100644
--- a/Master/texmf-dist/tex/optex/base/if-macros.opm
+++ b/Master/texmf-dist/tex/optex/base/if-macros.opm
@@ -1,6 +1,6 @@
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \newif {Special if-macros, is-macros and loops <2022-12-02>} % preloaded in format
+\_codedecl \newif {Special if-macros, is-macros and loops <2023-01-16>} % preloaded in format
\_doc ----------------------------
\secc Classical \code{\\newif}
@@ -64,6 +64,7 @@
\_def \_iterate {\_body \_ea \_iterate \_fi}
\_doc -----------------------------
+ {\_let\_moremainpoints=\_relax
\`\foreach` `<list>`\`\do` `{<what>}`
repeats `<what>` for each element of the
`<list>`. The `<what>` can include `#1` which is substituted by each
@@ -82,7 +83,7 @@
Recommendation: it is better to use private variants of \`\_foreach`.
When the user writes `\input tikz` then `\foreach` macro is redefined in
each TikZ environment.
- The private variants use \`\_do` separator instead `\do` separator.
+ The private variants use \`\_do` separator instead `\do` separator.}
\_cod -----------------------------
\_newcount\_frnum % the numeric variable used in \fornum
@@ -101,6 +102,7 @@
\_afterfi{\_foreachA{#1}{##1}}\_else\_afterfi{\_foreachA{#1}{#2}}\_fi}
\_doc -----------------------------
+ {\_let\_moremainpoints=\_relax
\`\fornum` `<from>..<to>` \`\do` `{<what>}` or
\`\fornumstep` `<num>: <from>..<to>` \`\do` `{<what>}`
repeats `<what>` for each number from `<from>` to `<to>` (with step `<num>`
@@ -110,7 +112,7 @@
The test in the \`\_fornumB` says: if (<to> $\string<$ <current number>
AND <step> is positive) or if (<to> $>$ <current number> AND <step> is
negative) then close loop by `\_getforstack`. Sorry, the condition is
- writen by somewhat cryptoid \TeX/ language.
+ writen by somewhat cryptoid \TeX/ language.}
\_cod -----------------------------
\_def\_fornum#1..#2\_do{\_fornumstep 1:#1..#2\_do}
@@ -292,16 +294,17 @@
\_public \isfont ;
\_doc ----------------------------
- The last macro \`\isnextchar` `<char>{<codeA>}{<codeB>}`
+ The macro \`\isnextchar` `<char>{<codeA>}{<codeB>}`
has a different syntax than all other is-macros.
It executes `<codeA>` if next character is equal to <char>.
- Else the `<codeB>` is executed. The macro is not expandable.
+ Else the `<codeB>` is executed. The macro is expandable.
\_cod ----------------------------
-\_long\_def\_isnextchar#1#2#3{\_begingroup\_toks0={\_endgroup#2}\_toks1={\_endgroup#3}%
- \_let\_tmp= #1\_futurelet\_next\_isnextcharA
+\_long\_def\_isnextchar#1#2#3{\_immediateassignment
+ \_def\_isnextcharA{\_isnextcharB{#1}{#2}{#3}}%
+ \_immediateassignment\_futurelet \_next \_isnextcharA
}
-\_def\_isnextcharA{\_the\_toks\_ifx\_tmp\_next0\_else1\_fi\_space}
+\_long\_def\_isnextcharB#1{\_ifx\_next#1\_ea\_ignoresecond\_else\_ea\_usesecond\_fi}
\_public \isnextchar ;
@@ -359,6 +362,7 @@
\_endcode
+2023-01-16 \isnextchar created expandable.
2022-12-02 \xcasesof: its first parameter is \long too.
2022-11-29 renamed to \casesof, \xcasesof.
2022-11-26 \casesby, \casesbyif introduced.
diff --git a/Master/texmf-dist/tex/optex/base/keyval.opm b/Master/texmf-dist/tex/optex/base/keyval.opm
index 7d089ce6b1f..21e6f9acf34 100644
--- a/Master/texmf-dist/tex/optex/base/keyval.opm
+++ b/Master/texmf-dist/tex/optex/base/keyval.opm
@@ -1,26 +1,39 @@
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \readkv {Key-value dictionaries <2020-12-21>} % preloaded in format
+\_codedecl \readkv {Key-value dictionaries <2023-01-14>} % preloaded in format
\_doc ----------------------------
- {\bf Implementation.}
+ {\bf Implementation.}\nl
The \`\readkv``<list>` expands its parameter and does replace-strings in order to
- remove spaces around equal signs and after commas. Double commas are
- removed. Then \`\_kvscan` reads the parameters list finished by the double
- comma and saves values to `\_kv:<key>` macros.\nl
- The \`\kv``{<key>}` expands the `\_kv:<key>` macro. If this macro isn't
- defined then \`\_kvunknown` is processed. You can re-define it if you want.
+ remove spaces around equal signs and after commas.
+ Then \`\_kvscan` reads the parameters list finished by `,\_fin,`
+ and saves values to `\_kv:<dict>:<key>` macros.
+ The `\_kvx:<dict>:<key>` is processed (if it is defined) with parameter
+ <value> after it.\nl
+ The \`\kvx``{<key>}{<code>}` defines the `\_kvx:<dict>:<key>#1` macro
+ and \`\nokvx``{<code>}` defines the `\_nokvx:<dict>:<key>` macro.\nl
+ The \`\kv``{<key>}` expands the `\_kv:<dict>:<key>` macro. If this macro isn't
+ defined then \`\_kvunknown` is processed. You can re-define it if you want.\nl
+ The \`\iskv``{<key>}\iftrue` (or `\iffalse`) is the test,
+ if the `<key>` is defined in current <dict>.
\_cod ----------------------------
\_def\_readkv#1{\_ea\_def\_ea\_tmpb\_ea{#1}%
- \_replstring\_tmpb{= }{=}\_replstring\_tmpb{ =}{=}%
- \_replstring\_tmpb{, }{,}\_replstring\_tmpb{,,}{,}%
- \_ea \_kvscan \_tmpb,,=,}
-\_def\_kvscan #1#2=#3,{\_ifx#1,\_else \_sdef{_kv:#1#2}{#3}\_ea\_kvscan\_fi}
-\_def\_kv#1{\_trycs{_kv:#1}{\_kvunknown}}
+ \_replstring\_tmpb{= }{=}\_replstring\_tmpb{ =}{=}\_replstring\_tmpb{, }{,}%
+ \_ea \_kvscan\_tmpb,\_fin,}
+\_def\_kvscan#1,{\_ifx\_fin#1\_empty\_ea\_ignoreit \_else\_ea\_useit \_fi
+ {\_kvsd #1==\_fin \_kvscan}}
+\_def\_kvsd#1=#2=#3\_fin{\_sdef{\_kvcs#1}{#2}%
+ \_trycs{_kvx:\_the\_kvdict:#1}%
+ {\_trycs{_nokvx:\_the\_kvdict}{\_ea\_ignoreit}{#1}\_ea\_ignoreit}{#2}}
+\_def\_kvx#1#2{\_sdef{_kvx:\_the\_kvdict:#1}##1{#2}}
+\_def\_nokvx#1{\_sdef{_nokvx:\_the\_kvdict}##1\_ea\_ignoreit\_fi##2{\_fi#1}}
+\_def\_kv#1{\_trycs{\_kvcs#1}{\_kvunknown}}
+\_def\_iskv#1#2{#2\_else\_ea\_unless\_fi \_ifcsname\_kvcs#1\_endcsname}
+\_def\_kvcs{_kv:\_the\_kvdict:}
\_def\_kvunknown{???}
-\public \readkv \kv ;
+\public \readkv \kvx \nokvx \kv \iskv ;
\_endcode
@@ -43,7 +56,7 @@ or simply `\myframe {text3}`. You can define `\myframe` as follows:
\begtt
\def\myframedefaults{% defaults:
frame-color=\Black, % color of frame rules
- text-color=\Black, % color ot text inside the frame
+ text-color=\Black, % color of text inside the frame
rule-width=0.4pt, % width of rules used in the frame
margins=2pt, % space between text inside and rules.
}
@@ -64,18 +77,54 @@ The last setting wins.
Third: the values can be used by the expandable \^`\kv{<key>}` macro.
The \^`\kv{<key>}` returns `???` if such key is not declared.
-You can use keys without values in the parameters list too, but with
-additional care. For example, suppose `draft` option without parameter.
-If a user writes `\myframe [..., draft, ...]{text}` then `\myframe` should behave differently.
-We have to add `DRAFTv=0,` in `\myframedefault` macro.
-Moreover, `\myframe` macro must include preprocessing of `\myframedefault` using
-\^`\replstring` which replaces the occurrence of `draft` by `DRAFTv=1`.
+You can use keys without values in the parameters list too.
+Then you can ask if the key is declared by \^`\iskv``{<key>}\iftrue`
+or the key is undeclared by \^`\iskv``{<key>}\iffalse`.
+For example, you write to your documentation of your code that
+user can set the `draft` option without the value. Then you can do
\begtt
\optdef\myframe [] #1{...
- \ea\addto\ea\myframedefaults\ea{\the\opt}%
- \replstring\myframedefaults{draft}{DRAFTv=1}%
- \readkv\myframedefaults
- ...
- \ifnum\kv{DRAFTv}=1 draft mode\else normal mode\fi
+ \readkv\myframedefaults \readkv{\the\opt}%
+ \iskv{draft}\iftrue ...draft mode... \else ...final mode... \fi
+ ...}
+\endtt
+Maybe, you want to allow not ony `draft` option but `final` option (which is
+opposite to `draft`) too and you want to apply the result from the last given
+option. Then `\iskv` doesn't work because you can only check if both options
+are declared but you don't know what one is given as last. But you can
+use \^`\kvx``{<key>}{<code>}` to declare <code> which is processed
+immediately when the `<key>` is processed by `\readkv`. For example
+\begtt
+\newcount\mydraftmode
+\kvx{draft}{\mydraftmode=1 }
+\kvx{final}{\mydraftmode=0 }
+\optdef\myframe [] #1{...
+ \readkv\myframedefaults \readkv{\the\opt}%
+ \ifnum\mydraftmode=1 ...draft mode... \else ...final mode... \fi
...}
\endtt
+The syntax of \^`\kvx` `{<key>}{<code>}` allows to use `#1` inside the code.
+It is replaced by the actual `<value>`. Example: `\kvx{opt}{\message{opt is #1}}`,
+then `\readkv{opt=HELLO}` prints \"opt is HELLO".
+
+The \^`\nokvx` `{<code>}` can declare a <code> processed for all <keys>
+undeclared by \^`\kvx`. The `#1` and `#2` can be used in the <code>,
+`#1` is <key>, `#2` is <value>. If `\nokvx` is unused then nothing is done
+for undeclared <key>. Example: `\nokvx{\opwarnig{Unknown option "#1"}}`.
+
+The default dictionary name (where key-value pairs are processed) is
+empty. You can use your specific dictionary by
+\^`\kvdict``={<name>}`. Then `\redakv`, `\kv`, `\iskv`, `\kvx` and `\nokvx`
+macros use this named dictionary of <key>/<value> pairs.
+Package options can be processed when
+`\kvdict={pkg:<pkg>}`, example is the `\mathset` macro in
+\ulink[https://petr.olsak.net/ftp/olsak/optex/math-doc.pdf]{{\tt math.opm} package}.
+
+Recommendation: If the value of the key-value pair includes `=` or `,` or
+`]`, then use the syntax `<key>={<value>}`.
+
+\_endinput
+
+2023-01-13 \kvx parameter added, \nokvx introduced.
+2023-01-07 \kvdict, \kvx, \iskv added.
+2020-12-21 Released
diff --git a/Master/texmf-dist/tex/optex/base/lists.opm b/Master/texmf-dist/tex/optex/base/lists.opm
index 189719302dd..57b057d6c8c 100644
--- a/Master/texmf-dist/tex/optex/base/lists.opm
+++ b/Master/texmf-dist/tex/optex/base/lists.opm
@@ -61,7 +61,7 @@
\_public \begitems \enditems \itemnum ;
\_doc ----------------------------
- \`\novspaces` sets \`\listskipamount` to 0pt.
+ \`\novspaces` sets \^`\listskipamount` to 0pt.
\_cod ----------------------------
\_def\_novspaces {\_removelastskip \_listskipamount=0pt \_relax}
@@ -71,9 +71,9 @@
Various item marks are saved in `\_item:<letter>` macros.
You can re-define then or define more such macros.
The \`\style` `<letter>` does \`\_printitem``={\_item:<letter>}`.
- More exactly: \^`\begitems` does `\_printitem=`\^`\defaultitem` first,
- then \`\style` `<letter>` does \`\_printitem``={\_item:<letter>}`
- when it is used and finally, `\_startitem` alias `*` uses `\_printitem`.
+ More exactly: \^`\begitems` does \^`\_printitem=`\^`\defaultitem` first,
+ then \^`\style` `<letter>` does \^`\_printitem``={\_item:<letter>}`
+ when it is used and finally, `\_startitem` alias `*` uses \^`\_printitem`.
\_cod -----------------------------
\_def\_style#1{%
diff --git a/Master/texmf-dist/tex/optex/base/math-macros.opm b/Master/texmf-dist/tex/optex/base/math-macros.opm
index 83d3c5ab513..6e2365c9cc9 100644
--- a/Master/texmf-dist/tex/optex/base/math-macros.opm
+++ b/Master/texmf-dist/tex/optex/base/math-macros.opm
@@ -368,7 +368,7 @@
\_doc -----------------------------
\`\big`, \`\Big`, \`\bigg`, \`\Bigg`, \`\bigl`, \`\bigm`, \`\bigr`, \`\Bigl`, \`\Bigm`,
- \`\Bigr`, \`\biggl`, \`\biggm`, \`\biggr`, \`\Biggl`, \`\Biggm`, \`\Bigg`, \`\Biggr`
+ \`\Bigr`, \`\biggl`, \`\biggm`, \`\biggr`, \`\Biggl`, \`\Biggm`, \`\Biggr`
are based on the \`\_scalebig` macro because we need the dependency on
the various sizes of the fonts.
\_cod -----------------------------
@@ -703,7 +703,7 @@
\_public\displaylines ;
\_doc -----------------------------
- \`\openup`, \`\eqalignno` and `\leqalignno` macros are copied from
+ \`\openup`, \`\eqalignno` and \`\leqalignno` macros are copied from
Plain \TeX/ unchanged.
\_cod -----------------------------
diff --git a/Master/texmf-dist/tex/optex/base/more-macros.opm b/Master/texmf-dist/tex/optex/base/more-macros.opm
index 418e71b7749..8c622432340 100644
--- a/Master/texmf-dist/tex/optex/base/more-macros.opm
+++ b/Master/texmf-dist/tex/optex/base/more-macros.opm
@@ -1,6 +1,6 @@
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \eoldef {OpTeX useful macros <2022-11-24>} % preloaded in format
+\_codedecl \eoldef {OpTeX useful macros <2023-01-18>} % preloaded in format
\_doc -----------------------------
We define \`\opinput` `{<file name>}` macro which
@@ -261,7 +261,7 @@
\_public \cstochar ;
\_doc -----------------------------
- You can use expandable \`\bp``{<dimen>}` convertor from
+ You can use expandable \`\bp``{<dimen>}` converter from
\TeX/ `<dimen>` (or from an expression accepted by
`\dimexpr` primitive) to a decimal value in big points
(used as natural unit in the PDF format). So, you can write, for example:
@@ -269,21 +269,32 @@
\pdfliteral{q \_bp{.3\hsize-2mm} \_bp{2mm} m 0 \_bp{-4mm} l S Q}
\endtt
You can use expandable \`\expr``{<expression>}` for analogical purposes.
- It expands to the value of the `<expression>` at expand processor level
- with \`\_decdigits` digits after the decimal point.
+ It expands to the value of the `<expression>` at expand processor level.
The `<expression>` can include `+-*/()` and decimal numbers in common syntax.
+ The math functions (and pi constant) have to be prefixed by `math.`,
+ because it is processed by Lua interpreter. For
+ example `\expr{math.pi*math.sqrt(2)}`.
+ The list of available functions is in
+ \ulink[https://www.lua.org/manual/5.3/manual.html\#6.7]{Lua manual}.
+
+ You can set the number of decimal digits after decimal point of the
+ results of `\bp` and `\expr`
+ by optional syntax `\bp[<digits>]{<dimen>}` and
+ `\expr[<digits>]{<expression>}`. Default is \`\_decdigits`.
The usage of prefixed versions \`\_expr` or \`\_bp` is more recommended
because a user can re-define the control sequences `\expr` or `\bp`.
\_cod -----------------------------
\_def\_decdigits{3} % digits after decimal point in \_bp and \_expr outputs.
-\_def\_pttopb{%
- \_directlua{tex.print(string.format('\_pcent.\_decdigits f',
+\_def\_pttopb#1{%
+ \_directlua{tex.print(string.format('\_pcent.#1f',
token.scan_dimen()/65781.76))}% pt to bp conversion
}
-\def\_bp#1{\_ea\_pttopb\_dimexpr#1\_relax}
-\def\_expr#1{\_directlua{tex.print(string.format('\_pcent.\_decdigits f',#1))}}
+\_def\_bp{\_isnextchar[{\_bpA}{\_bpA[\_decdigits]}}
+\_def\_bpA[#1]#2{\_pttopb{#1}\_dimexpr#2\_relax}
+\_def\_expr{\_isnextchar[{\_exprA}{\_exprA[\_decdigits]}}
+\_def\_exprA[#1]#2{\_directlua{tex.print(string.format('\_pcent.#1f',#2))}}
\_public \expr \bp ;
@@ -363,6 +374,7 @@
\_endcode % -------------------------------------
+2023-01-18 \bp, \expr have optional syntax for setting dec-digits
2022-11-24 \setpos, \posx, \posy moved from OpTeX trick here
2022-11-22 \docgen writes banner to log
2022-11-20 \docgen reads lines before \_codedecl in order to define pkg. version
diff --git a/Master/texmf-dist/tex/optex/base/optex.ini b/Master/texmf-dist/tex/optex/base/optex.ini
index 4941ead57c1..3266cf0ab1f 100644
--- a/Master/texmf-dist/tex/optex/base/optex.ini
+++ b/Master/texmf-dist/tex/optex/base/optex.ini
@@ -21,7 +21,7 @@
% OpTeX version
-\def\optexversion{1.09 Dec 2022}
+\def\optexversion{1.10 Feb 2023}
\def\fmtname{OpTeX}
\let\fmtversion=\optexversion
diff --git a/Master/texmf-dist/tex/optex/base/others.opm b/Master/texmf-dist/tex/optex/base/others.opm
index 98df836f763..cde2f02fa1f 100644
--- a/Master/texmf-dist/tex/optex/base/others.opm
+++ b/Master/texmf-dist/tex/optex/base/others.opm
@@ -177,9 +177,9 @@
\_else % LuaTeX 1.14 or newer:
\_doc -----------------------------
- We set `\partokenneame` to `\_par` in order to keep the name `\par` in
- user name space. I.e. a user can say `\def\par{paragraph}` for example
- without crash of processing the document. Se section~\ref[prefixed] for
+ We set `\partokenneame` to `\_par` in order to keep the name `\par` in the
+ public namespace for end users. I.e.\ a user can say `\def\par{paragraph}` for example
+ without crash of processing the document. Se section~\ref[namespaces] for
more details about the name space concept.\nl
Moreover, we set `\partokencontext` to one in order to the `\_par` token
is inserted not only at empty lines, but also at the end of `\vbox`, `\vtop` and
diff --git a/Master/texmf-dist/tex/optex/base/parameters.opm b/Master/texmf-dist/tex/optex/base/parameters.opm
index 499aee8d45c..855969f4de2 100644
--- a/Master/texmf-dist/tex/optex/base/parameters.opm
+++ b/Master/texmf-dist/tex/optex/base/parameters.opm
@@ -205,6 +205,14 @@
\_public \picwidth \picheight ;
\_doc -----------------------------
+ \`\kvdict` is dictionary name when \~`\readkv`, \~`\kvx`, \~`\kv`, and \~`\iskv` are
+ processed. The default is empty.
+ \_cod -----------------------------
+
+\_newtoks \_kvdict
+\_public \kvdict ;
+
+ \_doc -----------------------------
The \`\everytt` is the token list used in
\^`\begtt`...\^`\endtt` environment and
in the verbatim group opened by \^`\verbinput` macro. You can include a
@@ -542,12 +550,10 @@
% \_shadow=N \_overlapmargins=N \_hhkern=3pt \_vvkern=3pt}
\_newdimen \_roundness \_roundness=5mm % used in \clippingoval macro
-
\_public \ovalparams \circleparams \roundness ;
\_doc -----------------------------
- \OpTeX/ defines \"Standard \OpTeX/ markup language"%
- \fnote{Will be developed in 2021.}
+ \OpTeX/ defines \"Standard \OpTeX/ markup language"
which lists selected commands from chapter~1 and gives their behavior when a
converter from \OpTeX/ document to HTML or Markdown or \LaTeX/ is used.
The structure-oriented commands are selected here, but the commands which
diff --git a/Master/texmf-dist/tex/optex/base/prefixed.opm b/Master/texmf-dist/tex/optex/base/prefixed.opm
index a599e0ec856..023f3bc4de9 100644
--- a/Master/texmf-dist/tex/optex/base/prefixed.opm
+++ b/Master/texmf-dist/tex/optex/base/prefixed.opm
@@ -152,44 +152,70 @@
\_endcode %----------------------------------------------------
-\sec[prefixed] Concept of namespaces of control sequences
+\sec[basic-code] Basic principles of \OpTeX/ sources
-\secc Prefixing internal control sequences
+\secc[namespaces] Concept of namespaces of control sequences
-All control sequences used in \OpTeX/ are used and defined with `_` prefix.
-The user can be sure that when he/she does `\def\foo` then neither internal macros of
-\OpTeX/ nor \TeX/ primitives will be damaged. For example
-`\def\if{...}` will not damage macros because \OpTeX/'s macros
-are using `\_if` instead of `\if`.
+\OpTeX/ sets the category code of the \"`_`" character to 11 (letter)
+and it is never changed.\fnote
+{This is only singular exception form category codes given by plain \TeX.}
+So, we can always construct multiletter control sequence names from letters
+`A`--`Z`, `a`--`z`, and `_`. The \"letter `_`" works in math mode as a subscript
+constructor because it is set as math active character (see section~\ref[math-macros]).
-All \TeX/ primitives are initialized with two representative control
-sequences: `\word` and `\_word`, for example `\hbox` and `\_hbox`.
-The first alternative is reserved for users or such control sequences
-can be re-defined by a user.
-
-\OpTeX/ sets the character `_` as letter, so it can be used in
-control sequences. When a control sequence begins with this character
-then it means that it is a primitive or it is used in \OpTeX/ macros as
-internal. User can redefine such prefixed control sequence only
-if he/she explicitly knows what happens.
-
-We never change catcode of `_`, so internal macros can be
-redefined by user without problems if it is desired. We don't need
-something like `\makeatletter` from \LaTeX/.
-
-\OpTeX/ defines all new macros as prefixed. For public usage of such macros,
-we need to set their non-prefixed versions. This is done by
+We distinguish following namespaces for multiletter control sequences:
+\begitems
+* Only alphabetical names are in the {\em public namespace}. They are intended
+ for end users when creating a document. Sometimes it is called {\em user
+ namespace} too. For example `\hbox`, `\fontfam`, `\MyMacro`.
+* Only alphabetical lowercase names prefixed by single \"`_`" are in the
+ {\em private namespace}. It is used in \OpTeX/ internal macros.
+ For example `\_hbox`, `\_fontsel`.
+* Names in the form `\_<pkg>_<name>` are in the {\em package namespace},
+ see section~\ref[pkg-namespace]. For example `\_qr_size`, `\_math_alist`.
+* Names starting with two \"`_`" are in the {\em reserved namespace}. They can be
+ used for internal control sequences in font family files or in similar cases.
+* Other names which include \"`_`" but not as the first character can be used
+ too, but with care, see the end of this section.
+\enditems
+All \TeX/ primitives are initialized with two control sequences with the
+same meaning: {\em prefixed} control sequence
+(in private namespace, for example `\_hbox`)
+and {\em unprefixed} control sequence (in public namespace, for example `\hbox`).
+All \OpTeX/ macros intended for end users are initialized in these two forms
+too, for example `\_ref` and `\ref`.
+
+Users can declare any control sequences in the public namespace without worrying
+that \OpTeX/ behavior is changed. This is because \OpTeX/ uses exclusively
+prefixed control sequences in its macros. For example, a user can declare
+`\def\fi{finito}` and nothing bad happens, if the user doesn't use `\fi` in
+its original primitive meaning. You don't have to know all \TeX/ primitives
+and \OpTeX/ macros, you can declare control sequences for your use in the
+public namespace without limitations and nothing bad will happen.
+
+You can use control sequences from private or package namespace in
+a \"read-only manner" without changing \OpTeX/ behavior too.
+On the other hand, if you re-define a control sequence in the private name
+space, the \OpTeX/ behavior can be changed. You can do it
+but we suppose that you know what you are doing and what \OpTeX/
+behavior is changed.
+
+All multiletter control sequences declared by \OpTeX/ are defined in the private
+namespace first (`\_def\_macro{...}`). If the declared control sequences are
+intended for end users too then they are exported to the public namespace
+after that. It is done by the \^`\public` macro:
\begtt \catcode`\<=13
\public <list of control sequences> ;
\endtt
-
For example \^`\public`` \foo \bar ;` does `\let\foo=\_foo`, `\let\bar=\_bar`.
-At the end of each code segment in \OpTeX/, the `\_public` macro is used. You
-can see which macros are defined for public usage in that code segment.
+There is an exception of the above mentioned principle. Control sequences
+which are alternatives to math characters (`\alpha`, `\forall`, `\subset` etc.)
+are declared only in public name space if they are not used in any internal
+\OpTeX/ macros.
-The macro \^`\private` does the reverse job of `\public` with the same syntax.
+The macro \^`\private` does the reverse job of \^`\public` with the same syntax.
For example `\private \foo \bar ;` does `\let\_foo=\foo`, `\let\_bar=\bar`.
This should be used when an unprefixed variant of a control sequence is declared
already but we need the prefixed variant too.
@@ -199,45 +225,33 @@ In this documentation: if both variants of a control sequence are declared
the unprefixed variant. The code typically defines the prefixed variant
and then the \^`\public` (or `\_public`) macro is used.
-\secc[user-ns] Namespace of control sequences for users
-
-Users can (re)define or (re)declare any control sequence with a name without any `_`.
-This does not make any problem in internal \OpTeX/ macros.\fnote
-{The token `\par` is in user name space too from \OpTeX/ 1.04+ and
-Lua\TeX/ 1.14, see also the end of section~\ref[others].}
-
-User can define or declare control sequences with `_` character, for
-example `\my_control_sequence`, but with the following exceptions:
-
-\begitems
-* Control sequences which begin with `_` are reserved for \TeX/ primitives,
- \OpTeX/ internal macros and packages internal macros.
-* Multiletter control sequences in the form
- `\<word>_` or `\<word>_<one-letter>`, where
- <word> is a sequence of letters, are inaccessible, because they
- are interpreted as `\<word>` followed by `_` or as `\<word>` followed by
- `_<one-letter>`. This is important for writing math, for example:
-\begtt \adef-{_}
- \int-a^b ... is interpreted as \int _a^b
- \max-M ... is interpreted as \max _M
- \alpha-{ij} ... is interpreted as \alpha _{ij}
-\endtt
- This feature is implemented using Lua code at input processor level, see
- the section~\ref[math-macros] for more details. You can deactivate this feature by
- \^`\mathsboff`. After this, you can still write
- `$`$\int$`_a^b$` (Unicode) or `$\int _a^b$` % $∫_a^b$ (Unicode) or $\int _a^b$
- without problems but `\int``_a^b` yields to undefined control sequence
- `\int``_a`. You can activate this feature again by \^`\mathsbon`. The
- effect will take shape from next line read from input file.
-* Control sequences in the form `\_<pkg>_<word>` is intended for package
- writers as internal macros for a package with `<pkg>` identifier,
- see section~\ref[pkg-namespace].
-\enditems
-
The single-letter control sequences like `\%`, `\$`, `\^` etc. are not used
in internal macros. Users can redefine them, but (of course) some classical
features can be lost (printing percent character by `\%` for example).
+It is very tempting to use control sequence names with `_` in order to
+distinguish more words in the sequence name. If the first character isn't
+`_` then such a name is outside private and package namespaces, so they can
+be used for various purposes. For example `\my_control_sequence`. But there
+is an exception: control sequences in the form `\<word>_` or `\<word>_<one-letter>`,
+where <word> is a sequence of letters, are inaccessible, because they
+are interpreted as `\<word>` followed by `_` or as `\<word>` followed by
+`_<one-letter>`. This feature is activated because we want to write math
+formulae as in plain \TeX, for example:
+\begtt
+ \int_a^b ... is interpreted as \int _a^b
+ \max_M ... is interpreted as \max _M
+ \alpha_{ij} ... is interpreted as \alpha _{ij}
+\endtt
+It is implemented using Lua code at input processor level, see
+the section~\ref[math-macros] for more details. You can deactivate this feature by
+\^`\mathsboff`. After this, you can still write
+`$`$\int$`_a^b$` (Unicode) or `$\int _a^b$` % $∫_a^b$ (Unicode) or $\int _a^b$
+without problems but `\int``_a^b` yields to undefined control sequence
+`\int``_a`. You can activate this feature again by \^`\mathsbon`. The
+effect will take shape from next line read from input file.
+
+
\secc Macro files syntax
Segments of \OpTeX/ macros or external macro packages
@@ -272,7 +286,7 @@ put macros for creating your documentation between
first pair of \^`\_doc` ... \^`\_cod` used after \^`\_endcode`.
These macros should \^`\load[doc]` and must be finished by \^`\bye`.
Then you have code+documentation together in a single file and
-user can generate the documentation of our package by
+user can generate the documentation of your package by
\^`\docgen` used at command line:
\begtt
optex -jobname pkgname-doc '\docgen pkgname'
@@ -307,10 +321,10 @@ does `\let\foo = \_<pkg>_foo` for each given sequence when
\^`\_namespace{<pkg>}` is declared. Moreover, it prints a warning if `\foo` is
defined already. The \^`\_nsprivate` macro does reverse
operation to it without warnings. Example: you can define `\def\.macro{...}` and then
-set it to the user name space by `\_nspublic \macro;`.
+set it to the public namespace by `\_nspublic \macro;`.
It could happen that a package writer needs to declare a control sequence
-(say `\foo`) directly without setting it in `\_<pkg>_foo` name space
+(say `\foo`) directly without setting it in `\_<pkg>_foo` namespace
followed by using \^`\_nspublic`. The \^`\newpublic` prefix should be used in this
case, for example `\_newpublic\_def\foo` or `\_newpublic\_chardef\foo` or
`\_newpublic{\_long\_def}\foo`. The \^`\newpublic``<do>\<sequence>` prints
@@ -338,9 +352,9 @@ If you are writing a macro file that is intended to be published for
\OpTeX/, then you are greatly welcome. You should follow these rules:
\begitems
-* Don't use control sequences from the user namespace in the macro
+* Don't use control sequences from the public namespace in the macro
bodies if there is no explicit and documented reason to do this.
-* Don't declare control sequences in the user namespace if there are no
+* Don't declare control sequences in the public namespace if there are no
explicit and documented reasons to do this.
* Use control sequences from \OpTeX/ and primitive namespace
in read-only mode, if there is not an explicit and documented reason to
@@ -368,11 +382,12 @@ used directly in \OpTeX/ and from other published macros.
This extension `.opm` has precedence before `.tex` when
the \^`\load` macro is used.
-The `qrcode.opm` is the first example of how an external macro file for \OpTeX/
+The `math.opm` is a good example of how an external macro file for \OpTeX/
can look like.
\endinput
+2023-01-30 doc. about namespaces rewritten
2022-11-25 \_resetnamespace: moved \gdef\_namesp:#1 {} to \_namespace
2022-11-24 \newpublic introduced, \_checkexists with only two parameters.
2022-11-22 \currfile introduced and used in \_codedecl
diff --git a/Master/texmf-dist/tex/optex/base/references.opm b/Master/texmf-dist/tex/optex/base/references.opm
index 9da2bca30fb..56ad7ad5892 100644
--- a/Master/texmf-dist/tex/optex/base/references.opm
+++ b/Master/texmf-dist/tex/optex/base/references.opm
@@ -1,6 +1,6 @@
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \ref {References <2021-04-13>} % preloaded in format
+\_codedecl \ref {References <2022-01-22>} % preloaded in format
\_doc ----------------------------
\`\_Xpage` `{<gpageno>}{<pageno>}` saves the parameter pair into \`\_currpage`.
@@ -121,5 +121,6 @@ See section \ref[ref-file] for more information about `.ref` file concept.
\_endinput
+2022-01-22 ... extended format for \ref, \pgref
2021-04-13 ... \_slideshook introduced (used by \slides)
2020-03-03 ... released
diff --git a/Master/texmf-dist/tex/optex/base/sections.opm b/Master/texmf-dist/tex/optex/base/sections.opm
index 7d7a78232bd..7940a47bfac 100644
--- a/Master/texmf-dist/tex/optex/base/sections.opm
+++ b/Master/texmf-dist/tex/optex/base/sections.opm
@@ -171,7 +171,7 @@
First, we read the optional parameter `[<label>]`, if it exists.
The `\chap`, `\sec` and `\secc` macro reads its parameter using
\^`\scantoeol`. This causes that they cannot be used inside other macros.
- Use \`\_inchap`, \`\_insec`, and \`\_insecc` macros directly in such case.
+ Use \^`\_inchap`, \^`\_insec`, and \^`\_insecc` macros directly in such case.
\_cod ----------------------------
\_optdef\_chap[]{\_trylabel \_scantoeol\_inchap}
diff --git a/Master/texmf-dist/tex/optex/base/slides.opm b/Master/texmf-dist/tex/optex/base/slides.opm
index 39267064baa..84cf6f5db30 100644
--- a/Master/texmf-dist/tex/optex/base/slides.opm
+++ b/Master/texmf-dist/tex/optex/base/slides.opm
@@ -277,7 +277,7 @@
\_def\layers{\_layers}
\_doc -----------------------------
- We must to redefine \`\fnotenumpages` because the data from `.ref` file
+ We must to redefine \^`\fnotenumpages` because the data from `.ref` file
are less usable for implementing such a feature: the
footnote should be in more layers repeatedly. But we can suppose that
each page starts by `\pg;` macro, so we can reset the footnote counter by
diff --git a/Master/texmf-dist/tex/optex/base/table.opm b/Master/texmf-dist/tex/optex/base/table.opm
index 1866c0486d1..a249f1e30a0 100644
--- a/Master/texmf-dist/tex/optex/base/table.opm
+++ b/Master/texmf-dist/tex/optex/base/table.opm
@@ -1,6 +1,6 @@
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \table {Basic macros for OpTeX <2022-05-03>} % preloaded in format
+\_codedecl \table {Basic macros for OpTeX <2022-12-26>} % preloaded in format
\_doc -----------------------------
The result of the \`\table``{<declaration>}{<data>}` macro is inserted into
@@ -229,9 +229,9 @@
We don't want vertical line after red A to be in red.
\_cod -----------------------------
-\_def\_tabdeclarec{\_the\_tabiteml \_begingroup\_hfil##\_unsskip\_hfil\_endgroup \_the\_tabitemr}
-\_def\_tabdeclarel{\_the\_tabiteml \_begingroup ##\_unsskip\_hfil\_endgroup \_the\_tabitemr}
-\_def\_tabdeclarer{\_the\_tabiteml \_begingroup\_hfil##\_unsskip\_endgroup \_the\_tabitemr}
+\_def\_tabdeclarec{\_the\_tabiteml \_hfil{##}\_unsskip \_hfil \_the\_tabitemr}
+\_def\_tabdeclarel{\_the\_tabiteml {##}\_unsskip \_hfil\_the\_tabitemr}
+\_def\_tabdeclarer{\_the\_tabiteml \_hfil{##}\_unsskip \_the\_tabitemr}
\_doc -----------------------------
The \`\_paramtabdeclarep``{<data>}` is invoked when `p{<data>}`
@@ -587,6 +587,7 @@ after the second one.
\_endinput
+2022-12-26 \tabdeclare: use {##} in order to allow a\over b in table items
2022-05-03 \_let\_tablereplstring\_relax removed and {...} encloses whole \_tableB body
2022-05-02 \_tablereplstrings put in group: bug fix \table in \halign
2022-02-25 {}->\(begin|end)group in \_tabdeclare(l|r|c), bug when \tabitem(l|r)={$} fixed.
diff --git a/Master/texmf-dist/tex/optex/base/unimath-codes.opm b/Master/texmf-dist/tex/optex/base/unimath-codes.opm
index 418d0d28aa1..66be7487d4d 100644
--- a/Master/texmf-dist/tex/optex/base/unimath-codes.opm
+++ b/Master/texmf-dist/tex/optex/base/unimath-codes.opm
@@ -1,27 +1,82 @@
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \_ncharrmA {Uni math codes <2022-11-20>} % preloaded on demand by \loadmath
+\_codedecl \_ncharrmA {Uni math codes <2023-01-17>} % preloaded on demand by \loadmath
\_doc -----------------------------
- The control sequences for `\alpha`, `\beta` etc are redefined here.
- The `\alpha` expands to the character with Unicode `"03B1`, this is a normal
- character $α$. You can type it directly in your editor if you know how
- to do this.
+ Unicode math font includes all typical math alphabets together, user needs no
+ load more \TeX/ math families. These math alphabets are encoded by
+ different parts of Unicode table. We need auxiliary macros for setting
+ mathcodes by selected math alphabet.
+ \nl
+ \`\_umathrange` `{<from->-<to>}<class><family>\<first>` sets `\Umathcode`s
+ of the characters in the interval `<from>-<to>` to `\<first>`,
+ `\<first>+1`, `\<first>+2`
+ etc., but \`\_umathcharholes` are skipped
+ (`\_umathcharholes` are parts of the Unicode table not designed for math
+ alphabets, they cause that the math alphabets are
+ not continuously spread out in the table; I mean that the
+ designers were under the influence of drugs when they created
+ this part of the Unicode table).
+ The `<from>-<to>` clause includes characters like~`A-Z`.
+ Note that the `\_umathrange` sets the \`\_classfam` macro as <class>
+ <family> for later use.
\_cod -----------------------------
-\_umathnumB="0391
-\_greekdef \Alpha \Beta \Gamma \Delta \Epsilon \Zeta \Eta \Theta \Iota \Kappa
- \Lambda \Mu \Nu \Xi \Omicron \Pi \Rho \varTheta \Sigma \Tau \Upsilon \Phi
- \Chi \Psi \Omega \_relax
+\_newcount\_umathnumA \_newcount\_umathnumB
-\_umathnumB="03B1
-\_greekdef \alpha \beta \gamma \delta \varepsilon \zeta \eta \theta \iota \kappa
- \lambda \mu \nu \xi \omicron \pi \rho \varsigma \sigma \tau \upsilon
- \varphi \chi \psi \omega \vardelta \epsilon \vartheta \varkappa \phi
- \varrho \varpi \_relax
+\_def\_umathcorr#1#2{\_ea#1\_ea{\_the#2}}
+\_def\_umathprepare#1{\_def\_umathscanholes##1[#1]##2##3\_relax{##2}}
+\_def\_umathvalue#1{\_ea\_umathscanholes\_umathcharholes[#1]{#1}\_relax}
+
+\_def\_umathcharholes{% holes in math alphabets:
+ [119893]{"210E}[119965]{"212C}[119968]{"2130}[119969]{"2131}%
+ [119971]{"210B}[119972]{"2110}[119975]{"2112}[119976]{"2133}[119981]{"211B}%
+ [119994]{"212F}[119996]{"210A}[120004]{"2134}%
+ [120070]{"212D}[120075]{"210C}[120076]{"2111}[120085]{"211C}[120093]{"2128}%
+ [120122]{"2102}[120127]{"210D}[120133]{"2115}[120135]{"2119}
+ [120136]{"211A}[120137]{"211D}[120145]{"2124}%
+}
+\_def\_umathrange#1#2#3#4{\_umathnumB=#4\_def\_classfam{#2 #3 }\_umathrangeA#1}
+\_def\_umathrangeA#1-#2{\_umathnumA=`#1\_relax
+ \_loop
+ \_umathcorr\_umathprepare\_umathnumB
+ \_Umathcode \_umathnumA = \_classfam \_umathcorr\_umathvalue{\_umathnumB}
+ \_ifnum\_umathnumA<`#2\_relax
+ \_advance\_umathnumA by1 \_advance\_umathnumB by1
+ \_repeat
+}
\_doc -----------------------------
- The math alphabets are declared here using the
+ A few math characters have very specific Unicode and must be handled
+ individually. We can run \`\_umathrangespec``<list of characters>\relax`
+ just after \^`\_umathrange`. The `\_umathnumB` must be set to the first
+ destination code. The \^`\_umathrangespec` applies to each character from
+ the <list of characters> this:
+ `\Umathcode``<char-code>=\_classfam\_umathnumB` and increments
+ `\_umathnumB`. If `\_umathnumB=0` then it applies
+ `\Umathcode``<char-code>=\_classfam <char-code>`.
+ The \^`\_classfam` and `\_umathnumB` were typically set by previous call
+ of the \^`\_umathrange` macro.
+ \_cod -----------------------------
+
+\_def\_umathrangespec#1{\_ifx#1\_relax \_else
+ \_Umathcode `#1=\_classfam \_ifnum\_umathnumB=0 `#1 \_else \_umathnumB\_fi
+ \_unless\_ifnum\_umathnumB=0 \_advance\_umathnumB by1 \_fi
+ \_ea\_umathrangespec \_fi
+}
+
+ \_doc -----------------------------
+ The math alphabets are set by
+ \`\_rmvariables`, \`\_bfvariables`, \`\_itvariables`, \`\_bivariables`,
+ \`\_calvariables`, \`\_bcalvariables`, \`\_frakvariables`,
+ \`\_bfrakvariables`, \`\_bbvariables`,\nl \`\_sansvariables`,
+ \`\_bsansvariables`, \`\_isansvariables`, \`\_bisansvariables`,
+ \`\_ttvariables`,\nl \`\_itgreek`, \`\_rmgreek,` \`\_bfgreek`, \`\_bigreek`,
+ \`\_bsansgreek`, \`\_bisansgreek`,\nl \`\_itGreek`, \`\_rmGreek`, \`\_bfGreek`,
+ \`\_biGreek`, \`\_bsansGreek`, \`\_bisansGreek`,\nl \`\_rmdigits`,
+ \`\_bfdigits`, \`\_bbdigits`, \`\_sansdigits`, \`\_bsansdigits`,
+ \`\_ttdigits`.\nl
+ They are declared using the
\^`\_umathrange {<range>}<class><family><starting-code>` macro.
\_cod -----------------------------
@@ -68,30 +123,12 @@
\_protected\_def\_bigreek {\_umathrangegreek71\_greekbia}
\_protected\_def\_bsansgreek {\_umathrangegreek71\_greeksna}
\_protected\_def\_bisansgreek{\_umathrangegreek71\_greeksia}
-\_protected\_def\_itGreek {\_umathrangeGREEK71\_greekitA \_setnablait}
-\_protected\_def\_rmGreek {\_umathrangeGREEK71\_greekrmA \_setnablarm}
-\_protected\_def\_bfGreek {\_umathrangeGREEK71\_greekbfA \_setnablabf}
-\_protected\_def\_biGreek {\_umathrangeGREEK71\_greekbiA \_setnablabi}
-\_protected\_def\_bsansGreek {\_umathrangeGREEK71\_greeksnA \_setnablabsans}
-\_protected\_def\_bisansGreek{\_umathrangeGREEK71\_greeksiA \_setnablabisans}
-
- \_doc -----------------------------
- \`\_setnabla` is used in order to `\nabla` behaves like uppercase Greek
- letter, similar like `\Delta`. It depends on `\bf`, `\it` etc. selectors.
- If you want to deactivate this behavior, use `\def\_setnabla#1 {}`.
- \_cod -----------------------------
-
-\_def \_setnabla {\_Umathcode"2207 = 7 1}
-\_def \_setnablarm {\_setnabla"02207 }
-\_def \_setnablabf {\_setnabla"1D6C1 }
-\_def \_setnablait {\_setnabla"1D6FB }
-\_def \_setnablabi {\_setnabla"1D735 }
-\_def \_setnablabsans {\_setnabla"1D76F }
-\_def \_setnablabisans {\_setnabla"1D7A9 }
-
- \_doc -----------------------------
- Digits are configured like math alphabets.
- \_cod -----------------------------
+\_protected\_def\_itGreek {\_umathrangeGREEK71\_greekitA}
+\_protected\_def\_rmGreek {\_umathrangeGREEK71\_greekrmA}
+\_protected\_def\_bfGreek {\_umathrangeGREEK71\_greekbfA}
+\_protected\_def\_biGreek {\_umathrangeGREEK71\_greekbiA}
+\_protected\_def\_bsansGreek {\_umathrangeGREEK71\_greeksnA}
+\_protected\_def\_bisansGreek{\_umathrangeGREEK71\_greeksiA}
\_chardef\_digitrmO=`0
\_chardef\_digitbfO="1D7CE
@@ -108,6 +145,59 @@
\_protected\_def\_ttdigits {\_umathrange{0-9}71\_digitttO}
\_doc -----------------------------
+ The control sequences for `\alpha`, `\beta`, etc.\ are redefined here.
+ The `\alpha` will expand to the character with Unicode `"03B1`, this is a normal
+ character $α$. You can type it directly in your editor if you know how
+ to do this. These sequences are declared by
+ `\_greekdef``<list of sequences>\relax`.
+ \_cod -----------------------------
+
+\_def\_greekdef#1{\_ifx#1\_relax
+ \_else
+ \_edef#1{\_Uchar\_umathnumB}%
+ \_advance\_umathnumB by 1
+ \_ea\_greekdef \_fi
+}
+\_umathnumB="0391
+\_greekdef \Alpha \Beta \Gamma \Delta \Epsilon \Zeta \Eta \Theta \Iota \Kappa
+ \Lambda \Mu \Nu \Xi \Omicron \Pi \Rho \varTheta \Sigma \Tau \Upsilon \Phi
+ \Chi \Psi \Omega \_relax
+
+\_umathnumB="03B1
+\_greekdef \alpha \beta \gamma \delta \varepsilon \zeta \eta \theta \iota \kappa
+ \lambda \mu \nu \xi \omicron \pi \rho \varsigma \sigma \tau \upsilon
+ \varphi \chi \psi \omega \_relax
+
+ \_doc -----------------------------
+ The \`\_umathrangeGREEK``<class><family><first>` and
+ \`\_umathrangegreek``<class><family><first>` macros
+ for setting math codes of Greek characters are defined here. They use \^`\_umathrange`
+ for general codes but the exceptions must be handled by the
+ \^`\_umathrangespec` macro.
+ The exceptions are seven Greek characters:
+ $\epsilon, \vartheta, \varkappa, \phi, \varrho, \varpi, \nabla$.
+ The first six of these characters should behave as lowercase Greek letters
+ and the last one `\nabla` is uppercase Greek letter.
+ \_cod -----------------------------
+
+\_def\epsilon{^^^^03f5} \_def\vartheta{^^^^03d1} \_def\varkappa{^^^^03f0}
+\_def\phi{^^^^03d5} \_def\varrho{^^^^03f1} \_def\varpi{^^^^03d6}
+\_def \nabla{^^^^2207}
+
+\_def\_umathrangeGREEK#1#2#3{\_umathrange{^^^^0391-^^^^03a9}#1#2#3% \Alpha-\Omega
+ \_resetnabla % you can do \let\_resetnabla=\relax if you don't want to change \nabla shape
+}
+\_def\_resetnabla {%
+ \_ifnum\_umathnumB<950 \_umathnumB=0 \_else \_advance\_umathnumB by1 \_fi
+ \_umathrangespec ^^^^2207\_relax % \nabla
+}
+\_def\_umathrangegreek#1#2#3{%
+ \_umathrange{^^^^03b1-^^^^03c9}#1#2#3% \alpha-\omega
+ \_ifnum#3=\_greekrma \_umathnumB=0 \_else \_advance\_umathnumB by2 \_fi
+ \_umathrangespec ^^^^03f5^^^^03d1^^^^03f0^^^^03d5^^^^03f1^^^^03d6\_relax % \epsilon-\varpi
+}
+
+ \_doc -----------------------------
The math alphabets \`\cal`, \`\bbchar`, \`\frak`, \`\script` are re-defined
here. The \`\_marm`, \`\_mabf`, \`\_mait`, \`\_mabi`, \`\_matt`
used in \^`\rm`, \^`\bf`, \^`\it`, \^`\bi` are re-defined too.\nl
@@ -145,7 +235,7 @@
Each Unicode slot carries information about math type. This is saved in
the file `MathClass-15.txt` which is copied to `mathclass.opm` The file
has the following format:
- {\vitt{mathclass.opm}\verbinput (70-85) mathclass.opm }
+ {\vitt{mathclass.opm}\verbinput (70-85) mathclass.opm }%
We have to read this information and convert it to the `\Umathcode`s.
\_cod -----------------------------
@@ -170,34 +260,62 @@
\_doc -----------------------------
Each math symbol has its declaration in the file `unicode-math-table.tex`
which is copied to `unimath-table.opm`. The file has the following format:
- {\vitt{unimath-table.opm}\verbinput (36-41) unimath-table.opm }
- We have to read this information and set given control sequences to
- the relevant Unicode characters using `\chardef`. We don't use `\mathchardef`
- for them because the want to manage the matcodes (class, family, slot)
- only at single place: at Unicode characters. Control sequeces declared here
- are only pointers to these Unicode characters. Exceptions are delimiters and
- math accents.\nl
- If the character is delimiter then we declare \_d:<sequence> to be the
- `\chardef` equivalent of the character and `\let<sequence>=<character>`
- because `\left`, `\right` doesn't like `\chardef` equivalent of the
- character although it has its own delcode.
+ {\vitt{unimath-table.opm}\verbinput (36-41) unimath-table.opm }%
+ We have to read this information and set given control sequences as macros
+ which expand to the given Unicode character. This solution enables to use
+ such control sequences in PDF outlines where they expand to the appropriate
+ Unicode character.
+ We don't use `\mathchardef`, we set the mathcodes (class, family, slot)
+ only at single place: for Unicode math characters. For example for we
+ define `\times`:
+ \begtt
+ \def\times{^^d7} \Umathcode "D7 = 2 1 "D7
+ \endtt
+ Because math codes of Greek upright letters vary depending on
+ \^`\_itgreek`, \^`\_bfgreek`,
+ etc.\ macros, we need to keep the access directly to these characters.
+ We define `\mupalpha`, `\mupbeta`, ..., `\mupomega` macros as a code from
+ PUA (Private Use Area) of Unicode table and set mathcode of these
+ codes to the real upright alpha, beta, ..., omega.
\_cod -----------------------------
\_begingroup % \input unimath-table.opm (it is a copy of unicode-math-table.tex):
+ \_umathnumB="F800 % pointer to the Private User Area
\_def\UnicodeMathSymbol #1#2#3#4{%
- \_chardef#2=#1 % control sequence is only pointer to Unicode character
+ \_edef#2{\_Uchar #1}% control sequence is a macro which expands to the Unicode character
\_ifnum#1=\_Umathcodenum#1 \_Umathcode#1=0 1 #1 \_fi % it isn't set by mathclass.opm
- \_ifx#3\_mathopen \_setdelimiter#2\_fi
- \_ifx#3\_mathclose \_setdelimiter#2\_fi
- \_ifx#3\mathfence \_setdelimiter#2\_fi
\_ifx#3\_mathaccent \_protected\_def#2{\_Umathaccent fixed 7 1 #1 }\_fi
+ \_ifnum#1>"390 \_ifnum#1<"3F6
+ \_edef#2{\_Uchar\_umathnumB}% \mupAlpha, \mupBeta, \mupalpha, \mupbeta, ...
+ \_Umathcode\_umathnumB=0 1 #1
+ \_advance\_umathnumB by1
+ \_fi\_fi % \muGreek, \mugreek symbols
}
\_def\mathfence{F}%
- \_def\_setdelimiter#1{\_expanded{\_let\_cs{_d:\_csstring#1}=#1\_let#1=\Uchar#1}}
\_globaldefs=1 \_input unimath-table.opm
\_endgroup
\_doc -----------------------------
+ The macro `\int` expands to an <int-character>. We save the `\mathcode`
+ of the <int-character> to `\_int:<int-character>` using `\Umathchardef` and
+ declare <int-character> as math-active and define it
+ as `\_int:<int-character> \_nolimits`. Moreover, we define `\intop` as
+ `\_int:<int-character>` (it is the itegral with limits like in plain \TeX).
+ We do this with other int-like operators listed below too.
+ \_cod -----------------------------
+
+\_def\_intwithnolimits#1{\_ifx#1\_relax \_else
+ \_ea\_Umathcharnumdef\_csname _int:#1\_endcsname=\_Umathcodenum\_ea`#1 %
+ \_ea\_def \_csname\_csstring#1op\_ea\_endcsname\_ea{\_csname _int:#1\_endcsname}%
+ \_bgroup \_lccode`\~=\_ea`#1 \_lowercase{\_egroup
+ \_ea\_def\_ea~\_ea{\_csname _int:#1\_endcsname\_nolimits}\_mathcode`~="8000 }%
+ \_ea \_intwithnolimits \_fi
+}
+\_intwithnolimits \int \iint \iiint \oint \oiint \oiiint
+ \intclockwise \varointclockwise \ointctrclockwise \sumint \iiiint \intbar \intBar \fint
+ \pointint \sqint \intlarhk \intx \intcap \intcup \upint \lowint \_relax
+
+ \_doc -----------------------------
Many special characters must be declared with care...
\_cod -----------------------------
@@ -227,29 +345,8 @@
\_protected\_def \_cuberoot {\_Uradical 1 "0221B }
\_protected\_def \_fourthroot {\_Uradical 1 "0221C }
-\_def \nabla {^^^^2207} % \nabla behaves as uppercase Gereek letter, see \_setnabla
-
\_public \sqrt \cuberoot \fourthroot ;
- \_doc -----------------------------
- We save the `\mathcode` of `\int` to `\_intop` using `\Umathchardef` and
- declare Unicode character `\int` as math-active and define it
- as `\_intop\_nolimits`. We define `\intop` as `\_intop` for users
- (intergral with normal limits).
- We do this with other int-like operators listed below too.
- \_cod -----------------------------
-
-\_def\_intwithnolimits#1{\_ifx#1\_relax \_else
- \_ea\_Umathcharnumdef\_csname _\_csstring#1op\_endcsname=\_Umathcodenum#1%
- \_ea\_def \_csname\_csstring#1op\_ea\_endcsname\_ea{\_csname _\_csstring#1op\_endcsname}%
- \_bgroup \_lccode`\~=#1 \_lowercase{\_egroup
- \_ea\_def\_ea~\_ea{\_csname _\_csstring#1op\_endcsname\_nolimits}\_mathcode`~="8000 }%
- \_ea \_intwithnolimits \_fi
-}
-\_intwithnolimits \int \iint \iiint \oint \oiint \oiiint
- \intclockwise \varointclockwise \ointctrclockwise \sumint \iiiint \intbar \intBar \fint
- \pointint \sqint \intlarhk \intx \intcap \intcup \upint \lowint \_relax
-
\_protected\_def \_overbrace #1{\_mathop {\_Umathaccent 7 1 "023DE{#1}}\_limits}
\_protected\_def \_underbrace #1{\_mathop {\_Umathaccent bottom 7 1 "023DF{#1}}\_limits}
\_protected\_def \_overparen #1{\_mathop {\_Umathaccent 7 1 "023DC{#1}}\_limits}
@@ -366,6 +463,8 @@
\_let \upvartheta=\mupvartheta
\_let \upphi=\mupphi
\_let \upvarpi=\mupvarpi
+\_let \varTheta=\mupvarTheta
+\_let \vardelta=\delta
\_doc -----------------------------
The \`\not` macro is redefined here. If the `\_not!<char>` is defined
@@ -450,10 +549,9 @@
Example of using additional math font is in section 5.3 in the
\ulink[http://petr.olsak.net/ftp/olsak/optex/optex-math.pdf]{\tt optex-math.pdf} documentation
-
-You can combine more Unicode math fonts in single formula simply
-by the `\addUmathfont` macro, see
-\ulink[http://petr.olsak.net/optex/optex-tricks.html#addumathfont]{\OpTeX/ trick 0030}.
+More examples are in the
+\ulink[http://petr.olsak.net/optex/optex-tricks.html]{OpTeX tricks} and in the
+\ulink[https://petr.olsak.net/ftp/olsak/optex/math-doc.pdf]{math.opm} package.
See \url{http://tex.stackexchange.com/questions/308749}
for technical details about Unicode-math.
@@ -461,6 +559,11 @@ for technical details about Unicode-math.
\_endinput
History:
+2023-01-17 \int operators re-implemented
+2023-01-15 \mupalpha, \mupbeta etc. have codes from PUA
+2023-01-15 math control sequences are macros, they expand to math characters
+2023-01-14 \epsilon, \vartheta, \varkappa, \phi, \varrho, \varpi, ... bug fix
+2023-01-13 \mupalhpha, \mupbeta, ... bug fix
2022-11-20 \mathfence's get delimiter code too
2022-11-18 Delimiters re-implemented
2022-11-17 \Umathchardef replaced by \chardef
diff --git a/Master/texmf-dist/tex/optex/base/unimath-macros.opm b/Master/texmf-dist/tex/optex/base/unimath-macros.opm
index 96f87a6a9b3..d4cd9e5540a 100644
--- a/Master/texmf-dist/tex/optex/base/unimath-macros.opm
+++ b/Master/texmf-dist/tex/optex/base/unimath-macros.opm
@@ -1,6 +1,6 @@
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \loadmath {Unicode Math fonts <2022-12-01>} % preloaded in format
+\_codedecl \loadmath {Unicode Math fonts <2023-01-17>} % preloaded in format
\_doc -----------------------------
\`\loadmath` `{<Unicode-math font>}` loads the given font. It does:
@@ -143,66 +143,6 @@
\_def\_mparams{}
\_doc -----------------------------
- Unicode math font includes all typical math alphabets together, user needs not to
- load more \TeX/ math families. These math alphabets are encoded by
- different parts of Unicode table. We need auxiliary macros for setting
- mathcodes by selected math alphabet.
- \nl
- \`\_umathrange` `{<from->-<to>}<class><family>\<first>` sets `\Umathcode`s
- of the characters in the interval `<from>-<to>` to `\<first>`,
- `\<first>+1`, `\<first>+2`
- etc., but \`\_umathcharholes` are skipped
- (`\_umathcharholes` are parts of the Unicode table not designed for math
- alphabets, they cause that the math alphabets are
- not continuously spread out in the table; I mean that the
- designers were under the influence of drugs when they created
- this part of the Unicode table).
- The `<from>-<to>` clause includes characters like~`A-Z`.
- \nl
- \`\_umahrangegreek` `\<first>` is the same as
- `\_umathrange {<alpha>-<omega>}\<first>`.
- \nl
- \`\_umahrangeGREEK` `\<first>` is the same as
- `\_umathrange {<Alpha>-<Omega>}\<first>`.
- \nl
- \`\_greekdef` `<control sequences> \_relax` defines each control sequence
- as a normal character with codes `\_umathnumB`, `\_umathnumB+1`,
- `\_umathnumB+2` etc. It is used for redefinig the contol sequences for
- math Greek `\alpha`, `\beta`, `\gamma` etc.
- \_cod -----------------------------
-
-\_newcount\_umathnumA \_newcount\_umathnumB
-
-\_def\_umathcorr#1#2{\_ea#1\_ea{\_the#2}}
-\_def\_umathprepare#1{\_def\_umathscanholes##1[#1]##2##3\_relax{##2}}
-\_def\_umathvalue#1{\_ea\_umathscanholes\_umathcharholes[#1]{#1}\_relax}
-
-\_def\_umathcharholes{% holes in math alphabets:
- [119893]{"210E}[119965]{"212C}[119968]{"2130}[119969]{"2131}%
- [119971]{"210B}[119972]{"2110}[119975]{"2112}[119976]{"2133}[119981]{"211B}%
- [119994]{"212F}[119996]{"210A}[120004]{"2134}%
- [120070]{"212D}[120075]{"210C}[120076]{"2111}[120085]{"211C}[120093]{"2128}%
- [120122]{"2102}[120127]{"210D}[120133]{"2115}[120135]{"2119}
- [120136]{"211A}[120137]{"211D}[120145]{"2124}%
-}
-\_def\_umathrange#1#2#3#4{\_umathnumB=#4\_def\_tmp{#2 #3 }\_umathrangeA#1}
-\_def\_umathrangeA#1-#2{\_umathnumA=`#1\_relax
- \_loop
- \_umathcorr\_umathprepare\_umathnumB
- \_Umathcode \_umathnumA = \_tmp \_umathcorr\_umathvalue{\_umathnumB}
- \_ifnum\_umathnumA<`#2\_relax
- \_advance\_umathnumA by1 \_advance\_umathnumB by1
- \_repeat
-}
-\_def\_umathrangeGREEK{\_umathrange{^^^^0391-^^^^03a9}}
-\_def\_umathrangegreek{\_umathrange{^^^^03b1-^^^^03d6}}
-\_def\_greekdef#1{\_ifx#1\_relax \_else
- \_begingroup \_lccode`X=\_umathnumB \_lowercase{\_endgroup \_def#1{X}}%
- \_advance\_umathnumB by 1
- \_ea\_greekdef \_fi
-}
-
- \_doc -----------------------------
\`\addUmathfont` `<fam> {[<normal-font>]}{<ffeatures>} {[<bold-font>]}{<ffeatures>} {<factor>}`
allocates new <fam> using \^`\newfam` and adds loading this font to the
\~`\normalmath` and \~`\boldmath` macros. Note that allocationos using
@@ -230,16 +170,34 @@
}
\_doc -----------------------------
+ The math characters can be given directly (by their Unicode) or by a macro
+ like `\doteq`, `\times`, etc. These macros simply expand to the math character
+ with its Unicode. And this math character has its `\Umathcode` given by
+ <class>, <family>, <slot-number>. Sometimes, we may want to get these
+ quantities from the given Unicode math character by our macros. It is
+ possible by \`\themathcodeclass``<math-char>`,
+ \`\themathcodefam``<math-char>` and \`\themathcodechar``<math-char>` macros.
+ The parameter <math-char> is a math character or it is a macro like `\doteq`, `\times`.
+ Moreower, \`\thedelcodefam``<math-char>` and \`\thedelcodechar``<math-char>`
+ return delcode quaitities of givem math character.
+ \_cod -----------------------------
+
+\_def\_getmathcode#1#2{\_directlua{tex.print(tex.get#2code(token.scan_int())[#1])}}
+\_def\_themathcodeclass #1{\_getmathcode 1{math}\_ea`#1 }
+\_def\_themathcodefam #1{\_getmathcode 2{math}\_ea`#1 }
+\_def\_themathcodechar #1{\_getmathcode 3{math}\_ea`#1 }
+\_def\_thedelcodefam #1{\_getmathcode 1{del}\_ea`#1 }
+\_def\_thedelcodechar #1{\_getmathcode 2{del}\_ea`#1 }
+
+\_public \themathcodeclass \themathcodefam \themathcodechar \thedelcodefam \thedelcodechar ;
+
+ \_doc -----------------------------
\`\mathchars` `<fam> {<list of sequences>}`
saves <fam> to \`\_mafam` and runs for each sequence from the <list of sequences>
- the relevant code settings.
- The `\directlua` chunk prints the 8-digits hexadecimal code of the
- sequence followed by the sequence itself. The digts are scanned by \`\_mathcharsB`
- and new `\Umathcode` is declared.\nl
- If there exist \_d:<sequence> (i.e.\ it is delimiter) then `\Udelcode` is
- redeclared too. Finally, in case of `\int`-like operators the
- `\_intop` sequence is redeclared by `\Umathchardef`. Note that the used
- primitives have the syntax:
+ the relevant code settings using `\Umathcode` primitive.
+ In case of `\int`-like operators the <math class>=8 and we only
+ re-declare `\_int:<int-character>` as an operator with the new \^`\_mafam`.
+ Note that the used primitives have the syntax:
\begtt \catcode`<=13
\Umathchardef <sequence> = <math class> <math family> <slot number>
\Umathcode <code> = <math class> <math family> <slot number>
@@ -249,20 +207,13 @@
\_def\_mathchars {\_afterassignment\_mathcharsA \_chardef\_mafam=}
\_def\_mathcharsA #1{\_foreach #1\_do{%
- \_ifcsname _d:\_csstring##1\_endcsname \_ea \_mathcharsD \_csname _d:\_csstring##1\_endcsname
- \_else \_mathcharsC ##1\_fi
-}}
-\_def\_mathcharsC #1{\_ea\_mathcharsB
- \_directlua{tex.print(string.format("\_pcent08X", \_the\_Umathcode#1))}#1%
-}
-\_def\_mathcharsB #1#2#3#4#5#6#7#8#9{% #9 is given \math-sequence
- \_ifcsname _\_csstring#9op\_endcsname
- \_ea \_Umathchardef \_csname _\_csstring#9op\_endcsname=1 \_mafam #9\_relax
+ \_chardef\_tmp=\_themathcodeclass##1\_relax
+ \_ifnum\_tmp=8 % \int, \iint, \oint, etc.
+ \_ea\_Umathchardef \_csname _int:##1\_endcsname =1 \_mafam \_ea`##1
\_else
- \_Umathcode "#4#5#6#7#8=\_numexpr"#3/2\_relax \_mafam "#4#5#6#7#8
+ \_Umathcode \_ea`##1=\_tmp \_mafam \_themathcodechar##1
\_fi
-}
-\_def\_mathcharsD #1{\_mathcharsC #1\_relax \_Udelcode #1=\_mafam #1\_relax}
+}}
\_doc -----------------------------
\`\mathcodes` `<fam> {<list of pairs>}` sets mathcodes of given
@@ -276,10 +227,10 @@
\_def\_mathcodes{\_afterassignment\_mathcodesA\_chardef\_mafam=}
\_def\_mathcodesA#1{%
\_foreach #1\_do ##1##2{%
- \_ea\_foreach\_expanded{##2}\_do{\_Umathcode `####1=##1\_mafam`####1}%
+ \_ea\_foreach\_expanded{##2}\_do{\_Umathcode `####1=##1\_mafam \_ea`####1}%
}%
}
-\_def\_Urange #1-#2{\_fornum `#1..`#2\_do{\_Uchar##1 }}
+\_def\_Urange #1-#2{\_fornum \_ea`#1..\_ea`#2\_do{\_Uchar##1 }}
\_public \addUmathfont \mathchars \mathcodes \Urange ;
@@ -351,7 +302,8 @@ in the <list-of-pairs> is `<class-number><character>` (separated by optional
space) or `<class-number>{<list-of-characters>}`. The <list-of-characters>
includes declared characters or \^`\Urange` `<from>-<to>` which is equal to the
list of characters beginning <from> and ending <to>, for example
-`\Urange a-d` is equal to `abcd`.
+`\Urange a-d` is equal to `abcd`. The characters can be given directly or
+by the math sequences like `\times`, `\doteq` too.
The \^`\mathcodes` macro declares mathcode of given characters internally by
\begtt \catcode`<=13
@@ -385,6 +337,9 @@ the section~\ref[math-macros].
\_endinput
+2023-01-17 \mathchars: \int operators re-implemented
+2023-01-15 \_def\_umathrange moved to unimath-codes.opm
+2023.01-15 \themathcodeclass etc. introduced
2022-12-01 reading number by \_loadumathfamily more robust
2022-11-18 \mathchars improved, \Udelcodes are set too, \addUmathfont uses \ahead
2022-11-17 \Umathchardef replaced by \chardef