diff options
Diffstat (limited to 'macros/luatex')
38 files changed, 2357 insertions, 308 deletions
diff --git a/macros/luatex/optex/README b/macros/luatex/optex/README index caba16dda0..c88eb1f929 100644 --- a/macros/luatex/optex/README +++ b/macros/luatex/optex/README @@ -19,6 +19,11 @@ doc/ ... PDF version of the OpTeX documentation and sources. History: +<0.14> Typeseting Math with OpTeX: new document added. + Math macros corrected. + In-line verbatim in section titles allowed. + \eqbox implemented. + "\mnote up", "\displaylines to" (new features implemented) <0.13> \table have more features: \tabskip, \table to, \table pxto, \vspan The \eqalign reimplemented to be more flexible. The boundary character ":" introduced in the \table. diff --git a/macros/luatex/optex/base/alloc.opm b/macros/luatex/optex/base/alloc.opm index d5625321a9..b981c25b56 100644 --- a/macros/luatex/optex/base/alloc.opm +++ b/macros/luatex/optex/base/alloc.opm @@ -109,11 +109,11 @@ \_newdimen \tmpdim \_newdimen \_tmpdim \_doc ----------------------------- - A few registers are initialized like in plain\TeX/. Note that `\z@` and `\z@skip` from - plain\TeX/ is `\zo` and `\zoskip` because we absolutely + A few registers are initialized like in plain\TeX/. Note that `\z@skip` from + plain\TeX/ is `\zoskip` here because we absolutely don't support the `@` category dance. - Note that `\p@` is not defined because we can write 1pt which is more - legible. + The `\z@` and `\p@` is not defined because we can write 0pt or 1pt which is more + legible in source code. You can see `plain-at.opm` file. \_cod ----------------------------- \_newdimen\_maxdimen \_maxdimen=16383.99999pt % the largest legal <dimen> diff --git a/macros/luatex/optex/base/basic-macros.opm b/macros/luatex/optex/base/basic-macros.opm index 512678c312..83181f9510 100644 --- a/macros/luatex/optex/base/basic-macros.opm +++ b/macros/luatex/optex/base/basic-macros.opm @@ -92,6 +92,16 @@ \_public \loggingall \tracingall ; + \_doc ------------------------------ + Write a warning if the user did not to load a Unicode Font {\em or} + if there were unresolved references. \`\_byehook` is used in the \^`\bye` macro. + \_cod ------------------------------ + +\_def\_byehook{% + \_ifx\_initunifonts\_relax \_relax\_else \_opwarning{Unicode font was not loaded}\_fi + \_ifnum\_unresolvedrefs>0 \_opwarning{Rerun to get references right}\_fi +} + \_endcode % ------------------------------------- diff --git a/macros/luatex/optex/base/cite-bib.opm b/macros/luatex/optex/base/cite-bib.opm index c756a619bd..ff46c1deaa 100644 --- a/macros/luatex/optex/base/cite-bib.opm +++ b/macros/luatex/optex/base/cite-bib.opm @@ -89,6 +89,7 @@ \_ifcsname _bib:#1#2\_endcsname \_else \_addcitelist{#1#2}% \_opwarning{The cite [#1#2] unknown. Try to TeX me again}\_openref + \_incr\_unresolvedrefs \_addto\_savedcites{?,}\_def\_sortcitesA{}\_lastcitenum=0 \_ea\_gdef \_csname _bib:#1#2\_endcsname {}% \_ea\_skiptorelax \_fi diff --git a/macros/luatex/optex/base/fams-ini.opm b/macros/luatex/optex/base/fams-ini.opm index 7619de9657..d89a29c7a1 100644 --- a/macros/luatex/optex/base/fams-ini.opm +++ b/macros/luatex/optex/base/fams-ini.opm @@ -60,7 +60,7 @@ \_faminfo [Baskerville] {Free variants of classical Baskerville} {f-baskerville} { -,\caps: {\rm\bf\it\bi} } -\_famalias [BaskevilleF] +\_famalias [BaskervilleF] \_faminfo [Technika] {Fonts from visual style of CTU in Prague} {f-technika} { -,\light,\book, \caps, \caps\book: {\rm\bf\it\bi} -:{\stencil} } diff --git a/macros/luatex/optex/base/fnotes.opm b/macros/luatex/optex/base/fnotes.opm index 3a1f28cfc2..219b2cf293 100644 --- a/macros/luatex/optex/base/fnotes.opm +++ b/macros/luatex/optex/base/fnotes.opm @@ -1,6 +1,6 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \fnote {Footnotes, marginal notes OpTeX <2020-03-20>} % loaded in format +\_codedecl \fnote {Footnotes, marginal notes OpTeX <2020-05-26>} % loaded in format \_doc ----------------------------- \`\_gfnotenum` is conter which counts footnotes globally in the document. @@ -92,7 +92,8 @@ \_ifpgfnote \_openref \_fi \_wref \_Xfnote{}% \_ifpgfnote \_ifcsname _fn:\_the\_gfnotenum \_endcsname \_else - \_opwarning{unknown \_noexpand\fnote mark. TeX me again} + \_opwarning{unknown \_noexpand\fnote mark. TeX me again}% + \_incr\_unresolvedrefs \_fi\_fi \_opfootnote\_fnset\_printfnotemarkB } @@ -126,18 +127,32 @@ \_public \fixmnotes ; \_doc ----------------------------- - The outer box of marginal note has zero width and zero depth and it is appended - after current line using `\vadjust` primitive or it is inverted to vertical mode + The \`\_mnoteD``{<text>}` macro sets the position the marginal note. + The outer box of marginal note has zero width and zero depth and it is appended + after current line using `\vadjust` primitive or it is inverted to vertical mode as a box with `\vskip-\baselineskip` followed. \_cod ----------------------------- -\_long\_def\_mnote#1{\_ifvmode {\_mnoteA{#1}}\_nobreak\_vskip-\_baselineskip \_else +\_def\_mnote #1#{\_ifx^#1^\_else \_mnoteC#1\_end \_fi \_mnoteD} +\_def\_mnoteC up#1\_end{\_mnoteskip=#1\_relax} % \mnote up<dimen> {<text>} syntax +\_long\_def\_mnoteD#1{\_ifvmode {\_mnoteA{#1}}\_nobreak\_vskip-\_baselineskip \_else \_lower\_dp\_strutbox\_hbox{}\_vadjust{\_kern-\_dp\_strutbox \_mnoteA{#1}\_kern\_dp\_strutbox}% \_fi } \_public \mnote ; \_doc ----------------------------- + The \`\mnoteskip` is a dimen which denotes the vertical shift of marginal + note from its normal position. Positive value means shift up, negative + down. The `\mnoteskip` register is set to zero + after the marginal note is printed. The new sytax `\mnote up<dimen>{<text>}` + is possible too, but public `\mnoteskip` is kept for backward compatibility. + \_cod ----------------------------- + +\_newdimen\_mnoteskip +\_public \mnoteskip ; + + \_doc ----------------------------- The \`\_mnoteA` macro does the real work. The \`\_lrmnote``{<left>}{<right>}` uses only first or only second parameter depending on the left or right marginal note. @@ -149,6 +164,7 @@ \_edef\_mnotesfixed{\_cs{_mn:\_the\_mnotenum}}% \_else \_opwarning{unknown \_noexpand\mnote side. TeX me again}\_openref + \_incr\_unresolvedrefs \_def\_mnotesfixed{\_right}% \_fi\_fi \_hbox to0pt{\_wref\_Xmnote{}\_everypar={}% @@ -172,4 +188,5 @@ \_endcode % ------------------------------------- - +2020-05-26 \mnote up<dimen> implemented +2020-03-20 released diff --git a/macros/luatex/optex/base/fonts-resize.opm b/macros/luatex/optex/base/fonts-resize.opm index 5a9f0df40e..1709cb05cf 100644 --- a/macros/luatex/optex/base/fonts-resize.opm +++ b/macros/luatex/optex/base/fonts-resize.opm @@ -152,8 +152,8 @@ \_doc ----------------------------- The \`\_regtfm` `<font id> <optical size data>` saves the <optical size data> concerned to `<font id>`. - The `<optical size data>` is in the form as show below in the code where - `\regtfm` is used. + The `<optical size data>` is in the form as shown below in the code where + `\_regtfm` is used. \nl The \`\_wichtfm` `<fontname>` expands to the `<fontname>` or to the corrected `<fontname>` read from the `<optical size data>`. It is used in the @@ -266,7 +266,7 @@ create a size-dependent selector for such font then you can use The example above uses the 8\,bit `tfm` font. You can use Unicode font too, of course. The \^`\fontfam` macro initializes the extended `\font` primitive features for \LuaTeX/. If you didn't use this command, you must to initialize -these features by `\initunifonts` command, for example: +these features by the \^`\initunifonts` command explicitly, for example: \begtt \initunifonts diff --git a/macros/luatex/optex/base/graphics.opm b/macros/luatex/optex/base/graphics.opm index bc88a16de0..be2cfdab7e 100644 --- a/macros/luatex/optex/base/graphics.opm +++ b/macros/luatex/optex/base/graphics.opm @@ -421,5 +421,24 @@ \_endcode % ------------------------------------- +The \^`\inspic` is defined by `\pdfximage` and `\pdfrefximage` primitives. +If you want to use one picture more than once in your document, then the +following code is recommended: +\begtt \catcode`\<=13 +\newbox\mypic +\setbox\mypic = \hbox{\picw=3cm \inspic{<picture>}} + +My picture: \copy\mypic, again my picture: \copy\mypic, etc. +\endtt +This code downloads the picture data to the PFD oputput only once (when +`\setbox` is processed). Each usage of `\copy\mypic` puts only a pointer to +the picture data in the PDF. + +If you want to copy the same picture in different sizes, then choose +a \"basic size" used in `\setbox` and all different sizes can be realized by +the \^`\transformbox{<transformation>}{\copy\mypic}`. + +\_endinput + 2020-04-12: \_public \clipinoval \clipincircle ; added, bug fixed diff --git a/macros/luatex/optex/base/if-macros.opm b/macros/luatex/optex/base/if-macros.opm index 4685aed48e..39e3841719 100644 --- a/macros/luatex/optex/base/if-macros.opm +++ b/macros/luatex/optex/base/if-macros.opm @@ -1,6 +1,6 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \newif {Special if-macros, is-macros and loops <2020-05-06>} % preloaded in format +\_codedecl \newif {Special if-macros, is-macros and loops <2020-05-22>} % preloaded in format \_doc ---------------------------- \secc Classical \code{\\newif} @@ -72,25 +72,25 @@ \_def\_do{\_doundefined} % we need to ask \_ifx#1\_do ... \_long\_def\_foreach #1\_do#2{\_putforstack - \_immediateassignment\_def\_fbody##1{#2}% + \_immediateassignment\_gdef\_fbody##1{#2}% \_foreachA #1\_do} \_long\_def\_foreachA #1{\_ifx\_do#1\_getforstack\_else\_fbody{#1}\_ea\_foreachA\_fi} \_def\_fornum#1..#2\_do{\_fornumstep 1:#1..#2\_do} \_long\_def\_fornumstep#1:#2..#3\_do#4{\_putforstack \_immediateassigned{% - \_def\_fbody##1{#4}% - \_def\_fornumsgn{}% - \_def\_fornumrel{<}% - \_frnum=\_numexpr#2\_relax - \_ifnum\_numexpr#3<\_frnum \_def\_fornumrel{>}\_fi %decreasing sequence - \_ifnum\_numexpr#1\_fornumrel0 \_def\_fornumsgn{-}\_fi % correction + \_gdef\_fbody##1{#4}% + \_gdef\_fornumsgn{}% + \_gdef\_fornumrel{<}% + \_global\_frnum=\_numexpr#2\_relax + \_ifnum\_numexpr#3<\_frnum \_gdef\_fornumrel{>}\_fi %decreasing sequence + \_ifnum\_numexpr#1\_fornumrel0 \_gdef\_fornumsgn{-}\_fi % correction }% \_fornumB{#3}{#1}% } \_def\_fornumB #1#2{\_ifnum\_numexpr#1\_fornumrel\_frnum \_getforstack \_else \_ea\_fbody\_ea{\_the\_frnum}% - \_immediateassignment\_advance\_frnum by\_numexpr\_fornumsgn#2\_relax + \_immediateassignment\_global\_advance\_frnum by\_numexpr\_fornumsgn#2\_relax \_afterfi{\_fornumB{#1}{#2}}\_fi } \_def\_afterfi#1#2\_fi{\_fi#1} @@ -118,16 +118,16 @@ \_newcount\_forlevel \_def\_putforstack{\_immediateassigned{% \_ifnum\_forlevel>0 - \_sdef{_frnum:\_the\_forlevel\_ea}\_ea{\_the\_frnum}% - \_slet{_fbody:\_the\_forlevel}{_fbody}% + \_sxdef{_frnum:\_the\_forlevel\_ea}{\_the\_frnum}% + \_global\_slet{_fbody:\_the\_forlevel}{_fbody}% \_fi - \_advance\_forlevel by1 + \_global\_advance\_forlevel by1 }} \_def\_getforstack{\_immediateassigned{% - \_advance\_forlevel by-1 + \_global\_advance\_forlevel by-1 \_ifnum\_forlevel>0 - \_slet{_fbody}{_fbody:\_the\_forlevel}% - \_frnum=\_cs{_frnum:\_the\_forlevel}\_space + \_global\_slet{_fbody}{_fbody:\_the\_forlevel}% + \_global\_frnum=\_cs{_frnum:\_the\_forlevel}\_space \_fi }} @@ -252,6 +252,7 @@ \_endcode +2020-05-22 \foreach, \fornum: all settings are global, independent on TeX group 2020-05-06 \isnextchar: \let\tmp=#1 -> \let\tmp= #1 (bug fix, #1 should be space) 2020-05-02 \newif bug fix 2020-04-15 \fornumstep 3: 1..12 instead \fornum 1..12\step 3 diff --git a/macros/luatex/optex/base/languages.opm b/macros/luatex/optex/base/languages.opm index aa862de431..36800e95db 100644 --- a/macros/luatex/optex/base/languages.opm +++ b/macros/luatex/optex/base/languages.opm @@ -80,7 +80,7 @@ another meaning when `\oldaccents` command is used. The macros `\"` and `\'` are not defined as `\protected` because we need their expansion when `\outlines` are created. - User can declare quotes by \`\quoteschars``<clqq><crqq><clq><crq>`, where + User can declare quotes by \^`\quoteschars``<clqq><crqq><clq><crq>`, where `<clqq>...<crqq>` are normal quotes and `<clq>...<crq>` are alternative quotes. or use \`\altquotes` to swap between meaning of these two types of quotes. \nl @@ -98,8 +98,26 @@ \_let \_skquotes = \_csquotes \_let \_dequotes = \_csquotes + \_doc ----------------------------- + The \`\quoteschars``<lqq><rqq><lq><rq>` defines `\"` and `\"` as `\_qqA` + in in normal mode and as expadable macros in outline mode. + We want to well process the common cases: \code{\\"`&`"} or \code{\\"`\{`"}. + This is reason why the quotes parameter is read in verbatim mode and retokenized + again by `\scantextokens`. We want to allow to quote the quoutes mark + itself by \code{\\"{`"`}"}. This is reason why the sub-verbatim mode is + used when first character is \code{\{} in the parameter.\nl + The `\"` is defined as `\_qqA\_qqB<lqq><rqq>` and `\'` as `\_qqA\_qqC<lq><rq>`. + The \`\_qqA``\_qqB<clqq><crqq>` runs \`\_qqB``<lqq><rqq><text>"`. + \_cod ----------------------------- + \_def \_quoteschars #1#2#3#4{\_def\_altquotes{\_quoteschars#3#4#1#2}\_public\altquotes;% - \_def \"##1"{#1##1#2}\_def \'##1'{#3##1#4}} + \_protected\_def \"{\_qqA\_qqB#1#2}\_protected\_def \'{\_qqA\_qqC#3#4}% + \_regmacro{}{}{\_def \"##1"{#1##1#2}\_def \'##1'{#3##1#4}}} + +\_def\_qqA#1#2#3{\_bgroup\_setverb \_catcode`\ =10 + \_isnextchar\_bgroup{\_catcode`\{=1 \_catcode`\}=2 #1#2#3}{#1#2#3}} +\_long\_def\_qqB#1#2#3"{\_egroup#1\_scantextokens{#3}#2} +\_long\_def\_qqC#1#2#3'{\_egroup#1\_scantextokens{#3}#2} \_doc ----------------------------- Sometimes should be usable to leave the markup `"such"` or `'such'` i.e.~without @@ -107,10 +125,20 @@ by the \`\activequotes` macro and leave quotes without first backslash. First, declare `\<iso-code>quotes`, then \^`\altquotes` (if needed) and finally \^`\activequotes`. + + \`\_resetaquotes` redefines expandable version of `\"<text>"` and `\'<text>'` + used in outlines in order to the delimiter is {\em active} character. We + are testing if \^`\quoteschars` were used now because the error in outlines + can be more confusing. \_cod ----------------------------- -\_def\_activequotes{\_ea\_activequotesA\"""\_ea\_activequotesA\'''} -\_def\_activequotesA#1#2#3{\_bgroup\_lccode`\~=`#3\_lowercase{\_egroup\_adef#3##1~{#1##1#2}}} +\_def\_activequotes{\_adef"{\"}\_adef'{\'}\_resetaquotes} + +\_bgroup \_catcode`,=13 \_lccode`\~=`\" \_lccode`\,=`\' \_lowercase{\_egroup + \_def\_resetaquotes{% + \_bgroup \_the\_regoul \_edef\_tmp{\"?"}\_egroup % test if \quoteschar were used + \_regmacro{}{}{\_edef\"##1~{\"##1"}\_edef\'##1,{\'##1'}}} +} \_public \quoteschars \activequotes \enquotes \csquotes \skquotes \frquotes \plquotes \esquotes \grquotes \ruquotes \itquotes \dequotes ; diff --git a/macros/luatex/optex/base/makeindex.opm b/macros/luatex/optex/base/makeindex.opm index 5904b494b4..c7e9b8ef4a 100644 --- a/macros/luatex/optex/base/makeindex.opm +++ b/macros/luatex/optex/base/makeindex.opm @@ -283,7 +283,8 @@ \_cod ----------------------------- \_def\_makeindex{\_par - \_ifx\_iilist\_empty \_opwarning{index data-buffer is empty. TeX me again} + \_ifx\_iilist\_empty \_opwarning{index data-buffer is empty. TeX me again}% + \_incr\_unresolvedrefs \_else \_dosorting \_iilist % sorting \_iilist \_bgroup diff --git a/macros/luatex/optex/base/maketoc.opm b/macros/luatex/optex/base/maketoc.opm index f94571629e..46a2f8d50f 100644 --- a/macros/luatex/optex/base/maketoc.opm +++ b/macros/luatex/optex/base/maketoc.opm @@ -3,7 +3,7 @@ \_codedecl \maketoc {Macros for maketoc <2020-03-12>} % preloaded in format \_doc ------------------------------------ - \`\_Xtoc` `{<level>}{<type>}{<number>}{<title>}` (in `.ref` file) reads the + \`\_Xtoc` `{<level>}{<type>}{<number>}<title>` (in `.ref` file) reads the specified data and appends them to the \`\_toclist` as \^`\_tocline``{<level>}{<type>}{<number>}{<title>}{<gpageno>}{<pageno>}` where: @@ -17,15 +17,17 @@ \enditems The last two parameters are restored from previous \^`\_Xpage``{<pageno>}{<gpageno>}`, data were saved in the \^`\_currpage` macro. + + We read the <title> parameter by \^`\scantoeol` from `.ref` file + because the <title> can include something like \code{`\{`}. \_cod ------------------------------------ \_def\_toclist{} \_newifi \_ifischap \_ischapfalse -\_def\_Xtoc#1#2#3#4{\_ifnum#1=0 \_ischaptrue\_fi - \_addto\_toclist{\_tocline{#1}{#2}{#3}{#4}} - \_ea\_addto\_ea\_toclist\_ea{\_currpage}% -} +\_def\_Xtoc#1#2#3{\_ifnum#1=0 \_ischaptrue\_fi + \_addto\_toclist{\_tocline{#1}{#2}{#3}}\_scantoeol\_XtocA} +\_def\_XtocA#1{\_addto\_toclist{{#1}}\_ea\_addto\_ea\_toclist\_ea{\_currpage}} \_doc ------------------------------------ \`\_tocline``{<level>}{<type>}{<number>}{<title>}{<gpageno>}{<pageno>}` prints @@ -59,7 +61,7 @@ \_def\_pgn{\_ilink[pg:#5]}% \_the\_everytocline \_ifcsname _tocl:#1\_endcsname - \_cs{_tocl:#1}{#3}{#4}{#6}\_par + \_cs{_tocl:#1}{#3}{\_scantextokens{#4}}{#6}\_par \_fi \_egroup } @@ -100,6 +102,7 @@ \_def\_maketoc{\_par \_ifx\_toclist\_empty \_opwarning{\_noexpand\maketoc -- data unavailable, TeX me again}\_openref + \_incr\_unresolvedrefs \_else \_begingroup \_tocrefnum=0 \_penalty11333 \_the\_regtoc \_toclist diff --git a/macros/luatex/optex/base/math-macros.opm b/macros/luatex/optex/base/math-macros.opm index 71a7923906..6189dec1c7 100644 --- a/macros/luatex/optex/base/math-macros.opm +++ b/macros/luatex/optex/base/math-macros.opm @@ -1,6 +1,6 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \sin {Math macros plus mathchardefs <2020-05-11>} % preloaded in format +\_codedecl \sin {Math macros plus mathchardefs <2020-06-13>} % preloaded in format \_doc ----------------------------- The category code of the character `_` remains as letter (11) and the mathocode @@ -433,13 +433,23 @@ \_protected\_def\_cdots{\_mathinner{\_cdotp\_cdotp\_cdotp}} \_protected\_def\_vdots{\_vbox{\_baselineskip=.4em \_lineskiplimit=0pt \_kern.6em \_hbox{.}\_hbox{.}\_hbox{.}}} -\_protected\_def\_ddots{\_mathinner{% +\_protected\_def\_ddots{\_mathinner{% \_mkern1mu\_raise.7em\_vbox{\_kern.7em\_hbox{.}}\_mkern2mu \_raise.4em\_hbox{.}\_mkern2mu\_raise.1em\_hbox{.}\_mkern1mu}} \_public \ldots \cdots \vdots \ddots ; \_doc ----------------------------- + \`\adots` ispired by plain \TeX/ + \_cod ----------------------------- + +\_protected\_def\_adots{\_mathinner{% + \_mkern1mu\_raise.1em\_hbox{.}\_mkern2mu + \_raise.4em\_hbox{.}\_mkern2mu\_raise.7em\_vbox{\_kern.7em\_hbox{.}}\_mkern1mu}} + +\_public \adots ; + + \_doc ----------------------------- Math accents (encoding dependent declarations). \_cod ----------------------------- @@ -563,6 +573,7 @@ $#1\_leftharpoondown$}}}} \_protected\_def\_buildrel#1\over#2{\_mathrel{\_mathop{\_kern0pt #2}\_limits^{#1}}} \_protected\_def\_doteq{\_buildrel\_textstyle.\over=} +\_private \in \sim ; \_public \cong \notin \rightleftharpoons \buildrel \doteq ; \_protected\_def\_bmod{\_nonscript\_mskip-\_medmuskip\_mkern5mu @@ -571,31 +582,32 @@ \_public \bmod \pmod ; \_doc ----------------------------- - \`\matrix`, \`\pmatrix` and \`\bordermatrix` + \`\matrix` and \`\pmatrix` behave as in Plain \TeX/, if it is used in the - `\displaystyle` or `\textstyle`. On the other hand, it is printed in smaller size - (by appropriate amount) in `\scriptstyle` and `\scriptscriptstyle`. + `\displaystyle`. On the other hand, it is printed in smaller size + (by appropriate amount) in `\textstyle` = `\scriptstyle` and `\scriptscriptstyle`. This feature is new in \OpTeX/. \_cod ----------------------------- \_protected\_def\_matrix#1{\_null\_thinsk \_edef\_stylenum{\_the\_numexpr\_mathstyle/2\_relax}% \_vcenter{\_matrixbaselines\_math - \_ialign{\_hfil$\_matrixstyle##$\_hfil&&\_quad\_hfil$\_matrixstyle##$\_hfil\_crcr + \_ialign{\_the\_lmfil$\_matrixstyle##$\_hfil&&\_quad\_the\_lmfil$\_matrixstyle##$\_hfil\_crcr \_mathstrut\_crcr\_noalign{\_kern-\_baselineskip} #1\_crcr\_mathstrut\_crcr\_noalign{\_kern-\_baselineskip}}}\_thinsk} \_def\_matrixbaselines{\_normalbaselines \_def\_matrixstyle{}% - \_ifcase\_stylenum \_or \_or - \_baselineskip=.7\_baselineskip - \_def\_quad {\_hskip.7em\_relax}% - \_let\_matrixstyle=\_scriptstyle + \_let\_matrixbaselines=\_relax % \matrix inside matrix does not change size again + \_ifcase\_stylenum \_or \_matrixscriptbaselines \_or \_matrixscriptbaselines \_or \_baselineskip=.5\_baselineskip \_def\_quad {\_hskip.5em\_relax}% \_let\_matrixstyle=\_scriptscriptstyle \_fi } +\_def\_matrixscriptbaselines{\_baselineskip=.7\_baselineskip + \_def\_quad {\_hskip.7em\_relax}\_let\_matrixstyle=\_scriptstyle +} \_protected\_def\_pmatrix#1{\_left(\_matrix{#1}\_right)} \_public \matrix \pmatrix ; @@ -604,23 +616,24 @@ The \`\cases` and `\bordermatrix` macros are identical from plain \TeX/. \_cod ----------------------------- -\_protected\_def\_cases#1{\_left\{\_thinsk\_vcenter{\_normalbaselines\_math - \_ialign{$##\_hfil$&\_quad##\_hfil\_crcr#1\_crcr}}\_right.} +\_protected\_long\_def\_cases#1{\_left\{\_thinsk\_vcenter{\_normalbaselines\_math + \_ialign{$##\_hfil$&\_quad{##\_unsskip}\_hfil\_crcr#1\_crcr}}\_right.} \_newdimen\_ptrenwd \_ptrenwd=8.75pt % width of the big left ( \_protected\_def\_bordermatrix#1{\_begingroup \_math - \_setbox0=\_vbox{\_def\_cr{\_crcr\_noalign{\_kern.2em\_global\_let\_cr\_endline}}% - \_ialign{$##$\_hfil\_kern.2em\_kern\_ptrenwd&\_thinspace\_hfil$##$\_hfil - &&\_quad\_hfil$##$\_hfil\_crcr - \_omit\_strut\_hfil\_crcr\_noalign{\_kern-\_baselineskip}% - #1\_crcr\_omit\_strut\_cr}}% + \_setbox0=\_vbox{\_bordermatrixA #1\_stopbmatrix}% \_setbox2=\_vbox{\_unvcopy0 \_global\_setbox1=\_lastbox}% \_setbox2=\_hbox{\_unhbox1 \_unskip\_global\_setbox1=\_lastbox}% \_setbox2=\_hbox{$\_kern\_wd1 \_kern-\_ptrenwd\_left(\_kern-\_wd1 \_global\_setbox1=\_vbox{\_box1 \_kern.2em}% \_vcenter{\_kern-\_ht1 \_unvbox0 \_kern-\_baselineskip}\_thinsk\_right)$}% \_null\_thicksk\_vbox{\_kern\_ht1 \_box2}\_endgroup} +\_def\_bordermatrixA #1\cr#2\_stopbmatrix{% + \_ialign{$##$\_hfil\_kern.2em\_kern\_ptrenwd&\_thinspace\_hfil$##$\_hfil + &&\_quad\_hfil$##$\_hfil\_crcr + \_omit\_strut\_hfil\_crcr\_noalign{\_kern-\_baselineskip}% + #1\_crcr\_noalign{\_kern.2em}#2\_crcr\_omit\_strut\_cr}} \_public \cases \bordermatrix ; @@ -632,44 +645,56 @@ advanced by `\jot` (3pt in plain \TeX). It follows from the default settings of \^`\eqlines` and \^`\eqstyle` parameters. - In \OpTeX/, this macro is more flexible. You can set the - `\baselineskip` value by the \^`\eqlines` parameter and math style + In \OpTeX/, this macro is more flexible. See section 4.4 in the + \ulink[http://petr.olsak.net/ftp/olsak/optex/optex-math.pdf] + {Typesetting Math with \OpTeX/}. + The `\baselineskip` value is set by the \^`\eqlines` parameter and math style by the \^`\eqstyle` parameter. - For example, you need to put the system of euations as an index of sum - operator: - \begtt - $$ - \sum_{\eqlines{\baselineskip=.7\baselineskip}\eqstyle{\scriptstyle}\eqalign{ - i &\in A \cr - j &\in B \cr - k &\in C }} - i + j + k - $$ - \endtt - You can write more equation systems one next second: - \begtt - $$\eqalign{ - x + y + z &= 1 && a + b + c &= -1 \cr - u + v &= 20 && f + g &= -20 \cr - i &= j - }$$ - \endtt - You can use the third column for centered equations without aligning point - (as in \^`\displaylines`, but packed to the `\vcenter` box). For example: - \begtt \catcode`\<=13 - $$ \left( \eqspace=0pt \eqalign{&& <first equation>\cr && <second equation>} \right) $$ - \endtt - The \^`\eqspace` is additional space used in the third column to separate - equation systems one next second. + + There are more possible columns than two (used in classical Plain TeX): + `rlcrlcrlc` etc.\ where `r` and `l` columns are without spaces and `c` column + (if used) has the space \^`\eqspace`/2 at its both sides. \_cod ----------------------------- -\_def\_eqalign#1{\_null\_thinsk\_vcenter{\_the\_eqlines\_math +\_long\_def\_eqalign#1{\_null\_thinsk\_vcenter{\_the\_eqlines\_math \_ialign{&\_hfil$\_the\_eqstyle{##}$&$\_the\_eqstyle{{}##}$\_hfil &\_hskip.5\_eqspace\_hfil$\_the\_eqstyle{##}$\_hskip.5\_eqspace\_hfil \_crcr#1\_crcr}}\_thinsk} +\_public \eqalign ; + \_doc ----------------------------- - \`\openup`, \`\displaylines` and \`\eqalignno` macros are copied from + The \`\displaylines``{<formula>\cr<formula>\cr...<formula>}` + creates horizontally centered formulae. + It behaves exactly as in Plain \TeX/. The `\halign` is applied directly + in the outer display environment with lines of type `\hbox to\displaywidth`. + This enables to break lines inside such display to more pages but it is + impossible to use `\eqno` or `\leqno` or \^`\eqmark`. + + \OpTeX/ offers + `\dislaylines to<dimen>{<formula>\cr<formula>\cr...<formula>}` + as an alternative case of usage `\displaylines`. See section 4.3 in the + \ulink[http://petr.olsak.net/ftp/olsak/optex/optex-math.pdf] + {Typesetting Math with \OpTeX/}. + The centered formulas are in `\vcenter` in this case, + so lines cannot be broken to more pages, but this case + enables to use `\eqno` or `\leqno` or \^`\eqmark`. + \_cod ----------------------------- + +\_def\_displaylines #1#{\_ifx&\_ea\_displaylinesD + \_else \_def\_tmp to##1\_end{\_def\_tmp{\_dimexpr ##1}}\_tmp #1\_end + \_ea\_displaylinesto \_fi} +\_long\_def\_displaylinesD #1{\_display \_tabskip=\_zoskip + \_halign{\_hbox to\_displaywidth{$\_elign\_hfil\_displaystyle##\_hfil$}\_crcr + #1\_crcr}} +\_long\_def\_displaylinesto #1{\_vcenter{\_openup\_jot \_math \_tabskip=\_zoskip + \_halign{\_strut\_hbox to\_span\_tmp{$\_hss\_displaystyle##\_hss$}\_crcr + #1\_crcr}}} + +\_public\displaylines ; + + \_doc ----------------------------- + \`\openup`, \`\eqalignno` and `\leqalignno` macros are copied from Plain \TeX/ unchanged. \_cod ----------------------------- @@ -683,20 +708,17 @@ \_vskip-\_lineskiplimit \_vskip\_normallineskiplimit \_fi \_else \_penalty\_interdisplaylinepenalty \_fi}}} \_def\_elign{\_tabskip=\_zoskip\_everycr{}} % restore inside \_display -\_def\_displaylines#1{\_display \_tabskip=\_zoskip - \_halign{\_hbox to\_displaywidth{$\_elign\_hfil\_displaystyle##\_hfil$}\_crcr - #1\_crcr}} -\_def\_eqalignno#1{\_display \_tabskip=\_centering +\_long\_def\_eqalignno#1{\_display \_tabskip=\_centering \_halign to\_displaywidth{\_hfil$\_elign\_displaystyle{##}$\_tabskip=\_zoskip &$\_elign\_displaystyle{{}##}$\_hfil\_tabskip\_centering &\_llap{$\_elign##$}\_tabskip\_zoskip\_crcr #1\_crcr}} -\_def\_leqalignno#1{\_display \_tabskip=\_centering +\_long\_def\_leqalignno#1{\_display \_tabskip=\_centering \_halign to\_displaywidth{\_hfil$\_elign\_displaystyle{##}$\_tabskip=\_zoskip &$\_elign\_displaystyle{{}##}$\_hfil\_tabskip=\_centering &\_kern-\_displaywidth\_rlap{$\_elign##$}\_tabskip\_displaywidth\_crcr #1\_crcr}} -\_public \openup \eqalign \displaylines \eqalignno ; +\_public \openup \eqalignno \leqalignno ; \_doc ----------------------------- These macros are inspired from `ams-math.tex` file. @@ -941,7 +963,7 @@ \_let\circleddot\odot \_doc ----------------------------- - The \`\not` macro is re-defined to be smarter than in plain + The \^`\not` macro is re-defined to be smarter than in plain \TeX/. The macro follows this rule: \begtt \not< becomes \_nless @@ -979,7 +1001,7 @@ * \`\currstyle` which expands to `\displaystyle`, `\textstyle`, `\scriptstyle` or `\scriptscriptstyle` depending on the current math style when \^`\mathstyles` was opened. - * `\dobystyle{<D>}{<T>}{<S>}{<SS>}` is expandable macro. It expands to + * \`\dobystyle``{<D>}{<T>}{<S>}{<SS>}` is expandable macro. It expands to `<D>`, `<T>`, `<S>` or `<SS>` depending on the current math style when \^`\mathstyles` was opened. * The value of the \`\stylenum` is 0, 1, 2 or 3 @@ -1010,6 +1032,12 @@ \_endcode %--------------------------------------------------- +2020-06-14 \borermatrix, \cases corrected +2020-06-13 \adots introduced, \matrix smaller in T mode too. +2020-06-03 \notin corrected +2020-06-02 $$\par$$ error is supressed, so we define \(l)eqalign(no), \displayines as \long +2020-05-30 \cases: group added in the second column. + "\displaylines to<size>" implemented and documented. 2020-05-11 \let\|=\Vert, bug fixed 2020-04-27 \mathstyles introduced 2020-03-14 implemented diff --git a/macros/luatex/optex/base/math-unicode.opm b/macros/luatex/optex/base/math-unicode.opm index f35b8652e0..03222fdad0 100644 --- a/macros/luatex/optex/base/math-unicode.opm +++ b/macros/luatex/optex/base/math-unicode.opm @@ -1,6 +1,6 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \loadmath {Unicode Math fonts <2020-02-25>} % preloaded in format +\_codedecl \loadmath {Unicode Math fonts <2020-06-06>} % preloaded in format \_doc ----------------------------- \`\loadmath` `{<Unicode-math font>}` loads given font. It does: @@ -81,6 +81,8 @@ \_delimitershortfall=0.5\_fontdimen6\_textfont3 \_nulldelimiterspace=0.12\_fontdimen6\_textfont3 \_scriptspace=0.05\_fontdimen6\_textfont3 + {\_everymath{}\_global\_setbox0=\_hbox{$\_displaystyle{0\_atop0}$}}% correction for \choose + \_Umathfractiondelsize\_displaystyle = \_dimexpr(\_ht0-\_Umathaxis\_displaystyle)*2\_relax } \_doc ----------------------------- @@ -116,7 +118,7 @@ different parts of Unicode table. We need auxiliary macros for setting mathcodes by selected math alphabet. \nl - \`\_umathrange` `{<from->-<to>}\<first>` sets `\Umathcode`s + \`\_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 @@ -153,21 +155,17 @@ [120122]{"2102}[120127]{"210D}[120133]{"2115}[120135]{"2119} [120136]{"211A}[120137]{"211D}[120145]{"2124}% } -\_def\_umathrange#1#2{\_umathnumB=#2\_relax \_umathrangeA#1} +\_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 = 7 1 \_umathcorr\_umathvalue{\_umathnumB} + \_Umathcode \_umathnumA = \_tmp \_umathcorr\_umathvalue{\_umathnumB} \_ifnum\_umathnumA<`#2\_relax \_advance\_umathnumA by1 \_advance\_umathnumB by1 \_repeat } -\_def\_umathrangeGREEK{\_begingroup - \_lccode`A="0391 \_lccode`Z="03A9 - \_lowercase{\_endgroup \_umathrange{A-Z}}} -\_def\_umathrangegreek{\_begingroup - \_lccode`A="03B1 \_lccode`Z="03D6 - \_lowercase{\_endgroup \_umathrange{A-Z}}} +\_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 @@ -228,9 +226,13 @@ the section~\ref[math-macros]. \printdoc unimath-codes.opm \printdoctail unimath-codes.opm +\secc Printing all Unicode math slots in used math font +\printdoctail print-unimath.opm +\printdoc print-unimath.opm \_endinput +2020-06-07 \Umathfractiondelsize (for \choose brackets) corrected, see https://tug.org/pipermail/luatex/2020-June/007365.html 2020-04-15 \_setmathdimens -> \_setuniathdimens 2020-02-25 implemented diff --git a/macros/luatex/optex/base/more-macros.opm b/macros/luatex/optex/base/more-macros.opm index 51f1919870..595a4f2ed3 100644 --- a/macros/luatex/optex/base/more-macros.opm +++ b/macros/luatex/optex/base/more-macros.opm @@ -1,6 +1,6 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \eoldef {OpTeX useful macos <2020-05-03>} % preloaded in format +\_codedecl \eoldef {OpTeX useful macos <2020-05-22>} % preloaded in format \_doc ----------------------------- We define \`\opinput` `{<file name>}` macro which @@ -147,6 +147,30 @@ \_public \eoldef \skiptoeol \bracedparam ; \_doc ----------------------------- + \`\scantoeol``\macro <text to end of line>` scans the + `<text to end of line>` in verbatim mode and runs the + `\macro{<text to end of line>}`. The `\macro` + can be defined `\def\macro#1{...\scantextokens{#1}...}`. + The new tokenization of the parameter is processed when the parameter is used, + no when the parameter is scanned. This principle is used in definition + of \^`\chap`, \^`\sec`, \^`\secc` and \^`\_Xtoc` macros. + It means that user can write \code{\\sec text `&` text} for example. + Inline verbatim works in title sections. + + The verbatim scanner of `\scatoeol` keeps category 7 for `^` in + order to be able to use `^^J` as comment chracter which means that + the next line continues. + \_cod ----------------------------- + +\_def\_scantoeol#1{\def\_tmp{#1}\_begingroup \_setscancatcodes \_scantoeolA} +\_def\_setscancatcodes{\_setverb \_catcode`\^^M=12\_catcode`\^=7\_catcode`\ =10\_catcode`\^^J=14 } +\_catcode`\^^M=12 % +\_def\_scantoeolA#1^^M{\_endgroup \_tmp{#1}}% +\_normalcatcodes % + +\_public \scantoeol ; + + \_doc ----------------------------- The \`\replstring``\macro{<textA>}{<textB>}` replaces all occurrences of `<textA>` by `<textB>` in the `\macro` body. The `\macro` must be defined without parameters. The occurrences of @@ -176,7 +200,8 @@ If you really need primitive `\catcode` then you can use `\_catcode`. \_cod ----------------------------- -\_def\catcode{\_catcode\_string} % more robust in cases \catcode` or \catcode" +\_def\catcode#1{\_catcode \_if`\_noexpand#1\_ea`\_else\_if"\_noexpand#1"\_else + \_if'\_noexpand#1'\_else \_ea\_ea\_ea\_ea\_ea\_ea\_ea#1\_fi\_fi\_fi} \_doc ----------------------------- The \`\removespaces` `<text with spaces >{}` expands to <textwithoutspaces>. @@ -237,5 +262,6 @@ \_endcode % ------------------------------------- +2020-05-22 robust \catcode newly defined in order \catcode\string.... be possible 2020-05-03 \load macro introduced 2020-03-15 released diff --git a/macros/luatex/optex/base/multicolumns.opm b/macros/luatex/optex/base/multicolumns.opm index c593f72552..2305aacf5a 100644 --- a/macros/luatex/optex/base/multicolumns.opm +++ b/macros/luatex/optex/base/multicolumns.opm @@ -26,7 +26,7 @@ \_newcount\_mullines \_def\_begmulti #1 {\_par\_bgroup\_wipeepar\_multiskip\_penalty0 \_def\_Ncols{#1} - \_setbox6=\_vbox\_bgroup\_penalty0 + \_setbox6=\_vbox\_bgroup \_let\_setxhsize=\_relax \_penalty0 %% \hsize := column width = (\hsize+\colsep) / n - \colsep \_advance\_hsize by\_colsep \_divide\_hsize by\_Ncols \_advance\_hsize by-\_colsep diff --git a/macros/luatex/optex/base/optex.ini b/macros/luatex/optex/base/optex.ini index 27649370ef..dce5d1aaff 100644 --- a/macros/luatex/optex/base/optex.ini +++ b/macros/luatex/optex/base/optex.ini @@ -21,7 +21,7 @@ % OpTeX version -\def\optexversion{Beta 0.13 May 2020} +\def\optexversion{Beta 0.14 Jun 2020} \def\fmtname{OpTeX} % Engine testing: diff --git a/macros/luatex/optex/base/others.opm b/macros/luatex/optex/base/others.opm index f4bcc78698..225e54c37a 100644 --- a/macros/luatex/optex/base/others.opm +++ b/macros/luatex/optex/base/others.opm @@ -1,6 +1,6 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \uv {Miscenaleous <2020-04-02>} % preloaded in format +\_codedecl \uv {Miscenaleous <2020-05-22>} % preloaded in format \_doc ---------------------------- \`\useOpTeX` and \`\useoptex` are declared as `\relax`. @@ -73,8 +73,13 @@ \_doc ---------------------------- Lorem ipsum can be printed by \`\lipsum``[<range>]` or \`\lorem``[<range>]`, - for example `\lipsum[3]` or `\lipsum[112-121]`, max=150. The data are read - from \LaTeX/ file `lipsum.ltd.tex`. + for example `\lipsum[3]` or `\lipsum[112-121]`, max=150. + + First usage of `\lipsum` reads the \LaTeX/ file `lipsum.ltd.tex` + and prints the selected paragraph(s). Next usages of `\lipsum` + prints the selected paragraph(s) from memory. This second and more + usages of `\lipsum` are fully expandable. If you want to have all + printings of `\lipsum` expandable, use dummy `\lipsum[0]` first. \_cod ---------------------------- \_def \_lipsum {% @@ -87,12 +92,13 @@ } \_def\_negativermnm{\_romannumeral-`\.} \_def\_reallipsum[#1]{\_lipsumA #1\_empty-\_empty\_end} -\_def\_lipsumA #1-#2\_empty#3\_end{\_tmpnum=#1 \_edef\_tmp{\_ifx^#2^#1\_else#2\_fi}% - \_loop \_csname lips:\_the\_tmpnum\_endcsname \par % \par is better here - \_ifnum\_tmpnum<\_tmp \_advance\_tmpnum by1 \_repeat -} +\_def\_lipsumA #1-#2\_empty#3\_end{% + \_fornum #1..\_ifx^#2^#1\_else#2\_fi \_do {\_csname lips:##1\_endcsname \par}} + \def\lipsum {\_lipsum} \def\lorem {\_lipsum} \_endcode +2020-05-22 \lipsum uses \fornum (expandable after first usage) +2020-04-02 released
\ No newline at end of file diff --git a/macros/luatex/optex/base/outlines.opm b/macros/luatex/optex/base/outlines.opm index 0d041c743c..2f9a040881 100644 --- a/macros/luatex/optex/base/outlines.opm +++ b/macros/luatex/optex/base/outlines.opm @@ -5,6 +5,7 @@ \_def\_outlines#1{\_pdfcatalog{/PageMode/UseOutlines}\_openref \_ifx\_toclist\_empty \_opwarning{\_noexpand\outlines -- data unavailable. TeX me again}% + \_incr\_unresolvedrefs \_else \_ifx\_dest\_destactive \_else \_opwarning{\_noexpand\outlines doesn't work when \_noexpand\hyperlinks isn't declared}\_fi diff --git a/macros/luatex/optex/base/output.opm b/macros/luatex/optex/base/output.opm index 41948896e7..c113eae103 100644 --- a/macros/luatex/optex/base/output.opm +++ b/macros/luatex/optex/base/output.opm @@ -25,7 +25,7 @@ \_def \_begoutput{\_incr\_gpageno \_immediate\_wref\_Xpage{{\_the\_gpageno}{\_folio}}% - \_prepoffsets \_the\_regmark} % + \_setxhsize \_prepoffsets \_the\_regmark} \_def \_endoutput{\_advancepageno {\_globaldefs=1 \_the\_nextpages \_nextpages={}}% \_ifnum\_outputpenalty>-20000 \_else\_dosupereject\_fi @@ -33,6 +33,20 @@ \_def \_prepoffsets {} \_doc ----------------------------- + The `\hsize` value can be changed at various places in the document but + we need to have constant value \`\_xhsize` in output routine + (for headlines and footlines, for instance). This value is set + from current value of `\hsize` when \`\_setxhsize` macro is called. + This macro destroys itself, so the value is set only once. Typicaly it is + done when first \^`\_optexoutput` routine is called (see \^`\_begoutput`). + Or it is called at begining of the \^`\begtt`...`\endtt` environment before + `\hsize` value is eventually changed by user in this environment. + \_cod ----------------------------- + +\_newdimen \_xhsize +\_def\_setxhsize {\_global\_xhsize=\_hsize \_global\_let\_setxhsize=\_relax} + + \_doc ----------------------------- \`\gpageno` counts pages from one in whole document \_cod ----------------------------- @@ -71,7 +85,7 @@ \_def\_makeheadline {\_istoksempty \_headline \_iffalse \_vbox to0pt{\_vss \_baselineskip=\_headlinedist \_lineskiplimit=-\_maxdimen - \_line{\_the\_headline}\_hbox{}}\_nointerlineskip + \_hbox to\_xhsize{\_the\_headline}\_hbox{}}\_nointerlineskip \_fi } @@ -81,7 +95,7 @@ \_def\_makefootline{\_istoksempty \_footline \_iffalse \_baselineskip=\_footlinedist - \_lineskiplimit=-\_maxdimen \_line{\_the\_footline} + \_lineskiplimit=-\_maxdimen \_hbox to\_xhsize{\_the\_footline} \_fi } @@ -201,7 +215,7 @@ } \_def \_draftbox #1{\_setbox0=\_hbox{#1}% \_kern.5\_vsize \_kern4.5\_wd0 - \_hbox to0pt{\_kern.5\_hsize \_kern-1\_wd0 + \_hbox to0pt{\_kern.5\_xhsize \_kern-1\_wd0 \_pdfsave \_pdfrotate{55}\_pdfscale{10}{10}% \_hbox to0pt{\_localcolor\LightGrey \_box0\_hss}% \_pdfrestore diff --git a/macros/luatex/optex/base/parameters.opm b/macros/luatex/optex/base/parameters.opm index bd12bac070..f9fc3ee150 100644 --- a/macros/luatex/optex/base/parameters.opm +++ b/macros/luatex/optex/base/parameters.opm @@ -149,7 +149,7 @@ \_public \plaintexsetting ; \_doc ----------------------------- - \secc \OpTeX/ parameters + \secc[oparams] \OpTeX/ parameters The main principle how to configure \OpTeX/ is not to use only parameters. A designer can copy macros from \OpTeX/ and re-define them as required. @@ -361,20 +361,12 @@ The \`\mnotesize` is horizontal size of the marginal notes. \nl The \`\mnoteindent` is horizontal space between body-text and marginal note. - \nl - The \`\mnoteskip` is a dimen which denotes the vertical shift of marginal - note from its normal position. Positive value means shift up, negative - down. The `\mnoteskip` register is set to zero - after the marginal note is printed. - Use it as an exception of marginal note position if the marginal - notes overlaps or they are put at bottom of the page. \_cod ----------------------------- \_newtoks\_everymnote \_newdimen\_mnotesize \_mnotesize=20mm % the width of the mnote paragraph \_newdimen\_mnoteindent \_mnoteindent=10pt % ditance between mnote and text -\_newdimen\_mnoteskip -\_public \everymnote \mnotesize \mnoteindent \mnoteskip ; +\_public \everymnote \mnotesize \mnoteindent ; \_doc ----------------------------- The `\table` parameters follows. The \`\thistable` tokens list @@ -423,7 +415,7 @@ \_tabskipl=0pt\_relax % \tabskip used before first column \_tabskipr=0pt\_relax % \tabskip used after the last column \_public \everytable \thistable \tabiteml \tabitemr \tabstrut \tablinespace - \vvkern \hhkern \tsize \tabskiplr ; + \vvkern \hhkern \tsize \tabskipl \tabskipr ; \_doc ----------------------------- The \^`\eqalign` macro can be configured by \`\eqlines` and \`\eqstyle` @@ -438,6 +430,14 @@ \_public \eqlines \eqstyle \eqspace ; \_doc ----------------------------- + \`\lmfil` is \"left matrix filler" (for `\matrix` columns). The default + value does centering because right matrix filler is directly set to `\hfil`. + \_cod ----------------------------- + +\_newtoks \_lmfil \_lmfil={\_hfil} +\_public \lmfil ; + + \_doc ----------------------------- The output routine uses token list \`\headline` and \`\footline` in the same sense as in plain \TeX/. If they are non-empty then `\hfil` or `\hss` must be here because they are used inside `\hbox to\hsize`. diff --git a/macros/luatex/optex/base/pdfuni-string.opm b/macros/luatex/optex/base/pdfuni-string.opm index d7566eb91d..a289aae731 100644 --- a/macros/luatex/optex/base/pdfuni-string.opm +++ b/macros/luatex/optex/base/pdfuni-string.opm @@ -2,6 +2,11 @@ \_codedecl \pdfunidef {PDFunicode strings for outlines <2020-03-12>} % preloaded in format + \_doc ----------------------------- + The \`\_octalprint` is lua script which prints the character code in the + octal notation. + \_cod ----------------------------- + \_edef\_octalprint#1#2{\_noexpand\_directlua{% #1=character-code #2=character if ('#2'>='A' and '#2'<='Z') or ('#2'>='a' and '#2'<='z') then tex.print(string.format('000\_pcent s',"#2")) @@ -10,17 +15,34 @@ tex.print(string.format('\_pcent 03o\_nbb\_pcent03o',(#1-num)/256,num)) end }} + + \_doc ----------------------------- + \`\pdfunidef``\macro{<text>}` does more things than only converting to octal notation. + The <text> can be scanned in verbatim mode (it is true becuase \^`\_Xtoc` + reads the <text> in verbatim mode). First `\edef` do + `\_scantextokens\unexpanded` and second `\edef` expands the parameter + according to current values on selected macros from `\_regoul`. Then + \`\_removeoutmath` converts `..$x^2$..` to `..x^2..`, i.e removes dollars. + Then \`\_removeoutbraces` converts `..{x}..` to `..x..`. + Finaly, the <text> is detokenized, spaces are preprocessed using \^`\replstring` + and then the \`\_pdfunidefB` is repeated on each character. It calls the + `\directlua` chunk to print octal numbers in the macro \^`\_octalprint`. + \_cod ----------------------------- + \_def\_pdfunidef#1#2{% \_begingroup - \_catcode`\\=12 \_let\\=\_bslash \_the\_regoul \_relax % \_regmacro alternatives of logos etc. + \_ifx\_savedttchar\_undefined \_def#1{\_scantextokens{\_unexpanded{#2}}}% + \_else \_lccode`\;=\_savedttchar \_lowercase{\_prepinverb#1;}{#2}\fi + \_edef#1{#1}% \_escapechar=-1 - \_edef#1{#2\_empty}% + \_edef#1{#1\_empty}% \_escapechar=`\\ \_ea\_edef \_ea#1\_ea{\_ea\_removeoutmath #1$\_end$}% $x$ -> x \_ea\_edef \_ea#1\_ea{\_ea\_removeoutbraces #1{\_end}}% {x} -> x \_edef#1{\_detokenize\_ea{#1}}% \_replstring#1{ }{{ }}% text text -> text{ }text + \_catcode`\\=12 \_let\\=\_bslash \_edef\_out{\\376\\377}% \_ea\_pdfunidefB#1^% text -> \_out in octal \_ea @@ -39,6 +61,28 @@ \_def\_removeoutbracesA #1{\_ifx\_end#1\_else #1\_ea\_removeoutbraces\_fi} \_def\_removeoutmath #1$#2${#1\_ifx\_end#2\_else #2\_ea\_removeoutmath\_fi} + \_doc ----------------------------- + The \`\_prepinverb``<macro><separator>{<text>}`, + e.g.\ `\_prepinverb\tmpb|{aaa |bbb| cccc |dd| ee}` + does `\def\tmpb{<su>{aaa }bbb<su>{ cccc }dd<su>{ ee}}` where + <su> is `\scantextokens\unexpanded`. It means that in-line verbatim + are not argument of `\scantextoken`. First `\edef\tmpb` tokenizes again + the <text> but not the parts which were in the the in-line verbatim. + \_cod ----------------------------- + +\_def\_prepinverb#1#2#3{\_def#1{}% + \_def\_dotmpb ##1#2##2{\_addto#1{\_scantextokens{\_unexpanded{##1}}}% + \_ifx\_end##2\_else\_ea\_dotmpbA\_ea##2\_fi}% + \_def\_dotmpbA ##1#2{\_addto#1{##1}\_dotmpb}% + \_dotmpb#3#2\_end +} + + \_doc ----------------------------- + The \^`\regmacro` is used in order to sed the values of macros + `\em`, `\rm`, `\bf`, `\it`, `\bi`, `\tt`, `\/` and `~` to values usable in + PDF outlines. + \_cod ----------------------------- + \_regmacro {}{}{\_let\em=\_empty \_let\rm=\_empty \_let\bf=\_empty \_let\it=\_empty \_let\bi=\_empty \_let\tt=\_empty \_let\/=\_empty \_let~=\_space @@ -65,14 +109,4 @@ bytes FEFF. Moreover, each byte is encoded by three octal digits preceded by backslash. The only exception is the visible ASCII character encoding: such a character is encoded by its real byte preceded by `\000`. -The command \`\pdfunidef``\macro{string}` is implemented here -using `\directlua`. -The input string is preprocessed: detokenized, converted `\word /` to -`\word/` (used in logos) preprocessed spaces using \^`\replstring` and then the -\`\_pdfunidefB` is repeated on each character. It calls the `\directlua` chunk -to print octal numbers in the macro `\_octalprint`. - -The \^`\regmacro` is used in order to sed the values of macros -`\em`, `\rm`, `\bf`, `\it`, `\bi`, `\tt`, `\/` and `~` to values usable in -PDF outlines. diff --git a/macros/luatex/optex/base/plain-macros.opm b/macros/luatex/optex/base/plain-macros.opm index f5c16ba3bd..d3a158008e 100644 --- a/macros/luatex/optex/base/plain-macros.opm +++ b/macros/luatex/optex/base/plain-macros.opm @@ -332,7 +332,7 @@ \_def \_showhyphens #1{\_setbox0=\_vbox{\_parfillskip=0pt \_hsize=\_maxdimen \_tenrm \_pretolerance=-1 \tolerance=-1 \hbadness=0 \showboxdepth=0 \ #1}} -\_def \_bye {\_par \_vfill \_supereject \_end} +\_def \_bye {\_par \_vfill \_supereject \_byehook \_end} \_public \bye ; \_endcode % ------------------------------------- diff --git a/macros/luatex/optex/base/print-unimath.opm b/macros/luatex/optex/base/print-unimath.opm new file mode 100644 index 0000000000..a1a3ceb106 --- /dev/null +++ b/macros/luatex/optex/base/print-unimath.opm @@ -0,0 +1,56 @@ +%% This is part of OpTeX project, see http://petr.olsak.net/optex + +\_codedecl \_undefined {Printing Unicode-math table \string<2020-06-08>} + +\_begingroup + \_def\UnicodeMathSymbol#1#2#3#4{% + \_ifnum#1>"10000 \_endinput \_else \_printmathsymbol{#1}{#2}{#3}{#4}\_fi + } + \_def\UnicodeMathSymbolA#1#2#3#4{% + \_ifnum#1>"10000 \_printmathsymbol{#1}{#2}{#3}{#4}\_fi + } + \_def\_printmathsymbol#1#2#3#4{% + \_hbox{\_hbox to2em{$#2{}$\_hss}\_hbox to3em + {\small\_printop#3\_hss}{\_tt\_string#2\_trycs{_eq:\_string#2}{}}} + } + \_def\_eq#1#2{\_sdef{_eq:\_string#2}{=\_string#1}} + \_eq \diamond\smwhtdiamond \_eq \bullet\smblkcircle \_eq \circ\vysmwhtcircle + \_eq \bigcirc\mdlgwhtcircle \_eq \to\rightarrow \_eq \le\leq + \_eq \ge\geq \_eq \neq\ne \_eq \emptyset\varnothing \_eq \hbar\hslash + \_eq \land\wedge \_eq \lor\vee \_eq \owns\ni \_eq \gets\leftarrow + \_eq \mathring\ocirc \_eq \lnot\neg \_eq \backepsilon\upbackepsilon + \_eq \eth\matheth \_eq \dbkarow\dbkarrow \_eq \drbkarow\drbkarrow + \_eq \hksearow\hksearrow \_eq \hkswarow\hkswarrow + + \_tracinglostchars=0 + \_fontdef\small{\_setfontsize{at5pt}\_rm} + \_def\_printop{\_def\mathop{Op}} + \_def\mathalpha{Alph}\_def\mathord{Ord}\_def\mathbin{Bin}\_def\mathrel{Rel} + \_def\mathopen{Open}\_def\mathclose{Close}\_def\mathpunct{Punct}\_def\mathfence{Fence} + \_def\mathaccent{Acc}\_def\mathaccentwide{Accw}\_def\mathbotaccentwide{AccBw} + \_def\mathbotaccent{AccB}\_def\mathaccentoverlay{AccO} + \_def\mathover{Over}\_def\mathunder{Under} + \_typosize[7.5/9]\_normalmath \_everymath={} + + Codes U+00000 \_dots\ U+10000 + \_begmulti 3 + \_input unimath-table.opm + \_endmulti + + \_medskip\_goodbreak + Codes U+10001 \_dots\ U+1EEF1 \_let\UnicodeMathSymbol=\UnicodeMathSymbolA + \_begmulti 4 + \_input unimath-table.opm + \_endmulti +\_endgroup + +\_endcode + +This file can be used for testing your Unicode Math font +and/or for printing \TeX/ sequences which can be used in math. + +Load Unicode math font first (for example by `\fontfam[termes]` or by +`\loadmath{<math-font>}`) and then you +can do `\input print-unimath.opm`. The big table with all math symbols is printed. + +\_endinput diff --git a/macros/luatex/optex/base/ref-file.opm b/macros/luatex/optex/base/ref-file.opm index 3cf6f6be7d..c5fa396524 100644 --- a/macros/luatex/optex/base/ref-file.opm +++ b/macros/luatex/optex/base/ref-file.opm @@ -65,7 +65,7 @@ versa. \_cod ---------------------- -\_def\_REFversion{3} % actual version of .ref files in OpTeX +\_def\_REFversion{4} % actual version of .ref files in OpTeX \_def\_Xrefversion#1{\_ifnum #1=\_REFversion\_relax \_else \_endinput \_fi} \_public \Xrefversion ; % we want to ignore .ref files generated by OPmac @@ -107,7 +107,7 @@ The `.ref` file looks like: \begtt \catcode`\<=13 \Xrefversion{<ref-version>} \_Xpage{<gpageno>}{<pageno>} -\_Xtoc{<level>}{<type>}{<text>}{<title>} +\_Xtoc{<level>}{<type>}{<text>}<title> \_Xlabel{<label>}{<text>} \_Xlabel{<label>}{<text>} ... @@ -118,12 +118,12 @@ The `.ref` file looks like: % where <gpageno> is internal page number globally numbered from one and `<pageno>` is a page number (`\the\pageno`) used in pagination (they may be differ). -Each page begins with `\_Xpage`. +Each page begins with \^`\_Xpage`. The `<label>` is a label used by user in `\label[<label>]` and `<text>` is a text which should be referenced (the number of section or table, for example `2.3.14`). The `<title>` is a title of the chapter (`<level>`=1, `<type>`=`chap`), section (`<level>`=2, `<type>`=`sec`), subsection -(`<level>`=3, `<type>`=`secc`). The `\_Xpage` is written at begining of each +(`<level>`=3, `<type>`=`secc`). The \^`\_Xpage` is written at begining of each page, the `\_Xtoc` is written when chapter or section or subsection title exists on the page and `\_Xlabel` when labeled object prefixed by `\label[<label>]` exists on the page. diff --git a/macros/luatex/optex/base/references.opm b/macros/luatex/optex/base/references.opm index 5aaf36a87a..e00a0a2fda 100644 --- a/macros/luatex/optex/base/references.opm +++ b/macros/luatex/optex/base/references.opm @@ -10,6 +10,13 @@ \_def\_Xpage#1#2{\_def\_currpage{{#1}{#2}}\_lfnotenum=0 } \_doc ---------------------------- + Counter for number of unresolved references \`\_unresolvedrefs`. + \_cod ---------------------------- + +\_newcount\_unresolvedrefs +\_unresolvedrefs=0 + + \_doc ---------------------------- \`\_Xlabel` `{<label>}{<text>}` saves the <text> to `\_lab:<label>` and saves `[pg:<gpageno>]{<pageno>}` to `\_pgref:<label>`. \_cod ---------------------------- @@ -53,12 +60,14 @@ \_def\_ref[#1]{\_isdefined{_lab:#1}% \_iftrue \_ilink[ref:#1]{\_csname _lab:#1\_endcsname}% - \_else ??\_opwarning{label [#1] unknown. Try to TeX me again}\_openref + \_else ??\_opwarning{label [#1] unknown. Try to TeX me again}% + \_incr\_unresolvedrefs \_openref \_fi } \_def\_pgref[#1]{\_isdefined{_pgref:#1}% \_iftrue \_ea\_ea\_ea\_ilink \_csname _pgref:#1\_endcsname - \_else ??\_opwarning{pg-label [#1] unknown. Try to TeX me again}\_openref + \_else ??\_opwarning{pg-label [#1] unknown. Try to TeX me again}% + \_incr\_unresolvedrefs \_openref \_fi } \_public \ref \pgref ; diff --git a/macros/luatex/optex/base/sections.opm b/macros/luatex/optex/base/sections.opm index ee02064b9e..d4cda17b83 100644 --- a/macros/luatex/optex/base/sections.opm +++ b/macros/luatex/optex/base/sections.opm @@ -16,16 +16,19 @@ \_def \_seccfont {\_scalemain\_typoscale[\_magstep1/\_magstep1]\_boldify} \_doc --------------------------- - The \`\tit` macro is defined by `\eoldef`, it means that the parameter is - separated by end of line. The macros `\chap`, `\sec` and `\secc` use - `\eoldef` too. + The \`\tit` macro is defined using \^`\scantoeol` and \`\_printtit`. + It means that the parameter is + separated by end of line and inline verbatim is allowed. The same + principle is used in the \^`\chap`, \^`\sec` and \^`\secc` macros. \_cod --------------------------- -\_eoldef\_tit #1{\_vglue\_titskip +\_def\_printtit #1{\_vglue\_titskip {\_leftskip=0pt plus1fill \_rightskip=\_leftskip % centering - \_titfont \_noindent #1\_par}% + \_titfont \_noindent \_scantextokens{#1}\_par}% \_nobreak\_bigskip } +\_def\_tit{\_scantoeol\_printtit} + \_public \tit ; \_doc --------------------------- @@ -165,32 +168,35 @@ The \`\chap`, \`\sec` and \`\secc` macros are implemented here. The \`\_inchap`, \`\_insec` and \`\_insecc` macros does the real work, 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. \_cod ---------------------------- -\_optdef\_chap[]{\_trylabel \_inchap} -\_optdef\_sec []{\_trylabel \_insec} -\_optdef\_secc[]{\_trylabel \_insecc} +\_optdef\_chap[]{\_trylabel \_scantoeol\_inchap} +\_optdef\_sec []{\_trylabel \_scantoeol\_insec} +\_optdef\_secc[]{\_trylabel \_scantoeol\_insecc} \_def\_trylabel{\_istoksempty\_opt\_iffalse \_label[\_the\_opt]\_fi} -\_eoldef\_inchap #1{\_par \_sectionlevel=1 +\_def\_inchap #1{\_par \_sectionlevel=1 \_def \_savedtitle {#1}% saved to .ref file \_ifnonum \_else {\_globaldefs=1 \_incr\_chapnum \_chapx}\_fi \_edef \_therefnum {\_ifnonum \_space \_else \_thechapnum \_fi}% - \_printchap{#1}% + \_printchap{\_scantextokens{#1}}% \_resetnonumnotoc } -\_eoldef\_insec #1{\_par \_sectionlevel=2 +\_def\_insec #1{\_par \_sectionlevel=2 \_def \_savedtitle {#1}% saved to .ref file \_ifnonum \_else {\_globaldefs=1 \_incr\_secnum \_secx}\_fi \_edef \_therefnum {\_ifnonum \_space \_else \_thesecnum \_fi}% - \_printsec{#1}% + \_printsec{\_scantextokens{#1}}% \_resetnonumnotoc } -\_eoldef\_insecc #1{\_par \_sectionlevel=3 +\_def\_insecc #1{\_par \_sectionlevel=3 \_def \_savedtitle {#1}% saved to .ref file \_ifnonum \_else {\_globaldefs=1 \_incr\_seccnum \_seccx}\_fi \_edef \_therefnum {\_ifnonum \_space \_else \_theseccnum \_fi}% - \_printsecc{#1}% + \_printsecc{\_scantextokens{#1}}% \_resetnonumnotoc } \_public \chap \sec \secc ; @@ -215,7 +221,7 @@ \_fi } \_def \_wtotoc #1#2#3#4{\_edef\_tmp{{#1}{#2}{#3}{#4}}\_ea\_wtotocA\_tmp} -\_def \_wtotocA #1#2#3#4{\_wref\_Xtoc{{#1}{#2}{#3}{#4}}} +\_def \_wtotocA #1#2#3#4{\_wref\_Xtoc{{#1}{#2}{#3}#4}} \_doc ----------------------------- The \`\_abovetitle``{<penaltyA>}{<skipA>}` and \`\_belowtitle``{<skipB>}` pair diff --git a/macros/luatex/optex/base/slides.opm b/macros/luatex/optex/base/slides.opm index e25cc5ee7a..835bfa72a9 100644 --- a/macros/luatex/optex/base/slides.opm +++ b/macros/luatex/optex/base/slides.opm @@ -140,7 +140,7 @@ \_sdef{_spg:;}{\_closepage \_global\_slidelayer=1 \_resetpage \_openslide} \_sdef{_spg:.}{\_closepage \_end} \_sdef{_spg:+}{\_closepage \_incr\_slidelayer \_decr\_pageno \_openslide} - \_def\bye {\_closepage \_end} + \_def\bye {\_closepage \_byehook \_end} \_let\_layers=\_layersactive \_def\_destbox[##1:##2]{\_isequal{##1}{ref}\_iffalse \_destboxori[##1:##2]\_fi}% } diff --git a/macros/luatex/optex/base/table.opm b/macros/luatex/optex/base/table.opm index 4aaaa9a442..43f294eb4c 100644 --- a/macros/luatex/optex/base/table.opm +++ b/macros/luatex/optex/base/table.opm @@ -1,6 +1,6 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \table {Basic macros for OpTeX <2020-05-20>} % preloaded in format +\_codedecl \table {Basic macros for OpTeX <2020-05-26>} % preloaded in format \_doc ----------------------------- The result of the \`\table``{<declaration>}{<data>}` macro is inserted into @@ -57,7 +57,7 @@ \_doc ----------------------------- The \`\_tableB``{<data>}` saves `<data>` to `\_tmpb` - and does four \^`\replstring`s to prefix each macro \^`\crli` (etc.) + and does four \^`\replstring`s to prefix each macro \^`\crl` (etc.) by `\_crcr`. The reason is: we want to use macros which scan its parameter to the delimeiter written in right part of table item declaration. See \^`\fS` for example. The `\crcr` cannot be hidden in other macro in such case. @@ -92,8 +92,9 @@ \_cod ----------------------------- \_def\_tableB#1{\_def\_tmpb{#1}% - \_replstring\_tmpb{\crli}{\_crcr\crli}\_replstring\_tmpb{\crll}{\_crcr\crll}% - \_replstring\_tmpb{\crlli}{\_crcr\crlli}\_replstring\_tmpb{\crlp}{\_crcr\crlp}% + \_replstring\_tmpb{\crl}{\_crcr\crl}\_replstring\_tmpb{\crll}{\_crcr\crll}% + \_replstring\_tmpb{\crli}{\_crcr\crli}\_replstring\_tmpb{\crlli}{\_crcr\crlli}% + \_replstring\_tmpb{\crlp}{\_crcr\crlp}% \_edef\_tabskipmid{\_the\_tabskip}\_tabskip=\_tabskipl \_ifpxto \_tsize=\_hsize \_setbox0 = \_vbox{\_halign \_tableC}% @@ -275,7 +276,7 @@ \_public \crl \crll \crli \crlli \crlp \tskip ; \_doc ----------------------------- - The \`\mspan``[<declaration>]{<text>}` macro generates similar `\omit\span\omit\span` + The \`\mspan``{<number>}[<declaration>]{<text>}` macro generates similar `\omit\span\omit\span` sequence as plain \TeX/ macro `\multispan`. Moreover, it uses \^`\_scantabdata` to convert `<declaration>` from `\table` syntax to `\halign` syntax. \_cod ----------------------------- @@ -336,6 +337,28 @@ }\_kern\_vvkern\_hrule}\_vrule}} \_public \frame ; + \_doc ----------------------------- + \`\eqbox` and \`\eqboxsize` are implemented here. The widths of + all `\eqbox`es are saved to the `.ref` file in the format + \`\_Xeqbox``{<label>}{<size>}`. The `.ref` file is read again and maximum + box width for each <label> is saved to `\_eqb:<label>`. + \_cod ----------------------------- + +\_def\_Xeqbox#1#2{% + \_ifcsname _eqb:#1\_endcsname + \_ifdim #2>\_cs{_eqb:#1}\_relax \_sdef{_eqb:#1}{#2}\_fi + \_else \_sdef{_eqb:#1}{#2}\_fi +} +\_def\_eqbox #1[#2]#3{\_setbox0=\_hbox{{#3}}% + \_openref \_immediate\_wref \_Xeqbox{{#2}{\_the\_wd0}}% + \_ifcsname _eqb:#2\_endcsname + \_hbox to\_cs{_eqb:#2}{\_ifx r#1\_hfill\_fi\_hss\_unhbox0\_hss\_ifx l#1\_hfill\_fi}% + \_else \_box0 \_fi +} +\_def\_eqboxsize [#1]#2{\_trycs{_eqb:#1}{#2}} + +\public \eqbox \eqboxsize ; + \_endcode % ------------------------------------- \secc[table.bound] The boundary declarator \code{:} @@ -448,8 +471,41 @@ For example, % This gives the ratio of widths of individual paragraphs in the table. +\secc `\eqbox`: boxes with equal width acros the whole document + +The \^`\eqbox` `[<label>]{<text>}` behaves like `\hbox{<text>}` in the first +run of \TeX. But the widths of all boxes with the same label are saved to +`.ref` file and the maximum box width for each label is calculated at the +beginning of the next \TeX/ run. Then \^`\eqbox`~`[<label>]{<text>}` behaves +like `\hbox to <dim:label> {\hss <text>\hss}`, where <dim:label> is +the maximum width of all boxes +labeled by the same `[<label>]`. The documentation of the \LaTeX/ package +`eqparbox` includes more information and tips. + +The \^`\eqboxsize` `[<label>]{<dimen>}` expands to <dim:label> if this value is known, +else it expands to the given <dimen>. + +The optional parameter `r` or `l` can be writen before `[<label>]` (for example +`\eqbox r[label]{text}`) if you want to put the text to the right or to the +left side of the box width. + +Try the following example and watch what happens after first \TeX/ run and +after second one. + +\begtt +\def\leftitem#1{\par + \noindent \hangindent=\eqboxsize[items]{2em}\hangafter=1 + \eqbox r[items]{#1 }\ignorespaces} + +\leftitem {\bf first} \lorem[1] +\leftitem {\bf second one} \lorem[2] +\leftitem {\bf final} \lorem[3] +\endtt + + \_endinput +2020-05-26 \eqbox implemented 2020-05-20 \colnum implemented. \vspan implemented. 2020-05-19 \fL, \fR ets defined. diff --git a/macros/luatex/optex/base/unimath-codes.opm b/macros/luatex/optex/base/unimath-codes.opm index d0182a0f85..4718f0dd51 100644 --- a/macros/luatex/optex/base/unimath-codes.opm +++ b/macros/luatex/optex/base/unimath-codes.opm @@ -1,6 +1,6 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \_ncharrmA {Uni math codes <2020-03-14>} % preloaded on demand by \loadmath +\_codedecl \_ncharrmA {Uni math codes <2020-06-13>} % preloaded on demand by \loadmath \_doc ----------------------------- The control sequences for `\alpha`, `\beta` etc are redefined here. @@ -21,7 +21,8 @@ \varrho \varpi \_relax \_doc ----------------------------- - The math alphabets are declared here using the \^`\_umathrange` macro. + The math alphabets are declared here using the + \^`\_umathrange {<range>}<class><family><starting-code>` macro. \_cod ----------------------------- \_chardef\_ncharrmA=`A \_chardef\_ncharrma=`a @@ -39,20 +40,20 @@ \_chardef\_ncharsxA="1D63C \_chardef\_ncharsxa="1D656 \_chardef\_ncharttA="1D670 \_chardef\_nchartta="1D68A -\_protected\_def\_rmvariables {\_umathrange{A-Z}\_ncharrmA \_umathrange{a-z}\_ncharrma} -\_protected\_def\_bfvariables {\_umathrange{A-Z}\_ncharbfA \_umathrange{a-z}\_ncharbfa} -\_protected\_def\_nitvariables {\_umathrange{A-Z}\_ncharitA \_umathrange{a-z}\_ncharita} -\_protected\_def\_bivariables {\_umathrange{A-Z}\_ncharbiA \_umathrange{a-z}\_ncharbia} -\_protected\_def\_calvariables {\_umathrange{A-Z}\_ncharclA \_umathrange{a-z}\_ncharcla} -\_protected\_def\_bcalvariables {\_umathrange{A-Z}\_ncharbcA \_umathrange{a-z}\_ncharbca} -\_protected\_def\_frakvariables {\_umathrange{A-Z}\_ncharfrA \_umathrange{a-z}\_ncharfra} -\_protected\_def\_bfrakvariables {\_umathrange{A-Z}\_ncharbrA \_umathrange{a-z}\_ncharbra} -\_protected\_def\_bbvariables {\_umathrange{A-Z}\_ncharbbA \_umathrange{a-z}\_ncharbba} -\_protected\_def\_sansvariables {\_umathrange{A-Z}\_ncharsnA \_umathrange{a-z}\_ncharsna} -\_protected\_def\_bsansvariables {\_umathrange{A-Z}\_ncharbsA \_umathrange{a-z}\_ncharbsa} -\_protected\_def\_isansvariables {\_umathrange{A-Z}\_ncharsiA \_umathrange{a-z}\_ncharsia} -\_protected\_def\_bisansvariables {\_umathrange{A-Z}\_ncharsxA \_umathrange{a-z}\_ncharsxa} -\_protected\_def\_ttvariables {\_umathrange{A-Z}\_ncharttA \_umathrange{a-z}\_nchartta} +\_protected\_def\_rmvariables {\_umathrange{A-Z}71\_ncharrmA \_umathrange{a-z}71\_ncharrma} +\_protected\_def\_bfvariables {\_umathrange{A-Z}71\_ncharbfA \_umathrange{a-z}71\_ncharbfa} +\_protected\_def\_itvariables {\_umathrange{A-Z}71\_ncharitA \_umathrange{a-z}71\_ncharita} +\_protected\_def\_bivariables {\_umathrange{A-Z}71\_ncharbiA \_umathrange{a-z}71\_ncharbia} +\_protected\_def\_calvariables {\_umathrange{A-Z}71\_ncharclA \_umathrange{a-z}71\_ncharcla} +\_protected\_def\_bcalvariables {\_umathrange{A-Z}71\_ncharbcA \_umathrange{a-z}71\_ncharbca} +\_protected\_def\_frakvariables {\_umathrange{A-Z}71\_ncharfrA \_umathrange{a-z}71\_ncharfra} +\_protected\_def\_bfrakvariables {\_umathrange{A-Z}71\_ncharbrA \_umathrange{a-z}71\_ncharbra} +\_protected\_def\_bbvariables {\_umathrange{A-Z}71\_ncharbbA \_umathrange{a-z}71\_ncharbba} +\_protected\_def\_sansvariables {\_umathrange{A-Z}71\_ncharsnA \_umathrange{a-z}71\_ncharsna} +\_protected\_def\_bsansvariables {\_umathrange{A-Z}71\_ncharbsA \_umathrange{a-z}71\_ncharbsa} +\_protected\_def\_isansvariables {\_umathrange{A-Z}71\_ncharsiA \_umathrange{a-z}71\_ncharsia} +\_protected\_def\_bisansvariables {\_umathrange{A-Z}71\_ncharsxA \_umathrange{a-z}71\_ncharsxa} +\_protected\_def\_ttvariables {\_umathrange{A-Z}71\_ncharttA \_umathrange{a-z}71\_nchartta} \_chardef\_greekrmA="0391 \_chardef\_greekrma="03B1 \_chardef\_greekbfA="1D6A8 \_chardef\_greekbfa="1D6C2 @@ -61,20 +62,18 @@ \_chardef\_greeksnA="1D756 \_chardef\_greeksna="1D770 \_chardef\_greeksiA="1D790 \_chardef\_greeksia="1D7AA -\_protected\_def\_nitgreek {\_umathrangeGREEK\_greekrmA \_umathrangegreek\_greekita} -\_protected\_def\_rmgreek {\_umathrangeGREEK\_greekrmA \_umathrangegreek\_greekrma} -\_protected\_def\_bfgreek {\_umathrangeGREEK\_greekbfA \_umathrangegreek\_greekbfa} -\_protected\_def\_bigreek {\_umathrangeGREEK\_greekbfA \_umathrangegreek\_greekbia} -\_protected\_def\_sansgreek {\_umathrangeGREEK\_greeksnA \_umathrangegreek\_greeksna} -\_protected\_def\_isansgreek {\_umathrangeGREEK\_greeksnA \_umathrangegreek\_greeksia} - -% Another possibility (slanted capitals in \_nitgreek, \_bigreek, \_isansgreek): -%\_protected\_def\_nitgreek {\_umathrangeGREEK\_greekitA \_umathrangegreek\_greekita} -%\_protected\_def\_rmgreek {\_umathrangeGREEK\_greekrmA \_umathrangegreek\_greekrma} -%\_protected\_def\_bfgreek {\_umathrangeGREEK\_greekbfA \_umathrangegreek\_greekbfa} -%\_protected\_def\_bigreek {\_umathrangeGREEK\_greekbiA \_umathrangegreek\_greekbia} -%\_protected\_def\_sansgreek {\_umathrangeGREEK\_greeksnA \_umathrangegreek\_greeksna} -%\_protected\_def\_isansgreek {\_umathrangeGREEK\_greeksiA \_umathrangegreek\_greeksia} +\_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} +\_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 @@ -83,12 +82,12 @@ \_chardef\_digitbsO="1D7EC \_chardef\_digitttO="1D7F6 -\_protected\_def\_rmdigits {\_umathrange{0-9}\_digitrmO} -\_protected\_def\_bfdigits {\_umathrange{0-9}\_digitbfO} -\_protected\_def\_bbdigits {\_umathrange{0-9}\_digitbbO} -\_protected\_def\_sansdigits {\_umathrange{0-9}\_digitsnO} -\_protected\_def\_bsansdigits {\_umathrange{0-9}\_digitbsO} -\_protected\_def\_ttdigits {\_umathrange{0-9}\_digitttO} +\_protected\_def\_rmdigits {\_umathrange{0-9}71\_digitrmO} +\_protected\_def\_bfdigits {\_umathrange{0-9}71\_digitbfO} +\_protected\_def\_bbdigits {\_umathrange{0-9}71\_digitbbO} +\_protected\_def\_sansdigits {\_umathrange{0-9}71\_digitsnO} +\_protected\_def\_bsansdigits {\_umathrange{0-9}71\_digitbsO} +\_protected\_def\_ttdigits {\_umathrange{0-9}71\_digitttO} \_doc ----------------------------- The \`\cal`, \`\bbchar`, \`\frak`, \`\script` @@ -99,8 +98,10 @@ You can redefine them again if you need different behavior (for example you don't want to use sans serif bold in math). What to do: \begtt \advance\hsize by2em - \_protected\_def\_bf {\_tryloadbf\_tenbf \_inmath{\_bfvariables\_bfgreek\_bfdigits}} - \_protected\_def\_bi {\_tryloadbi\_tenbi \_inmath{\_bivariables\_bigreek\_bfdigits}} + \_protected\_def\_bf + {\_tryloadbf\_tenbf \_inmath{\_bfvariables\_bfgreek\_bfGreek\_bfdigits}} + \_protected\_def\_bi + {\_tryloadbi\_tenbi \_inmath{\_bivariables\_bigreek\_bfGreek\_bfdigits}} \_public \bf \bi ; \endtt \`\_inmath` `{<cmds>}` applies `<cmds>` only in math mode. @@ -113,18 +114,21 @@ % \bf and \bi behaves as sans serif in math, ... \_protected\_def\_rm {\_tryloadrm \_tenrm \_inmath{\_rmvariables \_rmdigits}} -\_protected\_def\_it {\_tryloadit \_tenit \_inmath{\_nitvariables}} -\_protected\_def\_bf {\_tryloadbf \_tenbf \_inmath{\_bsansvariables \_sansgreek \_bsansdigits}} -\_protected\_def\_bi {\_tryloadbi \_tenbi \_inmath{\_bisansvariables \_isansgreek \_bsansdigits}} +\_protected\_def\_it {\_tryloadit \_tenit \_inmath{\_itvariables}} +\_protected\_def\_bf + {\_tryloadbf \_tenbf \_inmath{\_bsansvariables \_bsansgreek \_bsansGreek \_bsansdigits}} +\_protected\_def\_bi + {\_tryloadbi \_tenbi \_inmath{\_bisansvariables \_bisansgreek \_bsansGreek \_bsansdigits}} \_protected\_def\_tt {\_tryloadtt \_tentt \_inmath{\_ttvariables \_ttdigits}} \_protected\_def\_bbchar {\_bbvariables \_bbdigits} \_protected\_def\_cal {\_calvariables} \_protected\_def\_frak {\_frakvariables} -\_protected\_def\_misans {\_isansvariables \_isansgreek \_sansdigits} -\_protected\_def\_mbisans {\_bisansvariables \_isansgreek \_bsansdigits} +\_protected\_def\_misans {\_isansvariables \_sansdigits} +\_protected\_def\_mbisans {\_bisansvariables \_bisansgreek \_bsansGreek \_bsansdigits} \_protected\_def\_script {\_rmvariables \_fam4 } +\_protected\_def\_mit {\_itvariables \_rmdigits \_itgreek \_rmGreek } -\_public \rm \it \bf \bi \tt \bbchar \cal \frak \misans \mbisans \script ; +\_public \rm \it \bf \bi \tt \bbchar \cal \frak \misans \mbisans \script \mit ; \_doc ----------------------------- Each Unicode slot carries information about math type. This is saved in @@ -181,7 +185,7 @@ \_global\_Udelcode`<=1 "027E8 % these characters have different meaning \_global\_Udelcode`>=1 "027E9 % as normal and as delimeter -\_nitgreek \_nitvariables \_rmdigits % default setting +\_mit % default math alphapbets setting \_Umathcode `- = 2 1 "2212 %\_Umathcode`: = 3 1 "3A % mathclass defines it as 6 1 "3A (punctuation) @@ -231,6 +235,11 @@ \_let\|=\Vert \_mathcode`\_="8000 +\_global\_Umathcode "22EF = 0 1 "22EF % mathclass.txt says that it is Rel +\_global\_Umathchardef \unicodecdots = 0 1 "22EF + +\_global\_Umathcode `/ = 0 1 `/ % mathclass says that / is Bin, Plain TeX says that it is Ord. + \_doc ----------------------------- Aliases are declared here. They are names not menitioned in the `unimath-table.opm` file but commonly used in \TeX. @@ -254,7 +263,7 @@ \_let \gets=\leftarrow \_let \mathring=\ocirc \_let \lnot=\neg -\_let \longdivision=\longdivisionsign +\_let \longdivisionsign=\longdivision \_let \backepsilon=\upbackepsilon \_let \eth=\matheth \_let \dbkarow=\dbkarrow @@ -294,15 +303,18 @@ \_let \upvarpi=\mupvarpi \_doc ----------------------------- - The \^`\not` macro is redefined here. + The \`\not` macro is redefined here. If the `\_not!<char>` is defined + (by \`\_negationof`) + then this macro is used. Else centered / is printed over the <char>. \_cod ----------------------------- \_protected\_def\_not#1{% - \_ifcsname _not!\_csstring#1\_endcsname \_csname _not!\_csstring#1\_endcsname - \_else \_mathrel{\_mathord{\_rlap{\_kern1pt/}}\_mathord{#1}}% - \_fi -} + \_trycs{_not!\_csstring#1}{\_mathrel\_mathstyles{% + \_setbox0=\_hbox{\_math$\_currstyle#1$}% + \_hbox to\_wd0{\_hss$\_currstyle/$\_hss}\_kern-\_wd0 \_box0 +}}} \_def\_negationof #1#2{\_ea\_let \_csname _not!\_csstring#1\_endcsname =#2} + \_negationof = \neq \_negationof < \nless \_negationof > \ngtr @@ -314,6 +326,44 @@ \_negationof \greater \ngtr \_negationof \forksnot \forks \_negationof \in \notin +\_negationof \mid \nmid +\_negationof \cong \ncong +\_negationof \leftarrow \nleftarrow +\_negationof \rightarrow \nrightarrow +\_negationof \leftrightarrow \nleftrightarrow +\_negationof \Leftarrow \nLeftarrow +\_negationof \Leftrightarrow \nLeftrightarrow +\_negationof \Rightarrow \nRightarrow +\_negationof \exists \nexists +\_negationof \ni \nni +\_negationof \paralel \nparalel +\_negationof \sim \nsim +\_negationof \approx \napprox +\_negationof \equiv \nequiv +\_negationof \asymp \nasymp +\_negationof \lesssim \nlesssim +\_negationof \ngtrsim \ngtrsim +\_negationof \lessgtr \nlessgtr +\_negationof \gtrless \ngtrless +\_negationof \prec \nprec +\_negationof \succ \nsucc +\_negationof \subset \nsubset +\_negationof \supset \nsupset +\_negationof \subseteq \nsubseteq +\_negationof \supseteq \nsupseteq +\_negationof \vdash \nvdash +\_negationof \vDash \nvDash +\_negationof \Vdash \nVdash +\_negationof \VDash \nVDash +\_negationof \preccurlyeq \npreccurlyeq +\_negationof \succcurlyeq \nsucccurlyeq +\_negationof \sqsubseteq \nsqsubseteq +\_negationof \sqsupseteq \nsqsupseteq +\_negationof \vartriangleleft \nvartriangleleft +\_negationof \vartriangleright \nvartriangleright +\_negationof \trianglelefteq \ntrianglelefteq +\_negationof \trianglerighteq \ntrianglerighteq +\_negationof \vinfty \nvinfty \_public \not ; @@ -357,5 +407,8 @@ can define: \_endinput History: +2020-06-13 Umathcode of / declared asi iin Plain TeX +2020-06-07 \_itgreek \_itGreek, \_rmgreek \_rmGreek etc. introduced, names changed +2020-06-03 \not\mid = \nmid added, \not corrected 2020-04-30 Bug fix: \phi, \varpi etc. were bad encoded 2020-04-09 Bug fix: \Udelcode`<, \Udelcode`> added diff --git a/macros/luatex/optex/base/unimath-table.opm b/macros/luatex/optex/base/unimath-table.opm index 511b67e8ce..066f57d352 100644 --- a/macros/luatex/optex/base/unimath-table.opm +++ b/macros/luatex/optex/base/unimath-table.opm @@ -1,6 +1,9 @@ %%^^A%% unicode-math-table.tex -- part of UNICODE-MATH <wspr.io/unicode-math> %%^^A%% Source file of the math symbols. +% Only \ddots, \adots and \vdots are called differently: +% \unicodeddots, \unicodeadots and \unicodevdots + \UnicodeMathSymbol{"00021}{\mathexclam }{\mathclose}{exclamation mark}% \UnicodeMathSymbol{"00023}{\mathoctothorpe }{\mathord}{number sign}% \UnicodeMathSymbol{"00024}{\mathdollar }{\mathord}{dollar sign}% @@ -563,10 +566,10 @@ \UnicodeMathSymbol{"022EB}{\nvartriangleright }{\mathrel}{not right triangle}% \UnicodeMathSymbol{"022EC}{\ntrianglelefteq }{\mathrel}{not left triangle, equals}% \UnicodeMathSymbol{"022ED}{\ntrianglerighteq }{\mathrel}{not right triangle, equals}% -\UnicodeMathSymbol{"022EE}{\vdots }{\mathrel}{vertical ellipsis}% +\UnicodeMathSymbol{"022EE}{\unicodevdots }{\mathrel}{vertical ellipsis}% \UnicodeMathSymbol{"022EF}{\unicodecdots }{\mathord}{three dots, centered}% -\UnicodeMathSymbol{"022F0}{\adots }{\mathrel}{three dots, ascending}% -\UnicodeMathSymbol{"022F1}{\ddots }{\mathrel}{three dots, descending}% +\UnicodeMathSymbol{"022F0}{\unicodeadots }{\mathrel}{three dots, ascending}% +\UnicodeMathSymbol{"022F1}{\unicodeddots }{\mathrel}{three dots, descending}% \UnicodeMathSymbol{"022F2}{\disin }{\mathrel}{element of with long horizontal stroke}% \UnicodeMathSymbol{"022F3}{\varisins }{\mathrel}{element of with vertical bar at end of horizontal stroke}% \UnicodeMathSymbol{"022F4}{\isins }{\mathrel}{small element of with vertical bar at end of horizontal stroke}% diff --git a/macros/luatex/optex/base/verbatim.opm b/macros/luatex/optex/base/verbatim.opm index 84d6d83ae5..c74338d2e2 100644 --- a/macros/luatex/optex/base/verbatim.opm +++ b/macros/luatex/optex/base/verbatim.opm @@ -120,7 +120,7 @@ number using `\_llap`. \_cod ---------------------------- -\_eoldef \begtt#1{\_par \_wipeepar +\_eoldef \begtt#1{\_par \_wipeepar \_setxhsize \_vskip\_parskip \_ttskip \_begingroup \_setverb @@ -213,7 +213,7 @@ \_else \_edef\_vinolines{\_the\_tmpnum}% \_fi - \_vskip\_parskip \_ttskip \_wipeepar + \_vskip\_parskip \_ttskip \_wipeepar \_setxhsize \_begingroup \_ifnum\_ttline<-1 \_let\_printverblinenum=\_relax \_else \_initverblinenum \_fi \_setverb \_adef{ }{\ }\_adef\^^I{\t}\_parindent=\_ttindent \_parskip=0pt diff --git a/macros/luatex/optex/doc/optex-doc.pdf b/macros/luatex/optex/doc/optex-doc.pdf Binary files differindex 41b0be5572..4c93161699 100644 --- a/macros/luatex/optex/doc/optex-doc.pdf +++ b/macros/luatex/optex/doc/optex-doc.pdf diff --git a/macros/luatex/optex/doc/optex-doc.tex b/macros/luatex/optex/doc/optex-doc.tex index d1952e201f..d72b177bf6 100644 --- a/macros/luatex/optex/doc/optex-doc.tex +++ b/macros/luatex/optex/doc/optex-doc.tex @@ -20,7 +20,7 @@ \tit Format Based on Plain \TeX/ and OPmac\fnotemark1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\hfill Version 0.13 +\hfill Version 0.14 \centerline{\it Petr Olšák, 2020} diff --git a/macros/luatex/optex/doc/optex-math.tex b/macros/luatex/optex/doc/optex-math.tex new file mode 100644 index 0000000000..80557fec82 --- /dev/null +++ b/macros/luatex/optex/doc/optex-math.tex @@ -0,0 +1,1610 @@ +%% This is part of OpTeX project, see http://petr.olsak.net/optex + +% Run optex optex-math (two times) to generate this document +% or look at PDF here: http://petr.olsak.net/ftp/olsak/optex/optex-math.pdf + +\fontfam[lmfonts] + +\font\ttlib=[LiberationMono-Regular] +\def\ttspec{\let\_ttfont=\ttlib} + +\report + +\def\new #1 {\mnote{\Red$\blacktriangleleft$\,\sans\setfontsize{at9pt}\rm#1}} +\fixmnotes\right +\enquotes +\activettchar` +\catcode`\<=13 +\def<#1>{$\langle\hbox{\it#1\/}\rangle$} +\everyintt={\catcode`\<=13 } +\def\ss#1{$\vrule height3pt#1\vrule height3pt$} + +\addto\_secfont\Blue \addto\_seccfont\Blue +\_def\_printsec#1{\_par + \_abovetitle{\_penalty-400}\_bigskip + {\_secfont \_noindent \_raggedright \llap{\_printrefnum[@\_quad]}#1\_nbpar}\_insertmark{#1}% + \_nobreak \_belowtitle{\_medskip}% + \_firstnoindent +} +\_def\_printsecc#1{\_par + \_abovetitle{\_penalty-200}\_medskip + {\_seccfont \_noindent \_raggedright \llap{\_printrefnum[@\_quad]}#1\_nbpar}% + \_nobreak \_belowtitle{\_medskip}% + \_firstnoindent +} + +\hyperlinks\Green\Green + +\insertoutline{MATH} +\outlines{0} + + + +\tit Typesetting Math with \OpTeX/ + +\vskip-\baselineskip \hfill Version 01 + +\author Petr Olšák + + + +This document is a brief summary about typesetting math. It describes \TeX/, +Plain \TeX/ and \OpTeX/ features concerned to math. The first two types of +features are documented in \TeX/book in chapters 16, 17 and 18, but it is +summarized here in short again in order to give a complete guide about math +typesetting for \OpTeX/ users. + +\new {} +The \OpTeX/ features which differs from standard \TeX/ or Plain \TeX/ are +documented with the red triangle at the margin (like in this paragraph). +Reader can simply distinguish between \"standard" features (given by +\TeX/ or Plain \TeX/) and new \OpTeX/ features. + +There are more types of extensions: e\TeX, lua\TeX/, Unicode math and +\OpTeX/ macros. The appropriate label (e\TeX, Lua\TeX/, Unicode, \OpTeX/) +is appended to the red triangle to inform you about the extension type. +Nevertheless, \OpTeX/ user doesn't have to worry about it, all extensions +are available if Unicode Math font is loaded (e.g., by the command +`\fonfam[lmfonts]`). See section 1.3.3 in \OpTeX/ documentation about +loading Unicode math fonts. + +{\iindent=2em +\bigskip +\maketoc } +\vfil\break + +\sec Basics structure of math formulas + +\secc General rules and terminology + +The in-line math (in the paragraph) is created by `$<math list>$`. The +display math (standalone line between paragraphs) is created by `$$<math list>$$`. +More than one line can be here if appropriate macro is used. In-line math is +processed in a \TeX/ group in {\em in-line math mode}. The display math is +processed in a \TeX/ group in {\em display math mode}. Spaces are +ignored in math modes. + +The <math list> is a sequence of {\em math atoms} and {\em other materials}. +The math atoms are {\em single math objects} or composed math atoms. + +\begitems +* The single math object is a single character to be printed in math mode + like `x`, `+`, `\int`. +* The math atom is constructed in genereal by `{<mat list 1>}^{<math list 2>}_{<math list 3>}`. + It consists from {\em nucleus} <math list 1>, exponent <math list 2> and subscript + <math list 3>. Each part of the atom should be empty. If the mentioned <math list> + consist only from a single math object then we need not to use brackets, for example + `x^2` is a math atom with `x` in nucleus, `2` in exponent and with empty subscript. + Or `a_{i,j}` is a math atom with `a` in nucleus, empty exponent and `i,j` in subscript. + The constructors for exponent `^` and for subscript `_` can be used in arbitrary order + followed by the nucleus, for example `z_1^{x+y}` it the same math atom as + `z^{x+y}_1`. The single math objects not followed by `^` nor `_` are + considered as math atoms with this object in nucleus and with empty + exponent and subscript (this is very common case). + \TeX/ assigns the {\em class} for each math atom, see section~\ref[class]. +* Other material can be \TeX/ box or glue (space) or `\kern` or `\vrule` etc. +\enditems + +Example: The `Z = \int``_\Omega x^{2y} + z\, dx` generates +$Z = \int_\Omega x^{2y} + z\, dx$ and it is <math list> which consists from: + +\begitems +* `Z` is math atom with empty exponent and subscript, class: Ord, +* `=` is math atom with empty exponent and subscript, class: Rel, +* `\int``_\Omega` is math atom with empty exponent and with subscript `\Omega`, class: Op, +* `x^{2y}` is math atom with exponent `2y` and empty subscript, class: Ord, + \begitems \let\_bullet=\circ + * `2` is math atom with empty exponent and subscript, class: Ord, + * `y` is math atom with empty exponent and subscript, class: Ord, + \enditems +* `+` is math atom with empty exponent and subscript, class: Bin, +* `z` is math atom with empty exponent and subscript, class: Ord, +* `\,` is other material, the glue (space) in this case, +* `d` is math atom with empty exponent and subscript, class: Ord, +* `x`is math atom with empty exponent and subscript, class: Ord. +\enditems + +\secc[class] Classes of math atoms + +\TeX/ assigns {\em a class} for each math atom.\fnote +{Using terminology of \TeX/book, each single math object has its {\em class} but the + math atom has its {\em kind} derived from this class. I use only one word + for both meanings in this document.} +This data type is used when +\TeX/ decides about horizontal spaces between atoms in the output. (Note +that spaces in the input are ignored.) For example, +`$xy$` prints two atoms without space between them but `$x+y$` is printed with +small spaces around the `+` binary operator. Compare: $xy$ and $x+y$. + +The class is assigned depending on the nucleus of the atom. If the nucleus is +not single math object, i.e. it is constructed by `{<math list>}` with braces +then the atom has its class Ord. If the nucleus is single math object constructed +without braces then the class of the atom depends on this single math +object. Each single math object must be declared in \TeX/ with its default +class. The following table lists the classes with typical examples. +Full set of all math objects used in math typesetting +is listed in the section~\ref[objects] with their default classes. + +\bigskip +\noindent\hfil\table{llll}{ + & Class & Meaning & Example \crl + 0 & Ord & ordinary object & variables, digits, $x, {\bbchar R}, \Gamma, 0, 1$ \cr + 1 & Op & big opertator & $\sum, \int, \bigcup$ \cr + 2 & Bin & binary operator & $+, \times, -, \pm, \cup$ \cr + 3 & Rel & reations & $=, \ne, \leq, \supseteq, \succsim$ \cr + 4 & Open & opening bracket & $\{, (, [, \langle$ \cr + 5 & Close & closing bracket & $\}, ), ], \rangle$ \cr + 6 & Punct & punctuation & comma \cr + & Inner & left-right & \code{\\left...\\right} outputs, see section~\ref[delims] +} +\bigskip + +There are three space types used by the algorithm for horizontal spacing in the +math formulas. + +\begitems +* Thin space: `\thinmuskip` primitive register, `\,` macro. Used around Op atoms. +* Medium space: `\medmuskip` primitive register, `\>` macro. Used around Bin atoms. +* Thick space: `\thickmusip` primitive register, `\;` macro. Used around Rel atoms. +\enditems + +\puttext 7.8cm -3.7cm {\rotbox{90}{Left atom}} +\puttext 11.5cm -.5cm {Right atom} +\puttext 8.2cm -4.4cm {\typosize[9/11] +\thistable{\def\_enspace{ }}% +\table {l|8c|} { + \omit & Ord & Op & Bin & Rel & Open & Close & Punct & \omit \hfil Inner \crlp{2-9} + Ord & 0 & 1 & 2 & 3 & 0 & 0 & 0 & 1 \cr + Op & 1 & 1 & & 3 & 0 & 0 & 0 & 1 \cr + Bin & 2 & 2 & & & 2 & & & 2 \cr + Rel & 3 & 3 & & 0 & 3 & 0 & 0 & 3 \cr + Open & 0 & 0 & & 0 & 0 & 0 & 0 & 0 \cr + Close & 0 & 1 & 2 & 3 & 0 & 0 & 0 & 1 \cr + Punct & 1 & 1 & & 1 & 1 & 1 & 1 & 1 \cr + Inner & 1 & 1 & 2 & 3 & 1 & 0 & 1 & 1 \crlp{2-9} +}} + +\hangindent=-8.7cm \hangafter=0 +Ord atoms are printed without spaces between them. The spaces are not +cummulated, so the rules about spaces mentioned above is only rough idea. +The exact rule for horizontal spaces is given for each pairs of atoms +in the table here. The symbol 0 means no space, 1 thin space, 2 medium space +and 3 means thick space. + +\hangindent=-8.7cm \hangafter-2 +The Bin atom is automaticaly transformed to the +Ord atom if no atom precedes or if Op, Bin, Rel, Open or Punct atom +precedes. And it is transformed to the Ord atom if Rel, Close or Punct atom +follows. This corresponds to the empty cells in the table. +Why such behavior? Compare \"\hbox{$0-1$}" and \"$-1$". The Bin atom in +the second case behaves like Ord atom because it is {\em unary minus}. +There is no space between unary minus and one. + +All medium spaces and thick spaces and some thin spaces from this table are +omitted if the <math list> is processed in script or scriptscript styles +(smaller size). See section~\ref[styles] about math styles. + +You can overwrite the default class derived from the nucleus of the atom by +\TeX/ primitives `\mathord`, `\mathop`, `\mathbin`, `\mathrel`, `\mathopen`, +`\mathclose`, `\mathpunct` and `\mathinner`. They can precede a nucleus of +the atom and they set the class of the atom. +For example, `x \mathrel+ y` behaves like `x = y` in spacing point of view but + +is printed. Another example: `\mathop{\rm lim} z` creates the atom `lim` in +roman font of class Op. So, the thin space is inserted between lim and $z$. + +There are more special kinds of math atoms: fractions, math accents, +radicals. They are constructed by special way (see next sections) but they behaves +like Ord atom in the horizontal spacing algorithm. + +\secc[styles] Math styles + +When a formula (or a sub-formula) is processed by \TeX/ then one from four +styles is active: display style ($D$), text style ($T$), script style ($S$) or +scriptscript style ($SS$). + +The $T$ style is started in in-line math mode `$...$` and the $D$ +style is started in display math mode `$$...$$`. The first level of exponents or +subscripts is processed in $S$ style and the second and more levels of +exponents or indexes are processed in $SS$ style. +There are special rules for math styles when fractions are constructed, see +section~\ref[frac]. + +The $D$ and $T$ style uses basic font size, $S$ uses smaller font size (typically +70~\%) and $SS$ style uses more smaller font size (typically 50~\%). Next +levels of \"more smaller fonts" are not used due to classical typographic rules. + +The nucleus of Op atoms (big operators, $\sum$, $\int$, etc.) have typically bigger versions +of the character shape for $D$ style than for $T$ style. +So, there are four sizes for such math +objects: one size for each math style. All other math objects (with non Op +class) are printed only in three sizes: The sizes for $T$ and $D$ styles are equal. + +The Op atom puts its exponent and subscript above and below the nucleus in $D$ +style but right to the nucleus in other styles: +$$ + `\sum``_{i=1}^\infty` \quad \hbox{gives}\quad \sum_{i=1}^\infty \hbox{ in $D$ style and} + \quad \textstyle \sum_{i=1}^\infty \hbox{ in $T$ style}. +$$ +This default behavior of the Op atom +can be modified by placing `\limits` or `\nolimits` or +`\displaylimits` \TeX/ primitive just after the Op nucleus before the constructors +of exponent and/or index. The `\nolimits` puts exponent and subscript right +to the nucleus (regardless of the current style) and `\limits` puts these +objects above and below the nucleus (regardless of the current style). There +can be more such primitives in a queue (due to a macro expansion, for +instance). Then the last primitive in the queue wins. +If the last primitive is `\displaylimits` then +default behavior is processed regardless there are `\limits` or `\nolimits` +before it. +$$ + `\sum\nolimits``_{i=1}^\infty` \quad \hbox{gives}\quad \sum\nolimits_{i=1}^\infty + \hbox{ in $D$ style and}\quad \textstyle\sum\nolimits_{i=1}^\infty + \hbox{ in $T$ style}. +$$ +Atoms of all other classes have their exponents and/or subscripts only right +to their nucleus without any exception. + +The primitives `\displaystyle`, `\textstyle`, `\scriptstyle` and +`\scriptscriptstyle` set the given style regardless the default rules. For +example, you can create a formula in in-line math mode and in $D$ style by +`$\displaystyle <fomula>$` or a formula in display mode and $T$ style can be printed +by `$$\textstyle <fomrula>$$`. + +If the subformula is placed below something (below a rule from root symbol, +below a fraction rule), then the processed style $D, T, S$ or $SS$ is {\em cramped}. +The exponents are positioned slightly lower than in non-cramped style. + +Several macros need to know what math style is currently processed (for +example they need to draw something in an appropriate size). But it +not possible simply due to the syntax of fractions (section~\ref[frac]). +This syntax requires to process all math lists in two steps: the first step +expands all macros and creates structured data of processed math list. The +second step reads the output of the first step, switches between math +styles and creates definitive output. So, macros (working in first step) +cannot know the current math +style because it is set only in the second step. \TeX/ supports the primitive +`\matchchioce{<D>}{<T>}{<S>}{<SS>}` which prepares four math lists in the +first step and only one of these four lists are used in the second step. We +can put different macros into each of the four parameters of `\mathchoice`. +Plain \TeX/ supports the macro `\mathpalette` which gives a more comfortable +interface of `\mathchoice` to macro programmer. + +\new \OpTeX/ +We describe another interface for creating macros depending on current +style. You can use `\mathstyles{<math list>}`. It +behaves like `{<math list>}`, moreover, you can use following commands inside such +<math list>: +\begitems +* The macro `\currstyle`. It expands to + `\displaystyle`, `\textstyle`, + `\scriptstyle` or `\scriptscriptstyle` depending on the current math style + when the `\mathstyles` was opened. +* The `\dobystyle{<D>}{<T>}{<S>}{<SS>}` is expandable macro. It expands its + parameter `<D>`, `<T>`, `<S>` or `<SS>` depending on the current math style + when `\mathstyles` was opened. +* The value of the `\stylenum` register is 0, 1, 2 or 3 + depending on the current math style when `\mathstyles` was opened. +\enditems +% +Example of usage of `\mathstyles`: +\def\mysymbol{\mathbin\mathstyles + {\kern1pt\vrule height\mysymbolA width\mysymbolA\kern1pt}} +\def\mysymbolA{\dobystyle{5pt}{5pt}{3.5pt}{2.5pt}} +\begtt +\def\mysymbol{\mathbin\mathstyles + {\kern1pt\vrule height\mysymbolA width\mysymbolA\kern1pt}} +\def\mysymbolA{\dobystyle{5pt}{5pt}{3.5pt}{2.5pt}} +Test: $a\mysymbol b_{c \mysymbol d}$ or $a\mysymbol b\over c$. +\endtt +This example gives Test: $a\mysymbol b_{c \mysymbol d}$ or $a\mysymbol b\over c$. + +The `\mathstyles` macro mentioned above uses \TeX/ primitive `\mathchoice`, so it +creates four math lists and only one is used. It may take more +computer time in special cases. +\new Lua\TeX/ +Lua\TeX/ supports the `\mathstyle` primitive +(no \"`s`" at the end of this control sequence) which +expands to values 0 to 7 depending on the current style: +$D, D', T, T', S, S', SS, SS'$ +(where $X'$ means cramped variant of the style). This primitive does +not use `\mathchoice` but it simply ignores the fraction syntax, so +`$a\mysymbol b\over c$` cannot work if `\mysymbol` is defined using the `\mathstyle` +primitive. See section 7.3.1 of Lua\TeX/ documentation for more information. + + +\secc[frac] Fractions + +The fraction can be constructed by `{<numerator>\over<denominator>}`. If the +fraction is only single object in the whole math mode (between dollars), +you need not to use the outer braces, so you can write `$1\over2$` to get $1\over2$. + +The <numerator> and <denominator> are printed in \"smaller" math style than +current math style. More exactly the following schema is used. +$D$: $T\over T$., $T$: $S\over S$, $S$: $SS\over SS$, $SS$: $SS\over SS$. +For example +$$ + `{a+b \over c}` \quad \hbox{is printed as } + {a+b\over c} \hbox{ in $D$ style and as } + \textstyle {a+b\over c} \hbox{ in $T$ style}. +$$ + +The \LaTeX/ macro `\frac{<numerator>}{<denominator>}` is not supported in +Plain \TeX/ nor in \OpTeX/ but you can define such macro if you want. + +The syntax with `\over` is more preferred because it is more human readable +notation. You can write the fraction in the same manner as you can read it. +You can compare: `$1\over2$` (one over two) with `$\frac12$` (frac twelve). + +Besides the `\over` primitive, there are analogical \TeX/ primitives which +create \"generalized" fractions. The result is similar as `{<above>\over <below>}` +but there is something extra: + +\begitems +* `{<above>\atop <below>}` does `{<above>\over<below>}` but + without the fractional rule. +* `{<above>\above<dimen><below>}` creates fractional rule with <dimen> thickness. +* `{<above>\overwithdelims<delim-l><delim-r><below>}` adds the <delim-l> left to + the fraction and the <delim-r> right to the fraction. +* `{<above>\atopwithdelims<delim-l><delim-r><below>}` is analogical to + `\overwithdelims` but without fractional rule. +* `{<above>\abovewithdelims<delim-l><delim-r><dimen><below>}` behaves as + `\overwithdelims` but the fractional rule has <dimen> thickness. +\enditems +% +The `\...withdelims` variants read <delim-l> and <delim-r>, they must be +declared as {\em math delimiter} in \TeX. They are vertically scalable +math objects, typically brackets. See section~\ref[delims] for more +information about math delimiters. Example: +$$ + `{n \atopwithdelims() k}`\quad \hbox{ creates } + {n \choose k} \hbox{ in $D$ style and } + \textstyle {n \choose k} \hbox{ in $T$ style}. +$$ +The `\choose` macro is defined by `\def\choose{\atopwithdelims()}`, so the +user can write `{n\choose k}` in order to get binomial coefficients. + + +\secc[delims] Vertically scalable objects: math delimiters + +The vertically scalable objects are called {\em delimiters}. For example, +all types of brackets are declared as delimiters. +This means that you can use a bracket in arbitrary +vertical size.\fnote{ +This is not exactly true, because traditional typography says that they +cannot be scaled continuously but by visible steps. This means that there is +a sequence of increasing brackets in the font, reader must see a difference +between each two sizes of brackets.} + +The following objects are declared as delimiters (i.e.\ vertically scalable): + +\bigskip +{\tt \adef!{\bslash} +\table{l 14c}{ + \rm source: & ( & ) & [ & ] & \code{\\\{} & \code{\\\}} & / + & !backslash & !langle & !rangle + & | & \code{\\|} & \cr + \rm output: &$($&$)$&$[$&$]$& $\{$ & $\}$ & $/$ + & $\backslash$ & $\langle$ & $\rangle$ + & $|$ & $\|$ +} +\medskip +\table{l 14c}{ + \rm source: & !lfloor & !rfloor & !lceil & !rceil \cr + \rm output: & $\lfloor$ & $\rfloor$ & $\lceil$ & $\rceil$ +} +\medskip +\table{l 14c}{ + \rm source: & !uparrow & !Uparrow & !dowarrow & !Downarrow + & !updownarrow & !Updownarrow \cr + \rm output: & $\uparrow$ & $\Uparrow$ & $\downarrow$ & $\Downarrow$ + & $\updownarrow$ & $\Updownarrow$ +}} +\bigskip +\noindent \new Unicode +If you are able to produce the characters $\langle$, $\rangle$,\fnote + {Do not confuse $\string<, >$ and $\langle, \rangle$. The first pair are Rel atoms + with meaning \"less than" or \"greater than", but the second pair are special + types of brackets. They are not directly available at computer keyboards without + using a keyboard macro.} +$\lfloor$, $\rfloor$, ... $\updownarrow$, $\Updownarrow$ +directly in your text editor then you can use these Unicode characters in your source instead of control +sequences `\langle`, `\rangle`, `\lfloor`, `\rfloor` ... `\updownarrow`, `\Updownarrow`. +For many users (including me), there is more simple to type `\lfloor` than to find +how to create the $\lfloor$ character in my text editor. Note that there exist +text editors (Emacs, for example) +enabling you to type `\lfloor` and this control sequence is immediately +converted to the $\lfloor$ Unicode character. +Your source looks pretty and you can use classical \TeX/ sequences. + +\new Unicode +There are more delimiters, but it heavily depends on loaded Unicode Math +font. For example, this document is printed in `latinmodern-math` font and +there are six more delimiters `\lBrack`~$\lBrack$, `\rBrack`~$\rBrack$, +`\lAngle` $\lAngle$, `\rAngle` $\rAngle$, `\lgroup` $\lgroup$, `\rgroup` $\rgroup$. +See section~\ref[objects] for table of all Unicode symbols for math typesetting. + +Arbitrary tall formula can be surrounded by a pair of delimiters using +`\left` and `\right` \TeX/ primitives: `\left<delim> <formula> \right<delim>`. +The delimiters are scaled to the height and depth of the <formula> +and vertically centered to the {\em math axis}.\fnote +{Math axis is a horizontal line passing through the center of symbols $+$ + and $-$. All vertically scalable objects are vertically centered with + respect to this axis.} +Example: +$$ + `+ \left\{ \sum_{i=1}^\infty x_i \right)` \quad \hbox{ gives } + + \left\{ \sum_{i=1}^\infty x_i \right). +$$ +The pair `\left<delim> <formula> \right<delim>` creates the formula in a +\TeX/ group. Such group can be nested with another groups. +Each `\left` must have its `\right` counterpart at the same group level. +If you don't want to create visible delimiter, use dot instead <delim>. +Example: +$$ + `\left. \int``_0^t e^{x^2}\,dx\, \right|_{t=42}` \quad \hbox{ gives } + \left. \int_0^t e^{x^2} \,dx\, \right|_{t=42} +$$ + +\new e\TeX/ +You can use `\middle<delim>` inside the <formula> which is surrounded by +`\left...\right`. Then the given <delim> is scaled to the same size like +their `\left` and `\right` counterparts. + +When a delimiter is used without `\left` nor `\right` prefix, then it is the +Open, Close, Ord or Bin atom by its natural meaning: +$(, [, \{, \ldots, \lfloor, \lceil$ are Open atoms, +$], ], \}, \ldots, \rfloor, \rceil$ are Close atoms, +$/, \backslash, |, \|$ are Ord atoms and +$\uparrow, \Uparrow, \ldots, \Updownarrow$ are Bin atoms. You can overwrite +this default setting, for example `\mathclose(`. If delimiters are used with +`\left` and `\right` prefixes then `\left<delim>` behaves like Open atom, +`\right<delim>` behaves like Close atom and the math list +`\left<delim><formula>\right<delim>` is encapsulated as a single Inner atom. +The `\middle<delim>` behaves like Open atom at its left side and like Close +atom at its right side. + +The sequence of increasing delimiters can be printed by the following +macros: +$$ + `(` \to (,\quad `\big(` \to \big(,\quad `\Big(` \to \Big(,\quad + `\bigg(` \to \bigg(, \quad `\Bigg(` \to \Bigg(. +$$ +The `\Bigg<delim>` is not maximal size of the bracket. Try +`\left(\vbox to5cm{}\right.`, for example. You can see that the font +\"cheats" from certain sizes, because there are not all infinity number of +sizes of brackets drawn in the font, of course. + +The `\big<delim>` creates Ord atom. We need to create Open atom +for opening bracket and Close atom for closing bracket more often. +Then we can use macros +`\bigl<delim>`, +`\Bigl<delim>`, +`\biggl<delim>`, +`\Biggl<delim>` for creating Open atoms and +`\bigr<delim>`, +`\Bigr<delim>`, +`\biggr<delim>`, +`\Biggr<delim>` for creating Close atoms. Unfortunately, the source is not +too attractive when more sizes of brackets are used, but typographic +traditions say that we have to distinguish brackets by the size in math +mode if they are in equal types: +$$ + `\Bigl( f\bigl( 2(x+y) + z\bigr) \Bigr)'` \quad \hbox{gives } + \Bigl(f\bigl(2(x+y)+z\bigr)\Bigr)'. +$$ + +\secc Horizontally scalable objects: math accents + +Arbitrary wide formula can be covered by {\em scalable math accent}. +Example: +$$ + `\overrightarrow {a+b+c+d+e+f}` \quad \hbox{gives } \overrightarrow {a+b+c+d+e+f}. +$$ +The usage is: control sequence of selected math accent followed by `{<math list>}`. + +Standard scalable math accents are: +`\overline` $\overline{abc}$, +`\overbrace` $\overbrace{abc}$, +`\overrightarrow` $\overrightarrow{abc}$, +`\overleftarrow`~$\overleftarrow{abc}$, +`\underline` $\underline{abc}$, +`\underbrace` $\underbrace{abc}$. + +A Op atom is created. The exponents and subscripts are centered above +and below the nucleus of this atom (regardless of the current style). Example: +$$ + `\overbrace {b\cdot b\cdot b \cdots b}^{k\times}` \quad \hbox{gives } + \overbrace {b\cdot b\cdot b \cdots b}^{k\times} +$$ +There are scalable accents with limited maximum width: +`\widehat` $\widehat{abc}$ and `\widetilde` $\widetilde{abc}$. If the +formula is wider than the font is able to cover then widest variant from the +font is used and it is horizontally centered. + +\new Unicode +There are more scalable accents in Unicode math fonts: +`\overparen` $\overparen{abc}$, `\underparen` $\underparen{abc}$, +`\overbracket` $\overbracket{abc}$, `\underbracket` $\underbracket{abc}$, +`\overleftrightarrow` $\overleftrightarrow{abc}$, +`\overleftharpoon` $\overleftharpoon{abc}$, +`\overrightharpoon` $\overrightharpoon{abc}$, + + +\secc Fixed math accents + +Fixed math accents can be applied to single math object or to the `{<math list>}`. +The accent is centered (with respect of slanting axis) and the result is a +nucleus of Ord +atom. For example `\dot x` gives $\dot x$. The list of fixed math accents +follows: `\acute x` $\acute x$, `\bar x` $\bar x$, +`\breve x` $\breve x$, `\check x` $\check x$, +`\dot x` $\dot x$, `\ddot x` $\ddot x$, +`\grave x` $\grave x$, `\hat x` $\hat x$, +`\vec x` $\vec x$, `\tilde x` $\tilde x$. + +\new Unicode +The additional fixed accents depends on used Unicode math font. The +`latinmodern-math` supports: +`\ovhook x` $\ovhook x$, `\ocirc x` $\ocirc x$, +`\leftharpoonaccent x` $\leftharpoonaccent x$, `\rightharpoonaccent x` $\rightharpoonaccent x$, +`\dddot x` $\dddot x$, `\ddddot x` $\ddddot x$, +`\widebridgeabove x` $\widebridgeabove x$, `\asteraccent x` $\asteraccent x$. + +There exist one special math accent `'` (single quote, ASCII 39) +which can be appended after a symbol like this: `f'` +and it creates $f'$ (typical meaning is the +derivation of the given function). You can put more such accents, for +example `g'''` gives $g'''$. + +\secc Roots + +There is a macro `\sqrt{<math list>}` to create square root. For example: +$$ + `\sqrt{\sqrt{\sqrt{x+1}+1}+1}` \quad \hbox{gives } + \sqrt{\sqrt{\sqrt{x+1}+1}+1} +$$ +The $n$-th root is created by the macro `\root <n>\of{<math list>}`. For +example `\root k+1\of x` gives $\root k+1\of x$. + +\secc Math alphabets + +Letters $a\dots z$, $A\dots Z$ and $\alpha$\dots$\omega$ are printed in italic +in math mode. This follows the traditional typographic rule. +All other math symbols, digits and uppercase Greek letters must be +upright.\fnote +{French typographic convention says that uppercase Greek letters have to be + in italic too. Use `\_itGreek` declaration in this case.} +These rules are independent of the current variant of surrounding text font. + +If we want to use the letters or digits +in another than this default shape, then we can use +{\em math alphabet selectors}: `\mit`, `\rm`, `\it`, `\bf`, `\cal`. +\new \OpTeX/ +\OpTeX/ supports more such selectors `\script`, `\frak`, `\bbchar`, `\bi`, see +section 1.3.3 in the \OpTeX/ documentation. The math selectors have local +validity in the group. + +The control sequences `\rm`, `\it`, `\bf`, and `\bi` act as variant selectors +of fonts in non-math mode (text mode) and they act +as math alphabet selectors in math mode. This \"overlaying" concept +is given by Plain \TeX/. Example: math operators lim, sin, cos, +log, etc.\ must be printed unslanted. We are using `\lim`, `\sin`, `\cos`, +`\log` etc.\ in math mode in order to comply this typographic convention. For +example `\sin` is defined as: +\begtt +\def\sin {\mathop{\rm sin}\nolimits} +\endtt +The `\rm` is used here as math alphabet selector, no variant selector of +text fonts. + +The list of all predefined `\rm`-like math operators follows: `\arccos`, +`\arcsin`, `\arctan`, `\arg`, `\cos`, `\cosh`, `\cot`, `\coth`, `\deg`. +`\det`, `\dim`, `\exp`, `\gcd`, `\hom`, `\inf`, `\ker`, `\lg`, `\lim`, +`\liminf`, `\limsup`, `\ln`, `\log`, `\max`, `\min`, `\Pr`, `\scs`, `\sin`, +`\sinh`, `\sup`, `\tan`, `\tanh`, You can define another such operator +analogically. + +\new Unicode +Unicode font can include the following math alphabets: +\begtt \typosize[9/11] +\_rmvariables % upright letters A-Z, a-z +\_bfvariables % bold letters A-Z, a-z +\_itvariables % italic letters A-Z, a-z +\_bivariables % bold italic letters A-Z, a-z +\_calvariables % calligraphic letters A-Z, a-z +\_bcalvariables % calligraphic letters A-Z, a-z +\_frakvariables % fraktur A-Z, a-z +\_bfrakvariables % bold fraktur A-Z, a-z +\_sansvaraibales % sans serif letters A-Z, a-z +\_bsansvaraibales % bold sans serif letters A-Z, a-z +\_isansvaraibales % slanted sans serif letters A-Z, a-z +\_bisansvaraibales % bold slanted sans serif letters A-Z, a-z +\_ttvariables % monospace, typewriter letters A-Z, a-z +\_bbvariables % double struck A-Z, a-z +\_rmdigits % upright digits 0..9 +\_bfdigits % bold digits 0..9 +\_sansdigits % sans serif digits 0..9 +\_bsansdigits % bold sans serif digits 0..9 +\_ttdigits % monospace typewriter digits 0..9 +\_bbdigits % double-struck digits 0..9 +\_rmgreek % upright Greek letters \alpha-\omega +\_itgreek % slanted Greek letters \alpha-\omega +\_bfgreek % bold Greek letters \alpha-\omega +\_bigreek % bold italic Greek letters \alpha-\omega +\_bsansgreek % bold sans serif Greek letters \alpha-\omega +\_bisansgreek % bold slanted snas serif Greek letters \alpha-\omega +\_itGreek % slanted Greek letters \Alpha-\Omega +\_bfGreek % bold Greek letters \Alpha-\Omega +\_biGreek % bold italic Greek letters \Alpha-\Omega +\_bsansGreek % bold sans serif Greek letters \Alpha-\Omega +\_bisansGreek % bold slanted snas serif Greek letters \Alpha-\Omega +\endtt +% +Not all Unicode math fonts include all math alphabets listed here. Typically, +the lowercase letters of calligraphic shape and all letters of +bold calligraphic shape are missing. + +\new \OpTeX/ +\OpTeX/ defines internal math alphabet selectors as mentioned in the +previous listing of math alphabets and sets as default: +\begtt \typosize[10/12] +\_itvariables \_rmdigits \_itgreek \_rmGreek +\endtt +% +Moreover, it defines the alphabet selectors at user level (see section 1.3.3 +of the \OpTeX/ manual). For example +\begtt \typosize[10/12] +\def\rm {\_tryload\_tenrm \_inmath{\_rmavariables \_rmdigits}} +\endtt +% +The first part +\new \OpTeX/ +`\_tryload\_tenrm` is applicable for text fonts and the +`\_inmath` part is processed only in math mode and sets the math alphabets. +You can see the file `unimath-codes.opm` where all user level selectors are +defined. You can redefine them. For example, \OpTeX/ defines `\bf` as a math +alphabet selector which selects sans serif bold in math. This is common +notation for vectors, tensors and matrices. If you dislike this, then you can define: +\begtt \typosize[10/12] +\def\bf {\_tryloadbf\_tenbf \_inmath{\_bfvariables\_bfdigits\_bfgreek\_bfGreek}} +\endtt + + +\secc[objects] List of single math objects + +\new Unicode +All single math objects is listed in the `unimath-table.opm` or +`unicode-math-table.tex` file. You can +look into this file. The codes, \TeX/ sequences, classes and comments +for all possible math codes are here. Maybe, your Unicode math font which is loaded, +does not support all these codes. +\new \OpTeX/ +You can try all codes of currently loaded font by +\begtt +\input print-unimath.opm +\endtt +The `unimath-table` is printed with characters available in loaded font. +\new \OpTeX/ +If the character is unsupported by the font then the slot is empty and only +\TeX/ sequence and the class of the code is printed in the table. +For example, this document loads `latimodern-math.otf` font. +And the result from `\input print-unimath.opm` looks like the following ten +pages. + +\bigskip +\input print-unimath.opm +\bigskip + +It isn't very comfortable to find something in the previous table +if you know the shape. You can try the online web tool +\ulink[https://detexify.kirelabs.org/classify.html]{Detexify}. +You can draw the symbol here and the suggestion of \TeX/ sequence is +printed. + +\def\g#1{{\tt\string#1}~$#1$} + +The generic \TeX/ sequences for the Greek letters can be used: +\g\alpha, \g\beta, \g\gamma, \g\delta, \g\varepsilon, \g\zeta, \g\eta, +\g\theta, \g\iota, \g\kappa, \g\lambda, \g\mu, \g\nu, \g\xi, +\g\omicron, \g\pi, \g\rho, \g\varsigma, \g\sigma, \g\tau, \g\upsilon, +\g\varphi, \g\chi, \g\psi, \g\omega, \g\vardelta, \g\epsilon, \g\vartheta, +\g\varkappa, \g\phi, \g\varrho, \g\varpi\ +and +\g\Alpha, \g\Beta, \g\Gamma, \g\Delta, \g\Epsilon, \g\Zeta, \g\Eta, \g\Theta, +\g\Iota, \g\Kappa, \g\Lambda, \g\Mu, \g\Nu, \g\Xi, \g\Omicron, \g\Pi, \g\Rho, +\g\Sigma, \g\Tau, \g\Upsilon, \g\Phi, \g\Chi, \g\Psi, \g\Omega. + +\new \OpTeX/ +The variant of Greek letters in the output +(upright, italic, bold, bold sans serif, etc.) +written by the sequences `\alpha`, `\beta` etc. depends on the math alphabet +selected by `\_itgreek`, `\_rmgreek`, etc. selectors. The user-level +selectors `\bf` and `\bi` set `\_bsansgreek` and `\_bisansgreek`, so +`{\bi\delta}` produces $\bi\delta$. + +\new Unicode +All characters available in the math font can be accessed by \TeX/ control +sequence or by direct using the Unicode character in the document source. +Example: +\begtt \adef/{} +$$ + \sum/_{k=0}^\infty e^{(\alpha+i\beta/_k)} = + e^\alpha \sum/_{k=0}^\infty e^{i\beta/_k} = + e^\alpha \sum/_{k=0}^\infty (\cos\beta/_k + i\sin\beta/_k). +$$ +\endtt +or +\begtt \ttspec +$$ + ∑_{k=0}^∞ e^{(α + iβ_k)} = e^α ∑_{k=0}^∞ e^{iβ_k} + = e^α ∑_{k=0}^∞ (\cos β_k + i\sin β_k). +$$ +\endtt +both gives the same result: +$$ + ∑_{k=0}^∞ e^{(α + iβ_k)} = e^α ∑_{k=0}^∞ e^{iβ_k} + = e^α ∑_{k=0}^∞ (\cos β_k + i\sin β_k). +$$ +\medskip + + +\sec Other specialities + +\secc The `\not` prefix + +You can apply `\not` to the following math object. +The slash $/$ is overprinted such math object, for example +`$a \not= b$` gives $a \not= b$. + +\new \OpTeX/ +If there exist a direct Unicode character for negation of a relation symbol +(for example `\ne` creates $\ne$ directly as a character U+2260) +then `\not<char>` expands to appropriate Unicode character. +For example `\not=` expands to `\ne` or `\not\in` expands to `\notin`. +If such character does not exist then +the centered $/$ is overprinted over the next character. + + +\secc The `\bulidrel` macro: text over relation + +The macro `\buildrel <text>\over <relation>` creates a new atom Rel with the +<relation> and with the smaller <text> above this <relation>. Example: +`$M \buildrel\rm def\over= X\cup Y$` gives $M\buildrel\rm def\over= X\cup Y$. + + +\secc Spaces + +Spaces between atoms are created automatically as were mentioned in +section~\ref[class]. But sometimes you have to help \TeX/ to create +appropriate space. You can use following macros: + +\begitems +* `\,` is {\em thin space} used around Op atoms, after comma, etc.: \ss\,, +* `\!` is negative thin space, +* `\>` is {\em medium space} used around Bin atoms: \ss\>, +* `\;` is {\em thick space} used around Rel atoms: \ss\;, +* `\quad` is {\em em space}: \ss\quad, +* `\qquad` is {\em double em space}: \ss\qquad. +\enditems +% +Of course, you can use {\em direct space} {\visiblesp`\ `} which is \TeX/ primitive +and gives interword space: \ss\ \ +or you can use `\hskip <value>` to put arbitrary space. + +The space size of `\,`, `\!` resp. `\>`, resp. `\;` is given by +`\thinmuskip`, resp. `\medmuskip`, resp. `\thickmuskip` values. You can see +in the `plain.tex` file that these default values differ very little in their basic +size but there is no stretchability/shrinkability in the `\,` space, there is small +stretchability in the `\>` space and more stretchability in the `\;` space. + +The registers `\thinmuskip`, `\medmuskip` and `\thickmuskip` store so called +{\em mu values} given by math unit `mu`. It is 1/18 em and this unit depends +on the current font size used in the math formula ($S$ or $SS$ styles use +smaller font size, the `mu` unit is smaller here). You can use `\muskip` +instead `\hskip` or `\mukern` instead `\kern` if you want to use this +special mu unit. It is allowed only in math mode. + +The `\quad` and `\qquad` spaces have fixed width and they can be used in text +mode too. (\OpTeX/ allows to use `\,` in text mode too). +Use `\quad` or `\qquad` if you want to separate more formulas created in +single math mode. Examples of typical usage of spaces: + +\begtt \adef/{} \typosize[10/12] +$$ \alpha\,(x+y), \qquad \int/_a^b \!\! f(x)\,{\rm d}x, \qquad \Gamma/_{\!i}. $$ +\endtt +$$ \alpha\,(x+y), \qquad \int_a^b \!\! f(x)\,{\rm d}x, \qquad \Gamma_{\!i}. $$ + + +\secc Texts in math mode + +If you write `$Hello world!$` (i.e.\ Hello world in math mode), then you get +$Hello world!$. It is interpreted as product of variables $H$ and $e$ and +$l^2$ and $o$ etc., followed by the symbol ! used for factorial. +The non-ASCII letters (with accents) don't work at all because they are +never used as symbols for variables. Spaces are ignored. + +If you want to write a short text in the math mode, then you can use +`\hbox{<text>}`. The `\hbox` primitive initializes text mode regardless of +the \"outer mode". Example: + +\begtt \adef/{} \typosize[10/12] +$$ \sum/_{n=0}^\infty (-1)^n a_n \hbox{ converges, if $a_n\searrow 0$.} $$ +\endtt +$$ \sum_{n=0}^\infty (-1)^n a_n \hbox{ converges, if $a_n\searrow 0$.} $$ +% +Note the space before the word \"converges". The space before `\hbox` is +irrelevant. Second notice: the example shows the text mode inside math mode +and the in-line math mode inside this text mode. The same result can be +produced by: + +\begtt \adef/{} \typosize[10/12] +$$ \sum/_{n=0}^\infty (-1)^n a_n \hbox{ converges, if } a_n\searrow 0. $$ +\endtt +% +The difference can be visible if the formula $a_n\searrow 0$ includes a +fraction, for example ${1\over2}a_n\searrow 0$. The first example prints the +fraction in the text style and the second example prints it the display style. + +The disadvantage of `\hbox` is that it starts in the text mode independently +of the current style, but we want to use smaller font in $S$ or $SS$ styles. +\new \OpTeX/ +You can use `\mathbox{<text>}` in such situations. This macro behaves like +`\hbox` but the text is appropriately smaller in $S$ and $SS$ styles. +Example: +$$ + `{\mathbox{cena}\over\mathbox{výkon}}` \quad \hbox{gives } + {\mathbox{cena}\over\mathbox{výkon}} \hbox{ in $D$ style and } + \textstyle {\mathbox{cena}\over\mathbox{výkon}} \hbox{ in $T$ style.} +$$ +Note that $\mathbox{cena}\over\mathbox{výkon}$ means $\rm price\over performance$ +and you can write `$\rm price\over performance$` when you are using only +words without spaces and accented letters. But phrases with spaces or accented letters +should be printed in text mode using `\hbox` or `\mathbox`. + +\secc `\vcenter` + +The `\vcenter` primitive behaves like `\vbox`, but it can be used only in +math mode and its result is vertically centered to the math axis. +For example, matrices, are created by tables in `\vcenter`. + +All big objects in math formula is centered to math axis and the baseline is +ignored. In the following example we create a new big math operator by +`\vcenter`: +\begtt +$$ + \def\myop#1{\mathop{\vcenter{\frame{\vbox to2em{\vss\hbox{ $#1$ }\vss}}}}} + F(x) = \myop{x(i)}_{i=1}^\infty +$$ +\endtt +\vskip-2em +$$ + \def\myop#1{\mathop{\vcenter{\frame{\vbox to2em{\vss\hbox{ $#1$ }\vss}}}}} + F(x) = \myop{x(i)}_{i=1}^\infty +$$ + + +\secc Three dots + +You can write `$1,2,\dots,n$` to get $1,2,\dots,n$. The `\dots` macro puts +thin space between dots and after the last dot, so the five object: comma, +dots, comma are exactly equidistant. + +Typographic conventions say that you have to use the repeating symbol +before and after three dots (comma in previous example) and the three dots +should be at baseline, if the repeating symbol is at baseline. Or they should be +at math axis, if the repeating symbol is at math axis. We have to use `\cdots` instead +`\dots` in second case. Example: +$$ + `a_1, a_2, \dots, a_n, \quad a_1 + a_2 + \cdots + a_n` \qquad + a_1, a_2, \dots, a_n, \quad a_1 + a_2 + \cdots + a_n +$$ +\vskip-.7em +There are `\vdots` $\vdots$, `\ddots` $\ddots$ and `\adots` $\adots$ which +can be used in matrices. + +\new Unicode +Three dots like the output of the `\dots` macro are present as a single +character in fonts too. This character is called ellipsis. Font designers +typically suggest this character with smaller spaces between dots than we +need in math mode. So the rule about equidistant \"comma, three dots, comma" +is not met when this character is used. You can try `$1,2,\unicodeellipsis, n$` +and `$1+2+\unicodecdots + n$`. You get $1,2,\unicodeellipsis, n$ and +$1+2+\unicodecdots + n$. If you feel that this is better, then you can set: +`\let\dots=\unicodeellipsis \let\cdots=\unicodecdots`. + +The Unicode fonts includes compact variants `\unicodevdots` $\unicodevdots$, +`\unicodeddots` $\unicodeddots$ and `\unicodeadots` $\unicodeadots$ too. + + +\secc Phantoms and `\smash` + +The `\phantom{<math list>}` macro creates an invisible subformula equal to +the formula generated by <math list>. It has its size, so it can +interfere with surrounding visible subformulas. This macro is very useful for +aligning with special requirements. Examples are shown in +sections~\ref[matrix] and~\ref[elines]. + +The `\vphantom{<math list>}` has only its vertical size (i.e.\ its height +and depth), the width is zero. The `\hphantom{<math list>}` has only its +width. + +The `\smash{<math list>}` is the opposite of `\vphantom`. It creates visible +subformula but it has only its width. Its height and depth are zero. + +The result of these macros is the nucleus of an Ord atom. You can use `\mathop`, +`\mathbin`, etc. primitives to change this class. For example +`$a\mathrel{\phantom{=}}b$` creates the same formula as $a=b$ with the same +distance from $a$ to $b$ but without the equal sign: +$a\mathrel{\phantom{=}}b$. + +These macros work in the text mode too. Then their argument is +the <horizontal list>. + + +\sec Structured objects + +\secc[matrix] Matrices + +The macro `\matrix{<data>}` creates a vertically centered table of items. +The <data> includes <items> separated by `&` and rows are separated by +`\cr`. The number of columns and rows are unlimited. Columns are printed centered +and separated by the `\quad` space. The vertically scalable +brackets around the table are not printed. You can use `\pmatrix{<data>}` +instead `\matrix{<data>}`: the vertically scalable parentheses () are inserted +around the table. Examples: + +\begtt +$$ + {\bf A} = \pmatrix{a_{1,1} & a_{1,2} & \cdots & a_{1,n} \cr + a_{2,1} & a_{2,2} & \cdots & a_{2,n} \cr + \vdots & \vdots & \ddots & \vdots \cr + a_{m,1} & a_{m,2} & \cdots & a_{m,n} }, +$$ +\endtt +$$ + {\bf A} = \pmatrix{a_{1,1} & a_{1,2} & \cdots & a_{1,n} \cr + a_{2,1} & a_{2,2} & \cdots & a_{2,n} \cr + \vdots & \vdots & \ddots & \vdots \cr + a_{m,1} & a_{m,2} & \cdots & a_{m,n} }, +$$ +or: + +\begtt +\def\qmatrix[#1]{\left[\matrix{#1}\right]} +$$ + \qmatrix[a&b&c\cr d&e&f\cr g&h&i] \cdot \qmatrix[x_1\cr x_2\cr x_3] + = \qmatrix[b_1\cr b_2\cr b_3]. +$$ +\endtt +$$ + \def\qmatrix[#1]{\left[\matrix{#1}\right]} + \qmatrix[a&b&c\cr d&e&f\cr g&h&i] \cdot \qmatrix[x_1\cr x_2\cr x_3] + = \qmatrix[b_1\cr b_2\cr b_3]. +$$ + +If you need to aling the columns by another way than to center, then you can +use phantom. Compare: + +\begtt +$$ + \pmatrix{ 1 & -1 & 0 \cr + 0 & 2 & 13 \cr + -3 & 0 & 5 } \quad \hbox{or} \quad + \def\0{\phantom0} \def\+{\phantom+} + \pmatrix { \+1 & -1 & \00 \cr + \+0 & \+2 & 13 \cr + -3 & \+0 & \05 } +$$ +\endtt +$$ + \pmatrix{ 1 & -1 & 0 \cr + 0 & 2 & 13 \cr + -3 & 0 & 5 } \quad \hbox{or} \quad + \def\0{\phantom0} \def\+{\phantom+} + \pmatrix { \+1 & -1 & \00 \cr + \+0 & \+2 & 13 \cr + -3 & \+0 & \05 } +$$ + +\new\OpTeX/ +Another option to set right aligned matrix is setting the `\lmfil`: +Its value is used at left side in each `\matrix` item. The right side is +set directly to `\hfil`. +\begtt +$$ + \lmfil={\hfill} % left matrix filler = \hfill + \pmatrix{ 1 & -1 & 0 \cr 0 & 2 & 13 \cr -3 & 0 & 5 } +$$ +\endtt + +\new \OpTeX/ +If you want to draw a vertical line inside the matrix, you can use `\adef|` +as in the following example: +\begtt +$$ + \adef|{\kern-.2em&\strut\vrule&\kern-.2em} + \def\+{\phantom+} + \pmatrix{1 & 2 & 3 | 0 \cr 4 & 5 & 6 | 1 \cr 7 & 8 & 9 | 2 } \sim + \pmatrix{1 & \+2 & \+3 | 0 \cr 0 & -3 & -6 | 1 \cr 0 & -6 & -12 | 2} \sim + \pmatrix{1 & 2 & 3 | 0 \cr 0 & 1 & 2 | -1/3 \cr 0 & 0 & 0 | 1 } +$$ +\endtt +$$ + \adef|{\kern-.2em&\strut\vrule&\kern-.2em} + \def\+{\phantom+} + \pmatrix{1 & 2 & 3 | 0 \cr 4 & 5 & 6 | 1 \cr 7 & 8 & 9 | 2 } \sim + \pmatrix{1 & \+2 & \+3 | 0 \cr 0 & -3 & -6 | 1 \cr 0 & -6 & -12 | 2} \sim + \pmatrix{1 & 2 & 3 | 0 \cr 0 & 1 & 2 | -1/3 \cr 0 & 0 & 0 | 1 } +$$ + +If you want to put something before opening bracket in the matrix, you can +use another `\matrix`. Example: + +\begtt +$$ + \adef|{\kern-.2em&\strut\vrule&\kern-.2em} + \def\+{\phantom+} + \def\r{{\bf r}} + \pmatrix{1 & 2 & 3 | 0 \cr 4 & 5 & 6 | 1 \cr 7 & 8 & 9 | 2 } \ \sim \ + \matrix{\cr 2.\r - 4\cdot 1.\r: \cr 3.\r -7\cdot 1.\r: } + \pmatrix{1 & \+2 & \+3 | 0 \cr 0 & -3 & -6 | 1 \cr 0 & -6 & -12 | 2} +$$ +\endtt +$$ + \adef|{\kern-.2em&\strut\vrule&\kern-.2em} + \def\+{\phantom+} + \def\r{{\bf r}} + \pmatrix{1 & 2 & 3 | 0 \cr 4 & 5 & 6 | 1 \cr 7 & 8 & 9 | 2 } \ \sim \ + \matrix{\cr 2.\r - 4\cdot 1.\r: \cr 3.\r -7\cdot 1.\r: } + \pmatrix{1 & \+2 & \+3 | 0 \cr 0 & -3 & -6 | 1 \cr 0 & -6 & -12 | 2} +$$ + +Plain \TeX/ defines the `\bordermatrix` macro which allows you to create a +top row above the brackets and left column before the opening bracket. +\TeX/book shows the following example: + +\begtt +$$ + M = \bordermatrix{ &C&I&C'\cr + C&1&0&0 \cr I&1-b&0 \cr C'&0&a&1-a } +$$ +\endtt +$$ + M = \bordermatrix{ &C&I&C'\cr + C&1&0&0 \cr I&1-b&0 \cr C'&0&a&1-a } +$$ + +The `\matrix` macro used in $D$ style creates all its items in $T$ style. +\new \OpTeX/ +If you are using the `\matrix` macro in $T$ style or $S$ style (but not in +fractions nor another matrices) then the resulting table is appropriately +smaller and all its items are processed in $S$ style. +If you are using `\matrix` in $SS$ style then the items are in $SS$ style too. +The following example shows one-column matrix in script style: +$$ + `\sum``_{\matrix{i\in M\cr j\in N\cr k\in P}} x_{i,j,k}` \ \hbox{ creates: } + \sum_{\matrix{i\in M\cr j\in N\cr k\in P}} x_{i,j,k} +$$ + + +\secc Cases + +The `\cases` macro can be used as in the following example: + +\begtt +$$ + f(x) = \cases{ 1 & for $x\le 0$, \cr + 100-x\over 100 & when $0 < x \le 100$, \cr + 0 & in other cases. } +$$ +\endtt +$$ + f(x) = \cases{ 1 & for $x\le 0$, \cr + 100-x\over 100 & when $0\string< x\le 100$, \cr + 0 & in other cases. } +$$ + +The `\cases` macro behaves like a special `\matrix` with two left aligned +columns and with left vertically scaled brace $\{$. +First column is processed in math mode and $T$ style, second column +is processed in text mode. We have to use `$...$` in the second column if +there is a math material. + + +\sec Lines in display mode + +\secc General principles + +The `$$<formula>$$` finalizes previous paragraph, prints centered <formula> on +single line with a vertical space above and below and opens next paragraph +with no indentation. + +From \TeX/'s point of view, the text above plus `$$<formula>$$` plus text +below is single paragraph interrupted by display <formula>. If there is no +text above (i.e. the opening `$$` are in vertical mode), then the internal +`\noindent` is processed first and empty line above <formula> is created. +Thus, it is definitely bad idea to open display mode in vertical mode: never +put empty line before `$$<formula>$$`. On the other hand, the empty line +just after `$$<formula>$$` says that the paragraph is finalized by the +<formula> and the next text (after the empty line) opens next paragraph with +indentation. Summary: + +\begitems +* \"Text above `$$<formula>$$` text below": the <formula> interrupts the + paragraph with \"Text above" and \"text below". The \"text below" is + without indentation. +* \"Text above `$$<formula>$$` empty line Text below": the \"Text below" + opens new paragraph with indentation. +* \"Empty line `$$<formula>$$`" is bad practice. +\enditems + +In contrast with the paragraph breaking, there is no built-in algorithm for +breaking display <formula> to more lines. If the <formula> is too wide then +overfull `\hbox` occurs and human must decide about splitting the <formula> +to more lines. The macros `\displaylines` and `\eqalign` are intended to +such task, see sections~\ref[dlines] and~\ref[elines]. + +On the other hand, the in-line math <formula>, i.e.\ the `$<formula>$` in a +paragraph, can be broken after a Bin atom (with penalty `\binoppenalty`) or +after a Rel atom (with penalty `\relpenalty`). If you don't want to break +such formula at a specific place then use `\nobreak`, for example +`$a+\nobreak b$`. If you want never to break such formulas then you can set +`\binoppenalty=10000`, `\relpenalty=10000`. (Default values are 700 and 500.) + + +\secc References to display lines + +The `$$<formula>\eqno<mark>$$` prints centered <formula> and the <mark> at +right margin. The `$$<formula>\leqno<mark>$$` prints centered <formula> and +the <mark> at left margin. Examples: + +\begtt +$$ a^2 + b^2 = c^2 \eqno (1) $$ +\endtt +$$ + a^2 + b^2 = c^2 \eqno (1) +$$ +\begtt \aftergroup\nobreak +$$ a^2 + b^2 = c^2 \leqno \rm Py $$ +\endtt +$$\predisplaypenalty=10000 + a^2 + b^2 = c^2 \leqno \rm Py +$$ +The <mark> is processed in math mode and $T$ style. If you want to put a +text here then you have to use `\rm <text>` or `\hbox{<text>}`. + +\new \OpTeX/ +The auto-generated <mark> can be created by `$$<formula>\eqmark$$`. The +<label> previously declared by `\label[<label>]` can be used. +Then it is associated to such +auto-generated <mark> and you can write a reference in the form +`see equation~\ref[<label>]`. You can write `\eqmark[<label>]` instead of +`\label[<label>]...\eqmark`. See the \OpTeX/ manual, section~1.4.3. + +\secc[dlines] The `\displaylines` macro + +This macro creates more horizontally centered formulas in one display mode. +The syntax is +\begtt \catcode`\<=13 +$$ \displaylines{ + <formula> \cr + <formula> \cr + ... \cr + <formula> +} $$ +\endtt +Usage of `\displaylines` is more +prefered than doing more display modes just behind each other. +Example: +\begtt +$$ \displaylines{ + (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \cr + = 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30. +} $$ +\endtt +$$ \displaylines{ + (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \cr + = 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30. +} $$ + +The output from `\displaylines` macro is breakable to more pages because +the lines are not encapsulated in one box. The macro uses a special feature of +`\halign` primitive. The disadvantage is that you cannot use `\eqno` nor +`\leqno` nor `\eqmark`. + +\new \OpTeX/ +\OpTeX/ provides alternative form: `\displaylines to<dimen> {<data>}`. +Then the centered formulas are encapsulated in a `\vcenter` box of width <dimen> and +usage of `\eqno` or `\leqno` or `\eqmark` is allowed. +The individual lines have the form `\hbox to<dimen>` and formulas are centered using +`\hss` from both sides. This means that you can set arbitrary <dimen> +without visual change of the formulas. Use smaller <dimen> value than +`\hsize` (or `\displaywidth`\fnote +{`\displaywith` = `\hsize` in most cases but it is +real display width when `\parshape` or `\hangindent` is used.}) +if you want to center formulas with `\eqno` appended. +The internal \TeX/ rule says: the formula with `\eqno` (or `\leqno`) is centered +if its width is less or equal `\displaywidth-4<mark-width>`. So +\begtt \catcode`\<=13 +$$ \displaylines to\hsize-8em {<formula>\cr<formula>}\eqno (1) $$ +\endtt +does global centering, because size of `(1)` is less than 2\,em. +You can do more experiments with this example, +for example `\diplaylines to\hsize{...}` +puts the `\eqno` mark to the next line in the display environment. Read +\TeX/book or \TeX/book naruby, where the precise explanation about such +positioning is. + +\new \OpTeX/ +You can use \"`\displaylines to<dimen>`" for more applications. For example, +you can put more +\"`\displaylines to<dimen>`" in single display mode, one next to second in order +to creating more centered columns with formulas; the width of such columns +are controlled by the <dimen> parameter. +Or, you can give an exception for first and last formula: + +\begtt \catcode`\<=13 +$$\displaylines to 10cm {<formula>\hfill \cr + <formula>\cr + <formula>\cr + \hfill <formula>} +$$ +\endtt +The example above gives similar result as the \LaTeX/ `multline` environment: +$$\displaylines to \hsize { + (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \hfill \cr + = 3x^9 + 3x^5 + 15x^3 + 4x^8 + 4x^4 + 20x^2 + 5x^7 + 5x^3 + 25x + + 6x^6 + 6x^2 + 30 = \cr + \hfill = 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30. } +$$ + + +\secc[elines] The `\eqalign` macro + +The usage is: +\begtt \catcode`\<=13 +$$ \eqalign { <left-side> & <right-side> \cr + <left-side> & <right-side> \cr + ... \cr + <left-side> & <right-side> +} $$ +\endtt +The `\vcenter` box is created with two columns, left column is right aligned +and right column is left aligned. Example: + +\vbox{ +\begtt +$$ \eqalign{ + x + 2y + 3z &= 600 \cr + 12x + y - 3z &= 7 \cr + 4x - y + 5z &= -5 \cr +} $$ +\endtt +\vskip-5.7\baselineskip +{\hsize=1.35\hsize +$$ \eqalign{ + x + 2y + 3z &= 600 \cr + 12x + y - 3z &= 7 \cr + 4x - y + 5z &= -5 \cr +} $$}} + +\bigskip\noindent +The tab \"`&`" should be used just before a relation, i.e. `&=` is right, `=&` +is wrong. All lines are aligned to the used tab. + +Maybe you want more precise alignment in the example above. You can use +`\phantom`: + +\par\nobreak\vbox{ +\begtt +$$ \def\1{\phantom1} \def\+{\phantom+} + \eqalign{ + x + 2y + 3z &= 600 \cr + 12x + \1y - 3z &= \+7 \cr + 4x - \1y + 5z &= -5 \cr +} $$ +\endtt +\vskip-5.7\baselineskip +{\hsize=1.35\hsize +$$ \def\1{\phantom1} \def\+{\phantom+} + \eqalign{ + x + 2y + 3z &= 600 \cr + 12x + \1y - 3z &= \+7 \cr + 4x - \1y + 5z &= -5 +} $$}} +\bigskip +Another typical usage of the `\eqalign` macro: + +\begtt \typosize[10/12] +$$ \eqalign{ + p(x)\,q(x) &= (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \cr + &= 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30. +} $$ +\endtt +$$ \eqalign{ + p(x)\,q(x) &= (3x^3 + 4x^2 + 5x + 6) \cdot (x^6 + x^2 + 5) = \cr + &= 3x^9 + 4x^8 + 5x^7 + 6x^6 + 3x^5 + 4x^4 + 20x^3 + 26x^2 + 25x + 30. +} $$ + +In \OpTeX/, \new\OpTeX/ +the `\eqalign` macro is more flexible. You can set the +`\baselineskip` value by the `\eqlines` parameter and math style +by the `\eqstyle` parameter. +For example, you need to put the system of \"equations" as an subscript of sum +operator: +\begtt \typosize[10/12] \adef/{} +$$ + \sum/_{\eqlines{\baselineskip=.7\baselineskip}\eqstyle{\scriptstyle}\eqalign{ + i &\in A \cr + \quad j &\in B\cup C \cr + m &\in C }} + i + j + m +$$ +\endtt +$$ + \sum_{\eqlines{\baselineskip=.7\baselineskip}\eqstyle{\scriptstyle}\eqalign{ + i &\in A \cr + \quad j &\in B\cup C \cr + m &\in C }} + i + j + m +$$ + +\indent \new\OpTeX/ +You can write more equation systems one next second: +\begtt +$$\eqalign{ + x + y + z &= 1 && a + b + c &= -1 \cr + u + v &= 20 && f + g &= -20 \cr + i &= j +}$$ +\endtt +You can use the third column for centered equations +without aligning point. For example: +\begtt \catcode`\<=13 +$$ \left( \eqspace=0pt \eqalign{&& <first equation>\cr + && <second equation>} \right) $$ +\endtt +The `\eqspace` is additional space used in the third column to separate +equation systems one next second. + +\new \OpTeX/ +\OpTeX/ extensions summary: +\begitems +* `\eqlines` and `\eqstyle` set baselineskip and math style of the formulas. +* `\eqalign` allows more than two columns: + First column is right aligned (no space). Second is left aligned (no space). + Third column (if used) + is centered with `\eqspace/2` at left and right boundary of the column. + Fourth is the same as first. Fifth is the same as second etc. The number + of columns which can be used in `\eqalign` is unlimited. +\enditems + +\secc The `\eqalign` macro with references + +You can give common mark to whole equation system by +`$$\eqalign{<data>}\eqno <mark>$$`. If you want to give marks to individual +lines of the equation system, then you can use another macro: +`\eqalignno`. The usage is similar as `\eqalign` but the +third column (if used) is intended to the equation mark. Example: + +\begtt +$$ \eqalignno{ + x + 2y + 3z &= 600 & \rm(A) \cr + 12x + y - 3z &= 7 & \rm(B) \cr + 4x - y + 5z &= -5 & \rm(C) \cr +} $$ +\endtt +\vskip-\baselineskip +$$ \eqalignno{ + x + 2y + 3z &= 600 & \rm(A) \cr + 12x + y - 3z &= 7 & \rm(B) \cr + 4x - y + 5z &= -5 & \rm(C) \cr +} $$ + +The `\leqalignno` macro is similar as `\eqalignno` but the marks are at the left +margin. The \OpTeX/ extensions of `\eqalign` are not available in +`\eqalignno` nor `\leqalignno` macros. + +\new \OpTeX/ +You can use auto-generated marks by `\eqmark` macro: +`$$\eqalign{<data>}\eqmark$$` or: +\begtt +$$ \eqalignno{ + x + 2y + 3z &= 600 & \eqmark[A] \cr + 12x + y - 3z &= 7 & \eqmark[B] \cr + 4x - y + 5z &= -5 & \eqmark[C] \cr +} $$ +\endtt + + +\sec Concept of loading math fonts + +\secc[fams] Math families + +\TeX/ is able to use more than one math font in math mode. This was a +necessity in old days when only 128-characters fonts existed. +Each math font used in math mode has its {\em math family} represented by a number. +Math family is a collection of three (almost) equal fonts in three sizes: +first for `\textstyle` and `\displaystyle`, second for `\scriptstyle` +and third for `\scriptscriptstyle`. + +\new Unicode +When Unicode math font is loaded then it includes all three optical sizes and +all characters needed for typeseting math formula. +Theoretically, we can use only one math family with this single font. But more math families +(i.e.\ more fonts in math mode) is still possible. You can combine +characters from more fonts (Unicode fonts and old TFM fonts together) in one math formula. + +\new \OpTeX/ +\OpTeX/ loads the specified Unicode math font into math family 1. The math +families 2 and 3 are reserved for specific \TeX/nical reasons, family 4 is +used for `\script` font and families 5, 6, 7, etc. can be used by user for +loading more fonts. The default macro for loading math fonts looks like: + +\begtt \typosize[10/12] +\_def\_normalunimath{% + \_loadumathfamily 1 {\_unimathfont}{} % Base Unicode math font + \_loadmathfamily 4 rsfs % \script (old TFM font) + \_setunimathdimens % set dimen parameters used in math formulas internally +}% +\let\_normalmath=\_normalunimath % this is done when Unicode math is initialized +\endtt +% +Whenever \OpTeX/ needs to resize math fonts (for example in footnotes or +titles), it calls the `\_normalmath` macro in order to reload all math +families to desired size. If you want to add a next font, you can add +`\_loadunimathfamily <family> {<Unicode-font>}{<features>}` or +`\_loadmathfamily <family> <TFM-font>` into the `\_normalmath` macro. +The example in section~\ref[newfam] shows how to do it. + +\secc Two variants of math fonts: normal and bold + +All math formulas in the whole document need only one Unicode font (or only one collection +of math fonts as mentioned in section~\ref[fams]). But this +is not really true if titles are in bold font. If a math formula is present in +such a bold title then all characters of this formula must be bolder. +For example \"normal" variables must be in bold italic in titles, symbols +like `+` `=` must be bold and \"normal bold" letters +(e.g., indicating vectors in math formula) must be extra bold in titles. +It means that all fonts from collection of math fonts must be bolder. +We need second collection of math fonts with bolder +shape. Unfortunately, it is not always available. + +\new \OpTeX/ +If you have bold variant of used Unicode math font, then you can use +`\loadboldmath` command, for example: +\begtt +\loadmath {[xitsmath-regular]} +\loadboldmath {[xitsmath-bold]} \to {[xitsmath-regular]} +\endtt +% +\OpTeX/ uses `\_normalmath` macro for loading collection of math fonts in +\"normal" cases and `\_boldmath` macro for bold titles. The font declared by +`\loadboldmath` is used in second case. But if the bold variant of the font is +not available (this is unfortunately more typical), then \OpTeX/ uses faked +bold of basic Unicode math font (the `embolden` internal font feature is +used). So, the default `\_boldmath` macro defined by \OpTeX/ looks like: + +\begtt \typosize[10/12] +\_def\_boldunimath{% + \_ifx\_unimathboldfont \_undefined + \_loadumathfamily 1 {\_unimathfont}{embolden=1.7;} % Base faked bold + \_else + \_loadumathfamily 1 {\_unimathboldfont}{} % Base real bold font + \_fi + \_loadmathfamily 4 rsfs % rsfs in not in bold, unfortunately + \_setunimathdimens +}% +\let\_boldmath=\_boldunimath % this is done when Unicode math is initialized +\endtt + +\secc[newfam] Example of using additional math font + +The font `bbold10.tfm` includes double stroked characters, for example +double stroked plus, double stroked Greek letters and digits. +Try to run `pdftex testfont`, then answer to the question about name of the +font: `bbold10` and then type command `\table\end`. The `testfont.pdf` is +printed with the table of characters of this font. +Most of these characters cannot be found in Unicode math fonts. + +\new \OpTeX/ +We show an example how to add this font to the collection of used math fonts. +We can re-define the `\_normalmath` macro by: +\begtt \typosize[10/12] +\addto\_normalmath {\_loadmathfamily 5 bbold } + +\_regtfm bbold 0 bbold5 5.5 bbold6 6.5 bbold7 7.5 bbold8 8.5 bbold9 + 9.5 bbold10 11.1 bbold12 15 bbold17 * % using all bbold*.tfm +\_normalmath % reload the math fonts collection +\endtt +% +The string \"`bbold`" is declared by `\_regtfm` as a collection of all +`bbold*.tfm` fonts, the optical sizes are supported. + +\addto\_normalmath {\_loadmathfamily 5 bbold } +\_regtfm bbold 0 bbold5 5.5 bbold6 6.5 bbold7 7.5 bbold8 8.5 bbold9 + 9.5 bbold10 11.1 bbold12 15 bbold17 * % using all bbold*.tfm +\_normalmath +\Umathchardef \bbplus 2 5 "2B +\Umathchardef \bble 3 5 "3C +\Umathchardef \bbge 3 5 "3E + +Finally, we must to declare new \TeX/ sequences for accessing the characters +from the new font, for example: + +\begtt \typosize[10/12] +\Umathchardef \bbplus 2 5 "2B +\Umathchardef \bble 3 5 "3C +\Umathchardef \bbge 3 5 "3E +\endtt +% +The `\Umathchardef` \TeX/ primitive declares new \TeX/ sequence used in math +typesetting. First parameter is class number (2 means Bin, 3 means Rel, +see the table in the section~\ref[class]). Second parameter is math +family number. It is 5, see the redefinition of the `\_normalmath` macro above. +Third parameter is the slot in the font. Now you can try to use these characters: +$$ + `a \bbplus b \bbge c` \quad \hbox{gives} \quad a \bbplus b \bbge c. +$$ +% +Maybe, you want to declare a special math selector which can be used as +`$\bball a+b>c$` in order to get $\bbchar a \bbplus b \bbge c$. +Then you can define: + +\begtt \typosize[10/12] +\def\bball {\bbchar \Umathcodenum `+ \bbplus + \Umathcodenum `> \bbge + \Umathcodenum `< \bble } +\endtt + +If you want to add all double stroked Greek letters into `\bball` +selector, then you can do something like this: + +\begtt \typosize[10/12] +\def\setbbgreek #1 {\tmpnum=#1\xargs\setbbgreekA} +\def\setbbgreekA #1{\Umathcode \_ea`#1 0 5 \tmpnum \advance\tmpnum by1 } + +\addto\bball {% + \setbbgreek "0B \alpha \beta \gamma \delta \epsilon \zeta \eta + \theta \iota \kappa \lambda \mu \nu \xi \pi \rho \sigma + \tau \upsilon \phi \chi ; + \setbbgreek "7F \omega ; + \setbbgreek "00 \Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon + \Phi \Psi \Omega ; } +\endtt +% +The `\Umathcode <input-code> <class> <family> <font-slot>` primitive is used +here. The control sequences `\alpha`, `\beta`, `\gamma` etc. are macros which expand +to the Unicode character of appropriate (non-math) Greek letter. We set the +Umathcode to such character, for example +\code{\\Umathcode `}$\_rmgreek\alpha$` 0 5 "0B` is processed. + +The bold variant of the font `bbold*.tfm` is not available, unfortunately. +We have to settle for normal version of the font in the `\_boldmath` macro: + +\begtt \typosize[10/12] + \addto \_boldmath {\_loadmathfamily 5 bbold } +\endtt + + +\bye diff --git a/macros/luatex/optex/doc/optex-techdoc.tex b/macros/luatex/optex/doc/optex-techdoc.tex index 0d53140a24..8d1b10186a 100644 --- a/macros/luatex/optex/doc/optex-techdoc.tex +++ b/macros/luatex/optex/doc/optex-techdoc.tex @@ -186,11 +186,12 @@ The `\margins` macro is documented in the section~\ref[marg]. \printdoc hi-syntax.opm \sec Graphics -\printdoc graphics.opm +\printdoctail graphics.opm +\printdoc graphics.opm -\sec[table] The \code{\\table} macro +\sec[table] The \code{\\table} macro, tables and rules \printdoctail table.opm -\secc[table.impl] Implemetation of the \code{\\table} macro +\secc[table.impl] Implemetation of the \code{\\table} macro and friends \printdoc table.opm \sec Balanced multi-columns @@ -214,7 +215,7 @@ The `\margins` macro is documented in the section~\ref[marg]. \sec[makeindex] Sorting and making Index \printdoc makeindex.opm -\sec Footnotes and marginal notes +\sec[fnotes] Footnotes and marginal notes \printdoc fnotes.opm \sec Styles diff --git a/macros/luatex/optex/doc/optex-userdoc.tex b/macros/luatex/optex/doc/optex-userdoc.tex index 15a33ee632..6d6672be4f 100644 --- a/macros/luatex/optex/doc/optex-userdoc.tex +++ b/macros/luatex/optex/doc/optex-userdoc.tex @@ -136,7 +136,8 @@ review printing. After review is done, the second line can be commented out. \secc Concept of default page %%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\OpTeX/ uses for page design very similar to Plain \TeX/ \"output routine". +\OpTeX/ uses \"output routine" for page design. +It is very similar to Plain \TeX/ output routine. There is \^`\headline` followed by \"page body" followed by \^`\footline`. The \^`\headline` is empty by default and it can be used for running headers repeated on each page. The \^`\footline` prints @@ -168,8 +169,7 @@ creating background of each page (colors, picture, watermark for example). The macro \^`\draft` uses this register and puts big text DRAFT as watermark to each page. You can try it. -More about the page layout is documented in files `parameters.opm` and -`output.opm`. +More about the page layout is documented in sections~\ref[oparams] and~\ref[output]. \secc Footnotes and marginal notes @@ -184,8 +184,7 @@ on each chapter from one\fnote document from one or \^`\fnotenumpages` if you want footnotes numbered at each page from one. Default setting is \^`\fnotenumchapters`}. The <text> is scaled to 80 \%. -User can redefine footnote mark or scaling, as shown in the file -`fnotes.opm`. +User can redefine footnote mark or scaling, as shown in the section~\ref[fnotes]. The \^`\fnote` macro is fully applicable only in \"normal outer" paragraph. It doesn't work inside boxes (tables, for example). If you are solving such @@ -219,11 +218,11 @@ The <text> is formatted as a little paragraph with the maximal width \^`\mnotesize` ragged left on the left margins or ragged right on the right margins. The first line of this little paragraph has its vertical position given by the position of \^`\mnote` in the text. The exceptions are possible -by setting the \^`\mnoteskip` register. You can implement such exceptions to -each \^`\mnote` manually in final printing in order to margin notes do not -overlap. The positive value of \^`\mnoteskip` shifts the note up and negative -value shifts it down. For example \^`\mnoteskip=2\baselineskip` \^`\mnote{<text>}` -shifts this (and only this) note two lines up. +by using the `up` keyword: \~`\mnote`` up<dimen>{<text>}`. +You can set such <dimen> to each \^`\mnote` manually in final printing +in order to margin notes do not overlap. The positive value of <dimen> +shifts the note up and negative value shifts it down. For example +\^`\mnote`` up 2\badselineskip{<text>}` shifts this marginal note two lines up. \sec Fonts @@ -255,7 +254,7 @@ be used before a variant selector and they can be (independently) combined: `\caps\it` or `\cond\caps\bf`. The modifiers keeps their internal setting until group ends or until another modifier which negates the previous feature is used. So -`\caps \rm First text \it Second text` +`{\caps \rm First text \it Second text}` gives {\caps \rm First text \it Second text}. \new @@ -278,7 +277,7 @@ This is {\em important} text. % = This is {\it important\/} text. \endtt \new -More about the \OpTeX/ Font Selection System is written the technical +More about the \OpTeX/ Font Selection System is written in the technical documentation in the section~\ref[fontsystem]. You can mix more font families in your document, you can declare your own variant selectors or modifiers etc. @@ -357,6 +356,10 @@ section~\ref[setfontsize]. \secc Typesetting math %%%%%%%%%%%%%%%%%%%%% +See the additional document +\ulink[http://petr.olsak.net/ftp/olsak/optex/optex-math.pdf] +{Typesetting Math with \OpTeX/} for more details about this issue. + \OpTeX/ preloads a collection of 7bit Computer Modern math fonts and AMS fonts in its format for math typesetting. You can use them in any size and in the \^`\boldmath` variant. @@ -368,12 +371,14 @@ math font. This font is automatically loaded unless you specify \^`\noloadmath` before first \^`\fontfam` command. See log file for more information about loading text font family and Unicode math fonts. If you prefer another Unicode math font, specify it by \^`\loadmath{[<font-file>]}` -or \^`\loadmath{font-name}` before first \^`\fontfam` command. +or \^`\loadmath{<font-name>}` before first \^`\fontfam` command. Hundreds math symbols and operators like in AMS\TeX/ are accessible. For example `\alpha` $\alpha$, `\geq`~$\geq$, `\sum` $\sum$, `\sphericalangle` $\sphericalangle$, `\bumpeq`, $\bumpeq$. See AMS\TeX/ -manual for complete list of symbols. +manual or +\ulink[http://petr.olsak.net/ftp/olsak/optex/optex-math.pdf] +{Typesetting Math with \OpTeX/} for complete list of math symbols. The following math alphabets are available: @@ -391,8 +396,8 @@ The following math alphabets are available: The last two selectors \^`\bf` and \^`\bi` select the sans serif fonts in math regardless the current text font family. This is common notation for vectors and -matrices. You can re-declare them, see the file `unimath-codes.opm` where -Unicode math variants of \^`\bf` and \^`\bi` selectors are defined. +matrices. You can re-declare them, see section~\ref[unimath-codes] where +definitions of Unicode math variants of \^`\bf` and \^`\bi` selectors are documented. The math fonts can be scaled by \^`\typosize` and \^`\typoscale` macros. Two math fonts collections are prepared: \^`\normalmath` for normal weight @@ -407,8 +412,6 @@ scriptscript). Moreover, there is the macro \^`\mathstyles{<math list>}` which d the current math style. It is documented at the end of the section~\ref[math-macros]. -The \^`\eqalign` macro is more flexible in \OpTeX/, see technical documentation about it. - \sec Typical elements of document %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -416,7 +419,7 @@ The \^`\eqalign` macro is more flexible in \OpTeX/, see technical documentation \secc[chap] Chapters and sections %%%%%%%%%%%%%%%%%%%%%%%%%% -The document can be divided into chapters (\^`\chap`), +The documents can be divided into chapters (\^`\chap`), sections (\^`\sec`), subsections (\^`\secc`) and they can be titled by \^`\tit` command. The parameters are separated by the end of current line (no braces are used): @@ -428,10 +431,6 @@ braces are used): \secc Subsection title <end of line> \endtt -If you want to write a title to more lines in your source file then you can -use percent character before <end of line>. Such <end of line> is not -scanned and reading of the title continues at the next line. - The chapters are automatically numbered by one number, sections by two numbers (chapter.section) and subsections by three numbers. If there are no chapters then section have only one number and subsection two. @@ -444,10 +443,17 @@ The first paragraph after the title of chapter, section and subsection is not indented but you can type `\let`\^`\_firstnoindent=\relax` if you need all paragraphs indented. -If a title is so long then it breaks to more lines. It is better to hint the +If a title is so long then it breaks to more lines in the output. It is better to hint the breakpoints because \TeX/ does not interpret the meaning of the title. User can put the \^`\nl` (it means newline) macro to the breakpoints. +If you want to arrange a title to more lines in your source file then you can +use `^^J` at the end of each line (except the last one). +When `^^J` is used, then reading of the title continues at the next line. +The \"normal" comment character `%` doesn't work in titles. +You can use \^`\nl`{\visiblesp` ^^J`} if you want to have corresponding lines in the source +and in the output. + The chapter, section or subsection isn't numbered if the \^`\nonum` precedes. And the chapter, section or subsection isn't delivered to the table of contents if \^`\notoc` precedes. You can combine both prefixes. @@ -457,7 +463,7 @@ contents if \^`\notoc` precedes. You can combine both prefixes. Apart from chapters, sections and subsections, there are another automatically numbered objects: equations, captions for tables and -figures. The user can declare more numbered object. +figures. The user can declare more numbered objects. If the user writes the \^`\eqmark` as the last element of the display mode then this equation is numbered. The equation number is printed in brackets. This number @@ -528,6 +534,10 @@ Example: <caption and table> \endinsert \endtt +% +The pair \^`\midinsert`...\^`\endinsert` prefers to put the enclosed object +to the current place. Only if this is unable due to page breaking, it +behaves like \^`\topinsert`...\^`\endinsert`. \new There are five prepared counters `A`, `B`, `C`, `D` and `E`. @@ -545,10 +555,10 @@ macro. For example: Three independent numbers are used in this example. One for Theorems and Corollaries second for Definitions and third for Examples. The user can write `\theorem Let $M$ be...` and the new paragraph is started with the text: -{\bf Theorem 2.3.1.} Let $M$ be... +{\bf Theorem 1.4.1.} Let $M$ be... You can add an optional parameter in brackets. For example, `\theorem [(L'Hôpital's rule)] Let $f$, $g$ be...` -is printed like {\bf Theorem 2.4.2 (L'Hôpital's rule).} Let $f$, $g$ be... +is printed like {\bf Theorem 1.4.2 (L'Hôpital's rule).} Let $f$, $g$ be... \secc References @@ -584,12 +594,12 @@ During each pass, the working `*.ref` file (with references data) is created and this file is used (if it exists) at the beginning of the document. You can use the \^`\label[<label>]` before the `\theorem`, `\definition` etc.\ -(macros defined by `\numberedpar`) if you want to reference these numbered objects. +(macros defined with `\numberedpar`) if you want to reference these numbered objects. You can't use `\theorem[<label>]` because the optional parameter is reserved to another purpose here. You can create a reference to whatever else by commands -\^`\label[<label>]\wlabel{<text>}`. The connection between <label> and +\^`\label[<label>]`\^`\wlabel{<text>}`. The connection between <label> and <text> is established. The \^`\ref[<label>]` will print <text>. By default, labels are not printed, of course. But if you are preparing a @@ -600,14 +610,14 @@ are printed at their destination places after such declaration. \secc Hyperlinks, outlines %%%%%%%%%%%%%%%%%%%%%%%%% -If the command \^`\hyperlinks <color-in> <color-out>` is used at the beginning of +If the command \^`\hyperlinks` `<color-in> <color-out>` is used at the beginning of the document, then the following objects are hyperlinked in the PDF output: \begitems * numbers generated by \^`\ref` or \^`\pgref`, * numbers of chapters, sections and subsections in the table of contents, -* numbers or marks generated by `\cite` command (bibliography references), -* texts printed by \^`\url` or \^`\ulink` commands. +* numbers or marks generated by \~`\cite` command (bibliography references), +* texts printed by \~`\url` or \~`\ulink` commands. \enditems The last object is an external link and it is colored by @@ -639,7 +649,7 @@ in footnotes have <color-fnf>. You can define relevant borders There are \"low level" commands to create the links. You can specify the destination of the internal link by \^`\dest[<type>:<label>]`. The -active text linked to the `\dest` can be created by +active text linked to the \^`\dest` can be created by \^`\ilink[<type>:<label>]{<text>}`. The `<type>` parameter is one of the `toc`, `pg`, `cite`, `ref` or another special for your purpose. These commands create internal links only when \^`\hyperlinks` is declared. @@ -657,17 +667,17 @@ You can insert the `\|` command in the `\url` argument as a potential breakpoint. If the linked text have to be different than the URL, you can use -\^`\ulink[<url>]{text}` macro. For example: +\^`\ulink[<url>]{<text>}` macro. For example: `\ulink[http://petr.olsak.net/optex]{\OpTeX/ page}` outputs to the text \ulink[http://petr.olsak.net/optex]{\OpTeX/ page}. The PDF format provides {\em outlines} which are notes placed in the special frame of -the PDF viewer. These notes can be managed as structured as hyperlinked +the PDF viewer. These notes can be managed as structured and hyperlinked table of contents of the document. The command \^`\outlines{<level>}` creates such outlines from data used for table of contents in the document. The <level> parameter gives the level of opened sub-outlines -in the default view. The deeper levels can be open by mouse click on the +in the default view. The deeper levels can be opened by mouse click on the triangle symbol after that. \new @@ -732,7 +742,7 @@ produces: Another style can be defined by the command \^`\sdef{_item:<style>}{<text>}`. Default item can be set by \^`\defaultitem={<text>}`. -The list environments can be nested. Each new level of item is indented by +The list environments can be nested. Each new level of items is indented by next multiple of \^`\iindent` value which is set to `\parindent` by default. The \^`\ilevel` register says what level of items is currently processed. Each \^`\begitems` starts \^`\everylist` tokens register. You can set, for @@ -751,7 +761,7 @@ found in the section~\ref[lists]. The macro \^`\table{<declaration>}{<data>}` provides similar <declaration> of tables as in \LaTeX: you can use letters `l`, `r`, `c`, each letter declares -one column (aligned to left, right, center respectively). +one column (aligned to left, right, center, respectively). These letters can be combined by the `|` character (vertical line). Example \begtt @@ -774,7 +784,7 @@ generates the following result: Apart from `l`, `r`, `c` declarators, you can use the `p{<size>}` declarator which declares the column with paragraphs of given width. More precisely, -a long text in the table cell is printed as an paragraph with given width. +a long text in the table cell is printed as a multiline paragraph with given width. By default, the paragraph is left-right justified. But there are alternatives: @@ -797,11 +807,12 @@ prefixed. For example `3c` means `ccc` or `c 3{|c}` means can use them in order to more legibility. The command `\cr` used in the <data> part of the table -is generally known. It marks the end of each row in the table. +is generally known from Plain \TeX. It marks the end of each row in the table. Moreover \OpTeX/ defines following similar commands: \begitems * \^`\crl` \dots\ the end of the row with a horizontal line after it. +* \^`\crll` \dots\ the end of the row with a double horizontal line after it. * \^`\crli` \dots\ like \^`\crl` but the horizontal line doesn't intersect the vertical double lines. * \^`\crlli` \dots\ like \^`\crli` but horizontal line is doubled. @@ -811,7 +822,7 @@ Moreover \OpTeX/ defines following similar commands: \^`\crlp{1-3,5}` is equal to \^`\crlp{1,2,3,5}`. \enditems -The \^`\tskip<dimen>` command works like the `\noalign{\vskip<dimen>}` +The \^`\tskip``<dimen>` command works like the `\noalign{\vskip<dimen>}` immediately after `\cr*` commands but it doesn't interrupt the vertical lines. \new @@ -917,7 +928,7 @@ More about it is in technical documentation in section~\ref[table.impl]. See the definition of the \^`\tabdeclarec` macro, for example. The `:` columns boundary declarator is described in section~\ref[table.bound]. -The tables with given width can be declared by `to<size>` or `xto<size>`. +The tables with given width can be declared by `to<size>` or `pxto<size>`. More about it is in section~\ref[table.w] Many tips about tables can be seen on the site \url{http://petr.olsak.net/optex/optex-tricks.html}. @@ -952,7 +963,7 @@ User can change values of the `\parindent` and \^`\ttindent` independently. The \^`\begtt` command starts internal group in which the catcodes are changed. \new Then the \^`\everytt` tokens register is run. It is empty by default and user can -control fine behavior by it. For example the catcodes can be reseted here. If +control fine behavior by it. For example the catcodes can be re-declared here. If you need to define active character in the \^`\everytt`, use \^`\adef` as in the following example: @@ -993,10 +1004,11 @@ Each occurrence of ? will be changed to ! and vice versa. \endtt The in-line verbatim surrounded by an `\activettchar` doesn't work in -parameter of macros and macro definitions, especially in titles declared by -\~`\chap`, \~`\sec` etc. +parameter of macros and macro definitions. (It works in titles declared by +\~`\chap`, \~`\sec` etc. and in \~`\fnote`s, because these macros are +specially defined in \OpTeX/). \new -You can use more robust command \^`\code{<text>}` in such +You can use more robust command \^`\code{<text>}` in problematic situations, but you have to escape following characters in the <text>: `\`, `#`, `%`, braces (if the braces are unmatched in the <text>), and space or `^` (if there are more than one subsequent spaces or `^` in @@ -1038,10 +1050,10 @@ numbers are printed. The \^`\verbinput` can be controlled by \^`\everytt`, \^`\ttindent` just like in \~`\begtt...`\~`\endtt`. -The \~`\begtt`...`\~``\endtt` pair or \~`\verbinput` can be used for listings of +The \~`\begtt`...\~`\endtt` pair or \~`\verbinput` can be used for listings of codes. Automatic syntax highlighting is possible, for example `\begtt` \^`\hisyntax{C}` activates colors for C programs. Or -`\verinput` \^`\hisyntax{HTML} (-) file.html` can be used for HTML or XML codes. +`\verbinput` \^`\hisyntax{HTML} (-) file.html` can be used for HTML or XML codes. \OpTeX/ implements C, Python, \TeX/, HTML and XML syntax highlighting. More languages can be declared, see the section~\ref[hisyntax]. @@ -1057,10 +1069,11 @@ and \~`\secc` used in the document. These data are read from external `*.ref` fi you have to run \TeX/ more than once (typically three times if the table of contents is at the beginning of the document). -The name of the section with table of contents is not printed. The direct usage -of \~`\chap` or \~`\sec` isn't recommended here because the table of contents +Typically, we don't want to repeat the name of the section \"table of contents" +in the table of contents again. The direct usage +of \~`\chap` or \~`\sec` isn't recommended here because the table of contents is typically not referenced to itself. You can print the unnumbered and unreferenced -title of the section by the code: +title of the section like this: \begtt \nonum\notoc\sec Table of Contents @@ -1094,9 +1107,9 @@ program is needed, the alphabetical sorting are done inside \TeX/ at macro level. The \^`\ii` command (insert to index) declares the word separated by the space -as the index item. This declaration is represented as invisible atom on the +as the index item. This declaration is represented as invisible item on the page connected to the next visible word. The page number of the page where -this atom occurs is listed in the index entry. So you can type: +this item occurs is listed in the index entry. So you can type: \begtt The \ii resistor resistor is a passive electrical component ... @@ -1114,7 +1127,7 @@ Note that the dot or comma have to be separated by space when \^`\iid` is used. This space (before dot or comma) is removed by the macro in the current text. -The multiple-words entries are commonly organized in the index as follows: +The multiple-words entries are commonly arranged in the index as follows: \medskip @@ -1139,7 +1152,7 @@ Example: The number of the parts of one index entry is unlimited. Note, that you can spare your typing by the comma in the \~`\ii` parameter. The previous example -is equivalent to `\ii linear/space` `\ii vector/space`. +is equivalent to `\ii linear/space \ii vector/space`~. Maybe you need to propagate to the index the similar entry to the linear/space in the form space/linear. You can do this by the shorthand `,@` @@ -1166,7 +1179,7 @@ The \^`\makeindex` creates the list of alphabetically sorted index entries without the title of the section and without creating more columns. \OpTeX/ provides another macros \^`\begmulti` and \^`\endmulti` for more columns: -\begtt +\begtt \catcode`\<=13 \begmulti <number of columns> <text> \endmulti @@ -1218,7 +1231,7 @@ depending on the used bib-style. For example the citations look like [Now08] or [Nowak, 2008]. The \^`\rcite[<labels>]` creates the same list as \^`\cite[<labels>]` but without -the outer brackets. Example: `[\rcite[tbn], pg.~13]` creates [4,~pg.13]. +the outer brackets. Example: `[\rcite[tbn], pg.~13]` creates [4,~pg.~13]. The \^`\ecite[<label>]{<text>}` prints the `<text>` only, but the entry labeled <label> is decided as to be cited. If \~`\hyperlinks` is used then <text> @@ -1334,10 +1347,10 @@ with CMYK components using \^`\setcmykcolor`. On the other hand, you can define a color with three RGB components and \^`\morecolors` defines such RGB colors. By default, the color model isn't converted but only stored to -PDF output for each used color by default. Thus, there may be a mix of color +PDF output for each used color. Thus, there may be a mix of color models in the PDF output which is not good idea. You can overcome this problem by declaration \^`\onlyrgb` or \^`\onlycmyk`. Then only selected color -model is used for PDF output and if an used color is declared by another color +model is used for PDF output and if a used color is declared by another color model then it is converted. The \^`\onlyrgb` creates colors more bright (usable for computer presentations). On the other hand CMYK makes colors more true\fnote @@ -1429,8 +1442,8 @@ with the current matrix so linear transformations can be composed. One linear transformation given by the `\pdfsetmatrix` above transforms the vector $[0,1]$ to [<a>,\,<b>] and $[1,0]$ to [<c>,\,<d>]. The stack-oriented commands `\pdfsave` and `\pdfrestore` gives a possibility of -storing and restoring the current transformation matrix and the current point. -The position of the current point have to be the same from \TeX{}'s point of +storing and restoring the current transformation matrix and the position of the current point. +This position have to be the same from \TeX{}'s point of view as from transformation point of view when `\pdfrestore` is processed. Due to this fact the `\pdfsave\rlap{<transformed text>}\pdfrestore` or something similar is recommended. @@ -1438,7 +1451,7 @@ or something similar is recommended. \OpTeX/ provides two special transformation macros \^`\pdfscale` and \^`\pdfrotate`: -\begtt +\begtt \catcode`\<=13 \pdfscale{<horizontal-factor>}{<vertical-factor>} \pdfrotate{<angle-in-degrees>} \endtt @@ -1470,8 +1483,8 @@ third: \pdfsave \pdfrotate{-15.3}\pdfsetmatrix{2 0 1.5 2}\rlap{text3}\pdfrestore You can see that \TeX/ knows nothing about dimensions of transfomed material, it treats it as with a zero dimension object. \new -It can be solved by the \^`\transformbox{<transformation>}{<text>}` -macro. This macro puts the transformed +The \^`\transformbox{<transformation>}{<text>}` +macro solves the problem. This macro puts the transformed material to a box with relevant dimension. The <transfromation> parameter includes one or more transfromation commands `\pdfsetmatrix`, `\pdfscale`, `\pdfrotate` with their parameters. The <text> is transformed text. @@ -1656,7 +1669,7 @@ document. Or you can use `<prefixed text>\address...` to put `<prefixed text>` before first line of the address. The \^`\slides` style creates a simple presentation slides. See an example -in the file `op-slides.tex`. Run `optex op-slides.tex` and see the usage of +in the file `op-slides.tex`. Run `optex op-slides.tex` and see the documentation of \^`\slides` style in the file `op-slides.pdf`. Analogical declaration macro `\book` is not prepared. Each book needs an @@ -1667,10 +1680,10 @@ design. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% You can load more macro packages by `\input{<file-name>}` or by -\^`\load[<file-names>]`. The first case is \TeX/ primitive command, it can be +\^`\load[<file-names>]`. The first case (`\input`) is \TeX/ primitive command, it can be used in the alternative old syntax `\input <filename><space>` too. The -second case allows to specify a comma separated list of included files. -Moreover, the \^`\load` macro loads each macro file only once, it sets +second case (\^`\load`) allows to specify a comma separated list of included files. +Moreover, it loads each macro file only once, it sets temporarily standard category codes during loading and it tries to load `<filename>.opm` or `<filename>.tex` or `<filename>`, first occurence wins. Example: @@ -1683,8 +1696,8 @@ local information about the fact that these file names `qrcode` and `tikz` were already used, i.\,e. next \^`\load` will skip them. It is strongly recommended to use the `\load` macro for loading external -macros, if you need them. On the other hand, if your document is structured -to more files, use simply the `\input` primitive. +macros, if you need them. On the other hand, if your source document is structured +to more files (with individual chapters or sections), use simply the `\input` primitive. \secc Lorem ipsum dolor sit @@ -1697,7 +1710,7 @@ neutral text for such experiments. Use \^`\lorem[<number>]` or \^`\lorem[<from>-<to>]`. It prints a paragraph (or paragraphs) with neutral text. The numbers <number> or <from>, <to> must be in the range 1 to 150 because there are 150 paragraphs with neutral text prepared for you. -The \^`\lipsum` macro is equivalent to \^`\lorem`. Example \^`\lipsum[1-150]` +The \^`\lipsum` macro is equivalent to \^`\lorem`. Example: \^`\lipsum[1-150]` prints all prepared paragraphs. \secc Logos @@ -1807,18 +1820,21 @@ put it as the first command in your document: All macros of Plain \TeX/ are re-written in \OpTeX/. Common macros should work in the same sense as in original Plain \TeX. Internal control sequences -\new like `\p@` or `\f@@t` are removed and mostly replaced by control sequences -prefixed by `_` (like `\_this`). All primitives and common macros have two +prefixed by `_` (like `\_this`). If you need to use basic set of such Plain +\TeX/ control sequences (for example you are reading an old macro file), +use `\load[plain-at]`. + +All primitives and common macros have two control sequences with the same meaning: in prefixed and unprefixed form. For example `\hbox` is equal to `\_hbox`. Internal macros of \OpTeX/ have and use only prefixed form. User should use unprefixed forms, but prefixed forms are accessible too, because the `_` is set as a letter category code globally (in macro files and in users document too). User -should re-define unprefixed forms of control sequences with no worries that +should re-define unprefixed forms of control sequences without worries that something internal will be broken (only the sequence `\par` cannot be -re-defined without internal change of \TeX/ behavior because it is -hard-coded in \TeX/s tokenization processor). +re-defined without change of internal \TeX/ behavior because it is +hard-coded in \TeX/, unfortunately). \new The Latin Modern 8bit fonts instead Computer Modern 7bit fonts are diff --git a/macros/luatex/optex/pkg/plain-at.opm b/macros/luatex/optex/pkg/plain-at.opm new file mode 100644 index 0000000000..8219ea7556 --- /dev/null +++ b/macros/luatex/optex/pkg/plain-at.opm @@ -0,0 +1,43 @@ +% This is macro package used by OpTeX, see http://petr.olsak.net/optex + +\_codedecl \_undefined {Obscure @ names from plain TeX <2020-05-22>} + +\_setctable \_optexcatcodes +% PlainTeX obscure names: +\_catcode`\@=11 +\_newdimen\z@ \z@=0pt +\_newdimen\p@ \p@=1pt +\_let\z@skip=\_zoskip +\_chardef\@ne=1 +\_chardef\tw@=2 +\_chardef\thr@@=3 +\_chardef\sixt@@n=16 +\_mathchardef\@m=1000 +\_mathchardef\@M=10000 +\_mathchardef\@MM=20000 +\_countdef\m@ne=22 \m@ne=-1 +\_chardef\@cclv=255 +\_mathchardef\@cclvi=256 +\_skipdef\skip@=0 +\_dimendef\dimen@=0 +\_dimendef\dimen@i=1 +\_dimendef\dimen@ii=2 +\_countdef\count@=255 +\_def\m@th{\_mathsurround\z@} +\_def\o@lign{\_lineskiplimit\z@ \_oalign} +\_def\n@space{\_nulldelimiterspace\z@ \m@th} +\_newdimen\p@renwd \p@renwd=8.75pt +\_def\alloc@#1#2#3#4#5{\_allocator#5{\_csstring#2}#3} +\_restorectable + +\_endcode + +We absolutely don't recommend to use such obscure names in your macros. But +sometimes you need to read an old plain TeX document or a macro file. You +can load this file in such cases. For example: + +\begtt + \load [plain-at, shapepar.sty] +\endtt + +\_endinput |