From 8e0a627bb31e2495bca858b5c44e63e510c3448c Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 9 Feb 2023 21:13:26 +0000 Subject: optex (9feb23) git-svn-id: svn://tug.org/texlive/trunk@65766 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/optex/base/alloc.opm | 6 +- Master/texmf-dist/tex/optex/base/basic-macros.opm | 5 +- Master/texmf-dist/tex/optex/base/doc.opm | 20 +- Master/texmf-dist/tex/optex/base/f-heros.opm | 8 +- Master/texmf-dist/tex/optex/base/fonts-resize.opm | 2 +- Master/texmf-dist/tex/optex/base/fonts-select.opm | 6 +- Master/texmf-dist/tex/optex/base/hisyntax-c.opm | 2 +- Master/texmf-dist/tex/optex/base/if-macros.opm | 20 +- Master/texmf-dist/tex/optex/base/keyval.opm | 99 ++++-- Master/texmf-dist/tex/optex/base/lists.opm | 8 +- Master/texmf-dist/tex/optex/base/math-macros.opm | 4 +- Master/texmf-dist/tex/optex/base/more-macros.opm | 28 +- Master/texmf-dist/tex/optex/base/optex.ini | 2 +- Master/texmf-dist/tex/optex/base/others.opm | 6 +- Master/texmf-dist/tex/optex/base/parameters.opm | 12 +- Master/texmf-dist/tex/optex/base/prefixed.opm | 153 +++++---- Master/texmf-dist/tex/optex/base/references.opm | 3 +- Master/texmf-dist/tex/optex/base/sections.opm | 2 +- Master/texmf-dist/tex/optex/base/slides.opm | 2 +- Master/texmf-dist/tex/optex/base/table.opm | 9 +- Master/texmf-dist/tex/optex/base/unimath-codes.opm | 265 ++++++++++----- .../texmf-dist/tex/optex/base/unimath-macros.opm | 123 +++---- Master/texmf-dist/tex/optex/pkg/math.opm | 378 ++++++++++++++++----- 23 files changed, 774 insertions(+), 389 deletions(-) (limited to 'Master/texmf-dist/tex/optex') 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 `\` 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 `\` 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 `\` 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` ` ` 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 concerned to the ``. The `` 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`. 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` ``\`\do` `{}` repeats `` for each element of the ``. The `` 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` `..` \`\do` `{}` or \`\fornumstep` `: ..` \`\do` `{}` repeats `` for each number from `` to `` (with step `` @@ -110,7 +112,7 @@ The test in the \`\_fornumB` says: if ( $\string<$ AND is positive) or if ( $>$ AND 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` `{}{}` + The macro \`\isnextchar` `{}{}` has a different syntax than all other is-macros. It executes `` if next character is equal to . - Else the `` is executed. The macro is not expandable. + Else the `` 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``` 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:` macros.\nl - The \`\kv``{}` expands the `\_kv:` 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::` macros. + The `\_kvx::` is processed (if it is defined) with parameter + after it.\nl + The \`\kvx``{}{}` defines the `\_kvx::#1` macro + and \`\nokvx``{}` defines the `\_nokvx::` macro.\nl + The \`\kv``{}` expands the `\_kv::` macro. If this macro isn't + defined then \`\_kvunknown` is processed. You can re-define it if you want.\nl + The \`\iskv``{}\iftrue` (or `\iffalse`) is the test, + if the `` is defined in current . \_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{}` macro. The \^`\kv{}` 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``{}\iftrue` +or the key is undeclared by \^`\iskv``{}\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``{}{}` to declare which is processed +immediately when the `` 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` `{}{}` allows to use `#1` inside the code. +It is replaced by the actual ``. Example: `\kvx{opt}{\message{opt is #1}}`, +then `\readkv{opt=HELLO}` prints \"opt is HELLO". + +The \^`\nokvx` `{}` can declare a processed for all +undeclared by \^`\kvx`. The `#1` and `#2` can be used in the , +`#1` is , `#2` is . If `\nokvx` is unused then nothing is done +for undeclared . 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``={}`. Then `\redakv`, `\kv`, `\iskv`, `\kvx` and `\nokvx` +macros use this named dictionary of / pairs. +Package options can be processed when +`\kvdict={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 `={}`. + +\_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:` macros. You can re-define then or define more such macros. The \`\style` `` does \`\_printitem``={\_item:}`. - More exactly: \^`\begitems` does `\_printitem=`\^`\defaultitem` first, - then \`\style` `` does \`\_printitem``={\_item:}` - when it is used and finally, `\_startitem` alias `*` uses `\_printitem`. + More exactly: \^`\begitems` does \^`\_printitem=`\^`\defaultitem` first, + then \^`\style` `` does \^`\_printitem``={\_item:}` + 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` `{}` macro which @@ -261,7 +261,7 @@ \_public \cstochar ; \_doc ----------------------------- - You can use expandable \`\bp``{}` convertor from + You can use expandable \`\bp``{}` converter from \TeX/ `` (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``{}` for analogical purposes. - It expands to the value of the `` at expand processor level - with \`\_decdigits` digits after the decimal point. + It expands to the value of the `` at expand processor level. The `` 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[]{}` and + `\expr[]{}`. 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 @@ -204,6 +204,14 @@ \_newdimen\_picheight \_picheight=0pt \_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 @@ -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 `\__` 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 ; \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 - `\_` or `\_`, where - is a sequence of letters, are inaccessible, because they - are interpreted as `\` followed by `_` or as `\` followed by - `_`. 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 `\__` is intended for package - writers as internal macros for a package with `` 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 `\_` or `\_`, +where is a sequence of letters, are inaccessible, because they +are interpreted as `\` followed by `_` or as `\` followed by +`_`. 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 = \__foo` for each given sequence when \^`\_namespace{}` 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 `\__foo` name space +(say `\foo`) directly without setting it in `\__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``\` 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` `{}{}` 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 `[