diff options
author | Norbert Preining <norbert@preining.info> | 2024-02-15 03:01:30 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2024-02-15 03:01:30 +0000 |
commit | 5b6839a58ea5468b40ebd52b579e680b8e62ff13 (patch) | |
tree | 1dfc09f53794115129a07bf566b466cc337606f5 /macros/optex/base | |
parent | a90336c3069c198b41b7b6eb76e3389610ad5eb7 (diff) |
CTAN sync 202402150301
Diffstat (limited to 'macros/optex/base')
24 files changed, 267 insertions, 79 deletions
diff --git a/macros/optex/base/alloc.opm b/macros/optex/base/alloc.opm index fae88d286e..180adddeff 100644 --- a/macros/optex/base/alloc.opm +++ b/macros/optex/base/alloc.opm @@ -120,19 +120,18 @@ \_newdimen \tmpdim \_newdimen \_tmpdim \_doc ----------------------------- - A few registers are initialized like in plain\TeX/. We absolutely + A few registers: \`\maxdimen`, \`\hideskip` and + \`\centering` are initialized like in plain\TeX/. We absolutely don't support the `@`category dance, so `\z@skip` - `\z@`, `\p@` etc. are defined but not recommended in \OpTeX/. - - The \`\_zo` and \`\_zoskip` (equivalents to `\z@` and `\z@skip`) - are declared here and used in some internal macros of \OpTeX/ - for improving speed. + `\z@`, `\p@` etc. are defined but not recommended. + The \`\_zo`, \`\_zoskip` and \`\voidbox` (equivalents to + `\z@`, `\z@skip` and `\voidb@x`) are preferred in \OpTeX. \_cod ----------------------------- \_newdimen\_maxdimen \_maxdimen=16383.99999pt % the largest legal <dimen> -\_newdimen\_zo \_zo=0pt \_newskip\_hideskip \_hideskip=-1000pt plus 1fill % negative but can grow \_newskip\_centering \_centering=0pt plus 1000pt minus 1000pt +\_newdimen\_zo \_zo=0pt \_newskip\_zoskip \_zoskip=0pt plus0pt minus0pt \_newbox\_voidbox % permanently void box register diff --git a/macros/optex/base/doc.opm b/macros/optex/base/doc.opm index fb96d35007..c334019de2 100644 --- a/macros/optex/base/doc.opm +++ b/macros/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-12-11>} % loaded on demand by \load[doc] +\_codedecl \printdoc {Macros for documentation printing <2023-12-10>} % loaded on demand by \load[doc] \_doc ----------------------------- General decalarations. @@ -41,8 +41,6 @@ \_doc ----------------------------- The listing mode is implemented here. The \`\maxlines` is maximal lines of code printed in the listing mode. - The \code{\\catcode`\\.=11} sets dot as letter in listngs (for package - documentation where `\.foo` sequeces exist). \_cod ----------------------------- \_newcount \_maxlines \_maxlines=100000 @@ -54,7 +52,7 @@ \_typosize[8/10] \_let\_printverbline=\_printcodeline \_ttline=\_inputlineno - \_setverb \_catcode`\.=11 + \_setverb \_ifnum\_ttline<0 \_let\_printverblinenum=\_relax \_else \_initverblinenum \_fi \_adef{ }{\ }\_adef\^^I{\t}\_parindent=\_ttindent \_parskip=0pt \_def\t{\_hskip \_dimexpr\_tabspaces em/2\_relax}% @@ -88,7 +86,8 @@ the first `_` or `.` is removed from `\_tmpa` and the test is repeated. \_cod ----------------------------- -\_def\_makecs{\_def\_tmpa{}\_futurelet\_next\_makecsA} +\_def\_makecs{\_def\_tmpa{}\_futurelet\_next\_makecsD} +\_def\_makecsD{\_if.\_next \_ea\_makecsB \_else \_ea\_makecsA \_fi} % \.foo is accepted \_def\_makecsA{\_ifcat a\_noexpand\_next \_ea\_makecsB \_else \_ea\_makecsF \_fi} \_def\_makecsB#1{\_addto\_tmpa{#1}\_futurelet\_next\_makecsA} \_def\_makecsF{\_let\_tmpb=\_tmpa @@ -363,6 +362,7 @@ have the same meaning: `\optexdoclink` in this example. And \endinput +2023-12-10 \catcode`.=11 removed, issue solved by \_makecsD. 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. diff --git a/macros/optex/base/f-fbb.opm b/macros/optex/base/f-fbb.opm new file mode 100644 index 0000000000..ac69a89a99 --- /dev/null +++ b/macros/optex/base/f-fbb.opm @@ -0,0 +1,26 @@ +%% This is part of the OpTeX project, see http://petr.olsak.net/optex + +\_famdecl [fbb] \FBembo {Bembo–like fonts derived from Cardo} + {\caps \swash} {\rm \bf \it \bi} {} + {[fbb-Regular]} + {\_def\_fontnamegen {[fbb-\_currV]:script=latn;\_capsV\_swaV\_fontfeatures}} + +\_wlog{\_detokenize{% +Modifier:^^J + \caps ...... caps & small caps + old digits^^J + \swash ..... alternative Q letter and some other characters^^J +}} + +\_moddef \resetmod {\_fsetV caps={},swa={} \_fvars Regular Bold Italic BoldItalic } +\_moddef \caps {\_fsetV caps=+smcp;\_ffonum; } +\_moddef \swash {\_fsetV swa=+swsh;+salt; } + +\_initfontfamily % new font family must be initialized + +\_endcode + +See historical notice in texdoc fbb. + +See the file `f-heros.opm` for information about principles of such +font-macro-files. + diff --git a/macros/optex/base/f-gentium.opm b/macros/optex/base/f-gentium.opm new file mode 100644 index 0000000000..e6775695c2 --- /dev/null +++ b/macros/optex/base/f-gentium.opm @@ -0,0 +1,26 @@ +%% This is part of the OpTeX project, see http://petr.olsak.net/optex + +\_famdecl [Gentium] \Gentium {Serif free fonts, support Greek, Cyrillic, IPA} + {\caps} {\rm \bf \it \bi} {Termes} + {[GentiumPlus-Regular]} + {\_def\_fontnamegen {[Gentium\_bkV Plus-\_currV]:\_capsV\_fontfeatures}} + +\_wlog{\_detokenize{% +Modifiers:^^J + \caps ...... caps & small caps^^J + \book ...... Book variants (a little bolder)^^J +}} + +\_moddef \resetmod {\_fsetV caps={} \_fsetV bk={} \_fvars Regular Bold Italic BoldItalic } +\_moddef \caps {\_fsetV caps=+smcp;\_ffonum; } +\_moddef \book {\_fsetV bk=Book } + +\_initfontfamily % new font family must be initialized + +\_loadmath {[texgyretermes-math]} + +\_endcode + +See the file `f-heros.opm` for information about principles of such +font-macro-files. + diff --git a/macros/optex/base/fams-ini.opm b/macros/optex/base/fams-ini.opm index 6dc19ca9b1..7d3f0332a8 100644 --- a/macros/optex/base/fams-ini.opm +++ b/macros/optex/base/fams-ini.opm @@ -107,6 +107,11 @@ \caps: {\rm\bf\it\bi} \caps\semibold: {\bf\bi} \caps\sans: {\rm\bf\it} -: {\mono\initials\displ\keybr} } +\_famfrom{Victor Gaultney} +\_faminfo [Gentium] {Serif free fonts, support Greek, Cyrrilic, IPA} {f-gentium} + { -,\caps,\book,\book\caps: {\rm\bf\it\bi} } +\_famalias [GentiumPro] + \_famfrom {Daniel Flipo} \_faminfo [KP fonts] {KP fonts -- Johannes Kepler project} {f-kpfonts} { -,\light,\sans,\mono, \caps, \caps\light, \caps\sans,\caps\mono,\swash: {\rm\bf\it\bi} } @@ -249,6 +254,11 @@ \_faminfo [GFSBodoni] {Based on Bodoni with greek letters} {f-gfsbodoni} { -: {\rm\bf\it\bi} \caps: {\rm} } +\_famfrom {David J. Perry, Michael Sharpe} +\_faminfo [fbb] {Bembo–like fonts derived from Cardo} {f-fbb} + { -,\caps: {\rm\bf\it\bi} \swash: {\rm} } +\_famalias [Bembo] \_famalias [FBembo] + \_famfrom {bBox Type GmbH, Carrois Corporate GbR, Edenspiekermann AG} \_faminfo [Fira] {Humanist sans-serif, originally designed for Firefox OS} {f-fira} { \thin,\light,\book,-,\medium,\mono,\mono\medium,% diff --git a/macros/optex/base/fonts-opmac.opm b/macros/optex/base/fonts-opmac.opm index 158f19299e..ca4d38b4ce 100644 --- a/macros/optex/base/fonts-opmac.opm +++ b/macros/optex/base/fonts-opmac.opm @@ -171,10 +171,12 @@ \_ea\_ifx \_the\_font \_tenbi \_additcorr \_bf \_else \_it \_aftergroup\_afteritcorr\_fi\_fi\_fi } -\_def\_additcorr{\_ifdim\_lastskip>\_zo - \_skip0=\_lastskip \_unskip\_italcorr \_hskip\_skip0 \_else\_italcorr \_fi} +\_def\_additcorr{\_ifhmode \_ifdim\_lastskip>\_zo + \_skip0=\_lastskip \_unskip \_additcorrA \_hskip\_skip0 \_else \_additcorrA \_fi\_fi} +\_def\_additcorrA{\_ifnum\_lastpenalty=\_zo \_italcorr \_else + \_ea\_unpenalty \_ea\_italcorr \_ea\_penalty \_the\_lastpenalty \_relax \_fi} \_def\_afteritcorr{\_futurelet\_next\_afteritcorrA} -\_def\_afteritcorrA{\_ifx\_next.\_else\_ifx\_next,\_else \_italcorr \_fi\_fi} +\_def\_afteritcorrA{\_ifhmode \_ifx\_next.\_else\_ifx\_next,\_else \_italcorr \_fi\_fi\_fi} \_let\_italcorr=\/ \_doc ----------------------------- @@ -218,6 +220,7 @@ \_endcode % ------------------------------------- History: +2024-01-25 \em: \_additcorr reimplemented to be more robust 2022-02-22 \_setmainvalues: only \rm initialized 2021-03-10 \boldify corrected 2021-03-09 \mfontsrule and \_setmathfonts introduced diff --git a/macros/optex/base/fonts-preload.opm b/macros/optex/base/fonts-preload.opm index 8562da786c..82387970e6 100644 --- a/macros/optex/base/fonts-preload.opm +++ b/macros/optex/base/fonts-preload.opm @@ -24,14 +24,14 @@ \_endcode %--------------------------------------------------- The format in Lua\TeX/ can download only non-Unicode fonts. Latin Modern EC is -loaded here. These fonts are totally unusable in LuaTeX when languages with out +loaded here. These fonts are totally unusable in \LuaTeX/ when languages with out of ASCII or ISO-8859-1 alphabets are used (for example Czech). We load only a few 8bit fonts here especially for simple testing of the format. But, if the user needs to do more serious work, he/she can -use `\fontfam` macro to load a selected font family of Unicode fonts. +use \^`\fontfam` macro to load a selected font family of Unicode fonts. We have a dilemma: when the Unicode fonts cannot be preloaded in the format then the basic -font set can be loaded by `\everyjob`. But why to load a set of fonts at the +font set can be loaded by \^`\everyjob`. But why to load a set of fonts at the beginning of every job when it is highly likely that the user will load something completely different. Our decision is: there is a basic 8bit font set in the format (for testing purposes only) and the user should load diff --git a/macros/optex/base/fonts-resize.opm b/macros/optex/base/fonts-resize.opm index 323e1d72a0..f4dd3c4033 100644 --- a/macros/optex/base/fonts-resize.opm +++ b/macros/optex/base/fonts-resize.opm @@ -5,7 +5,7 @@ \_doc ----------------------------- \`\initunifonts` macro extends \LuaTeX's font capabilities, in order to be able to load Unicode fonts. Unfortunately, this part of - \OpTeX/ depends on the `luaotfload` package, which adapts Con\TeX/t's generic + \OpTeX/ depends on the `luaotfload` package, which adapts \ConTeXt's generic font loader for plain \TeX/ and \LaTeX. `luaotfload` uses Lua functions from \LaTeX's `luatexbase` namespace, we provide our own replacements. \^`\initunifonts` sets itself to relax because we don't want to do @@ -62,7 +62,8 @@ The `\fontname` primitive returns the <font file name> optionally followed by <size spec>. The \`\xfontname` macro expands to <font file name> without <size spec>. We need to remove the part `<space>at<dimen>` from - `\fontname` output. The letters `at` have category 12. + `\fontname` output. The letters `at` have category 12 in the \`\_stringat` + macro. \_cod ----------------------------- \_edef\_stringat{\_string a\_string t} diff --git a/macros/optex/base/hyperlinks.opm b/macros/optex/base/hyperlinks.opm index 1d15b5e734..7c3e78635a 100644 --- a/macros/optex/base/hyperlinks.opm +++ b/macros/optex/base/hyperlinks.opm @@ -6,11 +6,12 @@ \`\dest``[<type>:<spec>]` creates a destination of internal links. The destination is declared in the format `<type>:<spec>`. If the \^`\hyperlinks` command in not used, then `\dest` does nothing else it is set to `\_destactive`. - The \`\_destactive` is implemented by `\_pdfdest` primitive. It creates a box + The \`\_destactive` is implemented by `\_pdfdest` primitive. It creates a + box using \`\_destbox``[<type>:<spec>]` in which the destination is shifted by \`\_destheight`. The reason is that the destination is exactly at the top border of the PDF viewer but we want to see - the line where the destination is. The destination box is positioned by a - different way dependent on the current vertical or horizontal mode. + the line where the destination is. The destination box is positioned + differently dependent on the current vertical or horizontal mode. \_cod ---------------------------- \_def\_destheight{1.4em} diff --git a/macros/optex/base/if-macros.opm b/macros/optex/base/if-macros.opm index 415b2c01c8..eae011ae26 100644 --- a/macros/optex/base/if-macros.opm +++ b/macros/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 <2023-10-17>} % preloaded in format +\_codedecl \newif {Special if-macros, is-macros and loops <2023-12-07>} % preloaded in format \_doc ---------------------------- \secc Classical \code{\\newif} @@ -95,8 +95,8 @@ \_immediateassignment \_long\_gdef\_fbody#2{\_testparam##1..\_iftrue #3\_ea\_fbody\_fi}% \_fbody #1#2\_finbody\_getforstack } -\_def\_testparam#1#2#3\_iftrue{\_ifx###1\_empty\_ea\_finbody\_else} -\_def\_finbody#1\_finbody{} +\_long\_def\_testparam#1#2#3\_iftrue{\_ifx###1\_empty\_ea\_finbody\_else} +\_long\_def\_finbody#1\_finbody{} \_long\_def\foreach #1\do#2#{\_isempty{#2}\_iftrue \_afterfi{\_foreachA{#1}{##1}}\_else\_afterfi{\_foreachA{#1}{#2}}\_fi} @@ -376,6 +376,7 @@ \_endcode +2023-12-07 \_testparam define \long (big fixed) 2023-10-17 \qcasesof introduced, \xcasesof reimplemented. 2023-01-16 \isnextchar created expandable. 2022-12-02 \xcasesof: its first parameter is \long too. diff --git a/macros/optex/base/keyval.opm b/macros/optex/base/keyval.opm index 68f3fea536..645a3b33a5 100644 --- a/macros/optex/base/keyval.opm +++ b/macros/optex/base/keyval.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \readkv {Key-value dictionaries <2023-10-23>} % preloaded in format +\_codedecl \readkv {Key-value dictionaries <2023-11-24>} % preloaded in format \_doc ---------------------------- {\bf Implementation.}\nl @@ -12,8 +12,10 @@ <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 \`\trykv``{<key>}{<code>}` + returns unexpanded value of <key> if declared, else it runs <code>.\nl + The \`\kv``{<key>}` returns expanded value of <key> if declared, + else returns expanded value of `.notdef` key else expands \`\_kvunknown`.\nl The \`\iskv``{<key>}\iftrue` (or `\iffalse`) is the test, if the `<key>` is defined in current <dict>. \_cod ---------------------------- @@ -28,12 +30,14 @@ {\_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##2{#1}} -\_def\_kv#1{\_trycs{\_kvcs#1}{\_kvunknown}} +\_def\_trykv#1{\_ea\_trykvA \_begincsname\_kvcs#1\_endcsname \_ignoreit} +\_def\_trykvA#1{\_ifx #1\_ignoreit \_ea\_useit\_else \_unexpanded\_ea{#1}\_fi} +\_def\_kv#1{\_expanded{\_trykv{#1}{\_trykv{.\_csstring\notdef}{\_kvunknown}}}} \_def\_iskv#1#2{#2\_else\_ea\_unless\_fi \_ifcsname\_kvcs#1\_endcsname} \_def\_kvcs{_kv:\_the\_kvdict:} \_def\_kvunknown{???} -\public \readkv \kvx \nokvx \kv \iskv ; +\public \readkv \kvx \nokvx \kv \trykv \iskv ; \_endcode @@ -75,7 +79,13 @@ register. First: we read default parameters by \^`\readkv\myframedefaults` and secondly the actual parameters are read by \^`\readkv{\the\opt}`. 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. +The \^`\kv{<key>}` returns `???` if such a <key> isn't declared +but if `.notdef` key is declared then its value is returned in this case. + +The \^`\kv{<key>}` macro fully expands the value of key. If you don't want to expand +the value, use \^`\trykv``{<key>}{<code>}`. It returns unexpanded value of <key> if +declared else returns expanded <code>. For example +`\edef\macro{\trykv{key}{}}` defines `\macro` as the unexpanded value of the `key`. You can use keys without values in the parameters list too. Then you can ask if the key is declared by \^`\iskv``{<key>}\iftrue` @@ -114,7 +124,7 @@ for undeclared <key>. Example: `\nokvx{\opwarning{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` +\^`\kvdict``={<name>}`. Then `\redakv`, `\kv`, `\trykv`, `\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 @@ -128,6 +138,7 @@ A more extensive example can be found in \_endinput +2023-11-24 \trykv introduced. 2023-10-23 minor changes in \readkv, empty key isn't processed. 2023-03-11 \nokvx: \fi bug (due to \afterfi in \trycs) fixed. 2023-01-13 \kvx parameter added, \nokvx introduced. diff --git a/macros/optex/base/logos.opm b/macros/optex/base/logos.opm index a510a74a30..1168c25b58 100644 --- a/macros/optex/base/logos.opm +++ b/macros/optex/base/logos.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \TeX {Logos TeX, LuaTeX, etc. <2020-02-28>} % preloaded in format +\_codedecl \TeX {Logos TeX, LuaTeX, etc. <2024-02-12>} % preloaded in format \_doc ---------------------------- Despite plain \TeX/ each macro for logos ends by \`\ignoreslash`. @@ -20,6 +20,18 @@ \_public \TeX \OpTeX \LuaTeX \XeTeX \ignoreslash ; + \_doc ---------------------------- + The \`\ConTeXt` logo is implemented as in the \ConTeXt/ format itself. + The kerning between \"Con" and \"\TeX/t" is calculated by measuring the kerning + between the letters \"T" and \"e". + \_cod ---------------------------- + +\_protected\_def \_ConTeXt{\_begingroup + Con\_setbox0=\_hbox{T\_kern\_zo e}\_setbox1=\_hbox{Te}{\_kern\_dimexpr\_wd1 -\_wd0}% + \_TeX t\_endgroup\_ignoreslash} + +\_public \ConTeXt ; + \_doc ----------------------------- The \`\_slantcorr` macro expands to the slant-correction of the current font. It is used to shifting A if the \`\LaTeX` logo is in italic. @@ -53,9 +65,12 @@ \_def\TeX{TeX\_ignslash}\_def\OpTeX{OpTeX\_ignslash}% \_def\LuaTeX{LuaTeX\_ignslash}\_def\XeTeX{XeTeX\_ignslash}% \_def\LaTeX{LaTeX\_ignslash}\_def\OPmac{OPmac\_ignslash}% + \_def\ConTeXt{ConTeXt\_ignslash}% \_def\CS{CS}\_def\csplain{csplain\_ignslash}% } \_public \ignslash ; \_endcode +2024-02-12 ConTeXt logo added. +2020-02-28 Released. diff --git a/macros/optex/base/margins.opm b/macros/optex/base/margins.opm index 0f544fc5dd..c77926f9ad 100644 --- a/macros/optex/base/margins.opm +++ b/macros/optex/base/margins.opm @@ -64,7 +64,9 @@ \_doc ---------------------------- \`\magscale` `[<factor>]` does `\mag=<factor>` and recalculates page - dimensions to their true values. + dimensions to their true values.\nl + \`\_truedimen``<dimen-register>` retunrs true value of <dimen-register> + regardless of `\mag`. \_cod ---------------------------- \_def\_trueunit{} diff --git a/macros/optex/base/math-macros.opm b/macros/optex/base/math-macros.opm index 00adc9f1aa..fa4317f25a 100644 --- a/macros/optex/base/math-macros.opm +++ b/macros/optex/base/math-macros.opm @@ -347,7 +347,10 @@ names from plain\TeX/ with `@` character are re-written in a more readable form.\nl \`\sp` is an alternative for `^`. The \`\sb` alternative for `_` was defined - at line 27 of the file `math-macros.opm`. + at line 27 of the file `math-macros.opm`.\nl + \`\_thinsk`, \`\_medsk`, \`\_thicksk` and \`\_thinneg` should be used + instead `\,`, `\>`, `\;` and `\!` in macros because a user can re-define + these single-letter sequences. \_cod ----------------------------- \_let\_sp=^ \public \sp ; diff --git a/macros/optex/base/more-macros.opm b/macros/optex/base/more-macros.opm index 8c62243234..3f4916a9c3 100644 --- a/macros/optex/base/more-macros.opm +++ b/macros/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 <2023-01-18>} % preloaded in format +\_codedecl \eoldef {OpTeX useful macros <2024-02-10>} % preloaded in format \_doc ----------------------------- We define \`\opinput` `{<file name>}` macro which @@ -119,8 +119,9 @@ \_newtoks\_opt \_def\_optdef#1[#2]{% - \_def#1{\_opt={#2}\_isnextchar[{\_cs{_oA:\_csstring#1}}{\_cs{_oB:\_csstring#1}}}% - \_sdef{_oA:\_csstring#1}[##1]{\_opt={##1}\_cs{_oB:\_csstring#1\_nospaceafter}}% + \_def#1{\_isnextchar[{\_cs{_oA:\_csstring#1}}{\_cs{_oA:\_csstring#1}[#2]}}% + \_sdef{_oA:\_csstring#1}[##1]{% + \_immediateassignment\_opt={##1}\_cs{_oB:\_csstring#1\_nospaceafter}}% \_sdef{_oB:\_csstring#1\_nospaceafter}% } \_def\_nospaceafter#1{\_ea#1\_romannumeral-`\.\_noexpand} @@ -130,12 +131,21 @@ \_public \opt \optdef \nospaceafter \nospacefuturelet ; \_doc ----------------------------- + \`\_noprefix` `<cs>` works like `\csstring` `<cs>`, but ignores not only + the first backlash but the second~\"`_`" ignores too (if it follows the + backslash). + \_cod ----------------------------- + +\_def\_noprefix#1{\_ea\_noprefixA \_csstring#1\_empty\_fin} +\_def\_noprefixA #1#2\_fin{\_if _#1\_else #1\_fi #2} + + \_doc ----------------------------- The declarator \`\eoldef``\macro #1{<replacement text>}` defines a `\macro` which scans its parameter to the end of the current line. This is the parameter `#1` which can be used in the `<replacement text>`. The catcode of the `\endlinechar` is reset temporarily when the parameter is scanned. - The macro defined by `\eoldef` cannot be used with its parameter inside + The macro defined by \^`\eoldef` cannot be used with its parameter inside other macros because the catcode dancing is not possible here. But the \`\bracedparam``\macro{<parameter>}` can be used here. The `\bracedparam` is a prefix that re-sets temporarily the `\macro` to a `\macro` with @@ -146,15 +156,16 @@ \_cod ----------------------------- \_def\_eoldef #1{\_def #1{\_begingroup \_catcode`\^^M=12 \_eoldefA #1}% - \_ea\_def\_csname _\_csstring #1:M\_endcsname} + \_ea\_def\_csname _eol:\_noprefix #1\_endcsname} \_catcode`\^^M=12 % -\_def\_eoldefA #1#2^^M{\_endgroup\_csname _\_csstring #1:M\_endcsname{#2}}% +\_def\_eoldefA #1#2^^M{\_endgroup\_csname _eol:\_noprefix #1\_endcsname{#2}}% \_normalcatcodes % \_eoldef\_skiptoeol#1{} -\_def\_bracedparam#1{\_ifcsname _\_csstring #1:M\_endcsname - \_csname _\_csstring #1:M\_ea \_endcsname - \_else \_csname _in\_csstring #1\_ea \_endcsname \_fi + +\_def\_bracedparam#1{% + \_trycs{_eol:\_noprefix#1}% + {\_errmessage{\_string\bracedparam: \_string#1 isn't defined by \_string\eoldef}}% } \_public \eoldef \skiptoeol \bracedparam ; @@ -270,7 +281,8 @@ \endtt You can use expandable \`\expr``{<expression>}` for analogical purposes. It expands to the value of the `<expression>` at expand processor level. - The `<expression>` can include `+-*/()` and decimal numbers in common syntax. + The `<expression>` can include `+-*/^()` and decimal numbers in common syntax. + Moreover, `a//b` means integer division and `a\%b` is remainder. 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)}`. @@ -298,6 +310,21 @@ \_public \expr \bp ; + \_doc ----------------------------- + The \^`\expr` and \^`\bp` macros return their results with given number of decimal + digits even if there are trailing zeros. There is the \^`\nnum` macro to + \"normalize" such decimal numbers. \`\nnum``{<number>}` expands its parameter + and removes trailing zeros after decimal point and removes the decimal point + if nothing follows. For example, use `\nnum{\expr[10]{<expression>}}`. + The `\nnum` macro is fully expandable. + \_cod ----------------------------- + +\_def\_nnum #1{\_ea\_nnumA\_expanded{#1}.\_fin} +\_def\_nnumA #1.#2\_fin{#1\_ifx~#2~\_else \_nnumB #20.\_fin \_fi} +\_def\_nnumB #10.#2\_fin{\_ifx~#2~\_nnumC#1\_else \_nnumB #1.0.\_fin \_fi} +\_def\_nnumC #1.{\_ifx~#1~\_else .#1\_fi} +\_public \nnum ; + \_doc ------------------ You can write \^`\setpos``[<label>]` somewhere and the position of such \^`\setpos``[<label>]` can be referenced by \^`\posx``[<label>]`, @@ -374,6 +401,9 @@ \_endcode % ------------------------------------- +2024-02-10 \optdef reimplemented, it can create expandable macros now. +2024-01-18 \bracedparam reimplemented. +2023-12-04 \nnum introduced 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 diff --git a/macros/optex/base/optex-tricks.opm b/macros/optex/base/optex-tricks.opm index 89fc7dd5e7..456a7472e1 100644 --- a/macros/optex/base/optex-tricks.opm +++ b/macros/optex/base/optex-tricks.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \_undefined {OpTeX tricks ready to autoload <2023-11-15>} % chunks loaded on demand +\_codedecl \_undefined {OpTeX tricks ready to autoload <2024-02-13>} % chunks loaded on demand % Selected OpTeX tricks are here, they are auto-loaded if the macro is used first % namespace: optextrick @@ -97,13 +97,14 @@ \_trick 105 \directoutput ; %%%%%%%%%%% -\_def\directoutput{\_begingroup \_afterassignment\.directoutputA \_setbox0=} +\_newbox\.outbox +\_def\directoutput{\_begingroup \_afterassignment\.directoutputA \_setbox\.outbox=} \_def\.directoutputA{\_aftergroup \.directoutputB} -\_def\.directoutputB{\_preshipout0\_box0 - \_pdfpageheight=\_dimexpr\_ht0+\_dp0+2\_vvkern \_relax - \_pdfpagewidth=\_dimexpr\_wd0+2\_hhkern\_relax +\_def\.directoutputB{\_preshipout\.outbox\_box\.outbox + \_pdfpageheight=\_dimexpr\_ht\.outbox+\_dp\.outbox+2\_vvkern \_relax + \_pdfpagewidth=\_dimexpr\_wd\.outbox+2\_hhkern\_relax \_hoffset=\_hhkern \_voffset=\_vvkern - \_shipout\_box0 + \_shipout\_box\.outbox \_incr\_pageno \_endgroup } @@ -735,12 +736,47 @@ +\_topskip \_relax } +\_trick 0129 \pgforeground ; +%%%%%%%%%%%% + +\_newtoks \pgforeground + +\_addto\_makefootline{ + \_istoksempty\pgforeground \_iffalse + \_vskip-\_prevdepth + \_vskip-\_vsize + \_vskip-\_voffset + \_istoksempty\_footline \_iffalse \_vskip-\_footlinedist \_fi + \_nointerlineskip + \_moveleft\_hoffset \_vbox{\_the\pgforeground} + \_fi +} + +\_trick 0130 \onlyifnew ; +%%%%%%%%%%%% + +\_def \onlyifnew#1#2{\_begingroup% + \_edef\.tmpA{\_csstring #2}% + \_edef\.tmpB{\_string #2}% + \_ea\_ifcsname\.tmpA\_endcsname% + \_ifx\.tmpA\.tmpB% #2 has no backslash + \_def\.onlyifnewA{#1{_optextrick_onlyifnewB}}\_else% + \_def\.onlyifnewA{#1\_optextrick_onlyifnewB}\_fi% + \_else% + \_ifx\.tmpA\.tmpB% + \_def\.onlyifnewA{#1{#2}}\_else% + \_def\.onlyifnewA{#1#2}\_fi% + \_fi\_ea\_endgroup\.onlyifnewA} + +%%%%%%%%%%%% \_trick end ; \_endcode +2024-02-13 \onlyifnew added +2024-02-12 \pgforeground added 2023-11-15 \correctvsize added -2023-11-09 \makeLOF, \makeLOT aded +2023-11-09 \makeLOF, \makeLOT added 2023-11-08 \ispageodd, \seccc added 2023-11-07 \settabs \import \incrpp added 2023-11-05 \twoblocks, \pstart added diff --git a/macros/optex/base/optex.ini b/macros/optex/base/optex.ini index b65832faf8..a659f43dc8 100644 --- a/macros/optex/base/optex.ini +++ b/macros/optex/base/optex.ini @@ -21,7 +21,7 @@ % OpTeX version -\def\optexversion{1.13 Nov 2023} +\def\optexversion{1.14 Feb 2024} \def\fmtname{OpTeX} \let\fmtversion=\optexversion diff --git a/macros/optex/base/others.opm b/macros/optex/base/others.opm index 9926c98fef..9b7e3a7ead 100644 --- a/macros/optex/base/others.opm +++ b/macros/optex/base/others.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \uv {Miscenaleous <2023-10-17>} % preloaded in format +\_codedecl \uv {Miscenaleous <2023-12-23>} % preloaded in format \_doc ---------------------------- \`\useOpTeX` and \`\useoptex` are declared as `\relax`. @@ -105,13 +105,14 @@ first sentence from the paragraph <number> using \`\_lipsumdot`. \_cod ---------------------------- +\_newbox\_nonebox \_def\_lipsumtext[#1]{\_lipsumload\_cs{_lip:#1}} \_def\_lipsum[#1]{\_lipsumA #1.]{#1}} \_def\_lipsumA #1.#2]#3{\_ifx^#2^\_lipsumB #1\_empty-\_empty\_fin \_else \_lipsumdot[#1].\_fi} \_def\_lipsumB #1-#2\_empty#3\_fin{% \_fornum #1..\_ifx^#2^#1\_else#2\_fi \_do {\_lipsumtext[##1]\_par}} \_def\_lipsumload{{% - \_setbox0=\_vbox{\_tmpnum=0 % vertical mode during \input lipsum.ltd.tex + \_setbox\_nonebox=\_vbox{\_tmpnum=0 % vertical mode during \input lipsum.ltd.tex \_def\ProvidesFile##1[##2]{}% \_def\SetLipsumLanguage##1{}% \_def\NewLipsumPar{\_incr\_tmpnum \_sxdef{_lip:\_the\_tmpnum}}% @@ -149,7 +150,7 @@ \_savecatcodetable\_tmpcatcodes \_catcodetable\_tmpcatcodes \_long\_def\_loadtrickA ##1\_trick##2#1##3;{##1}% \_wlog{Loading trick macros for \_string#1}% - \_setbox0=\_vbox{\_globaldefs=1 \_ea\_loadtrickA \_input {optex-tricks.opm}}% + \_setbox\_nonebox=\_vbox{\_globaldefs=1 \_ea\_loadtrickA \_input {optex-tricks.opm}}% \_restorectable \_endnamespace } \_def\_trick #1;{\_endinput} @@ -161,7 +162,8 @@ \shadedframe \roundframe \cancel \ignoreinspic \keystroke \colortab \crx \crtop \crbot \crmid \longtable \vcent \vbot \tnote \tabnodes \tablebefore \framedblocks \twoblocks \pstart \settabs \import \incrpp \ispageodd - \iniseccc \seccc \makeLOF \makeLOT \captionF \captionT \correctvsize ; + \iniseccc \seccc \makeLOF \makeLOT \captionF \captionT \correctvsize \pgforeground + \onlyifnew ; \_sdef{_item:m}{\_loadtrick{\style m}\_cs{_item:m}} \_doc ----------------------------- @@ -238,6 +240,7 @@ \_endcode +2023-12-23 \_nonebox instead box 0 introduced. 2023-10-17 \_loadtrick introduced. 2022-05-04 \lipsum[<num>]. changed to \lipsum[<num>.] to keep macro expandable. 2022-04-21 syntax \lipsum[<num>]. introduced. diff --git a/macros/optex/base/parameters.opm b/macros/optex/base/parameters.opm index f831fa6a2d..05abe42275 100644 --- a/macros/optex/base/parameters.opm +++ b/macros/optex/base/parameters.opm @@ -144,12 +144,12 @@ \_voffset=25mm \_hsize=160mm % 210mm (from A4 size) - 2*25mm (default margins) \_vsize=244mm % 297mm (from A4 size) - 2*25mm (default margins) -3mm baseline correction -\_pagewidth=210 true mm -\_pageheight=297 true mm +\_pdfpagewidth=210 true mm +\_pdfpageheight=297 true mm \_doc ----------------------------- If you insist on plain \TeX/ values of these parameters then you can - call the `\plaintexsetting` macro. + call the \`\plaintexsetting` macro. \_cod ----------------------------- \_def\_plaintexsetting{% @@ -162,8 +162,8 @@ \_voffset=0pt \_hsize=6.5in \_vsize=8.9in - \_pagewidth=8.5 true in - \_pageheight=11 true in + \_pdfpagewidth=8.5 true in + \_pdfpageheight=11 true in \_nonfrenchspacing } \_public \plaintexsetting ; diff --git a/macros/optex/base/plain-macros.opm b/macros/optex/base/plain-macros.opm index 6ae59108b5..f3aa8c5334 100644 --- a/macros/optex/base/plain-macros.opm +++ b/macros/optex/base/plain-macros.opm @@ -8,6 +8,8 @@ \begtt \addto \dospecials{\do\_} \endtt + \`\active` is character constant 13, we can use it in the context + \code{\\catcode`}<character>\code{=\\active}. \_cod ----------------------------- \_def\_dospecials {\do\ \do\\\do\{\do\}\do\$\do\&% @@ -138,6 +140,7 @@ \_doc ----------------------------- The \`\strutbox` is declared as 10pt size dependent (like in plain \TeX), but the macro `\_setbaselineskip` (from `fonts-opmac.opm`) redefines it. + The `\strut` macro puts the \^`\strutbox`. \_cod ----------------------------- \_newbox\_strutbox @@ -162,8 +165,8 @@ \_doc ----------------------------- Tabbing macros are omitted because they are obsolete. \nl - Indentation and others. \`\textindent`, \`\item`, \`\itemitem`, - \`\narrower`, \`\raggedright`, \`\ttraggedright`, \`\leavevmode`. + Indentation and similar macros are defined here: \`\hang`, \`\textindent`, + \`\item`, \`\itemitem`, \`\narrower`, \`\raggedright`, \`\ttraggedright`, \`\leavevmode`. \_cod ----------------------------- \_def \_hang {\_hangindent\_parindent} @@ -181,7 +184,7 @@ \_doc ----------------------------- Few character codes are set for backward compatibility. But old obscurities - (from plain TeX) based on \`\mathhexbox` + (from plain \TeX) based on \`\mathhexbox` are not supported -- an error message and recommendation to directly using the desired character is implemented by the \`\_usedirectly` macro). @@ -219,7 +222,7 @@ \_public \mathhexbox ; \_doc ----------------------------- - The \`\_unichars` macro is run in \~`\initunifonts`, + The \`\_unichars` macro is run when Unicode font family is loaded, Unicodes are used instead old plain \TeX/ settings. \_cod ----------------------------- @@ -263,6 +266,9 @@ macro \`\oldaccents` which defines accented macros. \nl Much more usable is to define these control sequences for other purposes. + \nl + The \`\_uniaccents` macro redeclares codes for accents and it is run when + Unicode font family is loaded. \_cod ----------------------------- \_def \_oldaccents {% @@ -342,7 +348,7 @@ \rightarrowfill \leftarrowfill \downbracefill \upbracefill ; \_doc ----------------------------- - The last part of plain \TeX/ macros: \`\magnification`, \`\bye`. + The last part of plain \TeX/ macros: \`\magnification`, \`\showhyphens`, \`\bye`. Note that math macros are defined in the `math-macros.opm` file (section~\ref[math-macros]). \_cod ----------------------------- @@ -361,7 +367,7 @@ \_public \showhyphens \bye ; \_doc ----------------------------- - Plain \TeX/ reads `hyphen.tex` with patterns as `\language=0`. We do the same. + Plain \TeX/ reads `hyphen.tex` with patterns when \^`\language``=0`. We do the same. \_cod ----------------------------- \_lefthyphenmin=2 \_righthyphenmin=3 % disallow x- or -xx breaks diff --git a/macros/optex/base/prefixed.opm b/macros/optex/base/prefixed.opm index 3d25b0c894..89aa0b4966 100644 --- a/macros/optex/base/prefixed.opm +++ b/macros/optex/base/prefixed.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \public {Prefixing and code syntax <2022-11-25>} % preloaded in format +\_codedecl \public {Prefixing and code syntax <2024-02-02>} % preloaded in format \_doc --------- All \TeX/ primitives have alternative control sequence `\_hbox` `\_string`, ... @@ -97,6 +97,8 @@ \_def \_nspublic {\_xargs \_nspublicA} \_def \_nspublicA #1{% \_checkexists \_nspublic {\_pkglabel _\_csstring #1}% + \_ifcsname _eol:\_ea\_ignoreit\_pkglabel _\_csstring #1\_endcsname % defined by \eoldef + \_slet {_eol:\_csstring #1}{_eol:\_ea\_ignoreit\_pkglabel _\_csstring #1}\_fi \_ea\_newpublic \_ea\_let \_ea#1\_csname \_pkglabel _\_csstring #1\_endcsname } \_def \_nsprivate {\_xargs \_nsprivateA} @@ -388,6 +390,8 @@ can look like. Another good and short example is \endinput +2024-02-02 \_nspublicA bug correction (#1 may be set as \outer) +2024-01-18 \_nspublic modified in order to \eoldef+\bracedparam 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. diff --git a/macros/optex/base/sections.opm b/macros/optex/base/sections.opm index ef5958e788..de647475ef 100644 --- a/macros/optex/base/sections.opm +++ b/macros/optex/base/sections.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \chap {Titles, chapters, sections, subsections <2023-05-02>} % preloaded in format +\_codedecl \chap {Titles, chapters, sections, subsections <2024-01-19>} % preloaded in format \_doc --------------------------- We are using scaled fonts for titles @@ -28,7 +28,7 @@ \_nobreak\_bigskip } \_def\_tit{\_scantoeol\_printtit} -\_let\_intit=\_printtit % used by \bracedparam +\_sdef{_eol:tit}{\_printtit} % enables \bracedparam\tit{title} \_public \tit ; @@ -156,7 +156,7 @@ \_doc ---------------------------- The \`\notoc` and \`\nonum` prefixes are implemented by - internal `\_ifnotoc` and `\_ifnonum`. They are reset + internal \`\_ifnotoc` and \`\_ifnonum`. They are reset after each chapter/section/subsection by the \`\_resetnonumnotoc` macro. \_cod ---------------------------- @@ -179,6 +179,10 @@ \_optdef\_secc[]{\_trylabel \_scantoeol\_insecc} \_def\_trylabel{\_istoksempty\_opt\_iffalse \_label[\_the\_opt]\_fi} +\_sdef{_eol:chap}{\_inchap} % enebles \bracedparam\chap{title} +\_sdef{_eol:sec}{\_insec} % enables \bracedparam\sec{title} +\_sdef{_eol:secc}{\_insecc} % enables \bracedparam\secc{title} + \_def\_inchap #1{\_par \_sectionlevel=1 \_def \_savedtitle {#1}% saved to .ref file \_ifnonum \_else {\_globaldefs=1 \_incr\_chapnum \_chapx}\_fi @@ -317,12 +321,14 @@ `\secl3` is `\secc` and all more levels (for <number>$>3$) are printed by the common \`\_seclp` macro. It declares only a simple design. If there is a requirement to use such more levels then the book designer can - define something different here. + define something different here.\nl + The variant `\_eol:secl` is defined to enable \^`\bracedparam``\secl<number> {<title-text>}`. \_cod ----------------------------- -\_def\_secl{\_afterassignment\_secla \_sectionlevel=} +\_def\_secl{\_let\_secle=\_ea \_afterassignment\_secla \_sectionlevel=} +\_sdef{_eol:secl}{\_def\_secle{\_ea\_bracedparam\_ea}\_afterassignment\_secla \_sectionlevel=} \_def\_secla{\_ifcase\_sectionlevel - \_or\_ea\_chap\_or\_ea\_sec\_or\_ea\_secc\_else\_ea\_seclp\_fi} + \_or \_secle\_chap \_or \_secle\_sec \_or \_secle\_secc \_else \_ea \_seclp\_fi} \_eoldef\_seclp#1{\_par \_ifnum\_lastpenalty=0 \_removelastskip\_medskip\_fi \_noindent{\_bf #1}\_vadjust{\_nobreak}\_nl\_ignorepars} \_def\_ignorepars{\_isnextchar\_par{\_ignoresecond\_ignorepars}{}} @@ -473,6 +479,8 @@ \_endcode % ------------------------------------- +2024-01-19 \bracedparam\secl enalbed +2024-01-18 \tit, \chap, \sec, \secc: added cooperation with new \bracedparam 2023-05-02 \_numprint used 2022-10-19 More robust \caption (two opened groups, \_printcaption introduced) 2022-08-02 Penalties in \_printsec, \_printsecc changed diff --git a/macros/optex/base/unimath-codes.opm b/macros/optex/base/unimath-codes.opm index 66be7487d4..d2b7e0e1e3 100644 --- a/macros/optex/base/unimath-codes.opm +++ b/macros/optex/base/unimath-codes.opm @@ -198,7 +198,8 @@ } \_doc ----------------------------- - The math alphabets \`\cal`, \`\bbchar`, \`\frak`, \`\script` are re-defined + The math alphabets \`\cal`, \`\bbchar`, \`\frak`, \`\script`, + \`\misans`, \`\mbisans` are re-defined here. The \`\_marm`, \`\_mabf`, \`\_mait`, \`\_mabi`, \`\_matt` used in \^`\rm`, \^`\bf`, \^`\it`, \^`\bi` are re-defined too.\nl You can redefine them again if you need different behavior (for example @@ -548,7 +549,7 @@ \secc More Unicode-math examples 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 +\ulink[http://petr.olsak.net/ftp/olsak/optex/optex-math.pdf]{\tt optex-math.pdf} documentation. 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. diff --git a/macros/optex/base/unimath-macros.opm b/macros/optex/base/unimath-macros.opm index 35842e674d..ac926b5e89 100644 --- a/macros/optex/base/unimath-macros.opm +++ b/macros/optex/base/unimath-macros.opm @@ -181,7 +181,9 @@ \`\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. + return delcode quaitities of given math character. + All these commands use the common Lua code defined in + the \`\_getmathcode``<code>{<math or del>}<character number>` macro. \_cod ----------------------------- \_def\_getmathcode#1#2{\_directlua{tex.print(tex.get#2code(token.scan_int())[#1])}} |