diff options
author | Karl Berry <karl@freefriends.org> | 2020-04-26 21:34:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-04-26 21:34:47 +0000 |
commit | 1990374c1e9958b0ebbce5d2b170bf659c24abe3 (patch) | |
tree | 581d2a1456d052543e6f26cdc0bafe711aca38de /Master | |
parent | 4427294b9b94376955632103bc89a3691257ccc3 (diff) |
optex (26apr20)
git-svn-id: svn://tug.org/texlive/trunk@54893 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
72 files changed, 6323 insertions, 4232 deletions
diff --git a/Master/texmf-dist/doc/luatex/optex/README b/Master/texmf-dist/doc/luatex/optex/README index 2c8fa6652c3..6f2d9d5eec5 100644 --- a/Master/texmf-dist/doc/luatex/optex/README +++ b/Master/texmf-dist/doc/luatex/optex/README @@ -8,6 +8,9 @@ See http://petr.olsak.net/optex History: +<0.10> Technical documentation added + \_famdecl instedad \_fontdecl in font family files (incompatible change). +<0.09> Syntax highlighting implemented. <0.08> \numberedpar implmented. \emergencystretch=20pt added as default. \inoval, \incircle, \clipinoval, \clipincircle imlemented. \puttext, \putpic x,y instead -y,x (incompatible change!) diff --git a/Master/texmf-dist/doc/luatex/optex/optex-doc.pdf b/Master/texmf-dist/doc/luatex/optex/optex-doc.pdf Binary files differindex b366233d9f4..7f9ec85ac85 100644 --- a/Master/texmf-dist/doc/luatex/optex/optex-doc.pdf +++ b/Master/texmf-dist/doc/luatex/optex/optex-doc.pdf diff --git a/Master/texmf-dist/doc/luatex/optex/optex-doc.tex b/Master/texmf-dist/doc/luatex/optex/optex-doc.tex index 0a1b6b5d8af..b4e41b68747 100644 --- a/Master/texmf-dist/doc/luatex/optex/optex-doc.tex +++ b/Master/texmf-dist/doc/luatex/optex/optex-doc.tex @@ -1,28 +1,25 @@ +%% This is part of OpTeX project, see http://petr.olsak.net/optex -\fontfam[LMfonts] -\typosize[11/13] -\enlang -\margins/1 a4 (2,2,2,2)cm +% Run optex optex-doc (three times) to generate OpTeX documentation. -\catcode`<=13 -\def<#1>{\hbox{$\langle$\it#1\/$\rangle$}} -\everyintt={\catcode`\<=13} -\everytt=\everyintt -\enquotes +\input doc.opm \let\enddocument=\endinput -\def\new{\mnote{\Red$\blacktriangleleft$}} -\fixmnotes\right +\typosize[10/12] -\activettchar` +\let\new=\relax -\hyperlinks{\Blue}{\Green} -\insertoutline{CONTENTS} \outlines{0} +\begingroup \typosize [11/13.5] + +\insertoutline{OpTeX} +\vglue1cm +\centerline{\setfontsize{at50pt}\rm\OpTeX} +\vskip-8mm -\tit \OpTeX/\nl Format Based on Plain \TeX/ and OPmac\fnotemark1 +\tit Format Based on Plain \TeX/ and OPmac\fnotemark1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\hfill Version 0.08 +\hfill Version 0.10 \centerline{\it Petr Olšák, 2020} @@ -30,39 +27,39 @@ \centerline{\url{http://petr.olsak.net/optex}} \fnotetext {The OPmac package is a set of simple additional macros to Plain \TeX{}. It -enables users to take advantage of basic \LaTeX/ functionality but keeps +enables users to take advantage of \LaTeX/ functionality but keeps Plain \TeX/ simplicity. See -\url{http://petr.olsak.net/opmac-e.html} for more information about it. -For OPmac users: the red triangle {\Red$\blacktriangleleft$} in the right margin -means that there is a difference from standard OPmac features.} +\url{http://petr.olsak.net/opmac-e.html} for more information about it.} -\notoc\nonum \sec Contents -\maketoc +\bigskip +\noindent +\OpTeX/ is \LuaTeX/ format with Plain \TeX/ and OPmac. Only \LuaTeX/ engine +is supported. -\nonum \sec Introduction -%%%%%%%%%%%% +\OpTeX/ should be a modern Plain \TeX/ with power from OPmac (Fonts +Selection System, colors, graphics, references, hyperlinks, +indexing, bibliography, ...) with preferred Unicode fonts. -\OpTeX/ is \LuaTeX/ format with Plain \TeX/ and OPmac. Only \LuaTeX/ engine -is supported. The main goal of \OpTeX/ is: +The main goal of \OpTeX/ is: \begitems * \OpTeX/ keeps the simplicity (like in Plain \TeX/ and OPmac macros). * There is no old obscurities concerning with various 8-bit encodings and various engines. -* \OpTeX/ provides a powerful font selection system (for Unicode font +* \OpTeX/ provides a powerful Fonts Selection System (for Unicode font families, of course). * \OpTeX/ supports hyphenations of all languages installed in your \TeX/ system. -* All features from OPmac macros are copied. -* Macros are documented in the same place where code is (macros for printing - such documentation will come in the future). +* All features from OPmac macros are copied. For example sorting words in + the Index\fnotemark1, reading `.bib` files directly\fnotemark1, syntax + highlighting\fnotemark1, colors, graphics, hyperlinks, references). + \fnotetext{All these features are implemented by \TeX/ macros, no external + program is needed.} +* Macros are documented in the same place where code is. * User name space of control sequences is separated from internal name space - of \OpTeX/ and primitives (`\foo` versus `\_foo`). + of \OpTeX/ and primitives (`\foo` versus `\_foo`). The name spaces for + macro writers are designed too. \enditems -\OpTeX/ should be a modern Plain \TeX/ with power from OPmac (fonts selection -system, colors, external graphics, references, hyperlinks, indexing, -bibliography, ...) with preferred Unicode fonts. - If you need to customize your document or you need to use something very specific, then you can copy relevant parts of \OpTeX/ macros into your macro file and do changes of these macros here. This is significant difference from @@ -70,1755 +67,45 @@ file and do changes of these macros here. This is significant difference from plenty of non-primitive parameters and syntax hiding \TeX/ internals. The macros from \OpTeX/ are simple and straightforward because they solve only what is explicitly needed, they does not create a new user level for -controlling your document over \TeX/. -And you can use \OpTeX/ macros, understand them an modify them. +controlling your document. We have \TeX. +You can use \OpTeX/ macros, understand them an modify them. \OpTeX/ offers a markup language for authors of texts (like \LaTeX), i.\,e.\ the fixed set of tags to define the structure of the document. This markup is different from the \LaTeX{} markup. It may offer to write the source text of the document somewhat clearer and more attractive. -\new -{\bf Disclaimer:} This software is under construction. It is possible -that some features documented here will be changed in future. +The manual includes two parts: user documentation and technical +documentation. The second part is generated directly from the sources of +\OpTeX/. There are many hyperlinks from one part to second and vice versa. -This manual desribes \OpTeX/ features only. We suppose that user knows \TeX/ -basic principles. They are described in many books. You can see a short +This manual describes \OpTeX/ features only. We suppose that user knows \TeX/ +basics. They are described in many books. You can see a short document \ulink[http://petr.olsak.net/ftp/olsak/optex/tex-nutshell.pdf] {\TeX/ in nutshell} too. +\vfil\break -\sec Starting with \OpTeX/ -%%%%%%%%%%%%%%%%%%%%%%%%% - -\new -\OpTeX/ is compiled as a format for \LuaTeX/. Maybe there is a command -`optex` in your \TeX/ distribution. Then you can write into command line - -\begtt -optex document -\endtt -% -You can try to process `optex op-demo` or `optex optex-doc`. - -If there is no `optex` command, see more information about installation -\OpTeX/ at \url{http://petr.olsak.net/optex}. - -A minimal document should be - -\begtt -\fontfam[LMfonts] -Hello World! \bye -\endtt - -The first line `\fontfam[LMfonts]` tells that Unicode Latin Modern -fonts (derived from Computer Modern) are used. If you omit this line then -preloaded Latin Modern fonts are used but preloaded fonts cannot be in -Unicode\fnote -{This is a technical limitation of \LuaTeX/ for fonts downloaded in formats: -only 8bit fonts can be preloaded.}. -So the sentence `Hello World` will be OK without the first line, but you -cannot print such sentence in another languages (for example `Ahoj světe!`) -where Unicode fonts are needed -because of the characters like `ě` are not mapped correctly in preloaded -fonts. - -A somewhat larger example with common settings should be: - -\begtt \catcode`!=0 -\fontfam[Termes] % selecting Unicode font family Termes (section !ref[fontfam]) -\typosize[11/13] % setting the basic font size and the baselineskip (sec. !ref[sizes]) -\margins/1 a4 (1,1,1,1)in % setting 1in margins for A4 paper (section !ref[marg]) -\cslang % Czech hyphenation patterns (section !ref[lang]) - -Tady je text. -\bye -\endtt -% -You can look at `op-demo.tex` file for more examples. - - -\sec Page layout -%%%%%%%%%%%%%%%% - -\secc[marg] Setting the margins -%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\OpTeX/ declares paper formats a4, a4l (landscape~a4), a5, a5l, b5, letter and -user can declare another own format by `\sdef`: - -\begtt -\sdef{_pgs:b5l}{(250,176)mm} -\sdef{_pgs:letterl}{(11,8.5)in} -\endtt - -The `\margins` command declares margins of the document. This command have -the following parameters: - -\begtt -\margins/<pg> <fmt> (<left>,<right>,<top>,<bot>)<unit> - example: -\margins/1 a4 (2.5,2.5,2,2)cm -\endtt - -Parameters are: - -\begitems -* <pg> \dots\ `1` or `2` specifies one-page or two-pages design. -* <fmt> \dots\ paper format (a4, a4l, a5, letter, etc. or user defined). -* <left>, <right>, <top>, <bot> \dots\ gives the amount of left, right, - top and bottom margins. -* <unit> \dots\ unit used for values <left>, <right>, <top>, <bot>. -\enditems - -Each of the parameters <left>, <right>, <top>, <bot> can be empty. -If both <left> and <right> are nonempty then `\hsize` is set. Else `\hsize` -is unchanged. If both <left> and <right> are empty then typesetting area is -centered in the paper format. The analogical rule works when <top> or <bot> -parameter is empty (`\vsize` instead `\hsize` is used). Examples: - -\begtt -\margins/1 a4 (,,,)mm % \hsize, \vsize untouched, - % typesetting area centered -\margins/1 a4 (,2,,)cm % right margin set to 2cm - % \hsize, \vsize untouched, vertically centered -\endtt - -If `<pg>=1` then all pages have the same margins. If `<pg>=2` then the -declared margins are true for odd pages. The margins at the even pages are -automaticaly mirrored in such case, it means that <left> is replaced by -<right> and vice versa. - -The `<fmt>` can be also in the form `(<width>,<height>)<unit>` where `<unit>` is -optional. If it is missing then `<unit>` after margins specification is -used. For example: - -\begtt -\margins/1 (100,200) (7,7,7,7)mm -\endtt -% -declares the paper 100$\times$200\,mm with all four margins 7\,mm. The spaces -before and after <fmt> parameter are necessary. - -The command `\magscale[<factor>]` scales the whole typesetting area. -\new The fixed point of such scaling is the upper left corner of the paper sheet. -Typesetting (breakpoints etc.) is unchanged. All units are relative after -such scaling. Only paper formats dimensions stays unscaled. Example: - -\begtt -\margins/2 a5 (22,17,19,21)mm -\magscale[1414] \margins/1 a4 (,,,)mm -\endtt -% -The first line sets the `\hsize` and `\vsize` and margins for final -printing at a5 format. The setting on the second line centers the scaled -typesetting area to the true a4 paper while breaking points for paragraphs -and pages are unchanged. It may be usable for -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 \"output routine" like Plain -\TeX/. 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 -centered page number by default. You can set the `\footline` to empty -using `\nopagenumbers` macro. - -The margins declared by `\margins` macro (documented in the previous -section~\ref[marg]) is concerned to the page body, -i.e.\ the `\headline` and `\footline` are placed to the top and bottom -margins. - -The distance between the `\headline` and the top of the page body is given by -`\headlinedist` register. The distance between bottom of the page body and -the `\footline` is given by `\footlinedist`. The default values are: - -\begtt -\headline = {} -\footline = {\_hss\_rmfixed \_folio \_hss} % \folio expands to page number -\headlinedist = 14pt % from baseline of \headline to top of page body -\footlinedist = 24pt % from last line in pagebody to baseline of footline -\endtt - -The page body should be divided to top insertions (floating tables and -figures) followed by a real text and followed by footnotes. -Typically, only real text is here. - -The `\pgbackground` tokens list is empty by default but it can be used for -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`. - -\secc Footnotes and marginal notes -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -The Plain \TeX/'s macro `\footnote` can be used as usual. But a new macro -`\fnote{<text>}` is defined. The footnote mark is added automatically and it -is numbered -\new -on each chapter from one\fnote -{You can declare `\fnotenumglobal` if you want footnotes numbered in whole -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`. - -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 -case you can use `\fnotemark<numeric-label>` inside the box: only the -footnote mark is generated here. When the box is finished you can use -`\fnotetext{<text>}`. This macro puts the <text> to the footnote. -The <numeric-label> have to be `1` if only one such command is in the box. -Second `\fnotemark` inside the same box have to have the parameter `2` etc. -The same number of `\fnotetext`s have to be written -after the box as the number of `\fnotemark`s inserted inside the box. -Example: - -\begtt -Text in a paragraph\fnote{First notice}... % a "normal" footnote -\table{...}{...\fnotemark1...\fnotemark2...} % two footnotes in a box -\fnotetext{Second notice} -\fnotetext{Third notice} -... -\table{...}{...\fnotemark1...} % one footnote in a box -\fnotetext{Fourth notice} -\endtt - -The marginal note can be printed by the `\mnote{<text>}` macro. The <text> -is placed to the right margin on the odd pages and it is placed to the left -margin on the even pages. This is done after second \TeX{} run because the -relevant information is stored in an external file and read from it again. -If you need to place the notes only to the fixed margin write -`\fixmnotes\right` or `\fixmnotes\left`. - -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. - - -\sec Fonts -%%%%%%%%%% - -\secc[fontfam] Font families -%%%%%%%%%%%%%%%%%%%%%%% - -You can select the font family by `\fontfam[<Family-name>]`. -The argument <Family-name> is case insensitive and spaces are ignored. So, -`\fontfam[LM Fonts]` is equal to `\fontfam[LMfonts]` and it is equal -to `\fontfam[lmfonts]`. Several aliases are prepared, thus -`\fontfam[Latin Modern]` can be used for loading Latin Modern family too. - -If you write `\fontfam[?]` then all font families registered in \OpTeX/ -are listed on the terminal and in the log file. -If you write `\fontfam[catalog]` then a catalog of all fonts registered in -\OpTeX/ and available in your \TeX/ system is printed. The instructions -how to register your own font family is appended in such catalog. - -If the family is loaded then {\em font modifiers} applicable in such font family -are listed on the terminal: (`\caps`, `\cond` for example). -And there are four basic {\em variant selectors} (`\rm`, `\bf`, `\it`, `\bi`). -The usage of variant selectors is the same as in Plain \TeX: -`{\it italics text}`, `{\bf bold text}` etc. - -The font modifiers (`\caps`, `\cond` for example) can -be used before a basic 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 text \it text` uses normal and italics in Caps and SmallCaps. - -\new -There is one special variant selector `\currvar` which does not change the -selected variant but reloads the font due to the (maybe newly -specified) font modifier(s). - -The context between variants `\rm`--`\it` and `\bf`--`\bi` is kept by the `\em` -macro (emphasize text). -It switches from current `\rm` to `\it`, from current `\it` to `\rm`, from -current `\bf` to `\bi` and from current `\bi` to `\bf`. -The italics correction `\/` is inserted automatically. Example: - -\begtt -This is {\em important} text. % = This is {\it important\/} text. -\it This is {\em important} text. % = This is\/ {\rm important} text. -\bf This is {\em important} text. % = This is {\bi important\/} text. -\bi This is {\em important} text. % = This is\/ {\bf important} text. -\endtt - -\new -More about the \OpTeX/ font selection system is written the file -`fonts-select.opm`. You can mix more font families in your document, you can -declare your own variant selectors or modifiers etc. - -\secc[sizes] Font sizes -%%%%%%%%%%%%%%%%%%%%% - -The command `\typosize[<fontsize>/<baselineskip>]` sets the font size of text and -math fonts and baselineskip. If one of these two parameters is empty, the -corresponding feature stays unchanged. Don't write the unit of these -parameters. The unit is internally set to `\ptunit` which is 1pt by default. -You can change the unit by the command `\ptunit=<something-else>`, -for instance `\ptunit=1mm` enlarges all font sizes declared by `\typosize`. -Examples: - -\begtt -\typosize[10/12] % default of Plain TeX -\typosize[11/12.5] % font 11pt, baseline 12.5pt -\typosize[8/] % font 8pt, baseline unchanged -\endtt - -The commands for font size setting described in this section -have local validity. If you put them into a group, -the settings are lost when the group is finished. If you set -something relevant with paragraph shape (baselineskip given by -`\typosize` for example) then you must first finalize the -paragraph and second to close the group: -`{\typosize[12/14] ...<text of paragraph>... \par}`. - -The command -`\typoscale[<font-factor>/<baselineskip-factor>]` -sets the text and math fonts -size and baselineskip as a multiple of the current fonts size and -baselineskip. The factor is written in \"scaled"-like way, it means that 1000 -means factor one. The empty parameter is equal to the parameter 1000, -i.e. the value stays unchanged. Examples: - -\begtt -\typoscale[800/800] % fonts and baselineskip re-size to 80 % -\typoscale[\magstep2/] % fonts bigger 1,44times (\magstep2 expands to 1440) -\endtt - -First usage of `\typosize` or `\typoscale` macro in your document sets so -called {\em main values}, i.\,e.\ main font size and main baselineskip. They are internally -saved in registers `\mainfosize` and `\mainbaselineskip`. - -\new -The `\typoscale` command does scaling in respect to current values by default. -If you want to do it in respect to main values, type `\scalemain` immediately -before `\typoscale` command. - -\begtt -\typosize[12/14.4] % first usage in document, sets main values internally -\typosize[15/18] % bigger font -\scalemain \typoscale[800/800] % reduces from main values, no from current. -\endtt - -The size of the current font can be changed by the command -`\thefontsize[<font-size>]` or can be rescaled by -`\thefontscale[<factor>]`. These macros don't change math fonts sizes nor -baselineskip. - -\new -There is \"low level" `\setfontsize{<size-spec>}` command which behaves like -a font modifier and sets given font size used by next variant selectors. -For example `\setfontsize{at15pt}\currvar` sets current variant to 15pt. - -If you are using a font family with \"optical sizes feature" (i.\,e.\ there -are more recommended sizes of the same font which are not scaled -linearly; good example is Computer Modern aka Latin Modern fonts) -then the recommended size is selected by all mentioned commands automatically. - -More information about resizing of fonts is documented in `fonts-resize.opm` -file. - -\secc Typesetting math -%%%%%%%%%%%%%%%%%%%%% - -\OpTeX/ preloads a collection of 7bit Computer Modern math fonts -and AMS fonts in its format. You can use them in any size and in the -`\boldmath` variant. -% -\new -Most declared text font families (see `\fontfam` in the section~\ref[fontfam]) -are configured with recommended Unicode -math font. This font is automaticlaly 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 `\loadfam` 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. - -The following math alphabets are available: - -\begtt \catcode`\$=3 \catcode`/=0 \medmuskip=0mu \adef{ }{ } -\mit % mathematical variables $abc-xyz,ABC-XYZ$ -\it % text italics $/it abc-xyz,ABC-XYZ$ -\rm % text roman $/rm abc-xyz,ABC-XYZ$ -\cal % normal calligraphics $/cal ABC-XYZ$ -\script % script $/script ABC-XYZ$ -\frak % fracture $/frak abc-xyz,ABC-XYZ$ -\bbchar % double stroked letters $/bbchar ABC-XYZ$ -\bf % sans serif bold $/bf abc-xyz,ABC-XYZ$ -\bi % sans serif bold slanted $/bi abc-xyz,ABC-XYZ$ -\endtt - -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 it, see the file `unimath-codes.opm` where math -variants of `\bf` and `\bi` selectors are defined. - -The math fonts can be scaled by `\typosize` and `\typoscale` macros. -Two math fonts collections are prepared: `\normalmath` for normal weight -and `\boldmath` for bold. The first one is set by default. - -\new -You can use `\mathbox{<text>}` inside math mode. It behaves as `{\hbox{<text>}}` -(i.e. the <text> is printed in horizontal non-math mode) -but the size of the <text> is adapted to the context of math size (text or script or -scriptscript). - - -\sec Typical elements of document -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\secc[chap] Chapters and sections -%%%%%%%%%%%%%%%%%%%%%%%%%% - -The document can be divided into chapters, sections and subsections and titled -by `\tit` command. The parameters are separated by the end of current line (no -braces are used): - -\begtt -\tit Document title <end of line> -\chap Chapter title <end of line> -\sec Section title <end of line> -\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 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. - -The implicit design of the titles of chapter etc.\ are implemented in the -macros `\_printchap`, `\_printsec` and `\_printsecc`. A designer can simply change -these macros if he/she needs another behavior. - -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 -breakpoints because \TeX/ does not interpret the meaning of the title. -User can put the `\nl` (it means newline) macro to the breakpoints. - -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. - -\secc[cap] Another numbered objects -%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -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. - -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 -resets in each section by default. - -If the `\eqalignno` is used, then user can put `\eqmark` to the last column -before `\cr`. For example: - -\begtt -\eqalignno{ - a^2+b^2 &= c^2 \cr - c &= \sqrt{a^2+b^2} & \eqmark \cr} -\endtt - -The next automatically numbered objects are captions which is tagged by `\caption/t` for -tables and `\caption/f` for figures. -The caption text follows. -The `\cskip` can be used between `\caption` text and the real object (table -or figure). You can use two orders: `<caption>\cskip <object>` or -`<object>\cskip <caption>`. -The `\cskip` creates appropriate vertical space between them. Example: - -\begtt -\caption/t The dependency of the computer-dependency on the age. -\cskip -\noindent\hfil\table{rl}{ - age & value \crl\noalign{\smallskip} - 0--1 & unmeasured \cr - 1--6 & observable \cr - 6--12 & significant \cr - 12--20 & extremal \cr - 20--40 & normal \cr - 40--60 & various \cr - 60--$\infty$ & moderate} -\endtt - -This example produces: - -\medskip -\caption/t The dependency of the computer-dependency on the age. -\cskip -\noindent\hfil\table{rl}{ - age & value \crl\noalign{\smallskip} - 0--1 & unmeasured \cr - 1--6 & observable \cr - 6--12 & significant \cr - 12--20 & extremal \cr - 20--40 & normal \cr - 40--60 & various \cr - 60--$\infty$ & moderate} -\medskip - -You can see that the word \"Table" followed by a number is added by the macro -`\caption/t`. -The caption text is centered. If it occupies more lines then the -last line is centered. - -The macro `\caption/f` behaves like `\caption/t` but it is intended for -figure captions with independent numbering. -The word (Table, Figure) depends on the actual selected language (see -section~\ref[lang] about languages). - -If you wish to make the table or figure as floating object, you need to use -Plain \TeX/ macros `\midinsert` or `\topinsert` terminated by `\endinsert`. -Example: - -\begtt -\topinsert % table and its caption is printed at the top of the current page - <caption and table> -\endinsert -\endtt - -\new -There are five prepared counters `A`, `B`, `C`, `D` and `E`. -They are reset in each chapter and section\fnote -{This feature can be changed, see the `sections.opm` in the technical documentation.}. -They can be used in context of `\numberedpar <letter>{<text>}` -macro. For example: -\begtt -\def\theorem {\numberedpar A{Theorem}} -\def\corollary {\numberedpar A{Corollary}} -\def\definition {\numberedpar B{Definition}} -\def\example {\numberedpar C{Example}} -\endtt -% -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... -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... - - -\secc References -%%%%%%%%%%%%%%% - -Each automatically numbered object documented in -sections \ref[chap] and \ref[cap] can be referenced -\new -if optional parameter -`[<label>]` is appended to `\chap`, `\sec`, -`\secc`, `\caption/t`, `\caption/f` or `\eqmark`. The alternative syntax is -to use `\label[<label>]` before mentioned commands (not necessarily directly -before). The reference is realized by `\ref[<label>]` or `\pgref[<label>]`. -Example: - -\begtt -\sec[beatle] About Beatles - -\noindent\hfil\table{rl}{...} % the table -\cskip -\caption/t [comp-depend] The dependency of the computer-dependency on the age. - -\label[pythagoras] -$$ a^2 + b^2 = c^2 \eqmark $$ - -Now we can point to the section~\ref[beatle] on the page~\pgref[beatle] -or write something about the equation~\ref[pythagoras]. Finally there -is an interesting Table~\ref[comp-depend]. -\endtt - -If there are forward referenced objects then user have to run \TeX{} twice. -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 `\label[<label>]` before `\theorem`, `\definition` (macros defined by -`\numberedpar`) if you want to reference these numbered objects. -You can't use `\theorem[<label>]` because the optional parameter -is reserved to another purpose. - -You can create a reference to whatever else by commands -`\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 -draft version of document, you can declare `\showlabels`. The labels -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 -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. -\enditems - -The last object is an external link and it is colored by -`<color-out>`. Others links are internal and they are colored by -`<color-in>`. Example: - -\begtt -\hyperlinks \Blue \Green % internal links blue, URLs green. -\endtt - -You can use another marking of active links: by frames which are visible in -the PDF viewer but invisible when the document is printed. The way to do it -is to define the macros `\pgborder`, `\tocborder`, `\citeborder`, -`\refborder` and `\urlborder` as the triple of RGB components of the used -color. Example: - -\begtt -\def\tocborder {1 0 0} % links in table of contents: red frame -\def\pgborder {0 1 0} % links to pages: green frame -\def\citeborder {0 0 1} % links to references: blue frame -\endtt - -By default these macros are not defined. It means that no frames are created. - -The hyperlinked footnotes can be activated by `\fnotelinks <color-fnt> <color-fnf>` -where footnote marks in text have `<color-fnt>` and the same footnote marks -in footnotes have <color-fnf>. You can define relevant borders -`\fntborder` and `\fnfborder` analogically as `\pgboreder` (for example). - -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 -`\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 decared. - -The `\url` macro prints its parameter in `\tt` font and creates a potential -breakpoints in it (after slash or dot, for example). If `\hyperlinks` -declaration is used then the parameter of `\url` is treated as an external URL link. -An example: `\url{http://www.olsak.net}` creates \url{http://www.olsak.net}. -The characters \code{\%}, `\`, `#`, `{` and `}` have to be protected by -backslash in the `\url` argument, the other special characters `~`, -`^`, `&` can be written as single character\fnote -{More exactly, there are the same rules as for \code{\\code} command, see -section~\ref[verbatim].}. -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[http://petr.olsak.net/optex]{\OpTeX/ page}` -creates -\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 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 -triangle symbol after that. - -\new -If you are using a special macro in section titles then `\outlines` macro -may crash. You must declare variant of the macro for outlines case which is -expandable. Use `\regmacro` in such case. See the section \ref[toc] for more information -about `\regmacro`. - -The command `\insertoutline{<text>}` inserts next entry into PDF outlines at -the main level~0. These entries can be placed before table of contents (created -by `\outlines`) or after it. Theirs hyperlink destination is in the place -where `\insertoutline` macro is used. - -\secc Lists -%%%%%%%%%% - -The list of items is surrounded by `\begitems` and `\enditems` commands. -The asterisk (`*`) is active within this environment and it starts one item. -The item style can be chosen by `\style` parameter written after `\begitems`: - -\begtt -\style o % small bullet -\style O % big bullet (default) -\style - % hyphen char -\style n % numbered items 1., 2., 3., ... -\style N % numbered items 1), 2), 3), ... -\style i % numbered items (i), (ii), (iii), ... -\style I % numbered items I, II, III, IV, ... -\style a % items of type a), b), c), ... -\style A % items of type A), B), C), ... -\style x % small rectangle -\style X % big rectangle -\endtt - -For example: - -\begtt -\begitems -* First idea -* Second idea in subitems: - \begitems \style i - * First sub-idea - * Second sub-idea - * Last sub-idea - \enditems -* Finito -\enditems -\endtt -% -produces: - -\begitems -* First idea -* Second idea in subitems: - \begitems \style i - * First sub-idea - * Second sub-idea - * Last sub-idea - \enditems -* Finito -\enditems - -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 -next multiple of `\iindent` 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 -example: -\begtt -\everylist={\ifcase\ilevel\or \style X \or \style x \else \style - \fi} -\endtt - -You can say `\begitems \novspaces` if you don't want vertical spaces above -and below the list. -More information about design of lists of items should be found in the `lists.opm` file. - -\secc Tables -%%%%%%%%%%% - -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). -These letters can be combined by the `|` character (vertical line). Example - -\begtt -\table{||lc|r||}{ \crl - Month & commodity & price \crli \tskip2pt - January & notebook & \$ 700 \cr - February & skateboard & \$ 100 \cr - July & yacht & k\$ 170 \crl} -\endtt -% -generates the following result: - -\bigskip -\noindent\hfil\table{||lc|r||}{ \crl - Month & commodity & price \crli \tskip2pt - January & notebook & \$ 700 \cr - February & skateboard & \$ 100 \cr - July & yacht & k\$ 170 \crl} -\bigskip - -Apart from `l`, `r`, `c` declarators, you can use the `p{<size>}` declarator -which declares the column of given width. More precisely, a long text in -the table cell is printed as an paragraph with given width. -To avoid problems with narrow left-right aligned paragraphs you can write -`p{<size>\raggedright}`, then the paragraph will be only left aligned. - -You can use `(<text>)` in the <declaration>. Then this text is applied in -each line of the table. For example `r(\kern10pt)l` adds more 10\,pt space -between `r` and `l` rows. - -An arbitrary part of the <declaration> can be repeated by a <number> -prefixed. For example `3c` means `ccc` or `c 3{|c}` means -`c|c|c|c`. Note that spaces in the <declaration> are ignored and you -can use them in order to more legibility. - -The command `\cr` used in the <data> part of the table -is generally known. It marks end row of the table. -Moreover \OpTeX/ defines following similar commands: - -\begitems -* `\crl` \dots\ the end of the row with a 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. -* `\crlp{<list>}` \dots\ like `\crli` but the lines are drawn only in the - columns mentioned in comma separated `<list>` of their numbers. - The <list> can include `<from>-<to>` declarators, for example - `\crlp{1-3,5}` is equal to `\crlp{1,2,3,5}`. -\enditems - -The `\tskip<dimen>` command works like the `\noalign{\vskip<dimen>}` -after `\cr*` commands but it doesn't interrupt the vertical lines. - -\new -You can use following parameters for the `\table` macro. Default values are listed -too. - -\begtt -\everytable={} % code used after settings in \vbox before table processing -\thistable={} % code used when \vbox starts, is is removed after using it -\tabiteml={\enspace} % left material in each column -\tabitemr={\enspace} % right material in each column -\tabstrut={\strut} % strut which declares lines distance in the table -\tablinespace=2pt % additional vertical space before/after horizontal lines -\vvkern=1pt % space between lines in double vertical line -\hhkern=1pt % space between lines in double horizontal line -\endtt - -Example: if you do `\tabiteml={$\enspace}\tabitemr={\enspace$}` then -the `\table` acts like \LaTeX's array environment. - -If there is an item which spans to more than one column in the table then -`\multispan{<number>}` macro from Plain \TeX{} can help you or, you can use -`\mspan<number>[<declaration>]{<text>}` -which spans <number> columns and formats the <text> by the -<declaration>. The <declaration> must include a declaration of only one column -with the same syntax as common `\table` <declaration>. -If your table includes vertical rules and you want to -create continuous vertical rules by `\mspan`, then use rule declarators `|` -only after `c`, `l` or `r` letter in `\mspan` <declaration>. The -exception is only in the case when `\mspan` includes first -column and the table have rules on the left side. The example of `\mspan` usage is below. - -The `\frame{<text>}` makes a frame around <text>. You can put the whole `\table` -into `\frame` if you need double-ruled border of the table. Example: - -\begtt -\frame{\table{|c||l||r|}{ \crl - \mspan3[|c|]{\bf Title} \crl \noalign{\kern\hhkern}\crli - first & second & third \crlli - seven & eight & nine \crli}} -\endtt -% -creates the following result: - -\hfil\frame{\table{|c||l||r|}{\crl - \mspan3[|c|]{\bf Title} \crl \noalign{\kern\hhkern}\crli - first & second & third \crlli - seven & eight & nine \crli}} -\bigskip - -The `c`, `l`, `r` and `p` are default \"declaration letters" but you can define -more such letters by `\def\_tabdeclare<letter>{<left>##<right>}`. More about -it is in technical documentation in the file `table.opm`. - -The rule width of tables and implicit width of all `\vrule`s and `\hrule`s -can be set by the command `\rulewidth=<dimen>`. The default value given -by \TeX/ is 0.4\,pt. - -Many tips about tables can be seen on -\url{http://petr.olsak.net/opmac-tricks-e.html}. - -\label[verbatim]\secc Verbatim -%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -The display verbatim text have to be surrounded by the `\begtt` and -`\endtt` couple. -The in-line verbatim have to be tagged (before and after) -by a character which is declared by -`\activettchar<char>`. For example \code{\\activettchar`} -declares the character \code{`} -for in-line verbatim markup. -And you can use \code{`\\relax`} for -verbatim `\relax` (for example). -\new -Another alternative of printing in-line -verbatim text is `\code{<text>}` (see below). - -If the numerical register `\ttline` is set to the non-negative value then -display verbatim will number the lines. The first line has the number -`\ttline+1` and when the verbatim ends then the `\ttline` value is equal to the -number of last line printed. Next `\begtt...\endtt` environment will follow -the line numbering. \OpTeX/ sets `\ttline=-1` by default. - -The indentation of each line in display verbatim is controlled by -`\ttindent` register. This register is set to the `\parindent` by default. -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 -you need to define active character in the `\everytt`, use `\adef` as in the -following example: - -\begtt \adef@{\string\endtt} -\everytt={\adef!{?}\adef?{!}} -\begtt -Each occurrence of the exclamation mark will be changed to -the question mark and vice versa. Really? You can try it! -@ -\endtt -% -The `\adef` command sets its parameter as active {\it after\/} -the value of `\everytt` is read. So you don't have to worry about active -categories. - -There is an alternative to `\everytt` named `\everyintt` which is used for -in-line verbatim surrounded by an `\activettchar` or processed by the `\code` -command. - -The `\everytt` is applied to all `\begtt...\endtt` environments (if it is not -decared in a group). There are tips for such global `\everytt` definitions here: - -\begtt -\everytt={\typosize[9/11]} % setting font size for verbatim -\everytt={\ttline=0} % each listing will be numbered from one -\everytt={\adef{ }{\char9251 }} % visualization of spaces (Unicode fonts) -\endtt - -\new -If you want to apply a special code only for one `\begtt...\endtt` -environment then don't set any `\everytt` but put desired material at the -same line where `\begtt` is. For example: - -\begtt \adef@{\string\endtt} -\begtt \adef!{?}\adef?{!} -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. -\new -You can use more robust command `\code{<text>}` in such -situations, but you must 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 -the <text>). Examples: - -\begtt -\code{\\text, \%\#} ... prints \text, %# -\code{@{..}*&^$ $} ... prints @{..}*&^$ $ without escaping, but you can - escape these characters too, if you want. -\code{a \ b} ... two spaces between a b, the second one must be escaped -\code{xy\{z} ... xy{z ... unbalanced brace must be escaped -\code{^\^M} ... prints ^^M, the second ^ must be escaped -\endtt - -You can print verbatim listing from external files by `\verbinput` command. -Examples: - -\begtt -\verbinput (12-42) program.c % listing from program.c, only lines 12-42 -\verbinput (-60) program.c % print from begin to the line 60 -\verbinput (61-) program.c % from line 61 to the end -\verbinput (-) program.c % whole file is printed -\verbinput (70+10) program.c % from line 70, only 10 lines printed -\verbinput (+10) program.c % from the last line read, print 10 lines -\verbinput (-5+7) program.c % from the last line read, skip 5, print 7 -\verbinput (+) program.c % from the last line read to the end -\endtt - - -The `\ttline` influences the line numbering by the same way as in -`\begtt...\endtt` environment. If `\ttline=-1` then real line numbers are -printed (this is default). If \code{\\ttline<-1} then no line -numbers are printed. - -The `\verbinput` can be controlled by `\everytt`, `\ttindent` just like -in `\begtt...\endtt`. - - -\sec Autogenerated lists -%%%%%%%%%%%%%%%%%%%%%%%% - -\secc[toc] Table of contents -%%%%%%%%%%%%%%%%%%%%%% - -The `\maketoc` command prints the table of contents of all `\chap`, `\sec` -and `\secc` used in the document. These data are read from external `*.ref` file, so -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 -is typically not referenced to itself. You can print the unnumbered and unreferenced -title of the section by the code: - -\begtt -\nonum\notoc\sec Table of Contents -\endtt - -\new -If you are using a special macro in section titles or chapter titles -and you need different behavior of such macro in other cases then use -`\regmacro{<case-toc>}{<case-mark>}{<case-outline>}`. -The parameters are applied locally in given cases. The `\regmacro` can be -used repeatedly: the parameters are accumulated (for more macros). -If a parameter is empty then original definition is used in given case. -For example: - -\begtt -% default value of \mylogo macro used in text and in the titles: -\def\mylogo{\leavevmode\hbox{\Red{\it My}\Black{\setfontsize{mag1.5}\rm Lo}Go}} -% another variants: -\regmacro {\def\mylogo{\hbox{\Red My\Black LoGo}}} % used in TOC - {\def\mylogo{\hbox{{\it My}\/LoGo}}} % used in running heads - {\def\mylogo{MyLoGo}} % used in outlines -\endtt - -\secc Making the index -%%%%%%%%%%%%%%%%%%%%% - -The index can be included into document by `\makeindex` macro. No external -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 -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: - -\begtt -The \ii resistor resistor is a passive electrical component ... -\endtt - -You cannot double the word if you use the `\iid` instead `\ii`: - -\begtt -The \iid resistor is a passive electrical component ... -or: -Now we'll deal with the \iid resistor . -\endtt - -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 by the format -(for example): - -\medskip - -linear~dependency 11, 40--50 - ---- independency 12, 42--53 - ---- space 57, 76 - ---- subspace 58 - -\medskip - -To do this you have to declare the parts of the index entries by the `/` separator. -Example: - -\begtt -{\bf Definition.} -\ii linear/space,vector/space -{\em Linear space} (or {\em vector space}) is a nonempty set of... -\endtt - -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`. - -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 `,@` -at the end of the `\ii` parameter. Example: - -\begtt -\ii linear/space,vector/space,@ -is equivalent to: -\ii linear/space,vector/space \ii space/linear,space/vector -\endtt - -If you really need to insert the space into the index entry, write `~`. - -If the `\ii` or `\iid` command is preceded by `\iitype <letter>`, then such -reference (or more references generated by one `\ii`) has specified type. -The page numbers of such references should be formatted -specially in the index. \OpTeX/ implements only `\iitype b`, `\iitype i` and -`\iitype u`. The page number in bold or in italics or underlined is printed -in the index when these types are used. Default index type is empty, which -prints page numbers in normal font. See \TeX/book index as an example. - -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 for more columns: - -\begtt -\begmulti <number of columns> -<text> -\endmulti -\endtt -The columns will be balanced. The Index can be printed by the following -code: - -\begtt -\sec Index -\begmulti 3 \makeindex \endmulti -\endtt - -Only \"pure words" can be propagated to the index by the `\ii` command. It -means that there cannot be any macro, \TeX/ primitive, math selector etc. -But there is another possibility to create such complex index entry. Use -\"pure equivalent" in the `\ii` parameter and map this equivalent to the -real word which is printed in the index by `\iis` command. Example: - -\begtt -The \ii chiquadrat $\chi$-quadrat method is -... -If the \ii relax `\relax` command is used then \TeX/ is relaxing. -... -\iis chiquadrat {$\chi$-quadrat} -\iis relax {\code{\\relax}} -\endtt -% -The `\iis <equivalent> {<text>}` creates one entry in the \"dictionary -of the exceptions". The sorting is done by the <equivalent> but the -<text> is printed in the index entry list. - -The sorting rules when `\makeindex` runs depends on the current language. -See section~\ref[lang] about languages selection. - -\secc Bib\TeX/ing -%%%%%%%%%%%%%%%% - -The command `\cite[<label>]` (or its variants of the type -\hbox{`\cite[<label-1>,<label-2>,...,<label-n>]`}) -creates the citation in the form [42] (or [15,~19,~26]). -If `\shortcitations` is declared at the beginning of the document then -continuous sequences of numbers are re-printed like this: -\hbox{[3--5,~7,~9--11]}. If -`\sortcitations` is declared then numbers generated by one `\cite` command -are sorted upward. - -If `\nonumcitations` is declared then the marks instead numbers are generated -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 `\ecite[<label>]{<text>}` prints the `<text>` only, but the entry labeled -<label> is decided as to be cited. If `\hyperlinks` is used then <text> -is linked to the references list. - -You can define alternative formating of `\cite` command. Example: - -\begtt -\def\cite[#1]{(\rcite[#1])} % \cite[<label>] creates (27) -\def\cite[#1]{$^{\rcite[#1]}$} % \cite[<label>] creates^{27} -\endtt - -The numbers printed by `\cite` correspond to the same numbers generated in -the list of references. -There are two possibilities to generate this -references list: - -\begitems -* Manually using `\bib[<label>]` commands. -* By `\usebib/<type> (<style>) <bib-base>` command which reads `*.bib` - files directly. -\enditems - -\new -Note that another two possibilities documented in OPmac (using external -Bib\TeX/ program) isn't supported because Bib\TeX/ is old program which does not -support Unicode. And Biber seems to be not compliant with Plain \TeX. - -\medskip\noindent -{\bf References created manually using `\bib[<label>]` command.} - -\begtt -\bib [tbn] P. Olšák. {\it\TeX{}book naruby.} 468~s. Brno: Konvoj, 1997. -\bib [tst] P. Olšák. {\it Typografický systém \TeX.} - 269~s. Praha: CSTUG, 1995. -\endtt - -If you are using `\nonumcitations` then you need to declare the <marks> -used by `\cite` command. To do it you must use long form of the `\bib` -command in the format `\bib[<label>] = {<mark>}`. The spaces around -equal sign are mandatory. Example: - -\begtt -\bib [tbn] = {Olšák, 2001} - P. Olšák. {\it\TeX{}book naruby.} 468~s. Brno: Konvoj, 2001. -\endtt - -\noindent -{\bf Direct reading of `.bib` files} is possible by `\usebib` macro. -This macro reads and uses macro package `librarian.tex` by Paul Isambert. -The usage is: - -\begtt -\usebib/c (<style>) <bib-base> % sorted by \cite-order (c=cite), -\usebib/s (<style>) <bib-base> % sorted by style (s=style). -% example: -\usebib/s (simple) op-example -\endtt - -The <bib-base> is one or more `*.bib` database source files (separated by -spaces and without extension) and the <style> is the part of the filename -`bib-<style>.opm` where the formatting of the references list is -defined. \OpTeX/ supports `simple` or `iso690` styles. The behavior of -`\usebib` is documented in `usebib.opm` and `bib-iso690.opm` files in detail. - -Not all records are printed from <bib-base> files: the command `\usebib` -selects only such bib-records which were used in `\cite` or `\nocite` -commands in your document. The `\nocite` behaves as `\cite` but prints -nothing. It only tels that mentioned bib-record should be printed in the -reference list. If `\notcite[*]` is used then all records from <bib-base> -are printed. - - -\sec Graphics -%%%%%%%%%%%%% - -\secc Colors -%%%%%%%%%%% - -\OpTeX/ provides a small number of color selectors: -{\Blue `\Blue`}, -{\Red `\Red`}, -{\Brown `\Brown`}, -{\Green `\Green`}, -{\Yellow `\Yellow`}, -{\Cyan `\Cyan`}, -{\Magenta `\Magenta`}, -{`\White`}, -{\Grey `\Grey`}, -{\LightGrey `\LightGrey`} and -`\Black`. User can define more -such selectors by setting four CMYK components -\new -or three RGB components. For example - -\begtt -\def \Orange {\setcmykcolor{0 0.5 1 0}} -\def \Purple {\setrgbcolor{1 0 1}} -\endtt - -\new -The command `\morecolors` reads more definitions of color selectors -from \LaTeX/ file `x11nam.def`. There is about 300 color names like -`\DeepPink`, `\Chocolate` etc. If there are numbered variants of the same -name, then you can append letters B, C, etc. to the name in \OpTeX/. For example -`\Chocolate` is Chocolate1, `\ChocolateB` is Chocolate2 etc. - -\new -The color selectors work locally in groups by default but with limitations. See -the file `colors.opm` for more information. - -The colors `\Blue`, `\Cyan` etc. are defined with CMYK components using `\setcmykcolor`. -But you can define a color with three RGB components too 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 -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 then it is converted. -The `\onlyrgb` creates colors more bright (usable for computer -presentations). On the other hand CMYK makes colors more true\fnote -{Printed output is more equal to the monitor preview especialy if you are -using ICC profile for your printer.} -for printing. - -\new -You can define your color by a linear combination of previously defined colors using -`\colordef`. For example: - -\begtt -\colordef \myCyan {.3\Green + .5\Blue} % 30 % green, 50 % blue, rest is white -\colordef \DarkBlue {\Blue + .4\Black} % Blue mixed with 40 % of black -\colordef \myGreen{\Cyan+\Yellow} % exact the same as \Green -\colordef \MyColor {.3\Orange+.5\Green+.2\Yellow} -\endtt -% -The linear combination is done in CMYK substractive color space by default -(RGB colors used in `\colordef` argument are converted first). -If the resulting component is greater than 1 then it is truncated to 1. -If a convex linear combination (as in the last example above) is used then it -emulates color behavior on a painter's palette. -You can use `\rgbcolordef` instead `\colordef` if you want to mix colors -in additive RGB color space. - -More about colors, about CMYK versus RGB and -about the `\colordef` command is written in the `colors.opm` file. - -\def\coloron#1#2#3{% - \setbox0=\hbox{#3}\leavevmode - {\localcolor\rlap{#1\strut \vrule width\wd0}#2\box0}% -} -The following example defines a macro which creates the -\coloron\Yellow\Brown{colored text on the colored background}. Usage: -`\coloron<background><foreground>{<text>}` - -The `\coloron` can be defined as follows: - -\begtt -\def\coloron#1#2#3{% - \setbox0=\hbox{#3}\leavevmode - {\rlap{#1\strut \vrule width\wd0}#2\box0}% -} -\coloron\Yellow\Brown{The brown text on the yellow backround} -\endtt - -\secc Images -%%%%%%%%%%% - -The `\inspic {<filename>.<extension>}` or -`\inspic <filename>.<extension><space>` -inserts the picture stored in -the graphics file with the name `<filename>.<extension>` to the document. -You can set the picture width by `\picw=<dimen>` -before `\inspic` command which declares the width of the picture -The image files can be in the PNG, JPG, JBIG2 or PDF format. - -The `\picwidth` is an equivalent register to `\picw`. Moreover there is an -`\picheight` register which denotes the height of the picture. If both -registers are set then the picture will be (probably) deformed. - -The image files are searched in `\picdir`. This token list is empty -by default, this means that the image files are searched in the -current directory. Example: `\picdir={img/}` supposes that image files are -in `img` subdirectory. Note: the directory name must end by `/` in `\picdir` -declaration. - -Inkscape\fnote -{A powerfull and free wysiwyg editor for creating vector graphics.} -is able to save a picture to PDF and labels of the picture to another -file\fnote -{Chose \"Omit text in PDF and create LaTeX file" option.}. -This second file should be read by \TeX/ in order to print labels -in the same font as document font. \OpTeX/ supports this feature by -`\inkinspic {<filename>.pdf}` command. It reads and displays both: PDF image -and labes generated by Inkscape. - -If you want to create a vector graphics (diagrams, schema, geometry -skicing) then you can do it in Wysiwyg graphics editor (Inkscape, Geogebra for -example), export the result to PDF and include it by `\inspic`. -If you want to \"programm" such pictures then Tikz package is recommended. -It works in Plain \TeX. - -\secc PDF transformations -%%%%%%%%%%%%%%%%%%%%%%%% - -All typesetting elements are transformed by linear -transformation given by the current transformation matrix. The -`\pdfsetmatrix {<a> <b> <c> <d>}` command makes the internal multiplication -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 -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. - -\OpTeX/ provides two special transformation macros: - -\begtt -\pdfscale{<horizontal-factor>}{<vertical-factor>} -\pdfrotate{<angle-in-degrees>} -\endtt - -These macros simply calls the properly `\pdfsetmatrix` command. - -It is known that the composition of transformations is not commutative. It -means that the order is important. You have to read the transformation -matrices from right to left. Example: - -\begtt -First: \pdfsave \pdfrotate{30}\pdfscale{-2}{2}\rlap{text1}\pdfrestore - % text1 is scaled two times and it is reflected about vertical axis - % and next it is rotated by 30 degrees left. -second: \pdfsave \pdfscale{-2}{2}\pdfrotate{30}\rlap{text2}\pdfrestore - % text2 is rotated by 30 degrees left then it is scaled two times - % and reflected about vertical axis. -third: \pdfsave \pdfrotate{-15.3}\pdfsetmatrix{2 0 1.5 2}\rlap{text3}% - \pdfrestore % first slanted, then rotated by 15.3 degrees right -\endtt -% -\par\nobreak\bigskip\smallskip -This gives the following result. -First: \pdfsave \pdfrotate{30}\pdfscale{-2}{2}\rlap{text1}\pdfrestore -second: \pdfsave \pdfscale{-2}{2}\pdfrotate{30}\rlap{text2}\pdfrestore -third: \pdfsave \pdfrotate{-15.3}\pdfsetmatrix{2 0 1.5 2}\rlap{text3}\pdfrestore -\par\nobreak\bigskip\penalty0%\bigskip - -You can see that \TeX/ knows nothing about dimensions of transfomed material, -it treats it as with a zero dimension object. -\new -This problem is solved by the `\transformbox{<transformation>}{<text>}` -macro which 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. - -Example: `\frame{\transformbox{\pdfscale{1}{1.5}\pdfrotate{-10}}{moj}}` -creates \frame{\transformbox{\pdfscale{1}{1.5}\pdfrotate{-10}}{moj}}. - -The `\rotbox{<deg>}{<text>}` is a shortcut for -`\transformbox{\pdfrotate{<deg>}}{<text>}`. - -\secc Ovals, circles -%%%%%%%%%%%%%%%%%%%% - -\new -The `\inoval{<text>}` creates a box like this: \inoval{text}. -Multiline text can be put in an oval by the command `\inoval{\vbox{<text>}}`. -Local settings can be set by -`\inoval[<settings>]{<text>}` or you can re-declare global settings by -`\ovalparams={<settings>}`. The default settings are: - -\begtt -\ovalparams={\roudness=2pt % diameter of circles in the corners - \fcolor=\Yellow % color used for filling oval - \lcolor=\Red % line color used in the border - \lwidth=0.5bp % line width in the border - \shadow=N % use a shadow effect - \overlapmargins=N % ignore margins by surrounding text - \hhkern=0pt \vvkern=0pt} % left-righ margin, top-bottom margin -\endtt -The total distance from text to oval boundary is `\hhkern+\roudness` at the left and right -sides and -`\vvkern+\roundness` at the top and bottom sides of the text. - -If you need a setting for the `<text>` (color, size, font etc.), use -`\oval{<text settings><text>}`. - -\new -The `\incircle[\ratio=1.8]{<text>}` creates a box like this \incircle[\ratio=1.8]{text}. -The `\ratio` is width/height. The usage is analogical like for oval. -The default settings of parameters are - -\begtt -\circleparams={\ratio=1 \fcolor=\Yellow \lcolor=\Red \lwidth=0.5bp - \shadow=N \ignoremargins=N \hhkern=2pt \vvkern=2pt} -\endtt - -\new -The macros `\clipinoval <x> <y> <width> <height> {<text>}` -and `\clipincircle` (with the same parameters) -print the `<text>` when a clipping path (oval or cirle) with given -`<with>` and `<height>` shifted its center by `<x>` to right and by `<y>` to up -is used. -The `\roundness=5mm` is default for `\clipingoval` and user can change it. -Example: - -\begtt -\clipingcircle 3cm 3.5cm 6cm 7cm {\picw=6cm \inspic{myphoto.jpg}} -\endtt - -\secc Putting images and texts wherever - -\new -The `\puttext <x> <y> {<text>}` puts the `<text>` shifted by `<x>` right and by -`<y>` up from current point of typesetting and does'n not change the -position of the current point. Assume coordinate system with origin in the -current point. Then `\puttext <x> <y> {<text>}` puts the text at the -coordinates `<x>`, `<y>`. More exactly the left edge of its baseline is at that -position. - -\new -The `\putpic <x> <y> <width> <height> {<image>}` puts the `<image>` of given -`<width>` and `<height>` at given position (its left-bottom corner). -You can write `\nospec` instead `<width>` or `<height>` if this parameter is -not given. - -\sec Others -%%%%%%%%%%% - -\secc[lang] Using more languages -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\OpTeX/ prepares hyphenation patterns for all languages if such patterns are -available in your \TeX/ system. -\new -Only USenglish patterns (original from Plain \TeX/) are preloaded. -Hyphenation patterns of all another languages are loaded on demand when you first use -the `\<iso-code>lang` command in your document. -For example `\delang` for German, `\cslang` for -Czech, `\pllang` for Polish. The <iso-code> is a shortcut -of the language (mostly from ISO 639-1). -You can list all available languages by `\langlist` -macro. This macro prints now: - -\medskip -{\typosize[9/11.5]\emergencystretch=4em \hbadness=2000 -\noindent \langlist -\par} -\medskip - -\new -For compatibility with e-plain macros, there is the command -`\uselanguege{<language>}`. The parameter <language> is long form of -language name, i.e.\ `\uselanguage{Czech}` works the same as `\cslang`. -The `\uselanguage` parameter is case insensitive. - -For compatibility with \csplain/, there are macros `\ehyph`, `\chyph`, -`\shyph` which are equivalent to `\enlang`, `\cslang` and `\sklang`. - -You can switch between language patterns by `\<iso-code>lang` commands mentioned -above. Default is `\enlang`. - -\OpTeX/ generates three words used for captions and titles in technical -articles or books: \"Chapter", \"Table" and \"Figure". These words need to be known -in used language and it depends on the previously used language selectors -`\<iso-code>lang`. \OpTeX/ declares these words only for few languages: -\new -Czech, German, Spanish, French, Greek, Italian, Polish, Russian, Slovak and -English, If you need to use these words in another languages or you want to -auto-generate more words in your macros, then you can declare it by -`\sdef` or `\_langw` commands as shown in the file `languages.opm`. - -The `\makeindex` command needs to know the sorting rules used in your language. -\OpTeX/ defines only few language rules for sorting: Czech, -Slovak and English. How to declare sorting rules for more languages are -described in the file `makeindex.opm`. - -If you declare `\<iso-code>quotes`, then the control sequences `\"` and `\'` -should be used like this: `\"<quoted text>"` or `\'<quoted text>'` -(note that the terminating character is the same but it isn't escaped). -This prints language dependent normal or alternative quotes around -<quoted text>. The language is specified by <iso-code>. \OpTeX/ declares -quotes only for Czech, German, Spanish, French, Greek, Italian, Polish, -Russian, Slovak and English (`\csquotes`, `\dequotes`, \dots, `\enquotes`). -You can simply define your own quotes as shown in `languages.opm` file. -The `\"` is used for quotes visualy more similar to the `"` character which -can be primary quotes or secondary quotes depending on the language rules. -May be you want to alternate meaning of these two types of quotes. Use -`\<isocode>quotes\altquotes` in such case. - -\secc Pre-defined styles -%%%%%%%%%%%%%%%%%%%%%%% - -\OpTeX/ defines three style-declaration macros `\report`, `\letter` and -`\slides`. You can use them at the beginning of your document if you are -preparing these types of document and you don't need to create your own -macros. - -The `\report` declaration is intended to create reports. It -sets default font size to 11\,pt and `\parindent` (paragraph indentation) to 1.2\,em. -The `\tit` macro uses smaller font because we assume that \"chapter level" -will be not used in reports. The first page has no page number, but next pages -are numbered (from number~2). Footnotes are numbered from one in whole -document. The macro `\author <authors><end-line>` can be used when -`\report` is declared. It prints `<authors>` in italics at center of the -line. You can separate authors by `\nl` to more lines. - -The `\letter` declaration is intended to create letters. See an example in -the file `op-letter.tex`. The `\letter` style sets default -font size to 11\,pt and `\parindent` to 0\,pt. It sets half-line space -between paragraphs. The page numbers are not printed. The `\subject` macro -can be used, it prints the word \"Subject:" or \"Věc" (or something else -depending on current language) in bold. Moreover, the `\address` macro -can be used when `\letter` is declared. The usage of the `\address` macro -looks like: - -\begtt -\address - <first line of address> - <second line of address> - <etc.> - <empty line> -\endtt - -It means that you need not to use any special mark at the end of lines: end -of lines in the source file are the same as in printed output. The -`\address` macro creates `\vtop` with address lines. The width of such -`\vtop` is equal to the most wide line used in it. So, you can use -`\hfill\address...` in order to put the address box to the right side of the -document. Or you can use `<prefixed text>\address...` to put -`<prefixed text>` before first line of the address. - -The `\slides` style ceates a simple presentation slides. See an example -in the file `op-slides.tex`. Run `optex op-slides.tex` and see the usage of -`\slides` style in the file `op-slides.pdf`. - -Analogical declaration macros `\book` is not prepared. Each book needs an -individual typographical care so you need to create specific macros for -design. - -\secc Lorem ipsum dolor sit -%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\new -A designer needs to concentrate to the design of the output and maybe he/she -needs a material for testing macros. There is the possibility to generate a -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]` -prints all prepared paragraphs. - -\secc Logos -%%%%%%%%%% - -\new -The control sequences for typical logos can be terminated by optional `/` -which is ignored when printing. This makes logos more legible in source file: - -\begtt -We are using \TeX/ because it is cool. \OpTeX/ is better than \LaTeX. -\endtt - -\secc The last page -%%%%%%%%%%%%%%%%%%% - -The number of the last page (it may be different from number of pages) is -expanded by `\lastpage` macro. It expands to `?` in first \TeX/ run and to -the last page in next \TeX/ runs. - -There is an example for footlines in the format \"current page / last page": - -\begtt -\footline={\hss \fixedrm \folio/\lastpage \hss} -\endtt - -\new -The `\lastpage` expands to the last `\folio` which is a decimal -number or roman nummeral (when `\pageno` is negative). If you need to know -total pages used in the document, use `\totalpages` macro. It expands to -zero (in first \TeX/ run) or to the number of all pages in the document -(in next \TeX/ runs). - -\secc Use \OpTeX/ -%%%%%%%%%%%%%%%%% - -\new -The command `\useOpTeX` (or `\useoptex`) does nothing in \OpTeX/ but it causes -an error (undefined control sequence) when another format is used. You can -put it as the first command in your document: - -\begtt -\useOpTeX % we are using OpTeX format, no LaTeX :) -\endtt - -\sec Summary -%%%%%%%%%%%% - -\begtt \typosize[10/12]\adef!{\string\endtt}\adef&{\kern.25em} -\tit Title (terminated by end of line) -\chap Chapter Title (terminated by end of line) -\sec Section Title (terminated by end of line) -\secc Subsection Title (terminated by end of line) - -\maketoc % table of contents generation -\ii item1,item2 % insertion the items to the index -\makeindex % the index is generated - -\label [labname] % link target location -\ref [labname] % link to the chapter, section, subsection, equation -\pgref [labname] % link to the page of the chapter, section, ... - -\caption/t % a numbered table caption -\caption/f % a numbered caption for the picture -\eqmark % a numbered equation - -\begitems % start list of the items -\enditems % end of list of the items -\begtt % start verbatim text -! % end verbatim text -\activettchar X % initialization character X for in-text verbatim -\code % another alternative for in-text verbatim -\verbinput % verbatim extract from the external file -\begmulti num % start multicolumn text (num columns) -\endmulti % end multicolumn text - -\cite [labnames] % refers to the item in the lits of references -\rcite [labnames] % similar to \cite but [] are not printed. -\sortcitations \shortcitations \nonumcitations % cite format -\bib [labname] % an item in the list of references -\usebib/? (style) bib-base % direct using of .bib file, ? in {s,c} - -\fontfam [FamilyName] % selection of font family -\typosize [font-size/baselineskip] % size setting of typesetting -\typoscale [factor-font/factor-baselineskip] % size scaling -\thefontsize [size] \thefontscale [factor] % current font size - -\inspic file.ext % insert a picture, extensions: jpg, png, pdf -\table {rule}{data} % simple macro for the tables like in LaTeX - -\fnote {text} % footnote (local numbering on each page) -\mnote {text} % note in the margin (left or right by page number) - -\hyperlinks {color-in}{color-out} % PDF links activate as clickable -\outlines {level} % PDF will have a table of contents in the left tab +\insertoutline{CONTENTS} \outlines{0} -\magscale[factor] % resize typesetting, line/page breaking unchanged -\margins/pg format (left, right, top, bottom)unit % margins setting +\notoc\nonum \sec Contents +\maketoc -\report \letter \slides % style declaration macros -\endtt +\chap User documentation +\input optex-userdoc +\endgroup -\sec Compatibility with Plain \TeX/ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%\end -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 -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 -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). +\input optex-techdoc -\new -The Latin Modern 8bit fonts instead Computer Modern 7bit fonts are -preloaded in the format, but only few ones. The full family set is ready to -use after the command `\fontfam[LMfonts]` which reads the fonts in OTF -format. +\vfil\break -\new -The text accents macros like `\'`, `\v`, `\"` are undefined\fnote -{The math accents macros like `\acute`, `\bar`, `\dot`, `\hat` still work.} -in \OpTeX/. Use real -letters like á, ř, ž in your source document instead these old accents macros. -If you really want to use them, you can initialize them by `\oldaccents` -command. But we don't recommend it. +\def\_printchap#1{\noindent{\_printrefnum[@]\_secfont #1}\medskip} -\new -The default paper size is not set as letter with 1\,in margins but as A4 with -2.5\,cm margins. You can change it, for example by -`\margins/1 letter (1,1,1,1)in`. This example sets the classical Plain \TeX/ -page layout. +\nonum\chap Index -\new -The origin for typographical area is not at top left 1\,in 1\,in coordinates -but at top left paper corner exactly. For example, `\hoffset` includes directly left -margin. +\begmulti 3 \tt \makeindex \endmulti \bye - diff --git a/Master/texmf-dist/doc/luatex/optex/optex-techdoc.tex b/Master/texmf-dist/doc/luatex/optex/optex-techdoc.tex new file mode 100644 index 00000000000..802a87d89f0 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/optex/optex-techdoc.tex @@ -0,0 +1,250 @@ +%% This is part of OpTeX project, see http://petr.olsak.net/optex + +% This file is read from optex-doc.tex +% Use: optex optex-doc (three times) to create whole documentation. + +\ifx\printdoc\undefined \input doc.opm \fi + +\chap Technical documentation + +This documentation is written in the source files `*.opm` between +the `\_doc` and `\_cod` pairs or after the `\_endcode` command. +When the format is generated by +\begtt +luatex -ini optex.ini +\endtt +then the text of the documentation is ignored and the format `optex.fmt` is +generated. On the other hand, if you run +\begtt +optex optex-doc.tex +\endtt +then the same `*.opm` files are read when the second chapter of this +documentation is printed. + +A knowledge about \TeX/ is expected from the reader. +You can see a short document +\ulink[http://petr.olsak.net/ftp/olsak/optex/tex-nutshell.pdf]{\TeX/ in a Nutshell} +or more detail +\ulink[https://eijkhout.net/texbytopic/texbytopic.html]{\TeX/ by topic}. + +Notices about hyperlinks. +If a control sequence is printed in red color in this documentation then +this denotes its \"main documentation point". Typically, the listing where +the control sequence is declared follows immediately. If a control sequence is +printed in the blue color in the listing or in the text +then it is active link which points (usually) to the main documentation point. +The main documentation point can be active link which points to a previous +text where the control sequence was +mentioned. Such occurrences are active links to the main documentation point. + +\sec The main initialization file + +The `optex.ini` file is read as main file when the format is generated. + +{\everytt={\typosize[8/10]\_let\_printverbline=\_printcodeline \medskip} + \def\docfile{optex.ini} + +\verbinput (-4) optex.ini +% +Category codes are set first. Note that the `_` is set to category code +\"letter", it can be used as a part of control sequence names. +Other category codes are set as in the plain \TeX/. + +\verbinput (6-20) optex.ini +% +The \`\optexversion` and \`\fmtname` are defined. + +\verbinput (22-25) optex.ini +% +We check if \LuaTeX/ engine is used at `-ini` state. And the `^^J` character +is set as `\newlinechar`. + +\verbinput (27-36) optex.ini +% +The basic macros for macro file syntax is defined, i.\,e.\ +`\_endcode`, `\_doc` and `\_cod`. +The `\_codedecl` will be re-defined later. + +\verbinput (38-42) optex.ini +% +Individual `*.opm` macro files are read. + +\verbinput (44-87) optex.ini + +% +The `\everyjob` register is initialized and the format is saved by +the `\dump` command. + +\verbinput (89-96) optex.ini + +} + +\printdoctail prefixed.opm +\secc The implementation of the name spaces +\edef\_Endcode{\_bslash _endcode\_pcent} +\printdoc prefixed.opm +\edef\_Endcode{\_bslash _endcode} + +\sec pdf\TeX/ initialization +\printdoctail luatex-ini.opm +\printdoc luatex-ini.opm + +\sec Basic macros +We define first bundle of basic macros. +\printdoc basic-macros.opm + +\sec Allocators for \TeX/ registers +\printdoctail alloc.opm +\printdoc alloc.opm + +\sec If-macros, loops, is-macros +\printdoc if-macros.opm + +\sec Setting parameters +\printdoctail parameters.opm +\printdoc parameters.opm + +\sec More \OpTeX/ macros +The second bundle of \OpTeX/ macros is here. +\printdoc more-macros.opm + +\sec Plain \TeX/ macros +All macros from plain \TeX/ are rewritten here. +Differences are mentioned in the documentation below. +\printdoc plain-macros.opm + +\sec Preloaded fonts for text mode +\printdoctail fonts-preload.opm +\printdoc fonts-preload.opm + +\printdoctail fonts-resize.opm +\printdoc fonts-resize.opm + +\printdoctail fonts-select.opm +\secc Implementation of the Font Selection System +\printdoc fonts-select.opm + +\sec Preloaded fonts for math mode +\printdoctail math-preload.opm +\printdoc math-preload.opm + +\sec[math-macros] Math macros +\printdoc math-macros.opm + +\sec Unicode-math fonts +\printdoctail math-unicode.opm + +\sec[opmac-fonts] Scaling fonts in document (high-level macros) +These macros are documented in section~\ref[sizes] from user point of view. +\printdoc fonts-opmac.opm + +\sec[output] Output routine +\printdoctail output.opm +\printdoc output.opm + +\sec Margins +The `\margins` macro is documented in the section~\ref[marg]. +\printdoc margins.opm + +\sec[colors] Colors +\printdoctail colors.opm +\printdoc colors.opm + +\sec[ref-file] The \code{.ref} file +\printdoctail ref-file.opm +\printdoc ref-file.opm + +\sec[references] References +\printdoctail references.opm +\printdoc references.opm + +\sec Hyperlinks +\printdoctail hyperlinks.opm +\printdoc hyperlinks.opm + +\sec[maketoc] Making table of contents +\printdoc maketoc.opm + +\sec PDF outlines +\secc Nesting PDF outlines +\printdoctail outlines.opm +\printdoc outlines.opm +\secc Strings in PDF outlines +\printdoctail pdfuni-string.opm +\printdoc pdfuni-string.opm + +\sec[sections] Chapters, sections, subsections +\printdoc sections.opm + +\sec[lists] Lists, items +\printdoc lists.opm + +\sec Verbatim, listings +\secc Inline and \"display" verbatim +\printdoc verbatim.opm +\secc[hisyntax] Listings with syntax highlighting +\printdoctail hi-syntax.opm +\printdoc hi-syntax.opm + +\sec Graphics +\printdoc graphics.opm + +\sec[table] The \code{\\table} macro +\printdoc table.opm + +\sec Balanced multi-columns +\printdoc multicolumns.opm + +\sec Citations, bibliography +\secc[bib] Macros for citations and bibliography preloaded in the format +\printdoc cite-bib.opm +\secc[usebib] The \code{\\usebib} command +\printdoctail usebib.opm +\secc The \code{usebib.opm} macro file loaded when \code{\\usebib} is used +\printdoc usebib.opm + +\secc[isobib] Usage of the \code{bib-iso690} style +{\everyintt={\catcode`\<=13 \visiblesp} +\printdoctail bib-iso690.opm } + +\secc Implementation of the \code{bib-iso690} style +\printdoc bib-iso690.opm + +\sec[makeindex] Sorting and making Index +\printdoc makeindex.opm + +\sec Footnotes and marginal notes +\printdoc fnotes.opm + +\sec Styles + \OpTeX/ provides three styles: `\report`, `\letter` and `\slides`. + Their behavior is documented in user part of the manual in the section + \ref[styles] and `\slides` style (for presentations) is documented in + `op-slides.pdf` which is an example of the presentation. +\secc \code{\\report} and \code{\\letter} styles +\printdoc styles.opm +\secc[slides] \code{\\slides} style for presentations +\printdoc slides.opm + +\sec Logos +\printdoc logos.opm + +\sec Multilingual support +\secc Lovercase, uppercase codes +\printdoctail uni-lcuc.opm +\secc Hyphenations +\printdoc hyphen-lan.opm +\printdoctail hyphen-lan.opm +\secc[langphrases] Multilingual phrases and quotation marks +\printdoc languages.opm + +\sec Other macros +Miscellaneous macros are here. +\printdoc others.opm + +\sec Printing documentation +\printdoctail doc.opm +\printdoc doc.opm + +\enddocument + diff --git a/Master/texmf-dist/doc/luatex/optex/optex-userdoc.tex b/Master/texmf-dist/doc/luatex/optex/optex-userdoc.tex new file mode 100644 index 00000000000..470214dfdc3 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/optex/optex-userdoc.tex @@ -0,0 +1,1803 @@ +%% This is part of OpTeX project, see http://petr.olsak.net/optex + +% This file is read from optex-doc.tex +% Use: optex optex-doc (three times) to create whole documentation. + +\sec Starting with \OpTeX/ +%%%%%%%%%%%%%%%%%%%%%%%%% + +\new +\OpTeX/ is compiled as a format for \LuaTeX/. Maybe there is a command +`optex` in your \TeX/ distribution. Then you can write into command line + +\begtt +optex document +\endtt +% +You can try to process `optex op-demo` or `optex optex-doc`. + +If there is no `optex` command, see more information about installation +\OpTeX/ at \url{http://petr.olsak.net/optex}. + +A minimal document should be + +\begtt +\fontfam[LMfonts] +Hello World! \bye +\endtt + +The first line \~`\fontfam[LMfonts]` tells that Unicode Latin Modern +fonts (derived from Computer Modern) are used. If you omit this line then +preloaded Latin Modern fonts are used but preloaded fonts cannot be in +Unicode\fnote +{This is a technical limitation of \LuaTeX/ for fonts downloaded in formats: +only 8bit fonts can be preloaded.}. +So the sentence `Hello World` will be OK without the first line, but you +cannot print such sentence in another languages (for example `Ahoj světe!`) +where Unicode fonts are needed +because of the characters like `ě` are not mapped correctly in preloaded +fonts. + +A somewhat larger example with common settings should be: + +\begtt \catcode`!=0 +\fontfam[Termes] % selecting Unicode font family Termes (section !ref[fontfam]) +\typosize[11/13] % setting default font size and baselineskip (sec. !ref[sizes]) +\margins/1 a4 (1,1,1,1)in % setting A4 paper, 1 in margins (section !ref[marg]) +\cslang % Czech hyphenation patterns (section !ref[lang]) + +Tady je zkušební textík v českém jazyce. +\bye +\endtt +% +You can look at `op-demo.tex` file for more complex, but still simple example. + + +\sec Page layout +%%%%%%%%%%%%%%%% + +\secc[marg] Setting the margins +%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +The \^`\margins` command declares margins of the document. This command have +the following parameters: + +\begtt \catcode`\<=13 +\margins/<pg> <fmt> (<left>,<right>,<top>,<bot>)<unit> + example: +\margins/1 a4 (2.5,2.5,2,2)cm +\endtt + +Parameters are: + +\begitems +* <pg> \dots\ `1` or `2` specifies one-page or two-pages design. +* <fmt> \dots\ paper format (a4, a4l, a5, letter, etc. or user defined). +* <left>, <right>, <top>, <bot> \dots\ gives the amount of left, right, + top and bottom margins. +* <unit> \dots\ unit used for values <left>, <right>, <top>, <bot>. +\enditems + +Each of the parameters <left>, <right>, <top>, <bot> can be empty. +If both <left> and <right> are nonempty then `\hsize` is set. Else `\hsize` +is unchanged. If both <left> and <right> are empty then typesetting area is +centered in the paper format. The analogical rule works when <top> or <bot> +parameter is empty (`\vsize` instead `\hsize` is used). Examples: + +\begtt +\margins/1 a4 (,,,)mm % \hsize, \vsize untouched, + % typesetting area centered +\margins/1 a4 (,2,,)cm % right margin set to 2cm + % \hsize, \vsize untouched, vertically centered +\endtt + +If `<pg>=1` then all pages have the same margins. If `<pg>=2` then the +declared margins are true for odd pages. The margins at the even pages are +automatically mirrored in such case, it means that <left> is replaced by +<right> and vice versa. + +\OpTeX/ declares following paper formats: a4, a4l (landscape~a4), +a5, a5l, b5, letter and user can declare another own format by `\sdef`: + +\begtt +\sdef{_pgs:b5l}{(250,176)mm} +\sdef{_pgs:letterl}{(11,8.5)in} +\endtt + +The `<fmt>` can be also in the form `(<width>,<height>)<unit>` where `<unit>` is +optional. If it is missing then `<unit>` after margins specification is +used. For example: + +\begtt +\margins/1 (100,200) (7,7,7,7)mm +\endtt +% +declares the paper 100$\times$200\,mm with all four margins 7\,mm. The spaces +before and after <fmt> parameter are necessary. + +The command \^`\magscale[<factor>]` scales the whole typesetting area. +\new The fixed point of such scaling is the upper left corner of the paper sheet. +Typesetting (breakpoints etc.) is unchanged. All units are relative after +such scaling. Only paper formats dimensions stays unscaled. Example: + +\begtt +\margins/2 a5 (22,17,19,21)mm +\magscale[1414] \margins/1 a4 (,,,)mm +\endtt +% +The first line sets the `\hsize` and `\vsize` and margins for final +printing at a5 format. The setting on the second line centers the scaled +typesetting area to the true a4 paper while breaking points for paragraphs +and pages are unchanged. It may be usable for +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". +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 +centered page number by default. You can set the \^`\footline` to empty +using \^`\nopagenumbers` macro. + +The margins declared by \^`\margins` macro (documented in the previous +section~\ref[marg]) is concerned to the page body, +i.e.\ the \^`\headline` and \^`\footline` are placed to the top and bottom +margins. + +The distance between the \^`\headline` and the top of the page body is given by +the \^`\headlinedist` register. The distance between bottom of the page body and +the \^`\footline` is given by \^`\footlinedist`. The default values are: + +\begtt +\headline = {} +\footline = {\_hss\_rmfixed \_folio \_hss} % \folio expands to page number +\headlinedist = 14pt % from baseline of \headline to top of page body +\footlinedist = 24pt % from last line in pagebody to baseline of footline +\endtt + +The page body should be divided to top insertions (floating tables and +figures) followed by a real text and followed by footnotes. +Typically, only real text is here. + +The \^`\pgbackground` tokens list is empty by default but it can be used for +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`. + + +\secc Footnotes and marginal notes +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +The Plain \TeX/'s macro \^`\footnote` can be used as usual. But a new macro +\^`\fnote{<text>}` is defined. The footnote mark is added automatically and it +is numbered +\new +on each chapter from one\fnote +{You can declare \^`\fnotenumglobal` if you want footnotes numbered in whole +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`. + +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 +case then you can use the command \^`\fnotemark``<numeric-label>` inside the box: only the +footnote mark is generated here. When the box is finished you can use +\^`\fnotetext{<text>}`. This macro puts the <text> to the footnote. +The <numeric-label> have to be `1` if only one such command is in the box. +Second \^`\fnotemark` inside the same box have to have the parameter `2` etc. +The same number of \^`\fnotetext`s have to be written +after the box as the number of \^`\fnotemark`s inserted inside the box. +Example: + +\begtt +Text in a paragraph\fnote{First notice}... % a "normal" footnote +\table{...}{...\fnotemark1...\fnotemark2...} % two footnotes in a box +\fnotetext{Second notice} +\fnotetext{Third notice} +... +\table{...}{...\fnotemark1...} % one footnote in a box +\fnotetext{Fourth notice} +\endtt + +The marginal note can be printed by the \^`\mnote{<text>}` macro. The <text> +is placed to the right margin on the odd pages and it is placed to the left +margin on the even pages. This is done after second \TeX{} run because the +relevant information is stored in an external file and read from it again. +If you need to place the notes only to the fixed margin write +\^`\fixmnotes\right` or \^`\fixmnotes\left`. + +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. + + +\sec Fonts +%%%%%%%%%% + +\secc[fontfam] Font families +%%%%%%%%%%%%%%%%%%%%%%% + +You can select the font family by \^`\fontfam[<Family-name>]`. +The argument <Family-name> is case insensitive and spaces are ignored in it. For +example, \^`\fontfam[LM Fonts]` is equal to \^`\fontfam[LMfonts]` and it is equal +to \^`\fontfam[lmfonts]`. Several aliases are prepared, thus +\^`\fontfam[Latin Modern]` can be used for loading Latin Modern family too. + +If you write \^`\fontfam[?]` then all font families registered in \OpTeX/ +are listed on the terminal and in the log file. +If you write \^`\fontfam[catalog]` then a catalog of all fonts registered in +\OpTeX/ and available in your \TeX/ system is printed. The instructions +how to register your own font family is appended in such catalog. + +If the family is loaded then {\em font modifiers} applicable in such font family +are listed on the terminal: (`\caps`, `\cond` for example). +And there are four basic {\em variant selectors} (\^`\rm`, \^`\bf`, \^`\it`, \^`\bi`). +The usage of variant selectors is the same as in Plain \TeX: +`{\it italics text}`, `{\bf bold text}` etc. + +The font modifiers (`\caps`, `\cond` for example) can +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` +gives {\caps \rm First text \it Second text}. + +\new +There is one special variant selector \^`\currvar` which does not change the +selected variant but reloads the font due to (maybe newly +specified) font modifier(s). + +The context between variants \^`\rm` $\leftrightarrow$ \^`\it` and +\^`\bf` $\leftrightarrow$ \^`\bi` is kept by the \^`\em` +macro (emphasize text). +It switches from current \^`\rm` to \^`\it`, from current \^`\it` to \^`\rm`, from +current \^`\bf` to \^`\bi` and from current \^`\bi` to \^`\bf`. +The italics correction `\/` is inserted automatically, if needed. Example: + +\begtt +This is {\em important} text. % = This is {\it important\/} text. +\it This is {\em important} text. % = This is\/ {\rm important} text. +\bf This is {\em important} text. % = This is {\bi important\/} text. +\bi This is {\em important} text. % = This is\/ {\bf important} text. +\endtt + +\new +More about the \OpTeX/ Font Selection System is written 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. + +\secc[sizes] Font sizes +%%%%%%%%%%%%%%%%%%%%% + +The command \^`\typosize[<fontsize>/<baselineskip>]` sets the font size of text and +math fonts and baselineskip. If one of these two parameters is empty, the +corresponding feature stays unchanged. Don't write the unit of these +parameters. The unit is internally set to \^`\ptunit` which is 1pt by default. +You can change the unit by the command \^`\ptunit=<something-else>`, +for instance \^`\ptunit=1mm` enlarges all font sizes declared by \^`\typosize`. +Examples: + +\begtt +\typosize[10/12] % default of Plain TeX +\typosize[11/12.5] % font 11pt, baseline 12.5pt +\typosize[8/] % font 8pt, baseline unchanged +\endtt + +The commands for font size setting described in this section +have local validity. If you put them into a group, +the settings are lost when the group is finished. If you set +something relevant with paragraph shape (baselineskip given by +\^`\typosize` for example) then you must first finalize the +paragraph before closing the group: +`{\typosize[12/14] ...<text of paragraph>... \par}`. + +The command \^`\typoscale[<font-factor>/<baselineskip-factor>]` +sets the text and math fonts +size and baselineskip as a multiple of the current fonts size and +baselineskip. The factor is written in \"scaled"-like way, it means that 1000 +means factor one. The empty parameter is equal to the parameter 1000, +i.e. the value stays unchanged. Examples: + +\begtt +\typoscale[800/800] % fonts and baselineskip re-size to 80 % +\typoscale[\magstep2/] % fonts bigger 1,44times (\magstep2 expands to 1440) +\endtt + +First usage of \^`\typosize` or \^`\typoscale` macro in your document sets so +called {\em main values}, i.\,e.\ main font size and main baselineskip. They are internally +saved in registers \^`\mainfosize` and \^`\mainbaselineskip`. + +\new +The \^`\typoscale` command does scaling in respect to current values by default. +If you want to do it in respect to main values, type \^`\scalemain` immediately +before \^`\typoscale` command. + +\begtt +\typosize[12/14.4] % first usage in document, sets main values internally +\typosize[15/18] % bigger font +\scalemain \typoscale[800/800] % reduces from main values, no from current. +\endtt + +The size of the current font can be changed by the command +\^`\thefontsize[<font-size>]` or can be rescaled by +\^`\thefontscale[<factor>]`. These macros don't change math fonts sizes nor +baselineskip. + +\new +There is \"low level" \^`\setfontsize{<size-spec>}` command which behaves like +a font modifier and sets given font size used by next variant selectors. +It doesn't change the font size immediately, but following variant slelector +does it. For example \^`\setfontsize{at15pt}`\^`\currvar` sets current variant to 15pt. + +If you are using a font family with \"optical sizes feature" (i.\,e.\ there +are more recommended sizes of the same font which are not scaled +linearly; good example is Computer Modern aka Latin Modern fonts) +then the recommended size is selected by all mentioned commands automatically. + +More information about resizing of fonts is documented in the +section~\ref[setfontsize]. + +\secc Typesetting math +%%%%%%%%%%%%%%%%%%%%% + +\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. +% +\new +Most declared text font families (see \^`\fontfam` in the section~\ref[fontfam]) +are configured with recommended Unicode +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. + +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. + +The following math alphabets are available: + +\begtt \catcode`\$=3 \catcode`/=0 \medmuskip=0mu \adef{ }{ } +\mit % mathematical variables $abc-xyz,ABC-XYZ$ +\it % text italics $/it abc-xyz,ABC-XYZ$ +\rm % text roman $/rm abc-xyz,ABC-XYZ$ +\cal % normal calligraphics $/cal ABC-XYZ$ +\script % script $/script ABC-XYZ$ +\frak % fracture $/frak abc-xyz,ABC-XYZ$ +\bbchar % double stroked letters $/bbchar ABC-XYZ$ +\bf % sans serif bold $/bf abc-xyz,ABC-XYZ$ +\bi % sans serif bold slanted $/bi abc-xyz,ABC-XYZ$ +\endtt + +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 it, see the file `unimath-codes.opm` where +Unicode math variants of \^`\bf` and \^`\bi` selectors are defined. + +The math fonts can be scaled by \^`\typosize` and \^`\typoscale` macros. +Two math fonts collections are prepared: \^`\normalmath` for normal weight +and \^`\boldmath` for bold. The first one is set by default, the second one +is usable for math formulae in titles typeset in bold, for example. + +\new +You can use \^`\mathbox{<text>}` inside math mode. It behaves as `{\hbox{<text>}}` +(i.e. the <text> is printed in horizontal non-math mode) +but the size of the <text> is adapted to the context of math size (text or script or +scriptscript). + + +\sec Typical elements of document +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\secc[chap] Chapters and sections +%%%%%%%%%%%%%%%%%%%%%%%%%% + +The document 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): + +\begtt \catcode`\<=13 +\tit Document title <end of line> +\chap Chapter title <end of line> +\sec Section title <end of line> +\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. + +The implicit design of the titles of chapter etc.\ are implemented in the +macros \^`\_printchap`, \^`\_printsec` and \^`\_printsecc`. A designer can simply change +these macros if he/she needs another behavior. + +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 +breakpoints because \TeX/ does not interpret the meaning of the title. +User can put the \^`\nl` (it means newline) macro to the breakpoints. + +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. + +\secc[cap] Another numbered objects +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +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. + +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 +resets in each section by default. + +If the \^`\eqalignno` is used, then user can put \^`\eqmark` to the last column +before `\cr`. For example: + +\begtt +\eqalignno{ + a^2+b^2 &= c^2 \cr + c &= \sqrt{a^2+b^2} & \eqmark \cr} +\endtt + +Another automatically numbered object is a caption which is tagged by \^`\caption/t` for +tables and \^`\caption/f` for figures. The caption text follows. +The \^`\cskip` can be used between \^`\caption` text and the real object (table +or figure). You can use two orders: `<caption>\cskip <object>` or +`<object>\cskip <caption>`. +The \^`\cskip` creates appropriate vertical space between them. Example: + +\begtt +\caption/t The dependency of the computer-dependency on the age. +\cskip +\noindent\hfil\table{rl}{ + age & value \crl\noalign{\smallskip} + 0--1 & unmeasured \cr + 1--6 & observable \cr + 6--12 & significant \cr + 12--20 & extremal \cr + 20--40 & normal \cr + 40--60 & various \cr + 60--$\infty$ & moderate} +\endtt + +This example produces: + +\medskip +\caption/t The dependency of the computer-dependency on the age. +\cskip +\noindent\hfil\table{rl}{ + age & value \crl\noalign{\smallskip} + 0--1 & unmeasured \cr + 1--6 & observable \cr + 6--12 & significant \cr + 12--20 & extremal \cr + 20--40 & normal \cr + 40--60 & various \cr + 60--$\infty$ & moderate} +\medskip + +You can see that the word \"Table" followed by a number is added by the macro +`\caption/t`. +The caption text is centered. If it occupies more lines then the +last line is centered. + +The macro \^`\caption/f` behaves like \^`\caption/t` but it is intended for +figure captions with independent numbering. +The word (Table, Figure) depends on the actual selected language (see +section~\ref[lang] about languages). + +If you wish to make the table or figure as floating object, you need to use +Plain \TeX/ macros \^`\midinsert` or \^`\topinsert` terminated by \^`\endinsert`. +Example: + +\begtt +\topinsert % table and its caption printed at the top of the current page + <caption and table> +\endinsert +\endtt + +\new +There are five prepared counters `A`, `B`, `C`, `D` and `E`. +They are reset in each chapter and section\fnote +{This feature can be changed, see the section~\ref[sections] in the technical documentation.}. +They can be used in context of \^`\numberedpar` `<letter>{<text>}` +macro. For example: +\begtt +\def\theorem {\numberedpar A{Theorem}} +\def\corollary {\numberedpar A{Corollary}} +\def\definition {\numberedpar B{Definition}} +\def\example {\numberedpar C{Example}} +\endtt +% +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... +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... + + +\secc References +%%%%%%%%%%%%%%% + +Each automatically numbered object documented in +sections \ref[chap] and \ref[cap] can be referenced +\new +if optional parameter +`[<label>]` is appended to \^`\chap`, \^`\sec`, +\^`\secc`, \^`\caption/t`, \^`\caption/f` or \^`\eqmark`. The alternative syntax is +to use \^`\label[<label>]` before mentioned commands (not necessarily directly +before). The reference is realized by \^`\ref[<label>]` or \^`\pgref[<label>]`. +Example: + +\begtt +\sec[beatle] About Beatles + +\noindent\hfil\table{rl}{...} % the table +\cskip +\caption/t [comp-depend] The dependency of the comp-dependency on the age. + +\label[pythagoras] +$$ a^2 + b^2 = c^2 \eqmark $$ + +Now we can point to the section~\ref[beatle] on the page~\pgref[beatle] +or write something about the equation~\ref[pythagoras]. Finally there +is an interesting Table~\ref[comp-depend]. +\endtt + +If there are forward referenced objects then user have to run \TeX{} twice. +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. +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 +<text> is established. The \^`\ref[<label>]` will print <text>. + +By default, labels are not printed, of course. But if you are preparing a +draft version of your document then you can declare \^`\showlabels`. The labels +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 +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. +\enditems + +The last object is an external link and it is colored by +<color-out>. Others links are internal and they are colored by +<color-in>. Example: + +\begtt +\hyperlinks \Blue \Green % internal links blue, URLs green. +\endtt + +You can use another marking of active links: by frames which are visible in +the PDF viewer but invisible when the document is printed. The way to do it +is to define the macros \^`\pgborder`, \^`\tocborder`, \^`\citeborder`, +\^`\refborder` and \^`\urlborder` as the triple of RGB components of the used +color. Example: + +\begtt +\def\tocborder {1 0 0} % links in table of contents: red frame +\def\pgborder {0 1 0} % links to pages: green frame +\def\citeborder {0 0 1} % links to references: blue frame +\endtt + +By default these macros are not defined. It means that no frames are created. + +The hyperlinked footnotes can be activated by \^`\fnotelinks` `<color-fnt> <color-fnf>` +where footnote marks in text have `<color-fnt>` and the same footnote marks +in footnotes have <color-fnf>. You can define relevant borders +\^`\fntborder` and \^`\fnfborder` analogically as \^`\pgborder` (for example). + +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 +\^`\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. + +The \^`\url` macro prints its parameter in \^`\tt` font and creates a potential +breakpoints in it (after slash or dot, for example). If \^`\hyperlinks` +declaration is used then the parameter of \^`\url` is treated as an external URL link. +An example: `\url{http://www.olsak.net}` creates \url{http://www.olsak.net}. +The characters \code{\%}, `\`, `#`, `{` and `}` have to be protected by +backslash in the \^`\url` argument, the other special characters `~`, +`^`, `&` can be written as single character\fnote +{More exactly, there are the same rules as for `\code` command, see +section~\ref[verbatim].}. +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[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 +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 +triangle symbol after that. + +\new +If you are using a special unprotected macro in section titles then \^`\outlines` macro +may crash. You must declare variant of the macro for outlines case which is +expandable. Use \~`\regmacro` in such case. See the section \ref[toc] for more information +about \~`\regmacro`. + +The command \^`\insertoutline{<text>}` inserts next entry into PDF outlines at +the main level~0. These entries can be placed before table of contents (created +by \^`\outlines`) or after it. Theirs hyperlink destination is in the place +where the \^`\insertoutline` macro is used. + +\secc Lists +%%%%%%%%%% + +The list of items is surrounded by \^`\begitems` and \^`\enditems` commands. +The asterisk (`*`) is active within this environment and it starts one item. +The item style can be chosen by the \^`\style` parameter written after \^`\begitems`: + +\begtt +\style o % small bullet +\style O % big bullet (default) +\style - % hyphen char +\style n % numbered items 1., 2., 3., ... +\style N % numbered items 1), 2), 3), ... +\style i % numbered items (i), (ii), (iii), ... +\style I % numbered items I, II, III, IV, ... +\style a % items of type a), b), c), ... +\style A % items of type A), B), C), ... +\style x % small rectangle +\style X % big rectangle +\endtt + +For example: + +\begtt +\begitems +* First idea +* Second idea in subitems: + \begitems \style i + * First sub-idea + * Second sub-idea + * Last sub-idea + \enditems +* Finito +\enditems +\endtt +% +produces: + +\begitems +* First idea +* Second idea in subitems: + \begitems \style i + * First sub-idea + * Second sub-idea + * Last sub-idea + \enditems +* Finito +\enditems + +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 +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 +example: +\begtt +\everylist={\ifcase\ilevel\or \style X \or \style x \else \style - \fi} +\endtt + +You can say \^`\begitems` \^`\novspaces` if you don't want vertical spaces above +and below the list. The nested item list are without vertical spaces +automatically. More information about design of lists of items should be +found in the section~\ref[lists]. + +\secc Tables +%%%%%%%%%%% + +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). +These letters can be combined by the `|` character (vertical line). Example + +\begtt +\table{||lc|r||}{ \crl + Month & commodity & price \crli \tskip2pt + January & notebook & \$ 700 \cr + February & skateboard & \$ 100 \cr + July & yacht & k\$ 170 \crl} +\endtt +% +generates the following result: + +\bigskip +\noindent\hfil\table{||lc|r||}{ \crl + Month & commodity & price \crli \tskip2pt + January & notebook & \$ 700 \cr + February & skateboard & \$ 100 \cr + July & yacht & k\$ 170 \crl} +\bigskip + +Apart from `l`, `r`, `c` declarators, you can use the `p{<size>}` declarator +which declares the column of given width. More precisely, a long text in +the table cell is printed as an paragraph with given width. +To avoid problems with narrow left-right aligned paragraphs you can write +`p{<size>`\^`\raggedright}`, then the paragraph will be only left aligned. + +You can use `(<text>)` in the <declaration>. Then this text is applied in +each line of the table. For example `r(\kern10pt)l` adds more 10\,pt space +between `r` and `l` rows. + +An arbitrary part of the <declaration> can be repeated by a <number> +prefixed. For example `3c` means `ccc` or `c 3{|c}` means +`c|c|c|c`. Note that spaces in the <declaration> are ignored and you +can use them in order to more legibility. + +The command `\cr` used in the <data> part of the table +is generally known. It marks end row of the table. +Moreover \OpTeX/ defines following similar commands: + +\begitems +* \^`\crl` \dots\ the end of the row with a 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. +* \^`\crlp{<list>}` \dots\ like \^`\crli` but the lines are drawn only in the + columns mentioned in comma separated `<list>` of their numbers. + The <list> can include `<from>-<to>` declarators, for example + \^`\crlp{1-3,5}` is equal to \^`\crlp{1,2,3,5}`. +\enditems + +The \^`\tskip<dimen>` command works like the `\noalign{\vskip<dimen>}` +after `\cr*` commands but it doesn't interrupt the vertical lines. + +\new +You can use following parameters for the \^`\table` macro. Default values are listed +too. + +\begtt +\everytable={} % code used in \vbox before table processing +\thistable={} % code used in \vbox, it is removed after using it +\tabiteml={\enspace} % left material in each column +\tabitemr={\enspace} % right material in each column +\tabstrut={\strut} % strut which declares lines distance in the table +\tablinespace=2pt % additional vert. space before/after horizontal lines +\vvkern=1pt % space between lines in double vertical line +\hhkern=1pt % space between lines in double horizontal line +\endtt + +Example: if you do \^`\tabiteml={$\enspace}`\^`\tabitemr={\enspace$}` then +the \^`\table` acts like \LaTeX's array environment. + +If there is an item which spans to more than one column in the table then +the macro \^`\multispan{<number>}` (from Plain \TeX) can help you. Another +alternative is +the command \^`\mspan``<number>[<declaration>]{<text>}` +which spans <number> columns and formats the <text> by the +<declaration>. The <declaration> must include a declaration of only one column +with the same syntax as common \^`\table` <declaration>. +If your table includes vertical rules and you want to +create continuous vertical rules by \^`\mspan`, then use rule declarators `|` +only after `c`, `l` or `r` letter in \^`\mspan` <declaration>. The +exception is only in the case when \^`\mspan` includes first +column and the table have rules on the left side. The example of \^`\mspan` +usage is below. + +The \^`\frame{<text>}` makes a frame around <text>. You can put the whole \^`\table` +into \^`\frame` if you need double-ruled border of the table. Example: + +\begtt +\frame{\table{|c||l||r|}{ \crl + \mspan3[|c|]{\bf Title} \crl \noalign{\kern\hhkern}\crli + first & second & third \crlli + seven & eight & nine \crli}} +\endtt +% +creates the following result: + +\hfil\frame{\table{|c||l||r|}{\crl + \mspan3[|c|]{\bf Title} \crl \noalign{\kern\hhkern}\crli + first & second & third \crlli + seven & eight & nine \crli}} +\bigskip + +The `c`, `l`, `r` and `p` are default \"declaration letters" but you can define +more such letters by `\def\_tabdeclare<letter>{<left>##<right>}`. More about +it is in technical documentation in the section~\ref[table]. + +The rule width of tables and implicit width of all `\vrule`s and `\hrule`s +can be set by the command \^`\rulewidth=<dimen>`. The default value given +by \TeX/ is 0.4\,pt. + +Many tips about tables can be seen on the site +\url{http://petr.olsak.net/optex/optex-tricks.html}. + +\label[verbatim]\secc Verbatim +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +The display verbatim text have to be surrounded by the \^`\begtt` and +\^`\endtt` couple. +The in-line verbatim have to be tagged (before and after) +by a character which is declared by +\^`\activettchar``<char>`. For example \code{\\activettchar`} +declares the character \code{`} +for in-line verbatim markup. +And you can use \code{`\\relax`} for +verbatim `\relax` (for example). +\new +Another alternative of printing in-line +verbatim text is \~`\code{<text>}` (see below). + +If the numerical register \^`\ttline` is set to the non-negative value then +display verbatim will number the lines. The first line has the number +\^`\ttline+1` and when the verbatim ends then the \^`\ttline` value is equal to the +number of last line printed. Next \^`\begtt...`\^`\endtt` environment will follow +the line numbering. \OpTeX/ sets \^`\ttline=-1` by default. + +The indentation of each line in display verbatim is controlled by +\^`\ttindent` register. This register is set to the `\parindent` by default. +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 +you need to define active character in the \^`\everytt`, use \^`\adef` as in the +following example: + +\begtt \adef@{\string\endtt} +\everytt={\adef!{?}\adef?{!}} +\begtt +Each occurrence of the exclamation mark will be changed to +the question mark and vice versa. Really? You can try it! +@ +\endtt +% +The \^`\adef` command sets its parameter as active {\it after\/} +the parameter of \^`\everytt` is read. So you don't have to worry about active +categories in this parameter. + +There is an alternative to \^`\everytt` named \^`\everyintt` which is used for +in-line verbatim surrounded by an \^`\activettchar` or processed by the \~`\code` +command. + +The \^`\everytt` is applied to all \^`\begtt...`\^`\endtt` environments (if it is not +decared in a group). There are tips for such global `\everytt` definitions here: + +\begtt \adef!{\char9251 } +\everytt={\typosize[9/11]} % setting font size for verbatim +\everytt={\ttline=0} % each listing will be numbered from one +\everytt={\visiblesp} % visualization!of!spaces +\endtt + +\new +If you want to apply a special code only for one \^`\begtt...`\^`\endtt` +environment then don't set any \^`\everytt` but put desired material at the +same line where \^`\begtt` is. For example: + +\begtt \adef@{\string\endtt} +\begtt \adef!{?}\adef?{!} +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. +\new +You can use more robust command \^`\code{<text>}` in such +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 +the <text>). Examples: + +\begtt +\code{\\text, \%\#} ... prints \text, %# +\code{@{..}*&^$ $} ... prints @{..}*&^$ $ without escaping, but you can + escape these characters too, if you want. +\code{a \ b} ... two spaces between a b, second one must be escaped +\code{xy\{z} ... xy{z ... unbalanced brace must be escaped +\code{^\^M} ... prints ^^M, the second ^ must be escaped +\endtt + +You can print verbatim listing from external files by the \^`\verbinput` command. +Examples: + +\begtt +\verbinput (12-42) program.c % listing from program.c, only lines 12-42 +\verbinput (-60) program.c % print from begin to the line 60 +\verbinput (61-) program.c % from line 61 to the end +\verbinput (-) program.c % whole file is printed +\verbinput (70+10) program.c % from line 70, only 10 lines printed +\verbinput (+10) program.c % from the last line read, print 10 lines +\verbinput (-5+7) program.c % from the last line read, skip 5, print 7 +\verbinput (+) program.c % from the last line read to the end +\endtt + +\new +You can insert additional commands for the \^`\verbinput` before +first opening bracket. They are processed in the local group. +For example, `\verbinput \hsize=20cm (-) program.c`. + +The \~`\ttline` influences the line numbering by the same way as in +\~`\begtt...`\~`\endtt` environment. If \~`\ttline=-1` then real line numbers are +printed (this is default). If \code{\\ttline<-1} then no line +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 +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. +\OpTeX/ implements C, Python, \TeX/, HTML and XML syntax highlighting. +More languages can be declared, see the section~\ref[hisyntax]. + + +\sec Autogenerated lists +%%%%%%%%%%%%%%%%%%%%%%%% + +\secc[toc] Table of contents +%%%%%%%%%%%%%%%%%%%%%% + +The \^`\maketoc` command prints the table of contents of all \~`\chap`, \~`\sec` +and \~`\secc` used in the document. These data are read from external `*.ref` file, so +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 +is typically not referenced to itself. You can print the unnumbered and unreferenced +title of the section by the code: + +\begtt +\nonum\notoc\sec Table of Contents +\endtt +If you need a customization of the design of the TOC, read the +section~\ref[maketoc]. + +\new +If you are using a special macro in section or chapter titles +and you need different behavior of such macro in other cases then use +\^`\regmacro{<case-toc>}{<case-mark>}{<case-outline>}`. +The parameters are applied locally in given cases. The \^`\regmacro` can be +used repeatedly: then the parameters are accumulated (for more macros). +If a parameter is empty then original definition is used in given case. +For example: + +\begtt +% default value of \mylogo macro used in text and in the titles: +\def\mylogo{\leavevmode\hbox{{\Red\it My}{\setfontsize{mag1.5}\rm Lo}Go}} +% another variants: +\regmacro {\def\mylogo{\hbox{\Red My\Black LoGo}}} % used in TOC + {\def\mylogo{\hbox{{\it My}\/LoGo}}} % used in running heads + {\def\mylogo{MyLoGo}} % used in outlines +\endtt + +\secc Making the index +%%%%%%%%%%%%%%%%%%%%% + +The index can be included into document by the \^`\makeindex` macro. No external +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 +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: + +\begtt +The \ii resistor resistor is a passive electrical component ... +\endtt + +You cannot double the word if you use the \^`\iid` instead \^`\ii`: + +\begtt +The \iid resistor is a passive electrical component ... +or: +Now we'll deal with the \iid resistor . +\endtt + +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: + +\medskip + +linear~dependency 11, 40--50 + +--- independency 12, 42--53 + +--- space 57, 76 + +--- subspace 58 + +\medskip + +To do this you have to declare the parts of the index entries by the `/` separator. +Example: + +\begtt +{\bf Definition.} +\ii linear/space,vector/space +{\em Linear space} (or {\em vector space}) is a nonempty set of... +\endtt + +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`. + +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 `,@` +at the end of the \~`\ii` parameter. Example: + +\begtt +\ii linear/space,vector/space,@ +is equivalent to: +\ii linear/space,vector/space \ii space/linear,space/vector +\endtt + +If you really need to insert the space into the index entry, write `~`. + +The \~`\ii` or \~`\iid` commands can be preceded by \^`\iitype` `<letter>`, then such +reference (or more references generated by one \~`\ii`) has specified type. +The page numbers of such references should be formatted +specially in the index. \OpTeX/ implements only \^`\iitype` `b`, +\^`\iitype` `i` and \^`\iitype` `u`: +the page number in bold or in italics or underlined is printed +in the index when these types are used. Default index type is empty, which +prints page numbers in normal font. The \TeX/book index is good example. + +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 +\begmulti <number of columns> +<text> +\endmulti +\endtt +The columns will be balanced. The Index can be printed by the following +code: + +\begtt +\sec Index +\begmulti 3 \makeindex \endmulti +\endtt + +Only \"pure words" can be propagated to the index by the \~`\ii` command. It +means that there cannot be any macro, \TeX/ primitive, math selector etc. +But there is another possibility to create such complex index entry. Use +\"pure equivalent" in the \~`\ii` parameter and map this equivalent to the +real word which is printed in the index by the \^`\iis` command. Example: + +\begtt +The \ii chiquadrat $\chi$-quadrat method is +... +If the \ii relax `\relax` command is used then \TeX/ is relaxing. +... +\iis chiquadrat {$\chi$-quadrat} +\iis relax {\code{\\relax}} +\endtt +% +The \^`\iis` `<equivalent> {<text>}` creates one entry in the \"dictionary +of the exceptions". The sorting is done by the <equivalent> but the +<text> is printed in the index entry list. + +The sorting rules when \^`\makeindex` runs depends on the current language. +See section~\ref[lang] about languages selection. + +\secc Bib\TeX/ing +%%%%%%%%%%%%%%%% + +The command \^`\cite[<label>]` (or +\hbox{\^`\cite[<label-1>,<label-2>,...,<label-n>]`}) +creates the citation in the form [42] (or [15,~19,~26]). +If \^`\shortcitations` is declared at the beginning of the document then +continuous sequences of numbers are re-printed like this: +\hbox{[3--5,~7,~9--11]}. If +\^`\sortcitations` is declared then numbers generated by one \^`\cite` command +are sorted upward. + +If \^`\nonumcitations` is declared then the marks instead numbers are generated +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 \^`\ecite[<label>]{<text>}` prints the `<text>` only, but the entry labeled +<label> is decided as to be cited. If \~`\hyperlinks` is used then <text> +is linked to the references list. + +You can define alternative formating of \^`\cite` command. Example: + +\begtt +\def\cite[#1]{(\rcite[#1])} % \cite[<label>] creates (27) +\def\cite[#1]{$^{\rcite[#1]}$} % \cite[<label>] creates^{27} +\endtt + +The numbers printed by \^`\cite` correspond to the same numbers generated in +the list of references. There are two possibilities to generate this +references list: + +\begitems +* Manually using \~`\bib[<label>]` commands. +* By \~`\usebib/<type> (<style>) <bib-base>` command which reads `*.bib` + files directly. +\enditems + +\new +Note that another two possibilities documented in OPmac (using external +Bib\TeX/ program) isn't supported because Bib\TeX/ is old program which does not +support Unicode. And Biber seems to be not compliant with Plain \TeX. + +\medskip\noindent +{\bf References created manually using \^`\bib[<label>]` command.} + +\begtt +\bib [tbn] P. Olšák. {\it\TeX{}book naruby.} 468~s. Brno: Konvoj, 1997. +\bib [tst] P. Olšák. {\it Typografický systém \TeX.} + 269~s. Praha: CSTUG, 1995. +\endtt + +If you are using \~`\nonumcitations` then you need to declare the <marks> +used by \~`\cite` command. To do it you must use long form of the \^`\bib` +command in the format \^`\bib[<label>] = {<mark>}`. The spaces around +equal sign are mandatory. Example: + +\begtt +\bib [tbn] = {Olšák, 2001} + P. Olšák. {\it\TeX{}book naruby.} 468~s. Brno: Konvoj, 2001. +\endtt + +\noindent +{\bf Direct reading of `.bib` files} is possible by \^`\usebib` macro. +This macro reads and uses macro package `librarian.tex` by Paul Isambert. +The usage is: + +\begtt +\usebib/c (<style>) <bib-base> % sorted by \cite-order (c=cite), +\usebib/s (<style>) <bib-base> % sorted by style (s=style). +% example: +\usebib/s (simple) op-example +\endtt + +The <bib-base> is one or more `*.bib` database source files (separated by +spaces and without extension) and the <style> is the part of the filename +`bib-<style>.opm` where the formatting of the references list is +defined. \OpTeX/ supports `simple` or `iso690` styles. The features of +the `iso690` style is documented in the section~\ref[isobib] in detail. + +Not all records are printed from <bib-base> files: the command \^`\usebib` +selects only such bib-records which were used in \~`\cite` or \^`\nocite` +commands in your document. The \^`\nocite` behaves as \~`\cite` but prints +nothing. It only tells that mentioned bib-record should be printed in the +reference list. If \^`\nocite[*]` is used then all records from <bib-base> +are printed. + + +\sec Graphics +%%%%%%%%%%%%% + +\secc Colors +%%%%%%%%%%% + +\OpTeX/ provides a small number of color selectors: +{\Blue `\Blue`}, +{\Red `\Red`}, +{\Brown `\Brown`}, +{\Green `\Green`}, +{\Yellow `\Yellow`}, +{\Cyan `\Cyan`}, +{\Magenta `\Magenta`}, +{`\White`}, +{\Grey `\Grey`}, +{\LightGrey `\LightGrey`} and +`\Black`. User can define more +such selectors by setting four CMYK components +\new +or three RGB components. For example + +\begtt +\def \Orange {\setcmykcolor{0 0.5 1 0}} +\def \Purple {\setrgbcolor{1 0 1}} +\endtt + +\new +The command \^`\morecolors` reads more definitions of color selectors. +There is about 300 color names like +`\DeepPink`, `\Chocolate` etc. If there are numbered variants of the same +name, then the letters B, C, etc. are appended to the name in \OpTeX/. For example +`\Chocolate` is Chocolate1, `\ChocolateB` is Chocolate2 etc. + +\new +The color selectors work locally in groups by default but with limitations. See +the technical documentation, section~\ref[colors] for more information. + +The basic colors \^`\Blue`, \^`\Red`, \^`\Cyan`, \^`\Yellow` etc.\ are defined +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 +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 then it is converted. +The \^`\onlyrgb` creates colors more bright (usable for computer +presentations). On the other hand CMYK makes colors more true\fnote +{Printed output is more equal to the monitor preview specially if you are +using ICC profile for your printer.} +for printing. + +\new +You can define your color by a linear combination of previously defined colors using +\^`\colordef`. For example: + +\begtt +\colordef \myCyan {.3\Green + .5\Blue} % 30 % green, 50 % blue, 20% white +\colordef \DarkBlue {\Blue + .4\Black} % Blue mixed with 40 % of black +\colordef \myGreen{\Cyan+\Yellow} % exact the same as \Green +\colordef \MyColor {.3\Orange+.5\Green+.2\Yellow} +\endtt +% +The linear combination is done in CMYK substractive color space by default +(RGB colors used in \^`\colordef` argument are converted first). +If the resulting component is greater than 1 then it is truncated to 1. +If a convex linear combination (as in the last example above) is used then it +emulates color behavior on a painter's palette. +You can use \^`\rgbcolordef` instead \^`\colordef` if you want to mix colors +in the additive RGB color space. + +\def\coloron#1#2#3{% + \setbox0=\hbox{{#2#3}}\leavevmode + \localcolor \rlap{#1\strut \vrule width\wd0}\box0 +} +The following example defines the macro for the +\coloron\Yellow\Brown{colored text on the colored background}. Usage: +`\coloron<background><foreground>{<text>}` + +The `\coloron` can be defined as follows: + +\begtt +\def\coloron#1#2#3{% + \setbox0=\hbox{{#2#3}}% + \leavevmode \rlap{#1\strut \vrule width\wd0}\box0 +} +\coloron\Yellow\Brown{The brown text on the yellow background} +\endtt + +\secc Images +%%%%%%%%%%% + +The \^`\inspic` `{<filename>.<extension>}` or +\^`\inspic` `<filename>.<extension><space>` +inserts the picture stored in +the graphics file with the name `<filename>.<extension>` to the document. +You can set the picture width by \^`\picw=<dimen>` +before \^`\inspic` command which declares the width of the picture +The image files can be in the PNG, JPG, JBIG2 or PDF format. + +The \^`\picwidth` is an equivalent register to `\picw`. Moreover there is an +\^`\picheight` register which denotes the height of the picture. If both +registers are set then the picture will be (probably) deformed. + +The image files are searched in \^`\picdir`. This token list is empty +by default, this means that the image files are searched in the +current directory. Example: \^`\picdir={img/}` supposes that image files are +in `img` subdirectory. Note: the directory name must end by `/` in +the \^`\picdir` declaration. + +Inkscape\fnote +{A powerfull and free wysiwyg editor for creating vector graphics.} +is able to save a picture to PDF and labels of the picture to another +file\fnote +{Chose \"Omit text in PDF and create LaTeX file" option.}. +This second file should be read by \TeX/ in order to print labels +in the same font as document font. \OpTeX/ supports this feature by +\^`\inkinspic` `{<filename>.pdf}` command. It reads and displays +both: PDF image and labels generated by Inkscape. + +If you want to create a vector graphics (diagrams, schema, geometry +skicing) then you can do it by Wysiwyg graphics editor (Inkscape, Geogebra for +example), export the result to PDF and include it by \^`\inspic`. +If you want to \"programm" such pictures then Tikz package is recommended. +It works in Plain \TeX. + +\secc PDF transformations +%%%%%%%%%%%%%%%%%%%%%%%% + +All typesetting elements are transformed by linear +transformation given by the current transformation matrix. The +`\pdfsetmatrix` `{<a> <b> <c> <d>}` command makes the internal multiplication +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 +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. + +\OpTeX/ provides two special transformation macros +\^`\pdfscale` and \^`\pdfrotate`: + +\begtt +\pdfscale{<horizontal-factor>}{<vertical-factor>} +\pdfrotate{<angle-in-degrees>} +\endtt + +These macros simply calls the properly `\pdfsetmatrix` command. + +It is known that the composition of transformations is not commutative. It +means that the order is important. You have to read the transformation +matrices from right to left. Example: + +\begtt +First: \pdfsave \pdfrotate{30}\pdfscale{-2}{2}\rlap{text1}\pdfrestore + % text1 is scaled two times and it is reflected about vertical axis + % and next it is rotated by 30 degrees left. +second: \pdfsave \pdfscale{-2}{2}\pdfrotate{30}\rlap{text2}\pdfrestore + % text2 is rotated by 30 degrees left then it is scaled two times + % and reflected about vertical axis. +third: \pdfsave \pdfrotate{-15.3}\pdfsetmatrix{2 0 1.5 2}\rlap{text3}% + \pdfrestore % first slanted, then rotated by 15.3 degrees right +\endtt +% +\par\nobreak\bigskip\smallskip +This gives the following result. +First: \pdfsave \pdfrotate{30}\pdfscale{-2}{2}\rlap{text1}\pdfrestore +second: \pdfsave \pdfscale{-2}{2}\pdfrotate{30}\rlap{text2}\pdfrestore +third: \pdfsave \pdfrotate{-15.3}\pdfsetmatrix{2 0 1.5 2}\rlap{text3}\pdfrestore +\par\nobreak\bigskip\penalty0%\bigskip + +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 +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. + +Example: \~`\frame{\transformbox{\pdfscale{1}{1.5}\pdfrotate{-10}}{moj}}` +creates \frame{\transformbox{\pdfscale{1}{1.5}\pdfrotate{-10}}{moj}}. + +The \^`\rotbox{<deg>}{<text>}` is shortcut for +\^`\transformbox{\pdfrotate{<deg>}}{<text>}`. + +\secc Ovals, circles +%%%%%%%%%%%%%%%%%%%% + +\new +The \^`\inoval{<text>}` creates a box like this: \inoval{text}. +Multiline text can be put in an oval by the command \^`\inoval{\vbox{<text>}}`. +Local settings can be set by +\^`\inoval[<settings>]{<text>}` or you can re-declare global settings by +\^`\ovalparams={<settings>}`. The default settings are: + +\begtt +\ovalparams={\roundness=2pt % diameter of circles in the corners + \fcolor=\Yellow % color used for filling oval + \lcolor=\Red % line color used in the border + \lwidth=0.5bp % line width in the border + \shadow=N % use a shadow effect + \overlapmargins=N % ignore margins by surrounding text + \hhkern=0pt \vvkern=0pt} % left-righ margin, top-bottom margin +\endtt +The total distance from text to oval boundary is `\hhkern+\roundness` at the left and right +sides and +`\vvkern+\roundness` at the top and bottom sides of the text. + +If you need to set a parameters for the <text> (color, size, font etc.), +put such setting right in front of the <text>: +\^`\inoval{<text settings><text>}`. + +\new +The \^`\incircle[\ratio=1.8]{<text>}` creates a box like this \incircle[\ratio=1.8]{text}. +The \^`\ratio` parameter means width/height. The usage is analogical like for oval. +The default parameters are + +\begtt +\circleparams={\ratio=1 \fcolor=\Yellow \lcolor=\Red \lwidth=0.5bp + \shadow=N \ignoremargins=N \hhkern=2pt \vvkern=2pt} +\endtt + +\new +The macros \^`\clipinoval` `<x> <y> <width> <height> {<text>}` +and \^`\clipincircle` (with the same parameters) +print the `<text>` when a clipping path (oval or cirle with given +`<with>` and `<height>` shifted its center by `<x>` to right and by `<y>` to up) +is used. +The `\roundness=5mm` is default for \^`\clipinoval` and user can change it. +Example: + +\begtt +\clipincircle 3cm 3.5cm 6cm 7cm {\picw=6cm \inspic{myphoto.jpg}} +\endtt + +\secc Putting images and texts wherever + +\new +The \^`\puttext` `<x> <y> {<text>}` puts the `<text>` shifted by `<x>` right and by +`<y>` up from current point of typesetting and does'n not change the +position of the current point. Assume coordinate system with origin in the +current point. Then \^`\puttext` `<x> <y> {<text>}` puts the text at the +coordinates `<x>`, `<y>`. More exactly the left edge of its baseline is at that +position. + +\new +The \^`\putpic` `<x> <y> <width> <height> {<image>}` puts the `<image>` of given +`<width>` and `<height>` at given position (its left-bottom corner). +You can write \^`\nospec` instead `<width>` or `<height>` if this parameter is +not given. + +\sec Others +%%%%%%%%%%% + +\secc[lang] Using more languages +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\OpTeX/ prepares hyphenation patterns for all languages if such patterns are +available in your \TeX/ system. +\new +Only USenglish patterns (original from Plain \TeX/) are preloaded. +Hyphenation patterns of all another languages are loaded on demand when you first use +the `\<iso-code>lang` command in your document. +For example \^`\delang` for German, \^`\cslang` for +Czech, \^`\pllang` for Polish. The <iso-code> is a shortcut +of the language (mostly from ISO 639-1). +You can list all available languages by \^`\langlist` +macro. This macro prints now: + +\medskip +{\typosize[8.5/11.5]\emergencystretch=4em \hbadness=4000 +\noindent \langlist +\par} +\medskip + +\new +For compatibility with e-plain macros, there is the command +\^`\uselanguage{<language>}`. The parameter <language> is long form of +language name, i.e.\ \^`\uselanguage{Czech}` works the same as \^`\cslang`. +The \^`\uselanguage` parameter is case insensitive. + +For compatibility with \csplain/, there are macros \^`\ehyph`, \^`\chyph`, +\^`\shyph` which are equivalent to \^`\enlang`, \^`\cslang` and \^`\sklang`. + +You can switch between language patterns by `\<iso-code>lang` commands mentioned +above. Default is \^`\enlang`. + +\OpTeX/ generates three phrases used for captions and titles in technical +articles or books: \"Chapter", \"Table" and \"Figure". These phrases need to be known +in used language and it depends on the previously used language selectors +`\<iso-code>lang`. \OpTeX/ declares these words only for few languages: +\new +Czech, German, Spanish, French, Greek, Italian, Polish, Russian, Slovak and +English, If you need to use these words in another languages or you want to +auto-generate more words in your macros, then you can declare it by +\^`\sdef` or \^`\_langw` commands as shown in the section~\ref[langphrases]. + +The \~`\makeindex` command needs to know the sorting rules used in your language. +\OpTeX/ defines only few language rules for sorting: Czech, +Slovak and English. How to declare sorting rules for more languages are +described in the section~\ref[makeindex]. + +If you declare `\<iso-code>quotes`, then the control sequences `\"` and `\'` +should be used like this: `\"<quoted text>"` or `\'<quoted text>'` +(note that the terminating character is the same but it isn't escaped). +This prints language dependent normal or alternative quotes around +<quoted text>. The language is specified by <iso-code>. \OpTeX/ declares +quotes only for Czech, German, Spanish, French, Greek, Italian, Polish, +Russian, Slovak and English (\^`\csquotes`, \^`\dequotes`, \dots, \^`\enquotes`). +You can simply define your own quotes as shown in `languages.opm` file. +The `\"` is used for quotes visualy more similar to the `"` character which +can be primary quotes or secondary quotes depending on the language rules. +May be you want to alternate meaning of these two types of quotes. Use +`\<isocode>quotes\altquotes` in such case. + +\secc[styles] Pre-defined styles +%%%%%%%%%%%%%%%%%%%%%%% + +\OpTeX/ defines three style-declaration macros \~`\report`, \~`\letter` and +\~`\slides`. You can use them at the beginning of your document if you are +preparing these types of document and you don't need to create your own +macros. + +The \^`\report` declaration is intended to create reports. It +sets default font size to 11\,pt and `\parindent` (paragraph indentation) to 1.2\,em. +The `\tit` macro uses smaller font because we assume that \"chapter level" +will be not used in reports. The first page has no page number, but next pages +are numbered (from number~2). Footnotes are numbered from one in whole +document. The macro `\author <authors><end-line>` can be used when +\^`\report` is declared. It prints `<authors>` in italics at center of the +line. You can separate authors by `\nl` to more lines. + +The \^`\letter` declaration is intended to create letters. See an example in +the file `op-letter.tex`. The \^`\letter` style sets default +font size to 11\,pt and `\parindent` to 0\,pt. It sets half-line space +between paragraphs. The page numbers are not printed. The \^`\subject` macro +can be used, it prints the word \"Subject:" or \"Věc" (or something else +depending on current language) in bold. Moreover, the \^`\address` macro +can be used when \^`\letter` is declared. The usage of the \^`\address` macro +looks like: + +\begtt +\address + <first line of address> + <second line of address> + <etc.> + <empty line> +\endtt + +It means that you need not to use any special mark at the end of lines: end +of lines in the source file are the same as in printed output. The +\^`\address` macro creates `\vtop` with address lines. The width of such +`\vtop` is equal to the most wide line used in it. So, you can use +`\hfill\address...` in order to put the address box to the right side of the +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 +\^`\slides` style in the file `op-slides.pdf`. + +Analogical declaration macro `\book` is not prepared. Each book needs an +individual typographical care. You need to create specific macros for +design. + +\secc Lorem ipsum dolor sit +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\new +A designer needs to concentrate to the design of the output and maybe he/she +needs a material for testing macros. There is the possibility to generate a +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]` +prints all prepared paragraphs. + +\secc Logos +%%%%%%%%%% + +\new +The control sequences for typical logos can be terminated by optional `/` +which is ignored when printing. This makes logos more legible in source file: + +\begtt +We are using \TeX/ because it is cool. \OpTeX/ is better than \LaTeX. +\endtt + +\secc The last page +%%%%%%%%%%%%%%%%%%% + +The number of the last page (it may be different from number of pages) is +expanded by \^`\lastpage` macro. It expands to `?` in first \TeX/ run and to +the last page in next \TeX/ runs. + +There is an example for footlines in the format \"current page / last page": + +\begtt +\footline={\hss \fixedrm \folio/\lastpage \hss} +\endtt + +\new +The \^`\lastpage` expands to the last \^`\folio` which is a decimal +number or Roman numeral (when \^`\pageno` is negative). If you need to know +total pages used in the document, use \^`\totalpages` macro. It expands to +zero (in first \TeX/ run) or to the number of all pages in the document +(in next \TeX/ runs). + +\secc Use \OpTeX/ +%%%%%%%%%%%%%%%%% + +\new +The command \^`\useOpTeX` (or \^`\useoptex`) does nothing in \OpTeX/ but it causes +an error (undefined control sequence) when another format is used. You can +put it as the first command in your document: + +\begtt +\useOpTeX % we are using OpTeX format, no LaTeX :) +\endtt + +\sec Summary +%%%%%%%%%%%% + +\begtt \typosize[10/12]\adef!{\string\endtt}\adef&{\kern.25em} +\tit Title (terminated by end of line) +\chap Chapter Title (terminated by end of line) +\sec Section Title (terminated by end of line) +\secc Subsection Title (terminated by end of line) + +\maketoc % table of contents generation +\ii item1,item2 % insertion the items to the index +\makeindex % the index is generated + +\label [labname] % link target location +\ref [labname] % link to the chapter, section, subsection, equation +\pgref [labname] % link to the page of the chapter, section, ... + +\caption/t % a numbered table caption +\caption/f % a numbered caption for the picture +\eqmark % a numbered equation + +\begitems % start list of the items +\enditems % end of list of the items +\begtt % start verbatim text +! % end verbatim text +\activettchar X % initialization character X for in-text verbatim +\code % another alternative for in-text verbatim +\verbinput % verbatim extract from the external file +\begmulti num % start multicolumn text (num columns) +\endmulti % end multicolumn text + +\cite [labnames] % refers to the item in the lits of references +\rcite [labnames] % similar to \cite but [] are not printed. +\sortcitations \shortcitations \nonumcitations % cite format +\bib [labname] % an item in the list of references +\usebib/? (style) bib-base % direct using of .bib file, ? in {s,c} + +\fontfam [FamilyName] % selection of font family +\typosize [font-size/baselineskip] % size setting of typesetting +\typoscale [factor-font/factor-baselineskip] % size scaling +\thefontsize [size] \thefontscale [factor] % current font size + +\inspic file.ext % insert a picture, extensions: jpg, png, pdf +\table {rule}{data} % simple macro for the tables like in LaTeX + +\fnote {text} % footnote (local numbering on each page) +\mnote {text} % note in the margin (left or right by page number) + +\hyperlinks {color-in}{color-out} % PDF links activate as clickable +\outlines {level} % PDF will have a table of contents in the left tab + +\magscale[factor] % resize typesetting, line/page breaking unchanged +\margins/pg format (left, right, top, bottom)unit % margins setting + +\report \letter \slides % style declaration macros +\endtt + + +\sec Compatibility with Plain \TeX/ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +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 +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 +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). + +\new +The Latin Modern 8bit fonts instead Computer Modern 7bit fonts are +preloaded in the format, but only few ones. The full family set is ready to +use after the command \~`\fontfam[LMfonts]` which reads the fonts in OTF +format. + +\new +The text accents macros like `\'`, `\v`, `\"` are undefined\fnote +{The math accents macros like `\acute`, `\bar`, `\dot`, `\hat` still work.} +in \OpTeX/. Use real +letters like á, ř, ž in your source document instead these old accents macros. +If you really want to use them, you can initialize them by \^`\oldaccents` +command. But we don't recommend it. + +\new +The default paper size is not set as letter with 1\,in margins but as A4 with +2.5\,cm margins. You can change it, for example by +\^`\margins/1 letter (1,1,1,1)in`. This example sets the classical Plain \TeX/ +page layout. + +\new +The origin for typographical area is not at top left 1\,in 1\,in coordinates +but at top left paper corner exactly. For example, `\hoffset` includes directly left +margin. + +\enddocument + + + +\sec Dependencies +%%%%%%%%%%%%%%%%% + +When `optex.fmt` is created then the following must be installed + +\begitems +* The `\luatex` program. +* Latin moder font metrics + `ec-lmr10.tfm`, `ec-lmbx10.tfm`, `ec-lmri10.tfm`, + `ec-lmbxi10.tfm`, `ec-lmtt10.tfm` (for basic text font initializing). +* Computer rmodern font metrics + `cmr10.tfm`, `cmmi10.tfm`, `cmsy10.tfm`, `cmex10.tfm` (for basic math + initializing). If there are more Computer Modern fonts then they are read + too. +* The file `hyphen.tex` form plain \TeX. +\enditems + +When `\fontfam` is used then the ability of Unicode fonts reading +is initialized using Lua scripts: `ltluatex.lua` (from \LaTeX/ package), +`luaotfload-main.lua` and more 20 similar `.lua` files (from `luaotfload` +package). + +When a font family is needed using `\fontfam` then such font family must be +installed in the OTF format otherwise the `\fontfam` command is ignored +(only warning about no-existent font family is printed). + +When `\cslang`, `\delang` etc. commands are used in the document +then the hyphenation patterns of relevant languages must be installed. +Moreover the Lua script `luatex-hyphen.lua` (from `hyph-utf8` package) +and data file `language-dat.lua` (from `hyphen-base` package) +must be installed. + +When `\usebib` command is used then `librarian.tex` file +(from the `librarian` macro package) must be installed. + +When `\morecolors` command is used then `x11nam.def` file +(from the `xcolor` package) must be installed. + +When `\lorem` command is used then `lipsum.ltd.tex` file +(from the `lipsum` package) must be installed. + diff --git a/Master/texmf-dist/tex/luatex/optex/alloc.opm b/Master/texmf-dist/tex/luatex/optex/alloc.opm index 81d9e6606d7..238e824e1af 100644 --- a/Master/texmf-dist/tex/luatex/optex/alloc.opm +++ b/Master/texmf-dist/tex/luatex/optex/alloc.opm @@ -2,6 +2,10 @@ \_codedecl \newdimen {Allocators for registers <2020-01-23>} % loaded in format + \_doc ----------------------------- + The limits are set first. + \_cod ----------------------------- + \_chardef\_maicount = 65535 % Max Allocation Index for counts registers in LuaTeX \_let\_maidimen = \_maicount \_let\_maiskip = \_maicount @@ -12,6 +16,10 @@ \_chardef\_maiwrite = 15 \_chardef\_maifam = 255 + \_doc ----------------------------- + Each allocation macro needs its own counter. + \_cod ----------------------------- + \_countdef\_countalloc=10 \_countalloc=255 \_countdef\_dimenalloc=11 \_dimenalloc=255 \_countdef\_skipalloc=12 \_skipalloc=255 @@ -22,6 +30,14 @@ \_countdef\_writealloc=17 \_writealloc=-1 \_countdef\_mathalloc=18 \_mathalloc=3 + \_doc ----------------------------- + The common allocation macro + \`\_allocator` `\<sequence> {<type>} \<primitive declarator>` + is defined. This idea was used in classical plain \TeX/ by + Donald Knuth too but the macro from plain \TeX/ seems to be + more complicated:). + \_cod ----------------------------- + \_def\_allocator #1#2#3{% \_global\_advance\_cs{_#2alloc}by1 \_ifnum\_cs{_#2alloc}>\_cs{_mai#2}% @@ -32,6 +48,13 @@ \fi } + \_doc ----------------------------- + The allocation macros + \`\newcount`, \`\newdimen`, \`\newskip`, \`\newmuskip`, \`\newbox`, + \`\newtoks`, \`\newread`, \`\newwrite` and \`\newmath` + are defined here. + \_cod ----------------------------- + \_def\_newcount #1{\_allocator #1{count}\_countdef} \_def\_newdimen #1{\_allocator #1{dimen}\_dimendef} \_def\_newskip #1{\_allocator #1{skip}\_skipdef} @@ -42,6 +65,12 @@ \_def\_newwrite #1{\_allocator #1{write}\_chardef} \_def\_newmath #1{\_allocator #1{fam}\_chardef} +\_public \newcount \newdimen \newskip \newmuskip \newbox \newtoks \newread \newwrite \newmath ; + + \_doc ----------------------------- + The \`\newinsert` macro is defined differently than others. + \_cod ----------------------------- + \_newcount\_insertalloc \_insertalloc=255 \_chardef\_insertmin = 201 @@ -54,6 +83,12 @@ \_wlog {\_string#1=\_string\_insert\_the\_insertalloc}% \_fi } +\_public \newinsert ; + + \_doc ----------------------------- + Other allocation macros \`\newattribute` and \`\newcatodetable` + have their counter allocated by the `\newcount` macro. + \_cod ----------------------------- \_newcount \_attributealloc \_attributealloc=0 \_chardef\_maiattribute=\_maicount @@ -63,26 +98,37 @@ \_chardef\_maicatcodetable=32767 \_def\_newcatcodetable #1{\_allocator #1{catcodetable}\_chardef} +\_public \newattribute \newcatcodetable ; + + \_doc ----------------------------- + We declare public and private versions of `\tmpnum` and `\tmpdim` + registers separately. They are independent registers. + \_cod ----------------------------- + \_newcount \tmpnum \_newcount \_tmpnum \_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 + don't support the `@` category dance. + Note that `\p@` is not defined because we can write 1pt which is more + legible. + \_cod ----------------------------- + \_newdimen\_maxdimen \_maxdimen=16383.99999pt % the largest legal <dimen> \_newskip\_hideskip \_hideskip=-1000pt plus 1fill % negative but can grow \_newskip\_centering \_centering=0pt plus 1000pt minus 1000pt \_newskip\_zoskip \_zoskip=0pt plus0pt minus0pt \_newbox\_voidbox % permanently void box register -\_public - \newcount \newdimen \newskip \newmuskip \newbox \newtoks \newread \newwrite \newmath - \newattribute \newcatcodetable - \insertmin \newinsert - \maxdimen \hideskip \centering \zoskip \voidbox ; +\_public \maxdimen \hideskip \centering \zoskip \voidbox ; \_endcode %--------------------------------------------------- Like plain\TeX, the allocators `\newcount`, `\newwrite`, etc. are defined. -The registers are allocated from 256 to `\mai<type>` which is 65535 in -LuaTeX. +The registers are allocated from 256 to the `\_mai<type>` which is 65535 in +\LuaTeX/. Unlike in Plain\TeX/, the mentioned allocators are not `\outer`. @@ -95,8 +141,10 @@ is wider. Inserts are allocated form 254 to 201 using `\newinsert`. You can define your own allocation concept (for example for allocation of -arrays) from top of registers array. For example for counts: +arrays) from top of registers array. The example shows a definition of +the array-like declarator of counters. +\nobreak \begtt \newcount \_maicount % redefine maximal allocation index as variable \_maicount = \maicount % first value is top of the array @@ -114,11 +162,4 @@ arrays) from top of registers array. For example for counts: } \endtt -The `\tmpnum` and `\tmpdim` are allocated, individual instance for internal -macros and for user's macros. - -A few registers are initialized like in plain\TeX/. Note that `\z@` and `\z@skip` from -plain\TeX/ is `\zo` and `\zoskip` because we don't support the `@` category dance. -Note that `\p@` is not defined because we can write 1pt which is more -legible. diff --git a/Master/texmf-dist/tex/luatex/optex/basics-macros.opm b/Master/texmf-dist/tex/luatex/optex/basic-macros.opm index b86fd2e2e9b..512678c312a 100644 --- a/Master/texmf-dist/tex/luatex/optex/basics-macros.opm +++ b/Master/texmf-dist/tex/luatex/optex/basic-macros.opm @@ -3,70 +3,84 @@ \_codedecl \sdef {Basic macros for OpTeX <2020-02-14>} % loaded in format \_doc ------------------------------ - `\bgroup`, `\egroup`, `\empty`, `\space`, `\null` and `\wlog` are classical - macros from plain \TeX/. + \`\bgroup`, \`\egroup`, \`\empty`, \`\space`, \`\null` and \`\wlog` + are classical macros from plain \TeX/. \_cod ------------------------------ -\let\_bgroup={ \let\_egroup=} +\_let\_bgroup={ \_let\_egroup=} \_def \_empty {} \_def \_space { } \_def \_null {\_hbox{}} \_def \_wlog {\_immediate\_write-1 } % write on log file (only) +\_public \bgroup \egroup \empty \space \null \wlog ; + \_doc ------------------------------ - `\bslash` is \"normal backslash" with category code 12. - `\nbb` and `\pcent` are double backslash and normal `%`, they should - be used in lua codes, for example. + \`\bslash` is \"normal backslash" with category code 12. + \`\nbb` and \`\pcent` are double backslash and normal~`%`, + they should be used in lua codes, for example. \_cod ------------------------------ -\_edef\_bslash {\_csstring\\} +\_edef \_bslash {\_csstring\\} \_edef \_nbb {\_bslash\_bslash} \_edef \_pcent{\_csstring\%} +\_public \bslash \nbb \pcent ; + \_doc ------------------------------ - `\sdef{<text>}` is equivalent to `\def\<text>`, where `\<text>` is a control + \`\sdef` `{<text>}` is equivalent to `\def\<text>`, where `\<text>` is a control sequence. You can use arbitrary parameter mask after `\sdef{<text>}`, don't put the (unwanted) space immediately after closing brace \code{\}}. - - `\sxdef{<text>}` is equivalent to `\xdef\<text>`. - - `\slet{<textA>}{<textB>}` is equivalent to `\let \<textA> = \<textB>`. + \nl + \`\sxdef` `{<text>}` is equivalent to `\xdef\<text>`. + \nl + \`\slet` `{<textA>}{<textB>}` is equivalent to `\let \<textA> = \<textB>`. \_cod ------------------------------ \_def \_sdef #1{\_ea\_def \_csname#1\_endcsname} \_def \_sxdef #1{\_ea\_xdef \_csname#1\_endcsname} \_def \_slet #1#2{\_ea\_let \_csname#1\_ea\_endcsname \_csname#2\_endcsname} +\_public \sdef \sxdef \slet ; + \_doc ------------------------------ - `\adef{<char>}{<body>}` puts the <char> as active character and defines it - as {<body>}. You can use parameter mask too, for example - `\adef @#1{...$1...}` + \`\adef` `{<char>}{<body>}` puts the <char> as active character and defines it + as `{<body>}`. You can declare a macro with parameters too. For example + `\adef @#1{...$1...}`. \_cod ------------------------------ -\_def \_adef #1{\_catcode`#1=13 \_begingroup - \_lccode`\~=`#1\_lowercase{\_endgroup\_def~}} +\_def \_adef #1{\_catcode`#1=13 \_begingroup \_lccode`\~=`#1\_lowercase{\_endgroup\_def~}} +\_public \adef ; \_doc ------------------------------ - `\cs{<text>}` is only a shortcut to `\csname <text>\endcsname`, but you need - one more `\ea` if you need to get the real control sequence `\<text>`. + \`\cs` `{<text>}` is only a shortcut to `\csname <text>\endcsname`, but you need + one more `\_ea` if you need to get the real control sequence `\<text>`. + \nl + \`\trycs` `{<csname>}{<text>}` expands to `\<csname>` + if it is defined else to the `<text>`. \_cod ------------------------------ \_def \_cs #1{\_csname#1\_endcsname} +\_def \_trycs#1#2{\_ifcsname #1\_endcsname \_csname #1\_endcsname \_else #2\_fi} +\_public \cs \trycs ; \_doc ------------------------------ - `\addto\macro{<text>}` adds <text> to your `\macro`, which must be defined. + \`\addto` `\macro{<text>}` adds `<text>` to your `\macro`, which must be defined. \_cod ------------------------------ \_long\_def \_addto #1#2{\_ea\_def\_ea#1\_ea{#1#2}} +\_public \addto ; \_doc ------------------------------ - `\opwarning{<text>}` prints warning on the terminal and to the log file. + \`\opwarning` `{<text>}` prints warning on the terminal and to the log file. \_cod ------------------------------ \_def \_opwarning #1{\_wterm{WARNING: #1.}} +\_public \opwarning ; \_doc ------------------------------ - `\loggingall` and `\tracingall` is similar as in plain \TeX/, but prints + \`\loggingall` and \`\tracingall` are defined similarly as in + plain \TeX/, but they print more logging information to the log file and to the terminal. \_cod ------------------------------ @@ -76,12 +90,7 @@ \_tracingifs=1 \_tracinggroups=1 \_tracingassigns=1 } \_def\_tracingall{\_tracingonline=1 \_loggingall} -\_public - \bgroup \egroup \empty \space \null \wlog - \bslash \nbb \pcent - \sdef \sxdef \slet \cs \adef - \addto \wlog \opwarning - \loggingall \tracingall ; +\_public \loggingall \tracingall ; \_endcode % ------------------------------------- diff --git a/Master/texmf-dist/tex/luatex/optex/bib-iso690.opm b/Master/texmf-dist/tex/luatex/optex/bib-iso690.opm index 3265eaea05c..b569de0d309 100644 --- a/Master/texmf-dist/tex/luatex/optex/bib-iso690.opm +++ b/Master/texmf-dist/tex/luatex/optex/bib-iso690.opm @@ -6,13 +6,19 @@ {This file can be read by: \_string\usebib/? (iso690) bibfiles command only} \_endinput \_fi -% misc: + \_doc ----------------------------- + \`\_maybetod` (alias `\.` in the style file group) does not put second dot. + \_cod ----------------------------- \_def\_maybedot{\_ifnum\_spacefactor=\_sfcode`\.\_relax\_else.\_fi} \_tmpnum=\_sfcode`\. \_advance\_tmpnum by-2 \_sfcode`\.=\_tmpnum \_sfcode`\?=\_tmpnum \_sfcode`\!=\_tmpnum \_let\.=\_maybedot % prevents from double periods + \_doc ----------------------------- + Option field. + \_cod ----------------------------- + \_CreateField {option} \_def\_isbiboption#1#2{\_edef\_tmp{\_noexpand\_isbiboptionA{#1}}\_tmp} \_def\_isbiboptionA#1{\_def\_tmp##1 #1 ##2\_relax{% @@ -30,7 +36,9 @@ \_newtoks\_biboptions \_public \biboptions ; -% Formating of Author/Editor lists: + \_doc ----------------------------- + Formating of Author/Editor lists. + \_cod ----------------------------- \_def\_firstauthorformat{% \_upper{\_Lastname}\_bprintc\_Firstname{, *}\_bprintc\_Von{ *}\_bprintc\_Junior{, *}% @@ -81,7 +89,9 @@ \_fi \_let\_upper=\upper -% Preparing bib-mark (used when \nonumcitations is set): + \_doc ----------------------------- + Preparing bib-mark (used when `\nonumcitations` is set). + \_cod ----------------------------- \_def\_setbibmark{% \_ifx\_dobibmark\_undefined \_def\_dobibmark{}\_fi @@ -89,7 +99,6 @@ \_ifx\_tmp\_empty \_RetrieveFieldIn{year}\_tmp \_edef\_tmp{\_dobibmark, \_tmp}\_fi \_bibmark=\_ea{\_tmp}% } - % Multilinguals: English Czech Slovak \_mtdef{bib.and} {, and } { a } {} @@ -129,7 +138,9 @@ \_fi\_fi } -% Non-standard fieldnames: + \_doc ----------------------------- + Non-standard fieldnames. + \_cod ----------------------------- \_CreateField {ednote} \_CreateField {citedate} @@ -140,20 +151,23 @@ \_CreateField {url} \_CreateField {bibmark} -% Sorting: + \_doc ----------------------------- + Sorting. + \_cod ----------------------------- \_SortingOrder{name,year}{lfvj} \_SpecialSort {key} -% Misc: + \_doc ----------------------------- + Supporting macros. + \_cod ----------------------------- \_def\_bibwarninga{\_bibwarning} \_def\_bibwarningb{\_bibwarning} \_def\_docitedate #1/#2/#3/#4\_relax{[\_Mtext{bib.citedate}% \_if^#2^#1\_else - \_if^#3^#1/#2\_else - \_docitedateA{#1}{#2}{#3}% + \_if^#3^#1/#2\_else \_docitedateA{#1}{#2}{#3}% \_fi\_fi ]% } \_def\_docitedateA#1#2#3{% @@ -197,7 +211,9 @@ \_ifx\_authorprint\_empty #2\_posteditor\_else \_authorprint\_fi } -% Entry types: + \_doc ----------------------------- + Entry types. + \_cod ----------------------------- \_sdef{_print:BEGIN}{% \_readbiboptions @@ -217,7 +233,8 @@ \_bprinta [ednote] {*.\ }{}% \_bprinta [address] {*\_bprintv[publisher]{:}{\_bprintv[year]{,}{.}}\ }{\_bibwarninga}% \_bprinta [publisher] {*\_bprintv[year]{,}{.}\ }{\_bibwarninga}% - \_bprintb [year] {\_doyear{##1}\_bprintv[citedate]{\_bprintv[numbering]{.}{}}{.}\ }{\_bibwarning}% + \_bprintb [year] {\_doyear{##1}\_bprintv[citedate]{\_bprintv[numbering]{.}{}}{.}\ }% + {\_bibwarning}% \_bprinta [numbering] {\_preparenumbering*\_bprintv[citedate]{}{\.}\ }{}% \_bprinta [citedate] {\_docitedate*///\_relax.\ }{}% #1% @@ -229,14 +246,16 @@ } \_sdef{_print:book}{% \_bprintb [!author] {\_doauthor1{##1}\.\ }{\_bibwarning}% - \_bprintb [title] {{\_em##1}\_bprintc\_titlepost{\.\ *}\_bprintv[howpublished]{}{\.}\ }{\_bibwarning}% + \_bprintb [title] {{\_em##1}\_bprintc\_titlepost{\.\ *}\_bprintv[howpublished]{}{\.}\ }% + {\_bibwarning}% \_bookgeneric{}% } \_sdef{_print:article}{% \_biboptionvalue{journalpost}\_journalpost \_bprintb [!author] {\_doauthor1{##1}\.\ }{\_bibwarning}% \_bprinta [title] {*.\ \_bprintc\_titlepost{*.\ }}{\_bibwarning}% - \_bprintb [journal] {{\_em##1}\_bprintc\_journalpost{\.\ *}\_bprintv[howpublished]{}{\.}\ }{\_bibwarninga}% + \_bprintb [journal] {{\_em##1}\_bprintc\_journalpost{\.\ *}\_bprintv[howpublished]{}{\.}\ }% + {\_bibwarninga}% \_bprinta [howpublished] {[*].\ }{}% \_bprinta [address] {*\_bprintb[publisher]{:}{,}\ }{}% \_bprinta [publisher] {*, }{}% @@ -245,7 +264,8 @@ \_bprinta [numbering] {\_preparenumbering*\_bprintv[citedate]{}{\.}\ } {\_bprinta [volume] {\_prevolume*\_bprintv[number,pages]{,}{\.}\ }{}% \_bprinta [number] {\_prenumber*\_bprintv[pages]{,}{\.}\ }{}% - \_bprintb [pages] {\_prepages\_hbox{##1}\_bprintv[citedate]{}{\.}\ }{\_bibwarninga}}% + \_bprintb [pages] {\_prepages\_hbox{##1}\_bprintv[citedate]{}{\.}\ }% + {\_bibwarninga}}% \_bprinta [citedate] {\_docitedate*///\_relax.\ }{}% \_bprinta [issn] {ISSN~*.\ }{}% \_bprintb [doi] {\_predoi DOI \_ulink[http://dx.doi.org/##1]{##1}.\ }{}% @@ -257,7 +277,8 @@ \_bprinta [title] {*.\ }{\_bibwarning}% \_Inclause \_bprintb [!editor] {\_doeditor1{##1}\.\ }{}% - \_bprintb [booktitle] {{\_em##1}\_bprintc\_titlepost{\.\ *}\_bprintv[howpublished]{}{\.}\ }{\_bibwarning}% + \_bprintb [booktitle] {{\_em##1}\_bprintc\_titlepost{\.\ *}\_bprintv[howpublished]{}{\.}\ }% + {\_bibwarning}% \_bookgeneric{\_bprintb [pages] {\_prepages\_hbox{##1}. }{}}% } \_slet{_print:inproceedings}{_print:inbook} @@ -265,7 +286,8 @@ \_sdef{_print:thesis}{% \_bprintb [!author] {\_doauthor1{##1}\.\ }{\_bibwarning}% - \_bprintb [title] {{\_em##1}\_bprintc\_titlepost{\.\ *}\_bprintv[howpublished]{}{\.}\ }{\_bibwarning}% + \_bprintb [title] {{\_em##1}\_bprintc\_titlepost{\.\ *}\_bprintv[howpublished]{}{\.}\ }% + {\_bibwarning}% \_bprinta [howpublished] {[*].\ }{}% \_bprinta [address] {*\_bprintv[school]{:}{\_bprintv[year]{,}{.}}\ }{\_bibwarning}% \_bprinta [school] {*\_bprintv[year]{,}{.}\ }{\_bibwarning}% @@ -273,7 +295,8 @@ \_bprintb [year] {\_doyear{##1}\_bprintv[citedate]{}{.}\ }{\_bibwarninga}% \_bprinta [citedate] {\_docitedate*///\_relax.\ }{}% \_bprinta [type] {*\_bprintv[ednote]{,}{.}\ }% - {\_ifx\_thesistype\_undefined\_bibwarning\_else\_thesistype\_bprintv[ednote]{,}{.}\ \_fi}% + {\_ifx\_thesistype\_undefined\_bibwarning + \_else\_thesistype\_bprintv[ednote]{,}{.}\ \_fi}% \_bprinta [ednote] {*.\ }{}% \_bprintb [doi] {\_predoi DOI \_ulink[http://dx.doi.org/##1]{##1}.\ }{}% \_bprintb [url] {\_preurl\_url{##1}. }{}% @@ -284,7 +307,8 @@ \_sdef{_print:generic}{% \_bprintb [!author] {\_doauthor1{##1}\.\ }{\_bibwarning}% - \_bprintb [title] {{\_em##1}\_bprintc\_titlepost{\.\ *}\_bprintv[howpublished]{}{\.}\ }{\_bibwarning}% + \_bprintb [title] {{\_em##1}\_bprintc\_titlepost{\.\ *}\_bprintv[howpublished]{}{\.}\ }% + {\_bibwarning}% \_bprinta [howpublished] {[*].\ }{}% \_bprinta [ednote] {\_prepareednote*\_bprintv[citedate]{}{.}\ }{\_bibwarning}% \_bprinta [year] {}{\_bibwarning}% @@ -315,7 +339,7 @@ See `op-example.bib` for an example of the `.bib` input. You can try it by: \end \endtt -\secc Common rules in .bib files +\seccc Common rules in \code{.bib} files There are entries of type `@FOO{...}` in the `.bib` file. Each entry consists of fields in the form `name = "value"`, or `name = {value}`. No matter which form is @@ -345,44 +369,42 @@ separated by spaces. You can declare the global option(s) in your document applied for each entry by `\biboptions={...}`. -\secc The author field +\seccc The author field -All names in the author list have to be separated by \"` and `". Each author -can be written by various formats (the `von` part is typically missing): +All names in the author list have to be separated by \"\code{ and }". +Each author can be written by various formats (the `von` part is typically missing): \begtt - Firstname(s) von Lastname - or - von Lastname, Firstname(s) - or - von Lastname, After, Firstname(s) +Firstname(s) von Lastname +or +von Lastname, Firstname(s) +or +von Lastname, After, Firstname(s) \endtt - Only the Lastname part is mandatory. Examples: - \begtt - Petr Olšák - or - Olšák, Petr +Petr Olšák +or +Olšák, Petr - Leonardo Piero da Vinci - or - da Vinci, Leonardo Piero - or - da Vinci, painter, Leonardo Piero +Leonardo Piero da Vinci +or +da Vinci, Leonardo Piero +or +da Vinci, painter, Leonardo Piero \endtt - -The separator \"` and `" between authors will be converted to comma during +The separator \"\code{ and }" between authors +will be converted to comma during printing, but between semifinal and final author the word \"and" (or something different depending on current language) is printed. The first author is printed in reverse order: \"LASTNAME, Firstname(s) von, After" and the others author are printed in normal order: \"Firstname(s) von LASTNAME, After". This feature follows the ISO 690 norm. The Lastname -is capitalised using uppercase letters, but if the \caps font modifier is defined, +is capitalized using uppercase letters. But if the `\caps` font modifier is defined, then it is used and printed `{\caps\_rm Lastname}`. -You can specify the option `aumax:<number>`. The <number> denotes the +You can specify the option `aumax:<number>`. The `<number>` denotes the maximum authors to be printed. The rest of authors are ignored and the `et~al.` is appended to the list of printed authors. This text is printed only if the `aumax` value is less than the real number of authors. @@ -398,44 +420,38 @@ There is no internal limit. But you can set the global options in your document by setting the `\biboptions` tokens list. For example: \begtt - \biboptions={aumax:7 aumin:1} - % if there is 8 or more authors then only first author is printed. +\biboptions={aumax:7 aumin:1} +% if there is 8 or more authors then only first author is printed. \entdd Examples: - \begtt - author = "John Green and Bob Brown and Alice Black", +author = "John Green and Bob Brown and Alice Black", \endtt - output: GREEN, John, Bob BROWN, and Alice BLACK. \begtt - author = "John Green and Bob Brown and Alice Black", - option = "aumax:1", +author = "John Green and Bob Brown and Alice Black", +option = "aumax:1", \endtt - output: GREEN, John~et~al. \begtt - author = "John Green and Bob Brown and Alice Black", - option = "aumax:2", +author = "John Green and Bob Brown and Alice Black", +option = "aumax:2", \endtt - output: GREEN, John, Bob BROWN~et~al. \begtt - author = "John Green and Bob Brown and Alice Black", - option = "aumax:3", +author = "John Green and Bob Brown and Alice Black", +option = "aumax:3", \endtt - output: GREEN, John, Bob BROWN, and Alice BLACK. \begtt - author = "John Green and Bob Brown and Alice Black", - option = "auetal", +author = "John Green and Bob Brown and Alice Black", +option = "auetal", \endtt - output: GREEN, John, Bob BROWN, Alice BLACK~et~al. If you need to add a text before or after authors list, you can use @@ -444,50 +460,46 @@ authors list. The <value> can include `\AU` macro which expands to the authors list. Example: \begtt - author = "Robert Calbraith", - option = "auprint:{\AU\space [pseudonym of J. K. Rowling]}", +author = "Robert Calbraith", +option = "auprint:{\AU\space [pseudonym of J. K. Rowling]}", \endtt - output: CALBRAITH Robert [pseudonym of J. K. Rowling]. You can use the `autrim:<number>` option. All Firstnames of all authors are trimmed (i. e. reduced to initials) iff the number of authors in the -author field is greater than or equal to <number>. There is an exception: +author field is greater than or equal to `<number>`. There is an exception: `autrim:0` means that no Firstnames are trimmed. This is default behavior. Another example: `autrim:1` means that all Firstnames are trimmed. \begtt - author = "John Green and Bob Brown and Alice Black", - option = "auetal autrim:1", +author = "John Green and Bob Brown and Alice Black", +option = "auetal autrim:1", \endtt - output: GREEN, J., B. BROWN, A. BLACK~et~al. If you need to write a team name or institution instead authors, replace all -spaces by \<space> in this name. Such text is interpreted as Lastname. You +spaces by `\ ` in this name. Such text is interpreted as Lastname. You can add the secondary name (interpreted as Firstname) after comma. Example: \begtt - author = "Czech\ Technical\ University\ in\ Prague, Faculty\ of\ Electrical\ Engeneering", + author = "Czech\ Technical\ University\ in\ Prague, + Faculty\ of\ Electrical\ Engeneering", \endtt - output: CZECH TECHNICAL UNIVERSITY IN PRAGUE, Faculty of Electrical Engeneering. -\secc The editor field +\seccc The editor field The editor field is used for list of the authors of the collection. The analogous rules as in author field are used here. It means that the -authors are separated by \"` and `", the Firstnames, Lastnames etc. are +authors are separated by \"\code{ and }", the Firstnames, Lastnames etc. are interpreted and you can use the options `edmax:<number>`, `edmin:<number>`, `edetal`, `edtrim:<number>` and `edprint:{<value>}` (with `\ED` macro). Example: - \begtt - editor = "Jan Tomek and Petr Karas", - option = "edprint:{\ED, editors.} edtrim:1", +editor = "Jan Tomek and Petr Karas", +option = "edprint:{\ED, editors.} edtrim:1", \endtt - Output: J. TOMEK and P. KARAS, editors. If `edprint` option is not set then `{\ED, eds.}` or `{\ED, ed.}` is used @@ -495,22 +507,20 @@ depending on the entry language and on the singular or plural of the editor(s). -\secc The ednote field +\seccc The ednote field The ednote field is used as the secondary authors and more editional info. The value is read as raw data without any interpretation of Lastname, Firstname etc. - \begtt - ednote = "Illustrations by Robert \upper{Agarwal}, edited by Tom \upper{Nowak}", +ednote = "Illustrations by Robert \upper{Agarwal}, edited by Tom \upper{Nowak}", \endtt - output: Illustrations by Robert AGARWAL, edited by Tom NOWAK. -The \upper command have to be used for Lastnames in ednote field. +The `\upper` command have to be used for Lastnames in ednote field. -\secc The title field +\seccc The title field This is the title of the work. It will be printed (in common entry types) by italics. The ISO 690 norm declares, that the title plus optional subtitle @@ -519,38 +529,35 @@ title have to be printed in upright font. This can be added by `titlepost:{<value>}`. Example: \begtt - title = "The Simple Title of The Work", +title = "The Simple Title of The Work", or - title = "Main Title: Subtitle", +title = "Main Title: Subtitle", or - title = "Main Title: Subtitle", - option = "titlepost:{Secondary title}", +title = "Main Title: Subtitle", +option = "titlepost:{Secondary title}", \endtt - The output of the last example: {\it Main Title: Subtitle}. Secondary title. -\secc The edition field +\seccc The edition field This field is used only for second or more edition of cited work. Write only the number without the word "edition". The shortcut "ed." (or something else depending on current language) is added automatically. Examples: \begtt - edition = "Second", - edition = "2nd", - edition = "2$^{\rm nd}$", - edition = "2.", +edition = "Second", +edition = "2nd", +edition = "2$^{\rm nd}$", +edition = "2.", \endtt - Output of the last example: 2. ed. \begtt - edition = "2." - lang = "cs", +edition = "2." +lang = "cs", \endtt - Output: 2. vyd. Note, that the example `edition = "Second"` may cause problems. If you are @@ -559,36 +566,34 @@ But you can use `editionprint:{<value>}` option. The the <value> is printed instead of edition field and shortcut. The edition field must be set. Example: \begtt - edition = "whatever", - option = "editionprint:{Second full revised edition}", +edition = "whatever", +option = "editionprint:{Second full revised edition}", \endtt - Output: Second full revised edition. You can use `\EDN` macro in `editionprint` value. This macro is expanded to the edition value. Example: \begtt - edition = "Second", - option = "editionprint:{\EDN\space full revised edition}", +edition = "Second", +option = "editionprint:{\EDN\space full revised edition}", or - edition = "Second full revised edition", - option = "editionprint:{\EDN}", +edition = "Second full revised edition", +option = "editionprint:{\EDN}", \endtt -\secc The address, publisher, year fields +\seccc The address, publisher, year fields This is an anachronism from ancient Bib\TeX/ (unfortunately no exclusive) that the address field includes only the city of the publisher residence. No more data are here. The publisher field includes the name of the publisher. \begtt - address = "Berlin", - publisher = "Springer Verlag", - year = 2012, +address = "Berlin", +publisher = "Springer Verlag", +year = 2012, \endtt - Output: Berlin: Springer Verlag, 2012. Note, that the year needn't to be inserted into quotes because it is pure @@ -605,17 +610,15 @@ sort sensitive, may be you need to print something else than only sorting key. Example: \begtt - year = 2000, - option = "yearpint:{© 2000}", +year = 2000, +option = "yearpint:{© 2000}", \endtt - Output: © 2000, sorted by: 2000. \begtt - year = "2012a", - option = "yearprint:{2012}", +year = "2012a", +option = "yearprint:{2012}", \endtt - Output: 2012, sorted by: 2012a. The address, publisher and year are typically mandatory fields. If they are @@ -624,12 +627,12 @@ option. Then this warning is suppressed. There is no difference in the printed output. -\secc The url field +\seccc The url field Use it without `\url` macro, but with `http://` prefix. Example: \begtt - url = "http://petr.olsak.net/opmac.html", +url = "http://petr.olsak.net/opmac.html", \endtt The ISO 690 norm recommends to add the text \"Available from" (or @@ -647,33 +650,31 @@ If the `urlalso` option is used, then the added text has the form current). -\secc The citedate field +\seccc The citedate field This is the citation date. The field must be in the form year/month/day. It means, that the two slashes must be written here. The output depends on the current language. Example: \begtt - citedate = "2004/05/21", +citedate = "2004/05/21", \endtt - -Output when `en` is current: [cit. 2004-05-21]. +Output when `en` is current: [cit. 2004-05-21].\nl Output when `cs` is current: [vid. 21.~5.~2004]. -\secc The howpublished field +\seccc The howpublished field This declares the available medium for cited document if it is not in printed form. Alternatives: online, CD, DVD, etc. Example: \begtt - howpublished = "online", +howpublished = "online", \endtt - Output: [online]. -\secc The volume, number, pages and numbering fields +\seccc The volume, number, pages and numbering fields The volume is the \"big mark" of the journal issue and the number is the \"small mark" of the journal issue and pages includes the page range of @@ -684,20 +685,18 @@ language of the entry. Example: \begtt - volume = 31, - number = 3, - pages = "37--42", +volume = 31, +number = 3, +pages = "37--42", \endtt - Output: Vol.~31, No.~3, pp.~37--42. \begtt - volume = 31, - number = 3, - pages = "37--42", - lang = "cs", +volume = 31, +number = 3, +pages = "37--42", +lang = "cs", \endtt - Output: ročník~31, č.~3, s.~37--42. If you disagree with the default prefixes, you can use the numbering field. @@ -706,12 +705,11 @@ and instead of any mentioned prefixes. The numbering can include macros `\VOL`, `\NO`, `\PP`, which are expanded to the respective values of fields. Example: \begtt - volume = 31, - number = 3, - pages = "37--42" - numbering = "Issue~\VOL/\NO, pages~\PP", +volume = 31, +number = 3, +pages = "37--42" +numbering = "Issue~\VOL/\NO, pages~\PP", \endtt - Output: Issue~31/3, pages~37--42 Note: The volume, numbers and pages fields are printed without numbering @@ -719,7 +717,7 @@ filed only in the `@ARTICLE` entry. It means, that if you need to visible them in the `@INBOOK`, `@INPROCEEDINGS` etc. entries, then you must to use numbering field. -\secc Common notes about entries +\seccc Common notes about entries The order of the fields in the entry is irrelevant. We use the printed order in this manual. The exclamation mark (!) denotes the mandatory field. If @@ -732,7 +730,7 @@ warnings about missing mandatory fields occurs. If the field is used but not mentioned in the entry documentation below then it is silently ignored. -\p The `@BOOK` entry +\secccc The `@BOOK` entry This is used for book-like entries. @@ -742,7 +740,7 @@ publisher(!), year(!), citedate, series, isbn(!), doi, url, note. The ednote field here means the secondary authors (illustrator, cover design etc.). -\p The `@ARTICLE` entry +\secccc The `@ARTICLE` entry This is used for articles published in a journal. @@ -753,7 +751,7 @@ doi, url, note. If the numbering is used then it is used instead volume, number, pages. -\p The `@INBOOK` entry +\secccc The `@INBOOK` entry This is used for the part of a book. @@ -768,7 +766,7 @@ about the part (chapter numbers etc.). The `@INPROCEEDINGS` and `@CONFERENCE` entries are equivalent to `@INBOOK` entry. -\p The `@THESIS` entry +\secccc The `@THESIS` entry This is used for student's thesis. @@ -783,7 +781,7 @@ There are nearly equivalent entries: `@BACHELORSTHESIS`, `@MASTERSTHESIS` and automatically. The type field is optional in such case. If it is used then it has a precedence before default setting. -\p The @MISC entry +\secccc The @MISC entry It is intended for various usage. @@ -792,13 +790,13 @@ Fields: author, title, howpublished, ednote, citedate, doi, url, note. You can use `\AU`, `\ED`, `\EDN`, `\VOL`, `\NO`, `\PP`, `\ADDR`, `\PUBL`, `\YEAR` macros in ednote field. These macros print authors list, editors list, edition, volume, number, pages, address, publisher and year field values -respecitively. +respectively. The reason of this entry is to give to you the possibility to set the format of entry by your own decision. The most of data are concentrated in ednote field. -\p The `@BOOKLET`, `@INCOLLECION`, `@MANUAL`, `@PROCEEDINGS`, `@TECHREPORT`, `@UNPUBLISHED` entries +\secccc The `@BOOKLET`, `@INCOLLECION`, `@MANUAL`, `@PROCEEDINGS`, `@TECHREPORT`, `@UNPUBLISHED` entries These entries are equivalent to `@MICS` entry because we need to save the simplicity. They are implemented only for (almost) backward compatibility @@ -806,7 +804,7 @@ with the ancient Bib\TeX/. But the ednote is mandatory field here, so you cannot use these entries from the old databases without warnings and without some additional work with the `.bib` file. -\secc The cite-marks (bibmark) used when \code{\\nonumcitations} is set +\seccc The cite-marks (bibmark) used when \code{\\nonumcitations} is set When `\nonumcitations` is set then `\cite` prints text orientes bib-marks instead numbers. This style file autogenerates these marks in the @@ -814,12 +812,12 @@ form \"Lastname of the first author, comma, space, the year" if bibmark field isn't declared. If you need to set an exception from this common format, then you can use bibmark field. -The OPmac trick \url{http://petr.olsak.net/opmac-tricks-e.html#bibmark} +The OPmac trick \url{http://petr.olsak.net/opmac-tricks-e.html\#bibmark} describes how to redefine the algorithm for bibmark auto-generating when you need the short form of the type [Au13]. -\secc Sorting +\seccc Sorting If `\usebib/c` is used then entries are sorted by citation order in the text. If `\usebib/s` is used then entries are sorted by \"Lastname, Firstname(s)" of @@ -840,8 +838,8 @@ of authors. If the `key` field is unset then the \"Lastname Firstname(s)" is used for sorting normally. Example: \begtt - author = "Světla Čmejrková", - key = "Czzmejrkova Svetla", +author = "Světla Čmejrková", +key = "Czzmejrkova Svetla", \endtt This entry is now sorted between C and D. @@ -851,7 +849,7 @@ references. You can do this by setting `key = "@"`, to each entry with your name because the `@` character is sorted before `A`. -\secc Languages +\seccc Languages There is the language of the outer document and the languages of each entry. The ISO 690 norm recommends that the technical notes (the prefix before URL, @@ -874,72 +872,69 @@ language is used. If the outer document language is known before creating of the `.bib` file, you can store some language-dependent phrases into it. On the other hand, if the -main document language is unknown, you can use the \Mtext macro to +main document language is unknown, you can use the `\Mtext` macro to create the text multilingual. Example: \begtt - howpublished = "\Mtext{blue-ray}" +howpublished = "\Mtext{blue-ray}" \endtt Now, you can set the variants of blue-ray into your macros: \begtt - \mtdef {blue-ray} {Blue-ray disc} {Blue-ray disk} {} +\mtdef {blue-ray} {Blue-ray disc} {Blue-ray disk} {} \endtt -\secc Tips for using more languages +\seccc Tips for using more languages This style prefers English, Czech and Slovak languages. However, you can add -more languages. You can see the avalable languages by expansion of \langlist -macro. And you can use the shortcuts of language names (`de` and `pl` in the -example below and you can define all phrases for your language: - +more languages. Use the shortcuts of language names (`de` and `pl` in the +example below). You can define all phrases for your language: \begtt - \def\mtdefx#1#2#3{\sdef{_mt:#1:de}{#2}\sdef{_mt:#1:pl}{#3}} +\def\mtdefx#1#2#3{\sdef{_mt:#1:de}{#2}\sdef{_mt:#1:pl}{#3}} - % German % Polish - \mtdefx {bib.and} { und } { a } - \mtdefx {bib.phdthesis} {Ph.D. Dissertation} {Praca doktorska} - ... + % German % Polish +\mtdefx {bib.and} { und } { a } +\mtdefx {bib.phdthesis} {Ph.D. Dissertation} {Praca doktorska} +... \endtt - -See more about language phrases in the \ref[languages] section. +See more about language phrases in the \ref[langphrases] section. -\secc Summary of non-standard fields +\seccc Summary of non-standard fields This style uses the following fields unkown by bib\TeX/: \begtt - option ... options separated by spaces - lang ... the language two-letter code of one entry - ednote ... editional info (secondary authors etc.) or - global data in @MISC-like entries - citedate ... the date of the citation in year/month/day format - numbering ... format for volume, number, pages - isbn ... ISBN - issn ... ISSN - doi ... DOI - url ... URL +option ... options separated by spaces +lang ... the language two-letter code of one entry +ednote ... editional info (secondary authors etc.) or + global data in @MISC-like entries +citedate ... the date of the citation in year/month/day format +numbering ... format for volume, number, pages +isbn ... ISBN +issn ... ISSN +doi ... DOI +url ... URL \endtt -\secc Summary of options +\seccc Summary of options \begtt - aumax:<number> ... maximum number of printed authors - aumin:<number> ... number of printed authors if aumax exceedes - autrim:<number> ... full Firstnames iff number of authors are less than this - auprint:{<value>} ... text instead auhors list (\AU macro may be used) - edmax, edmin, edtrim ... similar as above for editors list - edprint:{<value>} ... text instead editors list (\ED macro may be used) - titlepost:{<value>} ... text after title - yearprint:{<value>} ... text instead real year (\YEAR macro may be used) - editionprint:{<value>} . text instead real edition (\EDN macro may be used) - urlalso ... the ``available also from'' is used instead ``available from'' - unpublished ... the publisher etc. fields are not mandatory - nowarn ... no mandatory fields +aumax:<number> ... maximum number of printed authors +aumin:<number> ... number of printed authors if aumax exceedes +autrim:<number> ... full Firstnames iff number of authors are less than this +auprint:{<value>} ... text instead authors list (\AU macro may be used) +edmax, edmin, edtrim ... similar as above for editors list +edprint:{<value>} ... text instead editors list (\ED macro may be used) +titlepost:{<value>} ... text after title +yearprint:{<value>} ... text instead real year (\YEAR macro may be used) +editionprint:{<value>} . text instead real edition (\EDN macro may be used) +urlalso ... the ``available also from'' is used instead ``available from'' +unpublished ... the publisher etc. fields are not mandatory +nowarn ... no mandatory fields \endtt Another options in the option field are silently ignored. diff --git a/Master/texmf-dist/tex/luatex/optex/cite-bib.opm b/Master/texmf-dist/tex/luatex/optex/cite-bib.opm index 7f5b184d93a..44f8dee055a 100644 --- a/Master/texmf-dist/tex/luatex/optex/cite-bib.opm +++ b/Master/texmf-dist/tex/luatex/optex/cite-bib.opm @@ -3,7 +3,9 @@ \_codedecl \cite {Cite, Biblioraphy <2020-03-09>} % loaded in format \_doc ----------------------------- - Registers used by `\cite`, `\bib` macros are declared here + Registers used by `\cite`, `\bib` macros are declared here. + The \`\bibnum` counts the bibliography items from one. + The \`\bibmark` is used when `\nonumcitations` is set. \_cod ----------------------------- \_newcount\_bibnum % the bibitem counter @@ -12,15 +14,18 @@ \_public \bibnum \bibmark ; \_doc ----------------------------- - `\cite [<label>,<label>,...,<label>]` manages <labes> using `\_citeA` - and prints prints `[<bib-marks>]` using `\_printsavedcites`. - `\nocite [<label>,<label>,...,<label>]` only manages <labels> but prints nothing. - `\rcite [<label>,<label>,...,<label>]` behaves like `\cite` but prints + \`\cite` `[<label>,<label>,...,<label>]` manages <labes> using `\_citeA` + and prints `[<bib-marks>]` using `\_printsavedcites`. + \nl + \`\nocite` `[<label>,<label>,...,<label>]` only manages <labels> but prints nothing. + \nl + \`\rcite` `[<label>,<label>,...,<label>]` behaves like `\cite` but prints <bib-marks> without brackets. - `\ecite [<label>]{<text>}` behaves like `\rcite [<label>]` but prints + \nl + \`\ecite` `[<label>]{<text>}` behaves like `\rcite [<label>]` but prints <text> instead <bib-mark>. The <text> is hyperlinked like <bib-marks> when `\cite` or `\rcite` is used. - The emptpty internal macro `\_savedcites` will include the <bib-marks> list to + The emptpty internal macro \`\_savedcites` will include the `<bib-marks>` list to be printed. This list is set by `\_citeA` inside group and it is used by `\_printsavedcites` in the same group. Each `\cite`/`\rcite`/`\ecite` macro starts from empty list of <bib-marks> because new group is opened. @@ -36,16 +41,16 @@ \_public \cite \nocite \rcite \ecite ; \_doc ----------------------------- - <bib-marks> may be numbers or a special text related to cited bib-entry. - It depends on `\nonumcitations` and on used bib-style. The mapping from - <label> to <bib-makr> is done when `\bib` or `\usebib` is processed. + `<bib-marks>` may be numbers or a special text related to cited bib-entry. + It depends on \`\nonumcitations` and on used bib-style. The mapping from + <label> to <bib-mark> is done when `\bib` or `\usebib` is processed. These macros store the information to - `\_Xbib{<label>}{<number>}{<nonumber>}` where <number> and <nonumber> are + \`\_Xbib``{<label>}{<number>}{<nonumber>}` where <number> and <nonumber> are two variants of <bib-mark> (numbered or text-like). This information is read from `.ref` file and it is saved to macros - \_bib:<label> and \_bibm:<number>. First one includes number and second + `\_bib:<label>` and `\_bibm:<number>`. First one includes number and second one includes <nonumber>. The `\_lastbibnum` macro includes last number of - bib-entry used in the document. A designer can use it to set apropriate + bib-entry used in the document. A designer can use it to set appropriate indentation when printing the list of all bib-entries. \_cod ----------------------------- @@ -53,7 +58,7 @@ \_if^#3^\_else\_sdef{_bim:#2}{#3}\_fi\_def\_lastbibnum{#2}} \_doc ----------------------------- - `\_citeA <label>,` processes one label from list of labels given in the + \`\_citeA` `<label>,` processes one label from list of labels given in the parameter of `\cite`, `\nocite`, `\rcite` or `\ecite` macros. It adds the <label> to global list `\_citelist` which will be used by `\usebib` (it must to know what <labels> are used in the document in order to pick-up @@ -61,19 +66,19 @@ space and not to save the same <label> to `\_citelist` twice, we distinguish four cases: \begitems - * <label> was not declared by `\_Xbib` and it is first such <label> in the + * `<label>` was not declared by \^`\_Xbib` and it is first such <label> in the document: Then `\_bib:<label>` is undefined and we save label using `\_addcitlist`, write warning on the terminal and define `\_bib:<label>` as empty. - * <label> was not declared by `\_Xbib` but it was used previously in the + * `<label>` was not declared by \^`\_Xbib` but it was used previously in the document: Then `\_bib:<label>` is empty and we do nothing (only data to `\_savedcites` are saved). - * <label> was declared by `\_Xbib` and it is first such <label> in the + * `<label>` was declared by \^`\_Xbib` and it is first such <label> in the document: Then `\_bin:<label>` includes `\_bibnn{<number>}&` and we - test this case by `\if &\_bibnn{<number>}&` when `\_bibnn{<number>}` + test this case by `\if &\_bibnn{<number>}&`. This is true when `\_bibnn{<number>}` expands to empty. The <label> is saved by `\_addcitelist` and `\_bib:<label>` is re-defined directly as <number>. - * <label> was declared by `\_Xbib` and it was used previously in the + * `<label>` was declared by \^`\_Xbib` and it was used previously in the document. Then we do nothing (only data to `\_savedcites` are saved. \enditems The `\_citeA` macro runs repeatedly over whole list of <labels>. @@ -104,15 +109,16 @@ \_def\_citelist{} \_doc ----------------------------- - The <bib-marks> (in numeric or text form) are saved in `\_savedcites` + The `<bib-marks>` (in numeric or text form) are saved in \^`\_savedcites` macro separated by commas. - The `\_printsavedcites` prints them by normal order or sorted if - `\sortcitations` is specified or condensed if `\shordcitations` is - specified. - `\sortcitations` appends the dummy number 300000 and we suppose that normal + The \`\_printsavedcites` prints them by normal order or sorted if + \`\sortcitations` is specified or condensed if \`\shordcitations` is + specified.\nl + The `\sortcitations` appends the dummy number 300000 and we suppose that normal numbers of bib-entries are less than this constant. This constant is removed after sorting algorithm. - The macros for <bib-marks> printing folows (sorry, without detail + The \`\shortcitations` sets simply `\_lastcitenum=1`. + The macros for <bib-marks> printing follows (sorry, without detail documentation). They are documented in `opmac-d.pdf` (but only in Czech). \_cod ----------------------------- @@ -173,12 +179,12 @@ \_public \nonumcitations \sortcitations \shortcitations ; \_doc ----------------------------- - The `\bib [<label>] {<optional bib-mark>}` prints one bib-entry + The \`\bib` `[<label>] {<optional bib-mark>}` prints one bib-entry without reading any database. The bib-enty follows after this command. This command counts the used `\bib`s from one by `\bibnum` counter and - saves `\_Xbib{<label>}{\_the\_bibnum}{\_the\_bibmark}` into `.ref` file + saves \^`\_Xbib``{<label>}{\_the\_bibnum}{\_the\_bibmark}` into `.ref` file immediately using `\_wbib`. This is the core of creation of mapping from - <labels> to <bib-marks>. + `<labels>` to `<bib-marks>`. \_cod ----------------------------- \_def\_bib[#1]{\_def\_tmp{\_isnextchar={\_bibA[#1]}{\_bibmark={}\_bibB[#1]}}% @@ -196,18 +202,18 @@ \_public \bib ; \_doc ----------------------------- - The `\_printbib` prints the bib-entry itself. You can re-define it if you + The \`\_printbib` prints the bib-entry itself. You can re-define it if you want different design. The `\_pritbib` starts in horizontal mode after `\noindent` and after the eventual hyperlink destination is inserted. By default, the `\_printbib` sets the indentation by `\hangindent` and prints numeric <bib-marks> by `\llap{[\the\bibnum]}` If `\nonumcitations` then the `\_citelinkA` is not empty and <bib-marks> (`\the\bibnum` nor `\the\bibmark`) are not printed. - The text of bib-entry follows. User can create this text manualy - using `\bib` command or it is generated automaticaly from a `.bib` database + The text of bib-entry follows. User can create this text manually + using `\bib` command or it is generated automatically from a `.bib` database by `\usebib` command. - The vertical space between bib-entries is controlled by `\_bibskip` macro. + The vertical space between bib-entries is controlled by \`\_bibskip` macro. \_cod ----------------------------- \_def \_printbib {\_hangindent=\_iindent @@ -216,11 +222,11 @@ \_def \_bibskip {\_ifnum\_bibnum>0 \_smallskip \_fi} \_doc ----------------------------- - The `\usebib` command is implemted in `usebib.opm` file which is loaded + The \`\usebib` command is implemted in `usebib.opm` file which is loaded when the `\usebib` command is firstly used. The `usebib.opm` file loads the `librarian.tex` for scaning the `.bib` - files. This macro is external created by Paul Isambert. This is only one - such situation where \OpTeX/ macros depends on an external macro. + files. See the section~\ref[usebib], where the file `usebib.opm` is + documented. \_cod ----------------------------- \_def\_usebib{\_par \_opinput {usebib.opm} \_usebib} @@ -231,8 +237,8 @@ before the `\usebib` command is used because `\usebib` prints only such bib-entries their <labels> are saved in the `\_citelist`. But if some `\cite` is used after `\usebib`, then `\usebib` sets `\_addcitelist` to - `\_writeXcite`, so such `\cite` saves the information to the - `.ref`file in the format `\_Xcite{<label>}`. Such information are copied + \`\_writeXcite`, so such `\cite` saves the information to the + `.ref`file in the format \`\_Xcite``{<label>}`. Such information are copied to `\_citelistB` during reading `.ref` file and `\usebib` concats two lists of <labels> from `\_citelist` and `\_citelistB` and uses this concatenated list. diff --git a/Master/texmf-dist/tex/luatex/optex/colors.opm b/Master/texmf-dist/tex/luatex/optex/colors.opm index 90d3d6d7a3e..2745e0fc51d 100644 --- a/Master/texmf-dist/tex/luatex/optex/colors.opm +++ b/Master/texmf-dist/tex/luatex/optex/colors.opm @@ -3,8 +3,8 @@ \_codedecl \colordef {Colors <2020-03-18>} % loaded in format \_doc ----------------------------- - We declare internal boolean value `\_iflocalcolor` ad do - `\localcolor` as default. + We declare internal boolean value \`\_iflocalcolor` ad do + \`\localcolor` as default. \_cod ----------------------------- \_newifi \_iflocalcolor \_localcolortrue @@ -13,7 +13,10 @@ \_public \localcolor \nolocalcolor ; \_doc ----------------------------- - The basic colors in CMYK are here. + The basic colors in CMYK + \`\Blue` \`\Red` \`\Brown` \`\Green` \`\Yellow` \`\Cyan` \`\Magenta` + \`\Grey` \`\LightGrey` \`\White` and \`\Black` + are declared here. \_cod ----------------------------- \_def\Blue {\_setcmykcolor{1 1 0 0}} @@ -29,9 +32,16 @@ \_def\Black {\_setgreycolor{0}} \_doc ----------------------------- - By default, `\set/cmyk/rgb/grey/color` macros expands to `\_setcolor{<pdf-primitive>}` + By default, the \`\setcmykcolor` \`\setrgbcolor` and \`\setgreycolor` + macros with `{<componetns>}` parameter + expand to `\_setcolor{<pdf-primitive>}` using \`\_formatcmyk` + or \`\_formatrgb` or \`\_formatgrey` expandable macros. + For example `\setrgbcolor{1 0 0}` expands to `\_setcolor{1 0 0 rg 1 0 0 RG}`.\nl We set both types of colors (for lines (`K` or `RG` or `G`) and for fills (`r` or `rg` or `g`) together in the <pdf-primitive> command. + This is the reason why the \`\_fillstroke` uses both its parameters. + If only fills are needed you can do `\def\_fillstroke#1#2{#1}`. + If only strokes are needed you can do `\def\_fillstroke#1#2{#2}`. \_cod ----------------------------- \_def\_setcmykcolor#1{\_setcolor{\_formatcmyk{#1}}} @@ -40,22 +50,19 @@ \_def\_formatcmyk#1{\_fillstroke{#1 k}{#1 K}} \_def\_formatrgb#1{\_fillstroke{#1 rg}{#1 RG}} \_def\_formatgrey#1{\_fillstroke{#1 g}{#1 G}} +\_def\_fillstroke#1#2{#1 #2} \_public \setcmykcolor \setrgbcolor \setgreycolor ; \_doc ----------------------------- - The `\onlyrgb` declaration redefines `\_formatcmyk` in ordet it expands + The \`\onlyrgb` declaration redefines \^`\_formatcmyk` in order it expands to its conversion to RGB <pdf-primitive>. This conversion is done by - the `\_cmyktorgb` macro. Moreover, `\onlyrgb` re-defines three basic RGB - colors for RGB color space and re-declares `\_colordef` as `\_rgbcolordef`. - The `\onlycmyk` macro does a similar work, it re-defines `\_formatrgb` - macro. The Grey color space is unnchanged and works in both main + the \^`\_cmyktorgb` macro. Moreover, `\onlyrgb` re-defines three basic RGB + colors for RGB color space and re-declares \^`\colordef` as \^`\rgbcolordef`. + The \hbox{\`\onlycmyk`} macro does a similar work, it re-defines \^`\_formatrgb` + macro. The Grey color space is unchanged and works in both main settings (RGB or CMYK) without collisions. - The `\_fillstroke` uses the same color for fills and strokes. - If only fills are needed to declare do `\def\_fillstroke#1#2{#1}`. - If only strokes are needed to declare do `\def\_fillstroke#1#2{#2}`. \_cod ----------------------------- -\_def\_fillstroke#1#2{#1 #2} \_def\_onlyrgb{\_def\Red{\_setrgbcolor{1 0 0}}% \_def\Green{\_setrgbcolor{0 1 0}}\_def\Blue{\_setrgbcolor{0 0 1}}% \_let\_colordef=\_rgbcolordef @@ -66,10 +73,10 @@ \_public \onlyrgb \onlycmyk ; \_doc ----------------------------- - The `\_setcolor` macro redefines empty `\_ensureblack` macro (used in - output routine for headres and footers) to `\_encureblackA` which keeps - Black at start ot its parameter and retunrs to the current color at the - end of its parameter. Then the current color + The \`\_setcolor` macro redefines empty `\_ensureblack` macro (used in + output routine for headres and footers) to `\_ensureblackA` which sets + Black at the start of its parameter and retunrs to the current color at the + end of its parameter. The current color is saved into `\_currentcolor` macro and colorstack is pushed. Finally, the `\_colorstackpop` is initialized by `\aftergroup` if `\localcolor` is declared. @@ -89,8 +96,8 @@ \_colorstackpush\_pdfblackcolor #1\_colorstackpop} \_doc ----------------------------- - The colorstack is initialized here and basic macros - `\_colorstackpush`, `\_colorstackpop` and `\_colorstackset` + The colorstack is initialized here and the basic macros + \`\_colorstackpush`, \`\_colorstackpop` and \`\_colorstackset` are defined here. \_cod ----------------------------- @@ -102,23 +109,25 @@ \_doc ----------------------------- We need to open a special color stack for footnotes, because footnotes can follow on next pages and their colors are independent on colors - used in man page-body. + used in the main page-body. The \`\_openfnotestack` is defined as + \`\_openfnotestackA` when the \^`\_setcolor` is used first. + The \`\_fnotestack` is initializedin in `\everyjob` because the + initialization is not saved to the format. \_cod ----------------------------- -%\_mathchardef\_fnotestack=\_pdfcolorstackinit page {0 g 0 G} -% must be in \everyjob^^^ +%\_mathchardef\_fnotestack=\_pdfcolorstackinit page {0 g 0 G} % must be in \everyjob \_def \_openfnotestackA {\_pdfcolorstack\_fnotestack current} \_doc ----------------------------- We use lua codes for RGB to CMYK or CMYK to RGB conversions and for - addition color components in the `\colordef` macro. - `\_rgbtocmyk <R> <G> <B> ;` expands to <C> <M> <Y> <K>. - `\_cmyktorgb <C> <M> <Y> <K> ;` expands to <R> <G> <B>. - The `\_colorcrop`, `\_colordefFin` and `\_douseK` are auxiliary macros - used in `\colordef`. The `\colorcrop` rescales color components in order + addition color components in the \^`\colordef` macro. + The \`\_rgbtocmyk` `<R> <G> <B> ;` expands to `<C> <M> <Y> <K>` and + the \`\_cmyktorgb` `<C> <M> <Y> <K> ;` expands to `<R> <G> <B>`. + The \`\_colorcrop`, \`\_colordefFin` and \`\_douseK` are auxiliary macros + used in the \^`\colordef`. The `\_colorcrop` rescales color components in order to they are in $[0,1]$ interval. The `\colordefFin` expands to the values accumulated in Lua code `color_C`, `color_M`, `color_Y` and `color_K`. - The `\_douseK` applies `\useK` to CMYK components. + The `\_douseK` applies \^`\useK` to CMYK components. \_cod ----------------------------- \_def\_rgbtocmyk #1 #2 #3 ;{% @@ -160,7 +169,7 @@ \_doc ----------------------------- We have a problem with the `%.3f` directive in Lua code. It prints trailed zeros: (0.300 instead desired 0.3) but we want to save PDF file space. The macro - `\_stripzeros` removes these trailing zeros at expand processor + \`\_stripzeros` removes these trailing zeros at expand processor level. So `\_stripzeros 0.300 0.400 0.560 ;` expands to `.3 .4 .56`. \_cod ----------------------------- @@ -171,22 +180,22 @@ \_def\_stripzeroC #1 #2:{#1} \_doc ----------------------------- - The `\rgbcolordef` and `\cmykcolordef` use common macro - `\_commoncolordef` with different first four parameters. + The \`\rgbcolordef` and \`\cmykcolordef` use common macro + \`\_commoncolordef` with different first four parameters. The `\_commoncolordef <selector><K><R><G><what-define>{<data>}` does the real work. It initializes the Lua variables for summation. It expands <data> in the group where color selectors have - special meaning, then it adjusts the resulting string by `\replstring` + special meaning, then it adjusts the resulting string by \^`\replstring` and runs it. Example shows how the <data> are processed: \begtt - input <data>: ".3\Blue +.6^\KhakiC \useK -\Black" + input <data>: ".3\Blue + .6^\KhakiC \useK -\Black" expanded to: ".3 !=K 1 1 0 0 +.6^!=R .804 .776 .45 \_useK -!=G 0" adjusted to: "\_addcolor .3!=K 1 1 0 0 \_addcolor .6!^R .804 .776 .45 \_useK \_addcolor -1!=G 0" and this is processed. \endtt - `\_addcolor <coef.>!<mod><type>` expands to `\_addcolor:<mod><type> <coef>` - for example to `\_addcolor:=K <coef>` followed by one or three or four + \`\_addcolor` `<coef.>!<mod><type>` expands to `\_addcolor:<mod><type> <coef>` + for example it expands to `\_addcolor:=K <coef>` followed by one or three or four numbers (depending on <type>). <mod> is `=` (use as is) or `^` (use complementary color). <type> is `K` for CMYK, `R` for RGB and `G` for GREY color space. Uppercase <type> informs that `\cmykcolordef` is @@ -201,7 +210,8 @@ using `\_colordefFin`. If `\rgbcolordef` is processed, then we must to remove the last <K> component which is in the format `.0` in such case. The `\_stripK` macro does it. - Finaly, the <what-define> is defined as `<selector>{<expanded _tmpb>}`. + Finally, the `<what-define>` is defined as `<selector>{<expanded _tmpb>}`, + for example `\_setcmykclor{1 0 .5 .3}`. \_cod ----------------------------- \_def\_rgbcolordef {\_commoncolordef \_setrgbcolor krg} @@ -214,6 +224,7 @@ \_def\_setgreycolor##1{!=#4 ##1 }% \_let\_useK=\_relax \_edef\_tmpb{+#6}% + \_replstring\_tmpb{+ }{+}\_replstring\_tmpb{- }{-}% \_replstring\_tmpb{+}{\_addcolor}\_replstring\_tmpb{-}{\_addcolor-}% \_replstring\_tmpb{^!=}{!^}\_replstring\_tmpb{-!}{-1!}% \_ifx K#2\_let\_useK=\_douseK \_fi @@ -252,7 +263,7 @@ \_let\_colordef=\_cmykcolordef % default \_colordef is \_cmykcolordef \_doc ----------------------------- - Public versions of `\colordef` and `\useK` macros are declared using + Public versions of \`\colordef` and \`\useK` macros are declared using `\_def`, because the internal versions `\_colordef` and `\_useK` are changed during processing. \_cod ----------------------------- @@ -262,14 +273,14 @@ \_public \cmykcolordef \rgbcolordef ; \_doc ----------------------------- - The \LaTeX/ file `x11nam.def` is read by `\morecolors`. The numbers - 0,1,2,3,4 are trasformed to letters O, <none>, B, C, D in the name of the - color. Colors defined already are not re-defined. The empty \_showcolor` + The \LaTeX/ file `x11nam.def` is read by \`\morecolors`. The numbers + 0,1,2,3,4 are transformed to letters O, <none>, B, C, D in the name of the + color. Colors defined already are not re-defined. The empty \`\_showcolor` macro should be re-defined for color catalog printing. For example: \begtt \def\vr{\vrule height10pt depth2pt width20pt} - \def\_showcolor{\hbox{\tt \_bslash\_tmpb: \csname \_tmpb\endcsname \vr}\space\space} - \typosize[11/14] \begmulti 4 + \def\_showcolor{\hbox{\tt\_bslash\_tmpb: \csname\_tmpb\endcsname \vr}\space\space} + \begmulti 4 \typosize[11/14] \morecolors \endmulti \endtt @@ -298,45 +309,47 @@ and switches colors according to them. This is totally independent on \TeX/ group mechanism. You can declare `\nolocalcolor` at the beginning of the document, if you want this behavior. In this case, if you set a color then you must to return back to black color -using `\Black` manualy. +using `\Black` manually. By default, \OpTeX/ sets `\localcolor`. It means that the typesetting returns back to a previous color at the end of current group, so you cannot -write `\Black` explicitly. This is implemented using `\afterroup` feature. -There is a limitiation of this feature: when a color selector is used in a +write `\Black` explicitly. This is implemented using `\aftergroup` feature. +There is a limitation of this feature: when a color selector is used in a group of a box, which is saved by `\setbox`, then the activity or -recontruction of previous color are processed at `\setbox` time, no in the -box itself. You must to correct it by double group: +reconstruction of previous color are processed at `\setbox` time, no in the +box itself. You must correct it by double group: \begtt -\setbox=\hbox{\Red something} % bad: the \Black is done after \setbox -\setbox=\hbox{{\Red something}} % good: the \Black is done after group inside the box +\setbox0=\hbox{\Red text} % bad: \Black is done after \setbox +\setbox0=\hbox{{\Red text}} % good: \Black is done after group inside the box \endtt The implementation of colors is based on colorstack, so the current color -can follow acros more pages. It is not so obvious because PDF viewer (or PDF +can follow across more pages. It is not so obvious because PDF viewer (or PDF interpreter) manipulates with colors locally at each PDF page and it initializes each PDF page with black on white color. -Macros `\setcmykcolor{<C> <M> <Y> <K>}` or `\setrgbcolor{<R> <G> <B>}` -or `\_setgreycolor{<Grey>}` should be used in color selectors or user can +Macros \^`\setcmykcolor``{<C> <M> <Y> <K>}` or \^`\setrgbcolor``{<R> <G> <B>}` +or\nl \^`\setgreycolor``{<Grey>}` should be used in color selectors or user can specify these macros explicitly. -The color mixing processed by `\colordef` is done in the substractive color +The color mixing processed by the \^`\colordef` is done in the substractive color model CMYK. If the result has a component greater than 1 then all components are multiplied by a coefficient in order to maximal component is equal to 1. -You can move a common amount of CMY components (i.e. their minimum) to the +You can move a shared amount of CMY components (i.e. their minimum) to the $K$ component. This saves the color tonners and the result is more true. -This should be done by `\useK` command at the end of a linear combination +This should be done by \^`\useK` command at the end of a linear combination used in `\colordef`. For example -$$ - \colordef \myColor {.3\Green + .4\Blue \useK} -$$ +\begtt +\colordef \myColor {.3\Green + .4\Blue \useK} +\endtt The `\useK` command exactly does: $$ - k' =\min(C,M,Y), \ C=(C-k')/(1-k'), \ M=(M-k')/(1-k'), \ Y=(Y-k')/(1-k'), \ + \displaylines{ + k' =\min(C,M,Y), \cr \ C=(C-k')/(1-k'), \ M=(M-k')/(1-k'), \ Y=(Y-k')/(1-k'), \cr K = \min(1,K+k'). +} $$ You can use minus instead plus in the linear combination in `\colordef`. The @@ -352,25 +365,29 @@ occured during color mixing. Finally, you can use `^` immediately preceeded before macro name of the color. Then the complementary color is used here. \begtt -\colordef \mycolor {\Grey + .6^\Blue} % the same as \colordef\mycolor{\Grey+.6\Yellow} +\colordef\mycolor{\Grey+.6^\Blue} % the same as \colordef\mycolor{\Grey+.6\Yellow} \endtt -The `\rgbcolordef` can be used to mix colors in additive color model RGB. -If `\onlyrgb` is declared, then `\colordef` works as `\rgbcolordef`. +The \^`\rgbcolordef` can be used to mix colors in additive color model RGB. +If \^`\onlyrgb` is declared, then \^`\colordef` works as \^`\rgbcolordef`. -If a CMYK to RGB or RGB to CMYK conversion is needed then no ICC profiles are -supposed, but only the following simple formulae are used +If a CMYK to RGB or RGB to CMYK conversion is needed then +the following simple formulae are used +(ICC profiles are not supported): $$ \displaylines{ - \hbox{CMYK to RGB:}\quad + \hbox{CMYK to RGB:}\cr R = (1-C)(1-K), \ G = (1-M)(1-K), \ B = (1-Y)(1-K). \cr - \hbox{RGB to CMYK:}\quad + \hbox{RGB to CMYK:}\cr K'=\max(R,G,B), \ C=(K'-R)/K', \ M=(K'-G)/K', \ Y=(K'-B)/K', \ K=1-K'. } $$ The RGB to CMYK conversion is invoked when a color is declared using `\setrgbcolor` -and it is used in `\colordef` or if it is printed when `\onlycmyk` is declared. -The CMYK to RGB conversion is invoked when a color is declared using `\setcmykcolor` -and it is used in `\rgbcolordef` or if it is printed when `\onlyrgb` is declared. +and it is used in \^`\colordef` or if it is printed when \^`\onlycmyk` is declared. +The CMYK to RGB conversion is invoked when a color is declared using \^`\setcmykcolor` +and it is used in \^`\rgbcolordef` or if it is printed when \^`\onlyrgb` is declared. +\_endinput +2020-04-22 \replstring\tmpb{+ }{+}, {- }{-} added in \colordef, bug fixed +2020-03-18 introduced diff --git a/Master/texmf-dist/tex/luatex/optex/doc.opm b/Master/texmf-dist/tex/luatex/optex/doc.opm new file mode 100644 index 00000000000..210d67dc0eb --- /dev/null +++ b/Master/texmf-dist/tex/luatex/optex/doc.opm @@ -0,0 +1,259 @@ +%% This is part of OpTeX project, see http://petr.olsak.net/optex + +\_codedecl \printdoc {Macros for documentation printing <2020-04-22>} + + \_doc ----------------------------- + General decalarations. + \_cod ----------------------------- + +\fontfam[lmfonts] +\hyperlinks \Green \Green +\enlang +\enquotes + + \_doc ----------------------------- + Maybe, somebody needs `\seccc` or `\secccc`? + \_cod ----------------------------- + +\eoldef\seccc#1{\medskip \noindent{\bf#1}\par\nobreak\_firstnoindent} +\def\secccc{\medskip\noindent $\bullet$ } + + \_doc ----------------------------- + `\enddocument` can be redefined. + \_cod ----------------------------- + +\let\enddocument=\bye + + \_doc ----------------------------- + Full page of listing causes underfill `\vbox` in output routine. + We need to add a small tolerance. + \_cod ----------------------------- + +\pgbottomskip=0pt plus10pt minus2pt + + \_doc ----------------------------- + The listing mode is implemented here. + \_cod ----------------------------- + +\newcount \maxlines \maxlines=100000 + +\_eoldef\_cod#1{\_par \_wipeepar + \_vskip\_parskip \medskip \_ttskip + \_begingroup + \_typosize[8/10] + \_let\_printverbline=\_printcodeline + \_ttline=\_inputlineno + \_setverb + \_ifnum\_ttline<0 \_let\_printverblinenum=\_relax \_else \_initverblinenum \_fi + \_adef{ }{\ }\_adef\^^I{\t}\_parindent=\_ttindent \_parskip=0pt + \_relax \_ttfont + \_endlinechar=`^^J + \_def\_tmpb{\_start}% + \_readverbline +} +\_def\_readverbline #1^^J{% + \_def\_tmpa{\_empty#1}% + \_let\_next=\_readverbline + \_ea\_isinlist\_ea\_tmpa\_ea{\_Doc}\_iftrue \_let\_next=\_processinput \_fi + \_ea\_isinlist\_ea\_tmpa\_ea{\_Endcode}\_iftrue \_endinput \_let\_next=\_processinput \_fi + \_ifx\_next\_readverbline \_addto\_tmpb{#1^^J}\_fi + \_next +} +{\catcode`\ =13 \gdef\_aspace{ }}\def\_asp{\_ea\_noexpand\_aspace} +\_edef\_Doc{\_asp\_asp\_bslash _doc} +\_edef\_Endcode{\noexpand\_empty\_bslash _endcode} + + \_doc ----------------------------- + The scanner of the control sequences in the listing mode. + \_cod ----------------------------- + +\def\makecs{\def\tmp{}\futurelet\next\makecsA} +\def\makecsA{\ifcat a\_noexpand\next \_ea\makecsB \else \_ea\makecsF \_fi} +\def\makecsB#1{\addto\tmp{#1}\futurelet\next\makecsA} +\def\makecsF{\ifx\tmp\empty \csstring\\% + \else \ifcsname ,\tmp\endcsname \_link[cs:\tmp]{\Blue}{\csstring\\\tmp}% + \else \let\next=\tmp \_remfirstunderscore\next + \ifx\next\empty \let\next=\tmp \fi + \ifcsname ,\next\endcsname \_link[cs:\next]{\Blue}{\csstring\\\tmp}% + \else \_csstring\\\tmp \fi\fi\fi +} +\def\makecsI{\ifx\tmp\empty \csstring\\\relax + \else + \iindex{\tmp}% + \ifcsname cs:^\tmp\endcsname \else \dest[cs:^\tmp]\sxdef{cs:^\tmp}{}\fi + \_link[cs:\tmp]{\Blue}{\tt\csstring\\\tmp}% + \fi +} +\def\tryindex{\futurelet\next\tryindexA} +\def\tryindexA{\if\csstring\\\noexpand\next \_ea\tryindexB \fi} +\def\tryindexB#1{\let\makecsF=\makecsI \makecs} + +\_def\_processinput{% + \_let\_start=\_relax + \_ea\_replstring\_ea\_tmpb\_ea{\_aspace^^J}{^^J} + \_addto\_tmpb{\_end}% + \_isinlist\_tmpb{\_start^^J}\_iftrue \_advance\_ttline by1\_fi + \_replstring\_tmpb{\_start^^J}{\_start}% + \_replstring\_tmpb{\_start}{}% + \_replstring\_tmpb{^^J\_end}{\_end}% + \_replstring\_tmpb{^^J\_end}{}% + \_replstring\_tmpb{\_end}{}% + \_ea\_prepareverbdata\_ea\_tmpb\_ea{\_tmpb^^J}% + \_replthis{\_csstring\\}{\noexpand\makecs}% + \_ea\_printverb \_tmpb\_end + \_par + \_endgroup \_ttskip + \_isnextchar\_par{}{\_noindent}% +} + + \_doc ----------------------------- + The lines in the listing mode have Yellow background. + \_cod ----------------------------- + +\def\Yellow{\setcmykcolor{0.0 0.0 0.3 0.03}} + +\def\_printcodeline#1{\advance \maxlines by-1 + \ifnum \maxlines<0 \ea \endverbprinting \fi + \penalty \_ttpenalty \kern-4pt + \noindent\rlap{\Yellow \vrule height8pt depth5pt width\hsize}% + \printfilename + \indent \_printverblinenum #1\par} + +\def\printfilename{\hbox to0pt{% + \hskip\hsize\vbox to0pt{\vss\llap{\Brown\docfile}\kern7.5pt}\hss}% + \let\printfilename=\relax +} +\everytt={\_let\_printverblinenum=\_relax} + +\long\def\endverbprinting#1\_end{\fi \global\maxlines=100000 + \noindent\typosize[8/]\dots etc. (see {\tt\Brown\docfile})} + + \_doc ----------------------------- + `\docfile` is currently documented file. + \_cod ----------------------------- + +\def\docfile{} +\def\printdoc #1 {\_par \_def\docfile{#1}% + \everytt={\_ttshift=-15pt \_let\_printverblinenum=\_relax}% + \_ea\_cod \input #1 + \everytt={\_let\_printverblinenum=\_relax}% + \def\docfile{}% +} +\def\printdoctail #1 {\bgroup + \everytt={}\ttline=-1 \_ea\printdoctailA \input #1 \egroup} +{\long\gdef\printdoctailA#1\_endcode{}} + + \_doc ----------------------------- + You can do `\verbinuput \vitt{<filename>} (<from>-<to>) <filename>` + if you need analogical design like in listing mode. + \_cod ----------------------------- + +\def\vitt#1{\def\docfile{#1}\ttline=-1 + \everytt={\typosize[8/10]\_let\_printverbline=\_printcodeline \medskip}} + + \_doc ----------------------------- + The Index entries are without the trailing backslash. We must to add it + when printing Index. + \_cod ----------------------------- + +\addto \_ignoredcharsen {_} +\_def\_printii #1#2&{% + \_ismacro\_lastii{#1}\_iffalse \_newiiletter{#1}{#2}\_def\_lastii{#1}\_fi + \_gdef\_currii{#1#2}\_the\_everyii\_noindent + \_hskip-\_iindent \_ignorespaces\_printiiA\bslash#1#2//} + +\_def\_printiipages#1&{\_let\_pgtype=\_undefined \_tmpnum=0 + {\_rm\_printpages #1,:,\_par}} + +\_sdef{_tocl:1}#1#2#3{\_nofirst\_bigskip + \_bf\_llaptoclink{#1}{#2}\_hfill \_pgn{#3}\_tocpar\_medskip} + +\_activettchar` + + \_doc ----------------------------- + Main documentation point and hyperlinks to/from it. + \_cod ----------------------------- + +\def\`#1`{\edef\tmp{\csstring#1}\iindex{\tmp}% + \ifcsname cs:\tmp\endcsname\else \dest[cs:\tmp]\fi + \sxdef{cs:\tmp}{}% + \hbox{\ifcsname cs:^\tmp\endcsname + \_link[cs:^\tmp]{\Red}{\tt\csstring\\\tmp}\else + {\tt\Red\csstring\\\tmp}\fi}% +} + +\def\^`#1{\edef\tmp{\csstring#1}\iindex{\tmp}% + \hbox{\ifcsname cs:^\tmp\endcsname \else \dest[cs:^\tmp]\sxdef{cs:^\tmp}{}\fi + \_link[cs:\tmp]{\Blue}{\tt\string#1}}% + \futurelet\next\cslinkA +} +\def\cslinkA{\ifx\next`\_ea\_ignoreit \else \_ea\_ea\_ea`\_ea\_string\fi} + +\def\~`#1{\edef\tmp{\csstring#1}\iindex{\tmp}% + \hbox{\_link[cs:^\tmp]{\Blue}{\tt\string#1}}% + \futurelet\next\cslinkA +} + + \_doc ----------------------------- + The \code{<something>} will be print as <something>. + \_cod ----------------------------- + +\let\lt=< +\catcode`\<=13 + +\def<#1>{$\langle\hbox{\it#1\/}\rangle$} +\everyintt{\catcode`\<=13 } + +\_endcode %------------------------------------------- + +\noindent +The `\printdoc <filename><space>` and `\printdoctail <filename><space>` +commands are defined after the file `doc.opm` is load by `\input doc.opm`. + +The `\printcoc` starts reading of given `<filename>` from the second line. +The file is read in {\em the listing mode}. +The `\prindoctail` starts reading given `<filename>` from the +first occurrence of the `\_encode`. The file is read +in normal mode (like `\input <filename>`). + +The {\em listing mode} prints the lines as listing of a code. This mode is +finished when first {\visiblesp` \_doc`} occurs or first `\_endcode` +occurs. At least two spaces must precede before such `\_doc`. On the other +hand, the `\_encode` must be at the left edge of the line without spaces. +If this rule is not met then the listing mode continues. + +If the first line or the last line of the listing mode is empty then such +lines are not printed. The maximal number of printed lines in the listing +mode is `\maxlines`. Is is set to almost infinity (100000). You can set it +to a more sensible value. Such setting is valid only for the first following +listing mode. + +When the listing mode is finished by `\_doc` then next lines are read in the +normal way, but the material between `\begtt` ... `\endtt` pair +is shifted by three letters left. The reason is that the three spaces of +indentation is recommended in the `\_doc` ... `\_cod` pair and this shifting +is a compensation of this indentation. + +The `\_cod` macro ignores the rest of current line and starts the listing +mode again. + +When the listing mode is finished by the `\_endcode` then the `\endinput` is +applied, the reading of the file opened by `\printdoc` is finished. + +You cannot reach the end of the file (without `\_endcode`) in the listing +mode. + +The listing mode creates all control sequences which are listed in the +index as active link to the main documentation point of such control sequence +and prints them in blue. Other text is printed in black. + +The main documentation point is denoted by \code{\\`\\}`<sequence>`\code{`} +in red, for example \code{\\`\\foo`}. +The user documentation point is the first occurrence of +\code{\\^`\\}`<sequence>`\code{`}, for example \code{\\^`\\foo`}. +There can be more such markups, all of them are hyperlinks to the main +documentation point. +And main documentation point is hyperlink to the user documentation point, +if such point exists. Finally, the +\code{\\~`\\}`<sequence>`\code{`} (for example \code{\\~`\\foo`}) are +hyperlinks to the user documentation point. diff --git a/Master/texmf-dist/tex/luatex/optex/f-adventor.opm b/Master/texmf-dist/tex/luatex/optex/f-adventor.opm index 022b14a1de6..8dac5cf324a 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-adventor.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-adventor.opm @@ -1,19 +1,15 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Adventor] \Adventor {TeX Gyre Adventor based on Avantgarde Book} +\_famdecl [Adventor] \Adventor {TeX Gyre Adventor based on Avantgarde Book} {\caps} {\rm \bf \it \bi} {} {[texgyreadventor-regular]} + {\_def\_fontnamegen {[texgyreadventor-\_currV]:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Modifier:^^J \caps ...... caps & small caps^^J }} -\_protected\_def \Adventor {% - \_def \_currfamily {Adventor}% - \_def \_fontnamegen {[texgyreadventor-\_currV]:\_capsV\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fsetV caps={} \_fvars regular bold italic bolditalic } \_moddef \caps {\_fsetV caps=+smcp;+onum; } diff --git a/Master/texmf-dist/tex/luatex/optex/f-antt.opm b/Master/texmf-dist/tex/luatex/optex/f-antt.opm index d7015ed28db..4ec379ab395 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-antt.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-antt.opm @@ -1,8 +1,9 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Antykwa Torunska] \Antt {Traditional Polish font family} - {\cond \medium \light \caps} {\rm \bf \it \bi} {Pagella} - {[AntykwaTorunska-Regular]} +\_famdecl [Antykwa Torunska] \Antt {Traditional Polish font family} + {\cond \medium \light \caps} {\rm \bf \it \bi} {Pagella} + {[AntykwaTorunska-Regular]} + {\_def\_fontnamegen {[AntykwaTorunska\_sfamxV\_sfamyV-\_currV]:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Modifiers:^^J @@ -13,11 +14,6 @@ Modifiers:^^J \cond ...... condensed^^J }} -\_protected\def \Antt {% - \_def \_currfamily {Antt}% - \_def \_fontnamegen {[AntykwaTorunska\_sfamxV\_sfamyV-\_currV]:\_capsV\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fsetV sfamx={},sfamy={},caps={} \_fvars Regular Bold Italic BoldItalic } \_moddef \cond {\_fsetV sfamx=Cond \_fvars Regular . Italic . \_onlyif sfamy={}: {\_fvars Regular Bold Italic BoldItalic }} diff --git a/Master/texmf-dist/tex/luatex/optex/f-baskerville.opm b/Master/texmf-dist/tex/luatex/optex/f-baskerville.opm index a81e97f6398..a228c14a540 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-baskerville.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-baskerville.opm @@ -1,19 +1,15 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Baskerville] \Baskerville {Free vaiants of classical Baskerville} +\_famdecl [Baskerville] \Baskerville {Free vaiants of classical Baskerville} {\caps} {\rm \bf \it \bi} {} {[BaskervilleF-Regular]} + {\_def \_fontnamegen {[BaskervilleF-\_currV]:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Modifier:^^J \caps ...... caps & small caps^^J }} -\_protected\def \Baskerville {% - \_def \_currfamily {Baskerville}% - \_def \_fontnamegen {[BaskervilleF-\_currV]:\_capsV\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fsetV caps={} \_fvars Regular Bold Italic BoldItalic } \_moddef \caps {\_fsetV caps=+smcp;+onum; } diff --git a/Master/texmf-dist/tex/luatex/optex/f-bonum.opm b/Master/texmf-dist/tex/luatex/optex/f-bonum.opm index 6c163ce7cbe..900136e26fe 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-bonum.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-bonum.opm @@ -1,19 +1,15 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Bonum] \Bonum {TeX Gyre Bonum fonts based on Bookman} +\_famdecl [Bonum] \Bonum {TeX Gyre Bonum fonts based on Bookman} {\caps} {\rm \bf \it \bi} {Bonum} {[texgyrebonum-regular]} + {\_def\_fontnamegen {[texgyrebonum-\_currV]:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Modifier:^^J \caps ...... caps & small caps^^J }} -\_protected\def \Bonum {% - \_def \_currfamily {Bonum}% - \_def \_fontnamegen {[texgyrebonum-\_currV]:\_capsV\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fsetV caps={} \_fvars regular bold italic bolditalic } \_moddef \caps {\_fsetV caps=+smcp;+onum; } diff --git a/Master/texmf-dist/tex/luatex/optex/f-cursor.opm b/Master/texmf-dist/tex/luatex/optex/f-cursor.opm index 0774a6d0b9b..c7af7d6912e 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-cursor.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-cursor.opm @@ -1,19 +1,15 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Cursor] \Cursor {TeX Gyre Cursor fonts based on Courier} +\_famdecl [Cursor] \Cursor {TeX Gyre Cursor fonts based on Courier} {\caps} {\rm \bf \it \bi} {} {[texgyrecursor-regular]} + {\_def \_fontnamegen {[texgyrecursor-\_currV]:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Modifier:^^J \caps ...... caps & small caps^^J }} -\_protected\def \Cursor {% - \_def \_currfamily {Cursor}% - \_def \_fontnamegen {[texgyrecursor-\_currV]:\_capsV\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fsetV caps={} \_fvars regular bold italic bolditalic } \_moddef \caps {\_fsetV caps=+smcp;+onum; } diff --git a/Master/texmf-dist/tex/luatex/optex/f-gfsbodoni.opm b/Master/texmf-dist/tex/luatex/optex/f-gfsbodoni.opm index 4b743e07252..369f2474b2b 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-gfsbodoni.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-gfsbodoni.opm @@ -1,19 +1,15 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [GFS Bodoni] \GFSBodoni {Based on Bodoni with greek letters} +\_famdecl [GFS Bodoni] \GFSBodoni {Based on Bodoni with greek letters} {} {\rm \bf \it \bi} {} {[GFSBodoni]} + {\_def\_fontnamegen {[GFSBodoni\_currV]:\_fontfeatures}} \_wlog{\_detokenize{% Modifier:^^J \caps ...... doesn't work even though otfinfo -f lists smcp^^J }} -\_protected\def \GFSBodoni {% - \_def \_currfamily {GFSBodoni}% - \_def \_fontnamegen {[GFSBodoni\_currV]:\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fvars {} Bold It BoldIt } \_initfontfamily % new font family must be initialized diff --git a/Master/texmf-dist/tex/luatex/optex/f-heros.opm b/Master/texmf-dist/tex/luatex/optex/f-heros.opm index 5a03746cae2..d369ec89369 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-heros.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-heros.opm @@ -1,8 +1,9 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Heros] \Heros {TeX Gyre Heros fonts based on Helvetica} - {\caps \cond} {\rm \bf \it \bi} {FiraMath} - {[texgyreheros-regular]} +\_famdecl [Heros] \Heros {TeX Gyre Heros fonts based on Helvetica} + {\caps \cond} {\rm \bf \it \bi} {FiraMath} + {[texgyreheros-regular]} + {\_def\_fontnamegen{[texgyreheros\_condV-\_currV]:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Modifiers:^^J @@ -10,11 +11,6 @@ Modifiers:^^J \cond ...... condensed variants^^J }} -\_protected\_def \Heros {% - \_def \_currfamily {Heros}% - \_def \_fontnamegen {[texgyreheros\_condV-\_currV]:\_capsV\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fsetV caps={},cond={} \_fvars regular bold italic bolditalic } \_moddef \caps {\_fsetV caps=+smcp;+onum; } \_moddef \nocaps {\_fsetV caps={} } @@ -27,171 +23,181 @@ Modifiers:^^J \_endcode +The font family file declares the font family for selecting fonts from such +family at arbitrary size and with various shapes. Unicode fonts (OTF) +are preferred. The following example declares the Heros family: -The usage of font \OpTeX/ selection system is described in the -fonts-select.opm file. - - -\sec How to write font-macro-file for \OpTeX/ like this file -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\printdoc f-heros.opm -The font-macro-file declares a font family for selecting a font from such -family at arbitrary size and with various shapes. Unicode fonts (OTF) -are preferred. If we want to write such font file, we need to keep following -rules. +If you want to write such font file, you need to keep following rules. \begitems -* Use -\begtt -\_fontdecl [<Name of family>] \<Main-command> {<comments>} +* Use the \^`\_famdecl` command first. It has the following syntax: +\begtt \catcode`\<=13 +\_famdecl [<Name of family>] \<Familyselector> {<comments>} {<modifiers>} {<variant selectors>} {<comments about math fonts>} {<font-for-testing>} + {\_def\_fontnamegen{<font name or font file name generated>}} \endtt - as first command in this file. This writes information about font family at + This writes information about font family at the terminal and prevents loading such file twice. Moreover, it probes - existence of `<font-for-testing>` in your system. If it isn't exist, the + existence of `<font-for-testing>` in your system. If it doesn't exist, the file loading is skipped with a warning on the terminal. - The \_ifexistfam macro returns false in such case. + The \^`\_ifexistfam` macro returns false in such case. + The `\_fontnamegen` macro must be defined in the last parameter of the + `\_famdecl`. More about it is documented below. * You can use `\_wlog{\_detokenize{...` to write aditional information into log file. -* Define `\<Main-command>` (the commend `\Heros` here) as a `\_protected` - macro. This macro initializes the family and it must do: - \begitems - * Define `\_currfamily` as a short name of the font family. It must be - exactly the same as `<Main-command>` name but without backslash - (it is case sensitive). - * Define `\_fontfeatures` if they are something special. - * Define `\_fontnamegen` as a template of generic font name used as file - names (or font names) of OTF fonts. The rules about `\_fontnamegen` macro - are documented below. - * Use \_resetmod modifier to initialize values. - \enditems * You can declare optical sizes using `\_regoptsizes` if there are more font files with different optical sizes (like in Latin Modern). See `f-lmfonts.ofm` file for more information about this special feature. -* Declare font modifiers using `\_moddef` if they are present. The - \_resetmod must be declared in each font family. +* Declare font modifiers using `\_moddef` if they are present. The \`\resetmod` + must be declared in each font family. * Check if all your declared modifiers does not produce any space in - horizontal mode. For example check: X\caps Y, the letters XY must - be printed without any space. Do the same test with \<Main-command> - before releasing your font file, for example X\Heros Y. + horizontal mode. For example check: `X\caps Y`, the letters `XY` must + be printed without any space. +* Optionally, declare new variants by the \^`\famvardef` macro. * Run `\_initfontfamily` in order to start the family. +* If math font should be loaded, use `\_loadmath{<math font>}`. \enditems -The font file must declare `\_fontnamegen` macro which must expand (at -expand processor level only) to a file name of loaded font (or to its font -name) and to optional fontfeatures appended. The font selection -system uses this macro at primitive level in the following sense: +{\noindent \bf The \`\_fontnamegen` macro} +(declared in the last parameter of the `\_famdecl`) +must expand (at expand processor level only) to a file name of loaded font (or to its font +name) and to optional font features appended. The Font Selection +System uses this macro at primitive level in the following sense: \begtt - \font {\_fontnamegen} \_sizespec +\font \<selector> {\_fontnamegen} \_sizespec \endtt +% +Note that the extended `\font` syntax +`\font\<selector> {<font name>:<font features>} <size spec.>` or +`\font\<selector> {[<font file name>]:<font features>} <size spec.>` +is expected here. + +\bigskip +{\noindent\bf Example.} +Assume an abstract font family with fonts `xx-Regular.otf`, +`xx-Bold.otf`, `xx-Italic.otf` and `xx-BoldItalic.otf`. Then you can declare +the `\resetmod` (for initializing the family) by: +\begtt +\_moddef\resetmod{\_fvars Regular Bold Italic BoldItalic } +\endtt +and define the `\_fontnamegen` in the last parameter of the `\_famdecl` by: +\begtt +\_famdecl ... + {\def\_fontnamegen{[xx-\_currV]}} +\endtt +The following auxiliary macros are used here: +\begitems +* \^`\moddef` declares the family dependent modifier. The `\resetmod` saves + initial values for the family. +* \^`\_fvars` saves four names to the memory, they are used by the \^`\_currV` macro. +* \^`\_currV` expands to one of the four names dependent on `\rm` or `\bf` or + `\it` or `\bi` variant is required. +\enditems +Assume that the user needs `\it` variant in this family. Then the +`\_fontnamegen` macro expands to `[xx-\_currV]` and it expands to +`[xx-Italic]`. The Font Selection System uses `\font {[xx-Italic]}`. +This command loads the `xx-Italic.otf` font file. -For example, using macros from `f-heros.opm` the `\font` command expands its -parameters to: - +See more advanced examples in `f-<family>.opm` files. The `f-heros.opm` is listed +here. When Heros family is selected and `\bf` is asked then \begtt - \font {[texgyreheros-regular]:+tlig;} at10pt +\font {[texgyreheros-bold]:+tlig;} at10pt \endtt +% +is processed. -if the `\rm` variant is processed and if no additional font modifiers are -activated. Of course, you need to know something about fontname syntax for -extended `\font` primitive used with OTF fonts. The `[` `]` brackets tell us -that the file name (no font name) is specified inside such brackets. This -file (with additional `.otf` or `.ttf` extension) must be accessible by -Lua\TeX/ in your filesystem. Without spaces, there are font features -appended to file name (or font name) divided by semicolon. The `+tlig` font -feature means that TeX like ligatures (minus minus = endash, for example) -are active. Normal ligatures are active by default. You can list font -features of given font by `otfinfo -f fontfile.otf`. - -The `\_fontnamegen` macro must include colon followed by family dependent -font features (optional) and followed by `\_fontfeatures` (required). -If this is not true then font modifiers `\setff`, `\setfontcolor`, -`\setletterspace` and `\setwordspace` don't work. - -You can use any expandable macros or expandable primitives in `\fontnamegen` -macro. The simple macros in it with names `\_<word>V` are preferred. They +You can use any expandable macros or expandable primitives in the `\_fontnamegen` +macro. The simple macros in our example with names `\_<word>V` are preferred. They expand typically to their content. The macro `\_fsetV <word>=<content>` (terminated by a space) is equivalent to `\def\_<word>V{<content>}` and you can use it in font modifiers. You can use the `\_fsetV` macro in more general form: -\begtt - \_fsetV <wordA>=<valueA>,<wordB>=<valueB> ...etc. terminated by a space -\endtt - -with obvious result `\def\_<wordA>V{<valueA>}\def\_<wordB>V{<valueB>} etc. - -There is one special macro `\_currV` which expands to one of four variants -depending on which variant selector is in process. Four strings can be -saved by `\_fvars rm-variant bf-variant it-variant bi-varaiant` (all four strings -must be terminated by a space). One of these -string is used as expansion output of `\_currV` macro. Because we store - -\begtt - \_fvars regular bold italic bolditalic +\begtt \catcode`\<=13 + \_fsetV <word-a>=<value-a>,<word-b>=<value-b> ...etc. terminated by a space \endtt +% +with obvious result `\def \_<word-a>V {<value-a>}\def \_<word-b>V {<value-b>}` etc. -in `\resetmod` modifier then the `\_currV` expands (for example) -to `italic` if the `\it` variant selector is in process. - -Example: if both modifiers `\caps` and `\cond` were applied from this family -Heros and `\bf` variant is needed at 11pt then +Example: if both font modifiers `\caps` and `\cond` were applied from the Heros +family, then `\def\_capsV{+smcp;+onum}` and `\def\_condV{cn}` were processed +by these font modifiers. If user needs the `\bf` variant at 11\,pt now then +the \begtt - \font {[texgyreheroscn-bold]:+smcp;+tlig;} at11pt + \font {[texgyreheroscn-bold]:+smcp;+onum;+tlig;} at11pt \endtt - -is processed. We assume that a font file texgyreheroscn-bold.otf is present +% +is processed. We assume that a font file `texgyreheroscn-bold.otf` is present in your TeX system. -Define all modifiers using `\_moddef` macro. -The `\_moddef` macro does more things than simple `\_def`: +Recommendation: the \^`\_fontfeatures` macro at the end of the `\_fontnamegen` +macro in order to the \^`\setff`, \^`\setfontcolor`, \^`\setletterspace` +macros can work. + +\bigskip +{\noindent\bf The \^`\moddef` macro} +does more things than simple `\_def`: \begitems * The modifier macros are defined as `\_protected`. -* The modifier macros are defined as family-dependent. If user loads more - families then `\LMfonts \caps` does somewhat different job than - `\Heros \caps`, for example. +* The modifier macros are defined as family-dependent. \enditems +\noindent +The \^`\famvardef` macro has the same features. + +\bigskip +{\noindent\bf The `\<Familyselector>`} +is defined by the \^`\_famdecl` macro as: +\begtt \catcode`<=13 +\protected\def\<Familyselector> {% + \_def\_currfamily {<Familyselector>}% + \_def\_fontnamegen {<font name or font file name generated>}% + \resetmod +\endtt -Finally the `\_initfontfamily` must be run. It runs \<Main-command>. -So, the `\_resetmod` macro (declared as `\resetmod`) is processed. Finally it -runs `\_rm`, so first font from new family is loaded and is ready to use it. - -\secc Name conventions -%--------------------- - -Create modificators, new variants and `\<Main-command>` only as public, i.e. -without `_` prefix. We assume that if user re-defines them then he/she need +{\noindent\bf The font context} consists from + \begitems + * Family context, i.\,e.\ \^`\_currfamily` and \^`\_fontnamegen` values + saved by the `\<Familyselector>`, + * \^`\_sizespec` value saved by the \^`\setfontsize` macro, + * whatever what influences the expansion of the `\_fontnamegen` macro, + they are typically macros `\_<key>V` saved by the font modifiers. + \enditems + +{\noindent\bf The \^`\_initfontfamily` must be run} after modifers decaration. +It sets `\_let\_resetmod=\resetmod` and runs the `\<Familyselector>`. +Finally, it runs `\_rm`, so first font from new family is loaded and it +is ready to use it. + +\bigskip +{\noindent\bf Name conventions.} +Create font modifiers, new variants and the `\<Familyselector>` only as public, i.e. +without `_` prefix. We assume that if user re-defines them then he/she needs not them, so we have no problems. +The name of `\<Familyselector>` should begin with uppercase letter. + If you need to declare your private modifier (because it is used in another modifiers or macros, for example), use the name `\_wordM`. You can be sure that such name does not influence the private name space used by \OpTeX/. -The private variant `\_resetmod` must be used in your -`\<Main-command>` but you need not to declare it as private, -it is done automatically. Declare only `\restmod` by `\_moddef` macro. - -The name of `\<Main-command>` should begin with uppercase letter. - -See font-macro-file `f_libertine-s.opm` which is another example where no +\bigskip +{\noindent\bf Additional notes.} +See the font family file `f-libertine-s.opm` which is another example where no font files but font names are used. -\secc Additional notes -%--------------------- - -In very rare situations we have more files with almost the same font but -designed for different optimal sizes (so called "optical sizes"). See a -collection of lmroman*.otf files, for example. You can declare such font -files for various optical sizes using `\_optname` macro in the -`\_fontnamegen` macro. See the file `f-lmfonts.opm` for more details. +See the font family file `f-lmfonts.opm` where you can find the +the example of the optical sizes declaration including a documentation about +it. -If you need to create font-macro-file with non unicode font, you can do it. +If you need to create font family file with non-Unicode font, you can do it. The `\_fontnamegen` must expand to the name of TFM file in such case. But we -don't prefer such font-macro-files, because they are usable only with -laguages with alphabet subset to ISO-8859-1 (unicodes are equal to letter +don't prefer such font family files, because they are usable only with +languages with alphabet subset to ISO-8859-1 (Unicodes are equal to letter codes of such alphabets), but middle or east Europe use languages where such condition is not true. diff --git a/Master/texmf-dist/tex/luatex/optex/f-libertine-s.opm b/Master/texmf-dist/tex/luatex/optex/f-libertine-s.opm index 123585dac71..f08126984e5 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-libertine-s.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-libertine-s.opm @@ -1,8 +1,9 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Linux Libertine] \Libertine {Free Linux Libertine fonts} +\_famdecl [Linux Libertine] \Libertine {Free Linux Libertine fonts} {\sans \mono \caps} {\rm \bf \it \bi \initials \displ \keybr} {} {Linux Libertine O} + {\_def\_fontnamegen {Linux \_mainfamV\_V\_subfamV O/\_currV:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Modifiers^^J @@ -15,12 +16,6 @@ Special variants:^^J \keybr ..... keyboard, emulates keyboard buttons^^J }} -\_protected\_def \Libertine {% - \_def \_currfamily {Libertine}% - \_def\_fontnamegen {Linux \_mainfamV\_V\_subfamV O/\_currV:\_capsV\_fontfeatures}% - \_resetmod -} - \_moddef \resetmod {\_fsetV mainfam=Libertine,subfam={},caps={} \_fvars {} B I BI } \_moddef \sans {\_fsetV mainfam=Biolinum,subfam={} } \_moddef \mono {\_fsetV mainfam=Libertine,subfam={Mono } \_fvars {} . . . } diff --git a/Master/texmf-dist/tex/luatex/optex/f-libertine.opm b/Master/texmf-dist/tex/luatex/optex/f-libertine.opm index 041e3742f08..2aa52dad329 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-libertine.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-libertine.opm @@ -1,8 +1,9 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Linux Libertine] \Libertine {Free Linux Libertine fonts} +\_famdecl [Linux Libertine] \Libertine {Free Linux Libertine fonts} {\sans \mono \caps \semi} {\rm \bf \it \bi \initials \displ \keybr} {Libertinus} {[LinLibertine_R]} + {\_def\_fontnamegen {[Lin\_subfamV _\_currV]:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Modifiers:^^J @@ -16,11 +17,6 @@ Special variants:^^J \keybr ..... keyboard, emulates keyboard buttons^^J }} -\_protected\_def \Libertine {% - \_def \_currfamily {Libertine}% - \_def\_fontnamegen {[Lin\_subfamV _\_currV]:\_capsV\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fsetV subfam=Libertine,caps={} \_fvars R RB RI RBI } \_moddef \sans {\_fsetV subfam=Biolinum \_fvars R RB RI RBO } \_moddef \mono {\_fsetV subfam=Libertine \_fvars M MB MO MBO } diff --git a/Master/texmf-dist/tex/luatex/optex/f-lido.opm b/Master/texmf-dist/tex/luatex/optex/f-lido.opm index e082663125d..b91bf1df4f2 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-lido.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-lido.opm @@ -1,8 +1,9 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Lido] \Lido {by StormType Foundry designed for "lidove noviny"} +\_famdecl [Lido] \Lido {by StormType Foundry designed for "lidove noviny"} {\caps \cond} {\rm \bf \mr \mi \it \bi} {Termes} {[LidoSTF]} + {\_def\_fontnamegen {[LidoSTF\_condV\_currV]:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Variants:^^J @@ -13,11 +14,6 @@ Modifiers:^^J \medium .... sets \mr \bf \mi \bi family }} -\_protected\def \Lido {% - \_def \_currfamily {Lido}% - \_def \_fontnamegen {[LidoSTF\_condV\_currV]:\_capsV\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fsetV caps={},cond={},ital=Italic \_fvars {} Bold {\_italV} {Bold\_italV} } \_moddef \medium {\_fvars Medium Bold {Medium\_italV} {Bold\_italV} } \_moddef \cond {\_fsetV cond=Condensed,ital={} } diff --git a/Master/texmf-dist/tex/luatex/optex/f-lmfonts.opm b/Master/texmf-dist/tex/luatex/optex/f-lmfonts.opm index 3daf7045ceb..9f9a650a839 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-lmfonts.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-lmfonts.opm @@ -1,9 +1,10 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Latin Modern] \LMfonts {TeX Gyre fonts based on Coputer Modern} +\_famdecl [Latin Modern] \LMfonts {TeX Gyre fonts based on Coputer Modern} {\roman \sans \quotset \ttset \ttprop \ttlight \ttcond \upital \dunhill submods:\caps \slant \nbold \bolder} {\rm \bf \it \bi \tt} {LM} {[lmroman10-regular]} + {\_def\_fontnamegen {[\_optname{lm\_subfamV.\_currV}]:\_fontfeatures}} \_wlog{\_detokenize{% Modifiers (selects subfamily):^^J @@ -16,19 +17,13 @@ Modifiers (selects subfamily):^^J \ttcond .... condensed typewriter subfamily^^J \upital .... upright italic (only \rm)^^J \dunhill ... dunhill roman subfamily (only \rm, \it)^^J% -Submodifiers (setlects special variants of given subfamily):^^J +Sub-modifiers (selects special variants of given subfamily):^^J \caps ...... caps & small caps (available only at limited shapes)^^J \slant ..... slanted (default in some subfamilies)^^J \nbold ..... normal bold (extended bold is default)^^J \bolder .... extended bold^^J }} -\_protected\_def \LMfonts {% - \_def \_currfamily {LMfonts}% - \_def \_fontnamegen {[\_optname{lm\_subfamV.\_currV}]:\_fontfeatures}% - \_resetmod -} - \_def\_LMregfont #1 #2 #3{% \_edef\_tmp {\_noexpand\_regoptsizes #1 #2 \_ea\_detokenize\_ea{#3}}% \_lowercase\_ea{\_tmp}% OTF file names are lowercase @@ -118,79 +113,69 @@ Submodifiers (setlects special variants of given subfamily):^^J \_endcode -\sec How to wite font-macro-file with optical sizes for \OpTeX/ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -First, look at more clear example in `f-hermes.opm`. The basic documentation -is there. +\secc How to write the font family file with optical sizes -You can use `\_optname` macro in upur `\_fontnamegen`. This macro is fully +You can use \^`\_optname` macro when `\_fontnamegen` in expanded. This macro is fully expandable and its input is `<internal-template>` and its output is a -part of your `\_fontnamegen`, i.e. it is a part of a real font file name with -`.otf` extension. Shortly speaking: +part of the font file name `<size-dependent-template>` with respect to given +optical size. -\begtt - \_optname{<internal-template>} -> <part-of-file-name> -\endtt +You can declare a collection of `<size-dependent-template>`s for one +given `<internal-template>` by the \^`\_regoptsizes` macro. +The syntax is shown for one real case: -You can declare a collection of file names for only one -<optical-name-template> by `\_regoptsizes`. The syntax is shown for one real -case: - -\begtt - \_regoptsizes lmr.r lmroman?-regular - 5 <5.5 6 <6.5 7 <7.5 8 <8.5 9 <9.5 10 <11.1 12 <15 17 <* +\begtt +\_regoptsizes lmr.r lmroman?-regular + 5 <5.5 6 <6.5 7 <7.5 8 <8.5 9 <9.5 10 <11.1 12 <15 17 <* \endtt In general: -\begtt - \_regoptsizes <internal-template> {<default-size>} <resizing-data> +\begtt \catcode`\<=13 +\_regoptsizes <internal-template> <general-ouput-template> <resizing-data> \endtt Suppose our example above. Then `\_optname{lmr.r}` expands to lmroman?-regular where the question mark is substituted by a number depending on current `\_optsize`. If the `\_optsize` lies between two boundary -values (they are prefixed by `<` character) then the number written between -them is used. For example if $11.1 \lt \_optsize \_le 15$ then 12 is +values (they are prefixed by \code{<} character) then the number written between +them is used. For example if $11.1 \lt `\_optsize` \le 15$ then 12 is substituted instead question mark. The <resizing-data> virtually begins -with zero `<0`, but it is not explicitly written. The right part of -<resizing-data> must be terminated by `<*` which means "less than infinity". +with zero \code{<0}, but it is not explicitly written. The right part of +<resizing-data> must be terminated by \code{<*} which means "less than infinity". If `\_optname` gets an argument which is not registered <internal-template> then it expands to `\_failedoptname` which typically ends to error message about missing font. You can redefine `\_failedoptname` macro to some -existing font if you fint it useful. +existing font if you find it useful. -We are using a special macro \_LMregfont which sets the file names to +We are using a special macro `\_LMregfont` in `f-lmfonts.opm`. +It sets the file names to lowercase and enables to use a shortcasts isntead real <resizing-data>. -There are shortcats `\_regoptFS`, `\_regoptT`, etc. here. THe collection of -<internal-templates> are declared, each of them covers a collection of real +There are shortcats `\_regoptFS`, `\_regoptT`, etc. here. The collection of +`<internal-templates>` are declared, each of them covers a collection of real file names. -The modifiers redefines \_subfamV and \_currV ouput in this file -`f-lmfonts.opm`. These outputs are used in the paramater of `\_optname`, so -they decalre parts of <internal-template>, no parts of real file name. - -The `\optfontalias {<new-template>} {<declared-template>} decales -<new-template> wit the same meaning as previously <declared-template>. +The \^`\_optfontalias` `{<new-template>} {<internal-template>}` declares +`<new-template>` with the same meaning as previously declared +`<internal-template>`. The `\_optname` macro can be used even if no otical sizes are provided by a font family. Suppose that font file names are much more chaotic (because artists are very creative people), so you need to declare more systematic -<internal-templates> and do an alias from each <internal-template> to -<real-font-name>. For example, you can do it as folows: +`<internal-templates>` and do an alias from each `<internal-template>` to +`<real-font-name>`. For example, you can do it as follows: \begtt - \def\fontalias #1 #2 {\_regoptsizes #1 ?#2 {} <*} -% alias name real font name - \fontalias crea-a-regular {Creative Font} - \fontalias crea-a-bold {Creative FontBold} - \fontalias crea-a-italic {Creative olique} - \fontalias crea-a-bolditalic {Creative Bold plus italic} - \fontalias crea-b-regular {Creative Regular subfam} - \fontalias crea-b-bold {Creative subfam bold} - \fontalias crea-b-italic {Creative-subfam Oblique} - \fontalias crea-b-bolditalic {Creative Bold subfam Oblique} +\def\fontalias #1 #2 {\_regoptsizes #1 ?#2 {} <*} +% alias name real font name +\fontalias crea-a-regular {Creative Font} +\fontalias crea-a-bold {Creative FontBold} +\fontalias crea-a-italic {Creative olique} +\fontalias crea-a-bolditalic {Creative Bold plus italic} +\fontalias crea-b-regular {Creative Regular subfam} +\fontalias crea-b-bold {Creative subfam bold} +\fontalias crea-b-italic {Creative-subfam Oblique} +\fontalias crea-b-bolditalic {Creative Bold subfam Oblique} \endtt diff --git a/Master/texmf-dist/tex/luatex/optex/f-pagella.opm b/Master/texmf-dist/tex/luatex/optex/f-pagella.opm index 27127b7a6f1..f40b102b1cc 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-pagella.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-pagella.opm @@ -1,19 +1,15 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Pagella] \Pagella {TeX Gyre Pagella fonts based on Palatino} +\_famdecl [Pagella] \Pagella {TeX Gyre Pagella fonts based on Palatino} {\caps} {\rm \bf \it \bi} {Pagella} {[texgyrepagella-regular]} + {\_def\_fontnamegen {[texgyrepagella-\_currV]:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Modifier:^^J \caps ...... caps & small caps^^J }} -\_protected\def \Pagella {% - \_def \_currfamily {Pagella}% - \_def\_fontnamegen {[texgyrepagella-\_currV]:\_capsV\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fsetV caps={} \_fvars regular bold italic bolditalic } \_moddef \caps {\_fsetV caps=+smcp;+onum; } diff --git a/Master/texmf-dist/tex/luatex/optex/f-schola.opm b/Master/texmf-dist/tex/luatex/optex/f-schola.opm index d876582683a..c891317265b 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-schola.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-schola.opm @@ -1,19 +1,15 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Schola] \Schola {TeX Gyre Schola fonts based on New Century} +\_famdecl [Schola] \Schola {TeX Gyre Schola fonts based on New Century} {\caps} {\rm \bf \it \bi} {Schola} {[texgyreschola-regular]} + {\_def\_fontnamegen {[texgyreschola-\_currV]:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Modifier:^^J \caps ...... caps & small caps^^J }} -\_protected\def \Schola {% - \_def \_currfamily {Schola}% - \_def\_fontnamegen {[texgyreschola-\_currV]:\_capsV\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fsetV caps={} \_fvars regular bold italic bolditalic } \_moddef \caps {\_fsetV caps=+smcp;+onum; } diff --git a/Master/texmf-dist/tex/luatex/optex/f-technika.opm b/Master/texmf-dist/tex/luatex/optex/f-technika.opm index 1e572345a46..0d1af54100c 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-technika.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-technika.opm @@ -1,8 +1,9 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Technika] \Technika {Fonts from visual style of CTU in Prague} +\_famdecl [Technika] \Technika {Fonts from visual style of CTU in Prague} {\caps \light} {\rm \bf \it \bi \stencil} {} {[Technika-Regular]} + {\_def\_fontnamegen {[Technika\_stencilV-\_currV]:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Modifiers:^^J @@ -13,11 +14,6 @@ Special variant:^^J \stencil ... dashed leters (only uppercase)^^J }} -\_protected\def \Technika {% - \_def \_currfamily {Technika}% - \_def \_fontnamegen {[Technika\_stencilV-\_currV]:\_capsV\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fsetV stencil={},caps={} \_fvars Regular Bold Italic BoldItalic } \_moddef \light {\_fsetV stencil={} \_fvars Light Regular LightItalic Italic } \_moddef \book {\_fsetV stencil={} \_fvars Book Bold BookItalic BoldItalic } diff --git a/Master/texmf-dist/tex/luatex/optex/f-termes.opm b/Master/texmf-dist/tex/luatex/optex/f-termes.opm index e0ed0c63c45..b7652456404 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-termes.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-termes.opm @@ -1,19 +1,15 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [Termes] \Termes {TeX Gyre Termes fonts based on Times} +\_famdecl [Termes] \Termes {TeX Gyre Termes fonts based on Times} {\caps} {\rm \bf \it \bi} {Termes} {[texgyretermes-regular]} + {\_def\_fontnamegen {[texgyretermes-\_currV]:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Modifier:^^J \caps ...... caps & small caps^^J }} -\_protected\def \Termes {% - \_def \_currfamily {Termes}% - \_def \_fontnamegen {[texgyretermes-\_currV]:\_capsV\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fsetV caps={} \_fvars regular bold italic bolditalic } \_moddef \caps {\_fsetV caps=+smcp;+onum; } diff --git a/Master/texmf-dist/tex/luatex/optex/f-xcharter.opm b/Master/texmf-dist/tex/luatex/optex/f-xcharter.opm index d889c8ba2b1..7f6ff7a3561 100644 --- a/Master/texmf-dist/tex/luatex/optex/f-xcharter.opm +++ b/Master/texmf-dist/tex/luatex/optex/f-xcharter.opm @@ -1,8 +1,9 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_fontdecl [XCharter] \XCharter {An extension of Bitstream Charter} +\_famdecl [XCharter] \XCharter {An extension of Bitstream Charter} {\caps \slant} {\rm \bf \it \bi} {} {[XCharter-Roman]} + {\_def\_fontnamegen {[XCharter-\_currV]:\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Modifiers:^^J @@ -10,11 +11,6 @@ Modifiers:^^J \slant ..... slanted variants used in \it, \bi^^J }} -\_protected\def \XCharter {% - \_def \_currfamily {XCharter}% - \_def \_fontnamegen {[XCharter-\_currV]:\_capsV\_fontfeatures}% - \_resetmod -} \_moddef \resetmod {\_fsetV caps={} \_fvars Roman Bold Italic BoldItalic } \_moddef \slant {\_fvars Roman Bold Slanted BoldSlanted } \_moddef \caps {\_fsetV caps=+smcp;+onum; } diff --git a/Master/texmf-dist/tex/luatex/optex/fams-ini.opm b/Master/texmf-dist/tex/luatex/optex/fams-ini.opm index 265150b1181..5ecbfc361f1 100644 --- a/Master/texmf-dist/tex/luatex/optex/fams-ini.opm +++ b/Master/texmf-dist/tex/luatex/optex/fams-ini.opm @@ -20,24 +20,31 @@ \_faminfo [Termes] {TeX Gyre Termes fonts based on Times} {f-termes} { -,\caps: {\rm\bf\it\bi} } +\_famalias [Times] \_faminfo [Heros] {TeX Gyre Heros fonts based on Helvetica} {f-heros} { -,\caps,\cond,\caps\cond: {\rm\bf\it\bi} } +\_famalias [Helvetica] \_faminfo [Adventor] {TeX Gyre Adventor based on Avantgarde Book} {f-adventor} { -,\caps: {\rm\bf\it\bi} } +\_famalias [Avantgarde Book] \_faminfo [Bonum] {TeX Gyre Bonum fonts based on Bookman} {f-bonum} { -,\caps: {\rm\bf\it\bi} } +\_famalias [Bookman] \_faminfo [Pagella] {TeX Gyre Pagella fonts based on Palatino} {f-pagella} { -,\caps: {\rm\bf\it\bi} } +\_famalias [Palation] \_faminfo [Schola] {TeX Gyre Schola fonts based on New Century} {f-schola} { -,\caps: {\rm\bf\it\bi} } +\_famalias [New Century] \_faminfo [Cursor] {TeX Gyre Cursor fonts based on Courier} {f-cursor} { -,\caps: {\rm\bf\it\bi} } +\_famalias [Courier] \_famtext {Other fonts:} @@ -67,49 +74,57 @@ \_endcode -\sec How to register your own family -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -Read comments in `f-heros.opm` file if you want to prepare a font-macro-file for -your font family. - -Once you have prepared such file with the name f-famname.opm and \TeX/ is -able to see it in your filesystem then you can type \fontfam[famname] and +Once you have prepared a font family file with the name `f-<famname>.opm` and \TeX/ is +able to see it in your filesystem then you can type \^`\fontfam``[<famname>]` and the file is read, so the information about font family is loaded. The name -"famname" must be lowercase and without spaces. On the other hand the -`\fontfam` command gives more tolerance: you can write uppercase letters and -spaces here. The spaces are ignored and letters are converted to lowercase. -For example \fontfam [LM Fonts] is equivalent to \fontfam [LMfonts] and both +`<famname>` must be lowercase and without spaces in the file name +`f-<famname>.opm`. On the other hand the `\fontfam` command gives more tolerance: +you can write uppercase letters and spaces here. The spaces are ignored and +letters are converted to lowercase. +For example `\fontfam [LM Fonts]` is equivalent to \fontfam [LMfonts] and both commands load the file `f-lmfonts.opm`. -You can use your font-macro-file in sense of previous paragraph without +You can use your font file in sense of previous paragraph without registering it. But problem is that such families are not listed when `\fontfam[?]` is used and it is not included in font catalogue when `\fontfam[catalog]` is printed. The list of families taken in the catalogue and listed on the terminal is declared in two files: `fams-ini.opm` and `fams-local.opm`. The second file is optional. User can create it and write to it the information about user-defined families using the same syntax as in -existed file `fams-ini.opm`. - -The `\_faminfo` has the following syntax: - -\begtt - \_faminfo [Name Of Family] {Comments} {file-name} +existed file `fams-ini.opm`. + +The information from the user's `fams-local.opm` file has precedence. +For example `fams-ini.opm` declares aliases Times$\to$Termes etc. If you +have original Times purchased from Adobe then you can register your +declaration about Times family in `fams-local.opm`. When an user write +`\fontfam[Times]` then orginal Times (no Termes) is used in such case. + +The `fams-ini.opm` and `fams-local.opm` files use the macros +`\_famifo`, `\_famalias` and `\_famtext`. See the example from +`fams-ini.tex`: + +{\everytt={\typosize[8/10]\_let\_printverbline=\_printcodeline \medskip} + \def\docfile{fams-ini.opm} +\verbinput (3-27) fams-ini.opm +... etc. +} +\medskip + +The \^`\_faminfo` commad has the syntax: +\begtt \catcode`\<=13 +\_faminfo [<Family Name>] {<comments>} {<file-name>} { <mod-plus-vars> } \endtt - -The <mod-plus-vars> data is used when printing catalogue. It consists with +% +The `<mod-plus-vars>` data is used only when printing catalogue. It consists with one or more pairs `<mods>: {<vars>} <mods>: {<vars>}` etc. For each pair: each modifiers (separated by comma) are applied to each <vars> and prepared sample is printed. The `-` character means no modifiers should be applied. -The `\_famalias` declares an alias to the last +The \^`\_famalias` declares an alias to the last declared family. -The `\_famtext` writes a line to the terminal and to the log file when all +The \^`\_famtext` writes a line to the terminal and to the log file when all families are listed. -For modifiers and variants declared by `\_faminfo` the sample of letters -and other characters is printed. from `\catalogsample` register. - diff --git a/Master/texmf-dist/tex/luatex/optex/fnotes.opm b/Master/texmf-dist/tex/luatex/optex/fnotes.opm index 91365879a99..042a1e1b8a8 100644 --- a/Master/texmf-dist/tex/luatex/optex/fnotes.opm +++ b/Master/texmf-dist/tex/luatex/optex/fnotes.opm @@ -3,15 +3,17 @@ \_codedecl \fnote {Footnotes, marginal notes OpTeX <2020-03-20>} % loaded in format \_doc ----------------------------- - \begitems - * `\_gfnotenum` is conter which counts footnotes globaly in the document. - whole document, chapters, pages. - * `\_lfnotenum` is counter which counts footnotes at each chapter from one. - It is used for local page footnote counters too. - * `\_ifpgfnote` says that footnote numbers are counted on each page from - one. We need to run `\openref` in such case. - * `\fnotenum` is a macro which expands to footnote number counted in declared part. - \enditems + \`\_gfnotenum` is conter which counts footnotes globally in the document. + whole document, chapters, pages.\nl + \`\_lfnotenum` is counter which counts footnotes at each chapter from one. + It is used for local page footnote counters too.\nl + \`\_ifpgfnote` says that footnote numbers are counted on each page from + one. We need to run `\openref` in such case.\nl + \`\fnotenum` is a macro which expands to footnote number counted in declared part.\nl + \`\fnotenumchapters` declares footnotes numbered in each chapter from one + (default), \`\fnotenumglobal` declares footnotes numbered in whole + document from one and \`\fnotenumpages` declares footnotes numbered + at each page from one. \_cod ----------------------------- \_newcount\_gfnotenum \_gfnotenum=0 @@ -27,20 +29,21 @@ \_let \runningfnotes = \fnotenumglobal % for backward compatibility \_doc ----------------------------- - The `\_printfnotemark` prints the footnote mark. You can re-define this + The \`\_printfnotemark` prints the footnote mark. You can re-define this macro if you want another design of footnotes. For example \begtt \fnotenumpages \def \_printfnotemark {\ifcase 0\fnotenum\or *\or**\or***\or$^\mathbox{†}$\or$^\mathbox{‡}$\or$^\mathbox{††}$\fi} \endtt - This code gives footnotes* and ** and*** and† etc. + This code gives footnotes* and ** and*** and$^\mathbox{†}$ etc.\ and it supposes that there are no more than 6 footnotes at one page. If you want to distinguish between footnote marks in the text and in the front of footnote itself, then you can define `\_printfnotemarkA` and `\_printfnotemarkB`. - The following example shows an implementation of hyperlinked footnotes - (from text to footnote and bacward): + + The \`\fnotelinks``<colorA><colorB>` implements the hyperlinked footnotes + (from text to footnote and backward). \_cod ----------------------------- \_def \_printfnotemark {$^{\_fnotenum}$} % default footnote mark @@ -56,16 +59,17 @@ \public \fnotelinks ; \_doc ---------------------------- - Each footnote saves the `\_Xfnote` (without parameter) to the `.ref` - file (if `\openref`). We can create the mapping from <gfnotenum> to <pgfnotenum> - in the macro `\_fn:<fnotenum>`. Each `\_Xpage` macro sets the `\_pgfnote` to zero. + Each footnote saves the \`\_Xfnote` (without parameter) to the `.ref` + file (if `\openref`). We can create the mapping from `<gfnotenum>` to`<pgfnotenum>` + in the macro `\_fn:<fnotenum>`. Each \^`\_Xpage` macro sets the + `\_lfnotenum` to zero. \_cod ---------------------------- \_def \_Xfnote {\_incr\_lfnotenum \_incr\_gfnotenum \_sxdef{_fn:\_the\_gfnotenum}{\_the\_lfnotenum}} \_doc ---------------------------- - The `\fnote {<text>}` macro is simple, but `\fnotemark`, `\fnotetext` + The \`\fnote` `{<text>}` macro is simple, \`\fnotemark` and \^`\fnotetext` does the real work. \_cod ---------------------------- @@ -73,16 +77,15 @@ \_def\_fnotemark#1{{\_advance\_gfnotenum by#1\_advance\_lfnotenum by#1\relax \_printfnotemarkA}} \_doc ---------------------------- - The `\_fnotetext` calls `\_opfootnote` which is equivalent to plain \TeX/ - `\vfootnote`. It creates new data to Insert `\_footins`. The only - difference is that we are able to propagate a macro into Insert group + The \`\fnotetext` calls \^`\_opfootnote` which is equivalent to plain \TeX/ + \^`\vfootnote`. It creates new data to Insert \^`\footins`. The only + difference is that we are able to propagate a macro parameter into Insert group before the text is printed (see section \ref[output]). - This propageted macro is `\_fnset` which applies the `\everyfonte` and sets - smaller fonts. + This propagated macro is \`\_fnset` which sets smaller fonts. - Note that `\vfootnote` and `\_opfootnote` does't read the text as a + Note that \^`\vfootnote` and \^`\_opfootnote` does't read the text as a parameter but during normal horizontal mode. This is reason why catcode - changes (for example in-line verbaptim) can be used here. + changes (for example in-line verbatim) can be used here. \_cod ---------------------------- \_def\_fnotetext{\_incr\_gfnotenum \_incr\_lfnotenum % global increment @@ -93,18 +96,18 @@ \_fi\_fi \_opfootnote\_fnset\_printfnotemarkB } -\_def\_fnset{\_everypar={}\_the\_everyfnote \_scalemain \_typoscale[800/800]} +\_def\_fnset{\_everypar={}\_scalemain \_typoscale[800/800]} \_public \fnote \fnotemark \fnotetext ; \_doc ----------------------------- - By default `\mnote` are in right margin at odd pages and they are in left + By default \`\mnote``{<text>}` are in right margin at odd pages and they are in left margin at even pages. The `\mnote` macro saves its position to `.ref` - file as `\_Xmnote` without parameter. We define `\_mn:<mnotenum>` as + file as \`\_Xmnote` without parameter. We define `\_mn:<mnotenum>` as `\right` or `\left` when the `.ref` file is read. - The `\ifnum 0`$\le$`0#2` trick teturs true if <pageno> has numeric type and false - if it is non-numeric type (romannnumeral, for example). We prefer to use - <pageno>, but only if it has numeric type. We use <gpageno> in other cases. + The `\ifnum 0`$\le$`0#2` trick returns true if `<pageno>` has numeric type and false + if it is non-numeric type (Roman numeral, for example). We prefer to use + `<pageno>`, but only if it has numeric type. We use `<gpageno>` in other cases. \_cod ----------------------------- \_newcount\_mnotenum \_mnotenum=0 % global counter of mnotes @@ -114,8 +117,8 @@ \_def \_numtype #1#2{\_ifnum 0<0#1 #1\_else #2\_fi} \_doc ----------------------------- - User can declare `\fixmnotes\left` or `\fixmnotes\right`. It defines - `\_mnotesfixed` as `\_left` or `\_right` which declares the placement + User can declare \`\fixmnotes``\left` or \^`\fixmnotes``\right`. It defines + \`\_mnotesfixed` as `\_left` or `\_right` which declares the placement of all marginal notes and such declaration has a precedence. \_cod ----------------------------- @@ -135,8 +138,8 @@ \_public \mnote ; \_doc ----------------------------- - The `\_mnoteA` macro does the real work. The `\_lrmnote{<left>}{<right>}` - uses only first or only second parameter dependng on the left or right + 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. \_cod ----------------------------- diff --git a/Master/texmf-dist/tex/luatex/optex/fonts-opmac.opm b/Master/texmf-dist/tex/luatex/optex/fonts-opmac.opm index 7827d76c65a..19fa9bf29b8 100644 --- a/Master/texmf-dist/tex/luatex/optex/fonts-opmac.opm +++ b/Master/texmf-dist/tex/luatex/optex/fonts-opmac.opm @@ -1,6 +1,16 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \typosize {Font managing macros from OPmac <2020-03-27>} % loaded in format +\_codedecl \typosize {Font managing macros from OPmac <2020-04-14>} % loaded in format + + \_doc ----------------------------- + \`\typosize` `[<font-size>/<baselineskip>]` sets given parameters. + It sets text font size by the \^`\setfontsize` macro and math font sizes + by setting internal macros \^`\_sizemtext`, \^`\_sizemscript` and + \^`\_sizemsscript`. It uses common concept font thes sizes: 100\,\%, + 70\,\% and 50\,\%. + The \^`\_setmainvalues` sets the parameters as main values when + the `\_typosize` is called first. + \_cod ----------------------------- \_protected\_def \_typosize [#1/#2]{% \_textfontsize{#1}\_mathfontsize{#1}\_setbaselineskip{#2}% @@ -17,6 +27,14 @@ \_edef\_sizemsscript{\_ea\_ignorept \_the\_tmpdim \_ptmunit}% \_fi } +\_public \typosize ; + + \_doc ----------------------------- + \`\typoscale` `[<font-factor>/<baseline-factor>]` scales + font size and baselineskip by given factors in respect to current values. + It calculates the \^`\typosize` parameters and runs the \^`\typosize`. + \_cod ----------------------------- + \_protected\_def \_typoscale [#1/#2]{% \_ifx$#1$\_def\_tmp{[/}\_else \_settmpdim{#1}\_optsize @@ -30,6 +48,14 @@ \_tmpdim=#1pt \_divide\_tmpdim by1000 \_tmpdim=\_ea\_ignorept \_the#2\_tmpdim } +\_public \typoscale ; + + \_doc ----------------------------- + \`\_setbaselineskip` `{<baselineskip>}` sets new `\baselineskip` and + more values of registers which are dependent on the `<baselineskip>` + including the \^`\strutbox`. + \_cod ----------------------------- + \_def \_setbaselineskip #1{\_if$#1$\_else \_tmpdim=#1\_ptunit \_baselineskip=\_tmpdim \_relax @@ -42,14 +68,29 @@ \_setbox\_strutbox=\_hbox{\_vrule height.709\_tmpdim depth.291\_tmpdim width0pt}% \_fi } + + \_doc ----------------------------- + \`\_setmainvalues` sets the current font size and `\baselineskip` + values to the \`\mainfosize` and \hbox{\`\mainbaselineskip`} registers. + It redefines itself in order to set the main values only first. + \nl + \`\scalemain` returns to these values if they were set. Else they are set + to 10/12\,pt. + \_cod ----------------------------- + +\_newskip \_mainbaselineskip \_mainbaselineskip=0pt \_relax +\_newdimen \_mainfosize \_mainfosize=0pt + \_def\_setmainvalues {% \_mainbaselineskip=\_baselineskip \_mainfosize=\_optsize - \_topskip=\_mainfosize \_splittopskip=\_topskip % added 2020-03-27 - \_bf \_it \_bi \_rm \_normalmath % load fonts if \typosize is running firstly + \_topskip=\_mainfosize \_splittopskip=\_topskip + \_ifmmode \_else \_bf \_it \_bi \_rm \_fi % load all basic variants of the family + \_normalmath % load fonts if \typosize is running first \_let \_setmainvalues =\_setmainvaluesL } -\_def\_setmainvaluesL {\_rm \_everymath={\_normalmath}\_everydisplay={\_normalmath}} +\_def\_setmainvaluesL {\_ifmmode \_normalmath \_else + \_rm \_everymath={\_normalmath}\_everydisplay={\_normalmath}\_fi} \_def\_scalemain {% \_ifdim \_mainfosize=0pt \_mainfosize=10pt \_mainbaselineskip=12pt @@ -57,9 +98,13 @@ \fi \_optsize=\_mainfosize \_baselineskip=\_mainbaselineskip } +\_public \scalemain \mainfosize \mainbaselineskip ; -\_newskip \_mainbaselineskip \_mainbaselineskip=0pt \_relax -\_newdimen \_mainfosize \_mainfosize=0pt + \_doc ----------------------------- + \`\thefontsize` `[<size>]` and \`\thefontscale` `[<factor>]` + do modification of the size of the current font. They are implemented by the + \^`\newcurrfontsize` macro. + \_cod ----------------------------- \_protected\_def\_thefontsize[#1]{\_if$#1$\_else \_tmpdim=#1\_ptunit @@ -74,6 +119,15 @@ \_fi \_ignorespaces } +\_public \thefontsize \thefontscale ; + + \_doc ----------------------------- + \`\em` keeps the weight of the current vaiant and switches + roman $\leftrightarrow$ italic. It adds the italic correction by + the \`\_additcorr` and \`\_afteritcorr` macros. The second does not + add italic correction if the next character is dot or comma. + \_cod ----------------------------- + \_protected\_def\_em {% \_ea\_ifx \_the\_font \_tenit \_additcorr \_rm \_else \_ea\_ifx \_the\_font \_tenbf \_bi\_aftergroup\_afteritcorr\_else @@ -86,13 +140,36 @@ \_def\_afteritcorrA{\_ifx\_next.\_else\_ifx\_next,\_else \_italcorr \_fi\_fi} \_let\_italcorr=\/ + \_doc ----------------------------- + The \`\boldify` macro does `\let\it\bi` and `\let\normalmath=\boldmath`. + \_cod ----------------------------- + \_protected\_def \_boldify {% \_let \_setmainvalues=\_setmainvaluesL \_let\it =\_bi \_let\rm =\_bf \_let\_normalmath=\_boldmath \_let\_it=\_bi \_let\_rm=\_bf \_rm } -\_public \typosize \typoscale \thefontsize \thefontscale \em \boldify - \scalemain \mainfosize \mainbaselineskip ; +\_public \em \boldify ; + + \_doc ----------------------------- + We need to use a font selector for default pagination. Because we don't + know what default font size will be selected by the user, we use this + \`\_rmfixed` macro. It sets the `\rm` font from default font size + (declared by first \^`\typosize` command and redefines itself be only + the font switch for next pages. + \_cod ----------------------------- + +\_def \_rmfixed {% used in default \footline + {\_ifdim\_mainfosize=0pt \_mainfosize=10pt \_fi + \_fontdef\_rmfixed{\_setfontsize{at\mainfosize}\_resetmod\_rm}% + \_global\_let\_rmfixed=\_rmfixed} % next use will be font switch only + \_rmfixed +} +\_let \rmfixed = \_tenrm % user can redefine it + \_endcode % ------------------------------------- +History: +2020-04-14 \_setmainvaluesL: \_ifmmode test added +2020-03-27 \_setmainvalues: \_splittopskip=\_topskip added diff --git a/Master/texmf-dist/tex/luatex/optex/fonts-preload.opm b/Master/texmf-dist/tex/luatex/optex/fonts-preload.opm index 49b1f226e21..2ab3790f8f1 100644 --- a/Master/texmf-dist/tex/luatex/optex/fonts-preload.opm +++ b/Master/texmf-dist/tex/luatex/optex/fonts-preload.opm @@ -1,6 +1,6 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \rm {Latin Modern fonts (EC) preloaded <2020-01-23>} % loaded in format +\_codedecl \tenrm {Latin Modern fonts (EC) preloaded <2020-01-23>} % loaded in format % Only few text fonts are preloaded: @@ -11,27 +11,25 @@ \_font\_tentt=ec-lmtt10 % typewriter \_tenrm -\_protected\_def\_rm{\_tryloadrm \_tenrm \_fam0 } -% \bf, \it, \bi, \tt are defined in math-preload.opm -\_let\_tryload=\_relax - -\_public \rm ; +\_public \tenrm \tenbf \tenit \tenbi \tentt ; \_endcode %--------------------------------------------------- -Format in lua\TeX/ can download only non-unicode fonts, Latin Modern EC is +Format in lua\TeX/ can download only non-Unicode fonts. Latin Modern EC is loaded here. These fonts are totally unusable in LuaTeX when languages with out -of ASCII or ISO-1 alphabets are used (for example Czech). So, we load only -few fonts here for simple testing the format. But, if an user needs to do a -more serious work, he/she can use `\fontfam` macro in order to load a -selected font family of unicode fonts. - -The non-unicode fonts are not suported in op\TeX/. Use \fontfam[lmfonts] -at the begin of yor document. - -The font resizing macros are in fonts-resize.opm file. - -The `\fontfam` macro is defined in fontfam.opm file. - -The fonts for maths are preloaded in math-macros.opm file. +of ASCII or ISO-8859-1 alphabets are used (for example Czech). We load only +few 8bit fonts here especially for simple testing the format. +But, if the user needs to do a more serious work, he/she can +use `\fontfam` macro in order to load a selected font family of Unicode fonts. + +We have a dilemma: when the Unicode fonts cannot be preloaded in format then basic +font set can be loaded by `\everyjob`. But why to load a set of fonts ta the +beginning of every job when there is highly likely that the user will +load something completely different. Our decision is: there is a basic 8bit +font set and user will load the font at beginning of the document. + +The fonts selectors \`\tenrm`, \`\tenbf`, \`\tenit`, \`\tenbi`, \`\tentt` +are declared as `\public` here but only for backward compatibility. We don't +use them in the Font Selection System. But the protected versions of these +control sequences are used in the Font Selection System. diff --git a/Master/texmf-dist/tex/luatex/optex/fonts-resize.opm b/Master/texmf-dist/tex/luatex/optex/fonts-resize.opm index dbc5974852c..6c5ef27fb1d 100644 --- a/Master/texmf-dist/tex/luatex/optex/fonts-resize.opm +++ b/Master/texmf-dist/tex/luatex/optex/fonts-resize.opm @@ -1,8 +1,53 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \setfontsize {Font resizing macros <2020-03-17>} % preloaded in format +\_codedecl \setfontsize {Font resizing macros <2020-04-17>} % preloaded in format -%% resizefont variant-name \fontswitch, for example \resizefont{bf}\_tenbf + \_doc ----------------------------- + The \`\setfontsize` `{<sizespec>}` saves the `<sizespec>` to the \`\_sizespec` macro. + The \`\_optsize` value is calculated from the `<sizespec>`. + If the `<sizepec>` is in the `mag<number>` format then the contents of + the `\_sizespec` macro is re-calculated to the `at<dimen>` format using + previous `\_optsize` value. + \par \goodbreak + \_cod ----------------------------- + +\_newdimen \_optsize \_optsize=10pt +\_newdimen \_defaultoptsize \_defaultoptsize=10pt +\_newdimen\_lastmagsize + +\_def\_setfontsize #1{% + \_edef\_sizespec{#1}% + \_ea \_setoptsize \_sizespec\_relax + \_reloading +} +\_def\_setoptsize {\_isnextchar a{\_setoptsizeA} + {\_isnextchar m{\_setoptsizeC}{\_setoptsizeB}}} +\_def\_setoptsizeA at#1\_relax{\_optsize=#1\_relax\_lastmagsize=\_optsize} % at<dimen> +\_def\_setoptsizeB scaled#1\_relax{\_optsize=\_defaultoptsize\_relax} % scaled<scalenum> +\_def\_setoptsizeC mag#1\_relax{% + \_ifdim\_lastmagsize>0pt \_optsize=\_lastmagsize \_else \_optsize=\_pdffontsize\_font \_fi + \_optsize=#1\_optsize + \_lastmagsize=\_optsize + \_edef\_sizespec{at\_the\_optsize}% +} +\_public \setfontsize \defaultoptsize ; + + \_doc ----------------------------- + \`\_resizefont` `{<variant-name>}\<font switch>`, + for example `\resizefont{bf}\_tenbf` resizes the font given by the + variant. The variant `XX` have its font switch `\_tenXX`. + The \`\_doresizefont``\fontswitch` is used. It works in + TFM mode (\`\_doresizetfmfont`) or OTF mode (\^`\_doresizeunifont`). + In both modes, it does + \begtt \catcode`\<=13 + \_font \_tenXX = <fontname> \_sizespec + \endtt + The `<fontname>` is generated by the `\fontname` \TeX/ primitive where + \`\_rfontskipat` removes the `at<dimen>` part of the `\_fontname` output. + The `<fontname>` is generated differently in OTF mode, see + \^`\_doresizeunifont` macro.\nl + The \`\_whatresize` is defined as `<variant-name>`. + \_cod ----------------------------- \_def\_resizefont#1#2{% \_edef\_whatresize{#1}% @@ -22,40 +67,111 @@ \_def\_rfskipatX #1" #2\_relax{"\_whichtfm{#1}"} \_def\_rfskipatN #1 #2\_relax{\_whichtfm{#1}} -%% \setfontsize{at<size>} or \setfontsize{scaled<size>} + \_doc ----------------------------- + \`\fontdef` `<font switch>{<modifiers><variant selector>}` + opens group, runs `<modifiers><variant selector>` (i.e.\ it runs `#2` parameter). + The font switch `#1` saved in the \`\_fontselector` macro is re-declared + because the variant selector runs the \^`\_resizefont`. Now, we need to + keep the current meaning of the font switch `#1` but we must leave the + opened group. This is done by the \`\_keepmeaning` macro. + \nl + \`\fontlet` `<font switch A> <font switch B> <size spec>` does + \begtt \catcode`\<=13 + \font <font switch A> = <fontname> <sizespec> + \endtt + The `<fontname>` is extracted using the primitive command `\_fontname <font switch B>`. + \_cod ----------------------------- -\_newdimen \_optsize \_optsize=10pt -\_newdimen \_defaultoptsize \_defaultoptsize=10pt +\_def \_fontdef #1#2{\_begingroup + \_ifx\_fontselector\_undefined \_def\_fontselector{#1}\_fi + \_reloading #2% + \_ea \_keepmeaning \_fontselector \_endgroup +} +\_def\_fontlet#1#2{\_ifx #2=\_ea\_fontlet \_ea#1\_else + \_ea\_font\_ea#1\_ea\_rfontskipat\_fontname#2 \_relax\_space \_fi +} +\_def \_keepmeaning #1#2{\_global\_let\_keepmeaningdata=#1% + #2\_let#1=\_keepmeaningdata \_global\_let\_keepmeaningdata=\_undefined +} +\_public \fontdef \fontlet ; + + \_doc ----------------------------- + \`\newcurrfontsize` `<size spec>` sets current font size to the `<size spec>` + It is implemented by \^`\fontlet`. + The font switch of the current font is extracted by `\_the\_font`. + We must re-create the control sequence `\_the\_font` because + its original meaning is set to \"inaccessible" by \TeX/ when `\font` + primitive is started. + \nl + \`\resizethefont` is implemented by `\newcurrfontsize` using data from + the \^`\_sizespec` macro. + \_cod ----------------------------- -\_def\_setfontsize #1{% - \_edef\_sizespec{#1}% - \_ea \_setoptsize \_sizespec\_relax - \_reloading +\_def \_newcurrfontsize #1{% \newcurrfontsize{at25pt} + \_edef\_tmp{\_ea\_csstring \_the\_font}% + \_ea \_fontlet \_csname \_tmp\_ea\_endcsname \_the\_font \_space #1\_relax + \_csname \_tmp\_endcsname } +\_protected\_def \_resizethefont{\_newcurrfontsize\_sizespec} + + \_public \newcurrfontsize \resizethefont ; + + \_doc ----------------------------- + The variant selector is defined by `\protected\def\XX{\_tryloadXX \_tenXX}` + The `\_tryloadXX` can be in `\_relax` state if no font modifiers were + declared. But normally it does \^`\_resizefont``{XX}\tenXX`. This meaning + is activated by the \`\_reloading` macro. + \_cod ----------------------------- + \_def\_reloading{\_loadf{rm}\_tenrm \_loadf{bf}\_tenbf \_loadf{it}\_tenit \_loadf{bi}\_tenbi } \_def\_loadf#1#2{\sdef{_tryload#1}{\_ifmmode \_else \_resizefont{#1}#2\_fi}} \_def\_tryloadtt{\_resizefont{tt}\_tentt} -\_def\_setoptsize {\_isnextchar a{\_setoptsizeA} - {\_isnextchar m{\_setoptsizeC}{\_setoptsizeB}}} -\_def\_setoptsizeA at#1\_relax{\_optsize=#1\_relax\_lastmagsize=\_optsize} % at<dimen> -\_def\_setoptsizeB scaled#1\_relax{\_optsize=\_defaultoptsize\_relax} % scaled<scalenum> -\_def\_setoptsizeC mag#1\_relax{% - \_ifdim\_lastmagsize>0pt \_optsize=\_lastmagsize \_else \_optsize=\_pdffontsize\_font \_fi - \_optsize=#1\_optsize - \_lastmagsize=\_optsize - \_edef\_sizespec{at\_the\_optsize}} - -\_newdimen\_lastmagsize - -\_setfontsize{at10pt} % default size \_let\_tryloadrm=\_relax \_let\_tryloadbf=\_relax \_let\_tryloadit=\_relax \_let\_tryloadbi=\_relax + \_doc ---------------------------- + The font selection system allows to use \`\currvar` + instead explicitly specified variant selector. The current variant + is extracted from `\the\font` output which could be `\_tenXX` control + sequence. Then `\currvar` expands to `\_rm` or `\_it` etc. + \_cod ---------------------------- + +\_protected \_def \_currvar{\_cs{_currvar:\_ea \_csstring \_the\_font}} +\_sdef{_currvar:_tenrm}{\_rm} +\_sdef{_currvar:_tenbf}{\_bf} +\_sdef{_currvar:_tenit}{\_it} +\_sdef{_currvar:_tenbi}{\_bi} +\_sdef{_currvar:_tentt}{\_tt} +\_public \currvar ; + + \_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. + \nl + The \`\_wichtfm` `<fontname>` expands to the `<fontname>` or to the corrected + `<fontname>` read from the `<optical size data>`. It is used in the + \^`\_rfontskipat` macro and it is used in \^`\fontlet` macro. + It means that each `<fontname>` generated by the `\fontname` primitive in the + `\fontlet` macro is processed by the `\_whichtfm`. The real `<fontname>` or + corrected `<fontname>` (depending on the optical data does not exist or exist) + is the output of the expansion before `\font` primitive takes this output + as its parameter. + + The implementation detail: The `\_<font id>:reg` is defined as the + `<optical size data>` and all control sequences `\_<fontname>:reg` + from this data line has the same meaning because of the + \`\_reversetfm` macro. The `\_whichtfm` expands this data line and apply + \`\_dowhichtfm`. This macro select the right result from the data line + by testing with the current `\_optsize` value. + \_cod ----------------------------- + \_def\_regtfm #1 0 #2 *{\_ea\_def \_csname _#1:reg\_endcsname{#2 16380 \_relax}% \_def\_tmpa{#1}\_reversetfm #2 * % } @@ -78,41 +194,9 @@ } \_def\_ignoretfm #1\_relax{} -% \fontdef \new {\<modifiers>\<var-selector>} -\_def \_fontdef #1#2{\_begingroup - \_ifx\_fontselector\_undefined \_def\_fontselector{#1}\_fi - \_reloading #2% - \_ea \_keepmeaning \_fontselector \_endgroup -} -\_def\_fontlet#1#2{\_ifx #2=\_ea\_fontlet \_ea#1\_else - \_ea\_font\_ea#1\_ea\_rfontskipat\_fontname#2 \_relax\_space \_fi -} -\_def \_keepmeaning #1#2{\_global\_let\_keepmeaningdata=#1% - #2\_let#1=\_keepmeaningdata \_global\_let\_keepmeaningdata=\_undefined -} -\_protected \_def \_currvar{\_cs{_currvar:\_ea \_csstring \_the\_font}} -\_sdef{_currvar:_tenrm}{\_rm} -\_sdef{_currvar:_tenbf}{\_bf} -\_sdef{_currvar:_tenit}{\_it} -\_sdef{_currvar:_tenbi}{\_bi} -\_sdef{_currvar:_tentt}{\_tt} - -\_def \_newcurrfontsize #1{% \newcurrfontsize{at25pt} - \_edef\_tmp{\_ea\_csstring \_the\_font}% - \_ea \_fontlet \_csname \_tmp\_ea\_endcsname \_the\_font \_space #1\_relax - \_csname \_tmp\_endcsname -} - -\_def \_rmfixed {% used in default \footline - {\_ifdim\_mainfosize=0pt \_mainfosize=10pt \_fi - \_fontdef\_rmfixed{\_setfontsize{at\mainfosize}\_resetmod\_rm}% - \_global\_let\_rmfixed=\_rmfixed} % next use will be font switch only - \_rmfixed -} -\_let \rmfixed = \_tenrm % user can redefine it - - -%% Optical sizes data for preloaded Latin Modern fonts: + \_doc ----------------------------- + Optical sizes data for preloaded 8bit Latin Modern fonts: + \_cod ----------------------------- \_regtfm lmr 0 ec-lmr5 5.5 ec-lmr6 6.5 ec-lmr7 7.5 ec-lmr8 8.5 ec-lmr9 9.5 ec-lmr10 11.1 ec-lmr12 15 ec-lmr17 * @@ -121,64 +205,109 @@ \_regtfm lmri 0 ec-lmri7 7.5 ec-lmri8 8.5 ec-lmri9 9.5 ec-lmri10 11.1 ec-lmri12 * \_regtfm lmtt 0 ec-lmtt10 11.1 ec-lmtt12 * -\_public - \setfontsize \newcurrfontsize \fontdef \fontlet \currvar \defaultoptsize ; +\_setfontsize {at10pt} % default font size \_endcode %--------------------------------------------------- -This code is inspired from csfontsm.tex file. -\sec Scaling fonts to diferent sizes in text mode (low-level macros) -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\sec[setfontsize] Scaling fonts in text mode (low-level macros) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +The \^`\setfontsize` `{<size spec>}` +saves the information about `<size spec>`. This information is taken into +account when a variant selector (for example `\rm`, `\bf`, `\it`, `\bi`) +or `\resizethefont` is used. The `<size spec>` can be: +\begitems +* `at<dimen>`, for example `\setfontsize{at12pt}`. It gives the desired font size directly. +* `scaled<scale factor>`, for example `\setfontsize{scaled1200}`. The font is + scaled in respect to its native size (which is typically 10\,pt). It + behaves like `\font\... scaled<number>`. +* `mag<decimal number>`, for example `\setfontsize{mag1.2}`. The font is + scaled in respect to the current size of the fonts given by the previous + \^`\setfontsize` command. +\enditems +The initialization value in \OpTeX/ is given by `\setfontsize{at10pt}`. -There are four basic font-variant selectors `\rm`, `\bf`, `\it`, `\bi`. -Once a font family is loaded (for example fonts decalred in the format in -the `fonts-preloaded.opm` or loaded by `\fontfam`) then you can resize these -fonts using `\setfontsize{<sizespec>}`, for example `\setfontsize{at12pt}` -or `\setfontsize{scaled1300}`. Note that the word `at` or `scaled` must be -present here. This command itself does not rescaling, this is done at the -first moment you use next `\rm`, `\bf`, `\it` or `\bi` selectors. -Example. Assume that we are printing at 10pt and we use: +The \^`\resizethefont` resizes the current font to the size given by previous +\^`\setfontsize`. For example \begtt - \setfontsize{at15pt} ...still at 10pt... \rm ...now the text is at15pt... - \bf bold is at 15pt too ... + Here is 10 pt text, +\setfontsize{at12pt} 10 pt text here unchanged... +\resizethefont and 12 pt text is here. \endtt +% +The \^`\setfontsize` command acts like {\em font modifier}. It means that it +saves information about fonts but does not change the font actually until +variant selector or \^`\resizethefont` is used. -More meaningful is to use first variant selector immediatelly after -`\setfontsize` command. There is a special "variant selector" `\currvar` -which reloads the font from current variant, for example +The following example demonstrates the `mag` format of \^`\setfontsize` +parameter. It is only a curious example probably not used in practical +typography. \begtt - \it italics at10pt \setfontsize{at7pt}\currvar italics at 7pt. +\def\smaller{\setfontsize{mag.9}\resizethefont} +Text \smaller text \smaller text \smaller text. \endtt -If you are using font families by `\fontfam` then you can use more "font -modifiers". The `\setfontsize` command is only one of such font modifier. All font -modifiers does not actual change of fonts but first usage of a variant selector -takes this setting. See `fonts-select.opm` for more information about it. +If you load a font directly by `\font` primitive and you want to +create a size-dependent selector for such font then you can use +\^`\resizethefont`: + +\begtt +\font\tencomfortaa=Comfortaa-Regular-T1 at10pt +\def\comfortaa{\tencomfortaa\resizethefont} -You can declare `\<newfont>` which behaves as natural font switch declared -by `\font`: +\comfortaa Here is 10 pt text +\setfontsize{at12pt} +\comfortaa Here is 12 pt text +\endtt +% +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: \begtt - \fontdef \<newfont> {<modifiers> \<variant-selector>} +\initunifonts +\font\tencyklop=[cyklop-regular] at10pt % the font cyklop-regular.otf is loaded +\def\cyklop{\tencyklop\resizethefont} + +\cyklop Here is 10 pt text +\setfontsize{at12pt} +\cyklop Here is 12 pt text +\endtt + +\secc[fontdef] The \code{\\fontdef} declarator + +You can declare `\<newfont>` by the \^`\fontdef` command. + +\begtt \catcode`\<=13 + \fontdef \<newfont> {<font modifiers> \<variant-selector>} example: \fontdef \bigfont {\setfontsize{at15pt}\bf} \endtt - -This command runs `<modifiers> \<variant-selector>` in a group and sets the +% +This command runs `<font modifiers> \<variant-selector>` in a group and sets the resulting current font as `\<newfont>`. -The parameter of the `\fontdef` macro needs to be finalized by one of the -four standard variant selectors (or `\currvar`). +The resulting `\<newfont>` declared by \^`\fontdef` is \"fixed font switch" +independent of \^`\setfontsize` and other font modifiers. More exactly, it is +fixed font switch when it is used but it can depend on the current font +modifiers and font family and given font modifiers when it is declared. -We have another command for scaling: `\fontlet` which is able to resize -arbitrary font. The font must be presented by \<fontswhitch>, i.e. by -`\_tenrm`, `\_tenbf` etc. or arbitrary font switch you declared it by -`\font` primitive or `\fontdef` macro. The usage is: +The parameter of the \^`\fontdef` macro must be exactly finished by the +variant selector. More information about font modifiers +and variant selectors are in the section~\ref[fontsystem]. -\begtt +\secc[fontlet] The \code{\\fontlet} declarator + +We have another command for scaling: \^`\fontlet` which is able to resize +arbitrary font given by its font switch. +This font switch was declared it by the +`\font` primitive or the `\fontdef` macro. + +\begtt \catcode`\<=13 \fontlet \<newfont> = \<fontswitch> <sizespec> example: \fontlet \bigfont = \_tenbf at15pt @@ -189,36 +318,32 @@ was used. The advantage of `\fontdef` macro will be more clear when you load font families by `\fontfam` and you are using more font modifiers declared in such families. -The `\newcurrfontsize{<sizespec>}` resizes immediatelly current font. -No others fonts are resized. - -The parameter of `\setfontsize` should be in the format `at<dimen>` or -`scaled<scalenum>` or `mag<coefficient>`. The first two are know from -classical \TeX/. The third sets new font size to <coefficient> multiplied by -current font size (declared by at<dimen> or mag<coefficient>). For example -if we have do `\setfontsize{at12pt}` and next we write -`\setfontsize{mag1.5}\rm` then the current font size is `at19pt`. You can -define a funny macro `\bigger`: - -\begtt - \def\bigger {\setfontsize{mag1.3}\currvar} - text \bigger text \bigger text \bigger text... -\endtt +Summary: you can declare font switches: +\begitems +* by the `\font` primitive if you know the font file, +* by the \^`\fontlet` command if you know the font switch and the size, or +* by the \^`\fontdef` command if you know the variant and modifiers. +\enditems \secc Optical sizes There are font families with more font files where almost the same font is implemented in various design sizes: `cmr5`, `cmr6`, `cmr7`, `cmr8`, `cmr9`, -`cmr10`, `cmr12`, `cmr17` for example. This feature is called "optical +`cmr10`, `cmr12`, `cmr17` for example. This feature is called \"optical sizes". \OpTeX/ chooses a font with an optical size closest to desired size -specified by `\setfontsize`, when `at<dimen>` or `mag<coefficient>` is used. -When `scaled<scalenum>` is used then optical size is choosen using the value +specified by the \^`\setfontsize`, when `at<dimen>` or `mag<coefficient>` is used. +When `scaled<scale factor>` is used then optical size is chosen using the value of the `\defaultoptsize` register and such font is scaled by the specified -<scalenum>. There is `\defaultoptsize=10pt` by default. +`<scale factor>`. There is `\defaultoptsize=10pt` by default. +Font collections with optical sizes must be registered by the +\^`\_regtfm` for `tfm` files or \^`\_regoptsizes` for Unicode fonts. +\OpTeX/ registers 8bit Latin Moder fonts in the format (`fonts-resize.opm` file) +and OTF Latin Modern fonts in the `f-lmfonts.opm` file. \secc Implementation notes -... to do ... - +\_endinput +2020-04-17 \resizethefont introduced +2020-03-17 released diff --git a/Master/texmf-dist/tex/luatex/optex/fonts-select.opm b/Master/texmf-dist/tex/luatex/optex/fonts-select.opm index eaadc0dedce..5064e320ece 100644 --- a/Master/texmf-dist/tex/luatex/optex/fonts-select.opm +++ b/Master/texmf-dist/tex/luatex/optex/fonts-select.opm @@ -2,6 +2,20 @@ \_codedecl \fontfam {Fonts selection system <2020-03-18>} % preloaded in format + \_doc ----------------------------- + The \`\initunifonts` initializes extended `\font` primitive + (to be able to load Unicode fonts). Unfortunately, this part of + \OpTeX/ depends on \LaTeX/ lua codes `ltluatex.lua` and + `luaotfload-main.lua`. And this code need to be declared a + control sequence `\e@alloc@attribute@count` by `\countdef` primitive. + Moreover, the `\initunifont` switches with + the \^`\_doresizefont` macro to OTF mode which is represented by the + macro \`\_doresizeunifont`. This mode includes + a fallback to TFM mode if \^`\_fontnamegen` is not defined. + Finally, the `\initunifnt` sets itself to relax because we need not to do + this work twice. + \_cod ----------------------------- + \_def\_initunifonts {% \_ea\_newcount \_csname e@alloc@attribute@count\_endcsname \_global \_csname e@alloc@attribute@count\_endcsname=-1 @@ -20,22 +34,51 @@ \_font#1={\_fontnamegen} \_sizespec \_relax \_setwsp#1\_relax \_fi } -\_def\_fontdecl [#1]#2#3#4#5#6#7{% +\_public \initunifonts ; + + \_doc ----------------------------- + The \`\_famdecl` `[<Family Name>] \<Famselector> {<comment>} {<modifiers>} {<variants>} {<math>}`\nl + `{<font for testing>} {\def`\^`\_fontnamegen``{<data>}}` runs \^`\initunifonts`, then + checks if `\<Famselector>` is defined. If it is true, then closes the file by + `\endinput`. Else it defines `\<Famselector>` and saves it to the \`\_mainfamcommand` + macro because the \`\_initfontfamily` needs it. The \`\_currfamily` is set + to the `<Famselector>` because the following \^`\moddef` commands need to + be in the right font family context. The `\_currfamily` is set to the + `<Famselector>` by the `\<Famselector>` too, because `\<Famselector>` + must set the right faily context. The font family context is given by the current + `\_currfamily` value and by the actual meaning of the \^`\_fontnamegen` macro. + \_cod ----------------------------- + +\_def\_famdecl [#1]#2#3#4#5#6#7#8{% \_initunifonts \_uniaccents \_ifx #2\_undefined \_isfont{#7}\_iffalse \_opwarning{Family [#1] skipped, font "#7" not found}\_ea\_ea\_ea\_endinput \_else - \_def\_textfamily{#1}% \_edef\_currfamily {\_csstring #2}% \_def\_mainfamcommand{#2}\_def\_mathfaminfo{#6}% + \_protected\_edef#2{\_def\_noexpand\_currfamily{\_csstring #2}\_unexpanded{#8\_resetmod}}% \_wterm {FONT: [#1] -- \string#2 \_detokenize{(#3)^^J mods:{#4} vars:{#5} math:{#6}}}% \_fi \_else \_ea #2\_ea\_endinput \_fi } -\_def\_regoptsizes #1 #2?#3 #4*{\_sdef{_optsizes:#1}{#2?#3 #4* }} -\_def\_optfontalias #1#2{\_slet{_optsizes:#1}{_optsizes:#2}} -\_def\_optname #1{\_ifcsname _optsizes:#1\_endcsname - \_ea\_ea\_ea \_optnameA \_csname _optsizes:#1\_ea\_endcsname +\_def\_initfontfamily{% + \_mainfamcommand \_reloading \_rm +} + + \_doc ----------------------------- + \`\_regoptsizes` `<internal-template> <left-output>?<right-output> <resizing-data>` + prepares data for using by the \`\_optname` `<internal-template>` macro. + The data are saved to the `\_oz:<internal-template>` macro. + When the `\_optname` is expanded then the data are scanned by the macro + \`\_optnameA` `<left-output>?<right-output> <mid-output> `\code{<}`<size>` + in the loop.\nl + \`\_optfontalias` `{<template A>}{<template B>}` is defined as + `\let\_oz:<templateA>=\_oz:<templateB>`. + \_cod ----------------------------- + +\_def\_regoptsizes #1 #2?#3 #4*{\_sdef{_oz:#1}{#2?#3 #4* }} +\_def\_optname #1{\_ifcsname _oz:#1\_endcsname + \_ea\_ea\_ea \_optnameA \_csname _oz:#1\_ea\_endcsname \_else \_failedoptname{#1}\_fi } \_def\_failedoptname #1{optname-fails:(#1)} @@ -45,30 +88,26 @@ } \_def\_optnameC #1* {\_fi\_fi} \_def\_afterfifi #1\_fi\_fi{\_fi\_fi #1} +\_def\_optfontalias #1#2{\_slet{_oz:#1}{_oz:#2}} + + \_doc ----------------------------- + \`\_fvars` `<rm-template> <bf-template> <it-template> <bi-template>` + saves data for usage by the `\_currV` macro. If a template is only dot + then previous template is used (it can be used if the font family doesn't + dispose with all standard variants). + \nl + \`\_currV` expands to a template declared by `\_fvars` depending on the + `<variant name>`. Usable only of standard four variants. Next variants + can be declared by the \^`\famvardef` macro. + \nl + \`\_fset` `<key>=<value>,...,<key>=<value>` expands to + `\def\_<key>V{<value>}` in the loop. + \nl + \`\_onlyif` `<key>=<value-a>,<value-b>...,<value-z>: {<what>}` + runs <what> only if the `\_<key>V` is defined as `<value-a>` or + `<value-b>` or ... or `<value-z>`. + \_cod ----------------------------- -\_newifi \_ifexistfam -\_def\_isfont#1#2{% - \_begingroup - \_suppressfontnotfounderror=1 - \_font\_testfont={#1}\_relax - \_ifx\_testfont\_nullfont \_def\_tmp{\_existfamfalse \_unless} - \else \_def\_tmp{\_existfamtrue}\_fi - \_ea \_endgroup \_tmp #2% -} - -\_def \_defaultfontfeatures {+tlig;} -\_def \_setff #1{% - \_ifx^#1^\_let \_fontfeatures=\_defaultfontfeatures - \_else \_edef\_fontfeatures{\_fontfeatures #1;}\_fi - \_reloading -} -\_setff {} % default font features: +tlig; -\_def\_removefeature #1{% - \_isinlist\_fontfeatures{#1}\_iftrue - \_def\_tmp ##1#1##2;##3\_relax{\_def\_fontfeatures{##1##3}}% - \_ea \_tmp \_fontfeatures \_relax - \_fi -} \_def\_fvars #1 #2 #3 #4 {% \_sdef{_fvar:rm}{#1}% \_sdef{_fvar:bf}{#2}% @@ -88,18 +127,57 @@ \_edef\_act{\_noexpand\_isinlist{,#2,}{,\_cs{_#1V},}}\_act \_iftrue #3\_fi } + + \_doc ----------------------------- + The \`\moddef` `\<modifier> {<data>}` simply speaking does + `\def\<modifier>{<data>}`, but we need to respect + the family context. In fact, `\protected\def\_f:<current family>:<modifier>{<data>}` is + performed and the `\<modifier>` is defined as + \`\_famdepend``\<modifier>{_f:\_currfamily:<modifier>}`. It expands to + `\_f:\_currfamily:<modifier>` value if it is defined or it prints + warning. When the `\_currfamily` value is + changed then we can declare the same `\<modifier>` with different meaning. + + When user declare a prefixed variant of the `\<modifier>` then unprefixed + modifier name is used in internal macros, this is reason why we are using + the \`\_remifirstunderscore``\_tmp` (where `\_tmp` expands to + `_<something>` or to `<something>`. The `\_remifirstunderscore` + redefines `\_tmp` in the way that it + expands only to `<something>` without the first `_`. + \_cod ----------------------------- + \_def \_moddef #1#2{\_edef\_tmp{\_csstring#1}\_remfirstunderscore\_tmp \_sdef{_f:\_currfamily:\_tmp}{#2\_reloading}% \_protected \_edef #1{\noexpand\_famdepend\noexpand#1{_f:\noexpand\_currfamily:\_tmp}}% \_ea \_ifx \_csname\_tmp\_endcsname #1\_else \_ea \_public \_csname\_tmp\_endcsname ;\_fi } +\_def\_remfirstunderscore#1{\_ea\_remfirstunderscoreA#1\_relax#1} +\_def\_remfirstunderscoreA#1#2\_relax#3{\_if _#1\_def#3{#2}\_fi} + \_protected \_def\_resetmod {\_cs{_f:\_currfamily:resetmod}} % private variant of \resetmod \_def\_currfamily{} % default current family is empty \_def\_famdepend#1#2{\_ifcsname#2\_endcsname \_csname#2\_ea\_endcsname \_else \_opwarning{\string#1 is undeclared in current family "\_currfamily", ignored}\_fi } +\_public \moddef ; + + \_doc ----------------------------- + The \`\famvardef` `\<XX> {<data>}` + uses analogical trick like \^`\moddef` with + the \^`\_famdepend` macro. The auxiliary + \`\_famvardefA` `\<XX> \_ten<XX> \_tryload<XX> {<data>}` is used. + It does: + \begitems + * `\protected\def \<XX> {\_famdepend \<XX> {_f:\_currfamily:<XX>}}`, + * `\def \_f:<current family>:<XX> {\_tryload<XX>\_ten<XX>}` keeps family dependent definition, + * `\def \_tryload<XX> {`\^`\fontdef`` \_ten<XX> {<data>}}` loads actually the font `\_ten<XX>`, + * `\def \_currvar:_ten<XX> {\<XX>}` in ordef to the \^`\currvar` macro + work correctly. + \enditems + \_cod ----------------------------- + \_def\_famvardef#1{\_edef\_tmp{\_csstring#1}\_remfirstunderscore\_tmp \_ea\_famvardefA \_ea#1\_csname _ten\_tmp\_ea\_endcsname \_csname _tryload:\_tmp\_endcsname @@ -116,25 +194,41 @@ \_sdef{_currvar:\csstring#2}{#1}% \_fi } -\_def\_initfontfamily{% - \_mainfamcommand \_reloading \_rm -} -\def\_fontfam[#1]{% +\_public \famvardef ; + + \_doc ----------------------------- + The \`\fontfam` `[<Font Family>]` does: + \begitems + * Convert its parameter to lower case and without spaces, e.g.\ `<fontfamily>`. + * If the file `f-<fontfamily>.opm` exists read it and finish. + * Try to load user defined `fams-local.opm`. + * If the `<fontfamily>` is declared in `fams-local.opm` or `fams-ini.opm` + read relevant file and finish. + * Print the list of declared families. + \enditems + The `fams-local.opm` is read by the \`\_tryloadfamslocal` macro. It sets + itself to `\_relax` because we need not to load this file twice. + The \`\_listfamnames` macro prints registered font families to the + terminal and to the log file. + \_cod ----------------------------- + +\_def\_fontfam[#1]{% \_lowercase{\_edef\_famname{\_ea\_removespaces #1 {} }}% - \_ifcsname _famf:\_famname\_endcsname \_edef\_famfile{\_cs{_famf:\_famname}}% - \_else \_edef\_famfile{f-\_famname}\_fi - \_ifx \_famfile\_empty \_listfamnames \_fi - \_isfile {f-\_famname.opm}\_iftrue - \_opinput {f-\_famname.opm} - \_else \_isfile {fams-local.opm}\_iftrue \_opinput {fams-local.opm} \_fi - \_ifcsname _famf:\_famname\_endcsname \_edef\_famfile{\_cs{_famf:\_famname}}% - \_else \_edef\_famfile{f-\_famname}\_fi - \_isfile {\_famfile.opm}\_iftrue \_opinput {\_famfile.opm} - \_else \_opwarning{Family [#1] undeclared, "\_famfile.opm" not found}% - \_fi \_fi \_relax + \_isfile {f-\_famname.opm}\_iftrue \_opinput {f-\_famname.opm}% + \_else + \_tryloadfamslocal + \_edef\_famfile{\_trycs{_famf:\_famname}{}}% + \_ifx\_famfile\_empty \_listfamnames + \_else \_opinput {\_famfile.opm}% + \_fi\_fi +} +\_def\_tryloadfamslocal{% + \_isfile {fams-local.opm}\_iftrue + \_opinput {fams-local.opm} + \_fi + \_let \_tryloadfamslocal=\_relax % need not to load fams-local.opm twice } -\_sdef{_famf:?}{} \_sdef{_famf:{} }{} -\_def\_listfamnames #1\_fi\_relax{\_fi +\_def\_listfamnames {% \_wterm{===== List of font families ======} \_begingroup \_let\_famtext=\_wterm @@ -142,12 +236,31 @@ \_wterm{ \_space\_noexpand\fontfam [##1] -- ##2}% \_let\_famalias=\_famaliasA}% \_opinput {fams-ini.opm} - \_isfile {fams-local.opm}\_iftrue \_opinput {fams-local.opm} \_fi + \_isfile {fams-local.opm}\_iftrue \_opinput {fams-local.opm}\_fi \_message{^^J}% \_endgroup } \_def\_famaliasA{\_message{ \_space\_space\_space\_space -- alias:} - \_def\_famalias[##1]{\_message{[##1]}}\_famalias} + \_def\_famalias[##1]{\_message{[##1]}}\_famalias +} +\_public \fontfam ; + + \_doc ----------------------------- + When the `fams-ini.opm` or `fams-loca.opm` files are read then we need + to save ony a mapping from family names or alias names to the font family file + names. All other information is ignored in this case. But if these files + are read by the `\_listfamnames` macro or when printing a catalog then + more infrormation is used and printed.\nl + \`\_famtext` does nothing or prints the text on the terminal. + \nl + \`\_faminfo` `[<Family Name>] {<comments>} {<file-name>} {<mod-plus-vars>}` + does\nl `\_def \_famf:<familyname> {<file-name>}` or prints information on + the terminal. + \nl + \`\_famalias` `[<Family Alias>]` does `\def \_famf:<familyalias> {<file-name>}` + where `<file-name>` is stored from the previous `\_faminfo` command. Or + prints information on the terminal. + \_cod ----------------------------- \_def\_famtext #1{} \_def\_faminfo [#1]#2#3#4{% @@ -161,12 +274,59 @@ } \_input fams-ini.opm \_let\_famfile=\_undefined + + \_doc ----------------------------- + When the \^`\fontfam``[catalog]` is used then the file + `fonts-tatalog.opm` is read. The macro \^`\_faminfo` is redefined here + in order to print catalog samples of all declared modifiers/variant + pairs. The user can declare different samples and different behavior of + the catalog, see the end of catalog listing for more information. + The default parameters + \`\catalogsample`, \`\catalogmathsample`, \`\catalogonly` and + \`\catalogexclude` of the catalog are declared here. + \_cod ----------------------------- + \_newtoks \_catalogsample \_newtoks \_catalogmathsample \_newtoks \_catalogonly \_newtoks \_catalogexclude \_catalogsample={ABCDabcd Qsty fi fl áéíóúüů řžč ÁÉÍÓÚ ŘŽČ 0123456789} +\_public \catalogonly \catalogexclude \catalogsample \catalogmathsample ; + + \_doc ----------------------------- + The font features are managed in the \`\_fontfeatures` macro. + They have their implicit values saved in the \`\_defaultfontfeatures` + and the \`\setff` `{<features>}` + can add next font features. If there is the same font feature as the newly + added one then the old value is removed from the `\_fontfeatures` list. + \_cod ----------------------------- + +\_def \_defaultfontfeatures {+tlig;} +\_def \_setff #1{% + \_ifx^#1^\_let \_fontfeatures=\_defaultfontfeatures + \_else \_edef\_fontfeatures{\_fontfeatures #1;}\_fi + \_reloading +} +\_setff {} % default font features: +tlig; +\_def\_removefeature #1{% + \_isinlist\_fontfeatures{#1}\_iftrue + \_def\_tmp ##1#1##2;##3\_relax{\_def\_fontfeatures{##1##3}}% + \_ea \_tmp \_fontfeatures \_relax + \_fi +} +\_public \setff ; + + \_doc ----------------------------- + The \`\setfontcolor` and \`\setletterspace` are macros based on the + special font features provided by \LuaTeX/ (and by \XeTeX/ too but it is not + our business). The \`\setwordspace` recalulates the `\fontdimen2,3,4` + of the font using the \`\setwsp` macro which is used by the + \^`\_doresizeunifont` macro. It activates a dummy font feature `+Ws` too in + order the font is reloded by the `\font` primitive (with independent + `\fontdimen` registers). + \_cod ----------------------------- + \_def\_savedfontcolor{} \_def\_savedletterspace{} \_def\_savedwsp{} @@ -195,200 +355,228 @@ \_sdef{_fc:white}{FFFFFFFF} \_sdef{_fc:grey}{00000080} \_sdef{_fc:lgrey}{00000025} \_sdef{_fc:black}{} % ... you can declare more colors... -\_public - \fontfam \initunifonts \isfont - \setff \setfontcolor \setletterspace \setwordspace \famvardef \moddef - \catalogonly \catalogexclude \catalogsample \catalogmathsample ; +\_public \setfontcolor \setletterspace \setwordspace ; \_endcode %--------------------------------------------------- -\sec Usage of font selection system -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -Try to write `\fontfam[?]`. All font families registered in \OpTeX/ -font selection system are listed on the terminal and in the log file. -You can choose one of them and use it, for example `\fontfam[Termes]` or -`\fontfam[LM Fonts]`. Then you can use four basic variant selectors `\rm` or -or `\bf` or `\it` or `\bi` and desired fonts are printed. - -You can write `\fontfam[Catalog]` and all fonts registered in \OpTeX/ are -printed with their templates. - -The fonts registered in \OpTeX/ have their macros in "font files", each family -in one font file with the name `f-famname.opm`. All families are collected -in `fams-ini.opm`. You can read the documentation in the file `fams-ini.opm` -and in the files `f-heros.opm`, `f-lmfonts.opm` for more information how -to install and how to register your own font family. Note that all families -registered in such files are Unicode fonts. Non-Unicode fonts are not -preferred in \OpTeX/ but you can use them using classical `\font` primitive, -of course. - -There are two equal possibilities how to load a font family: `\fontfam[Family]` -or `\input f-fontfamily.opm`. - -There are "main family command", "font modifiers" and "variant selectors" in -each family. Each family provides four default variant selectors mentioned above -(may be, in few cases a missing variants are substituded) -A few families provides more than these four variant selectors. - -Mostly all families provides "font modifiers" like `\caps`, `\light`, -`\cond`. Supported font modifiers are listed in terminal or in the -catalogue. A font modifier does nothing with current font, but the next -variant selectors select a modified font. You can combine more than one -font modifiers followed by a variant selector. The font is reloaded at the -moment when variant selector is processed. The following example -supposes that we are working with a font family where `\caps` and `\cond` -font modifiers are provided. - +\sec[fontsystem] The Font Selection System +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +The basic principles of the Font Selection System used in \OpTeX/ +was documented in the section~\ref[fontfam]. + +\secc Terminology + +We distinguish between +\begitems +* {\em font switchers}, they are declared by the `\font` primitive or by + \^`\fontlet` or \^`\fontdef` macros, +* {\em variant selectors}, there are four basic variant selectors + `\rm`, `\bf`, `\it`, `\bi`, there is a special selector `\currvar` + and more variant selectors can be declared by the \^`\famvardef` macro. +* {\em font modifiers} (for example `\cond`, `\caps`, \^`\setfontsize``{<size spec>}`), + they are in two types: bulid in (like \^`\setfontsize`) or + declared modifiers (by by the \^`\moddef` macro). +* {\em family selectors} (for example `\Termes`, `\LMfonts`), + they are declared typically in the {\em font family files}. +\enditems + +These selectors / switchers sets its values locally. When the \TeX/ group is +leaved then selected font and the {\em font context} are returned back to the values +used when the group was opened. They have the following features: + +\begitems +* The {\em font switchers} select fonts independent on the font context. +* The {\em variant selectors} select the font depending on the font context and on + the specified variant. +* The {\em font modifiers} create a change in the font context but they + don't select the font itself. +* The {\em family selectors} set a family in the font context and resets all + font modifiers. They dont't select the font itself. +\enditems + +The variant selectors and declared font modifiers are +defined in the family context. They can behave differently in different +families. + +The fonts registered in \OpTeX/ have their macros in the {\em font family files}, +each family is declared in one font family file with the name `f-famname.opm`. +All families are collected in `fams-ini.opm` and user can give more +declarations in the file `fams-local.opm`. + +\secc Font families, selecting fonts + +The \^`\fontfam` `[<Font Family>]` opens the relevant font family file where +the `<Font Family>` is declared. The family selector is defined here by rules +described in the section~\ref[fontfamfiles]. Font modifiers and variant +selectors may be declared here. Their definitions depends on given family. +The family is set as active in the font context and `\rm` variant selector is run. + +The available declared font modifiers and declared variant selectors are +listed in the log file when font family is load. Or you can print +`\fontfam[catalog]` to show available font modifiers and variant selectors. + +The font modifiers can be independent, like `\cond` and `\light`. They can +be arbitrary combined (in arbitrary order) and if the font family disposes +with all such sub-variants then the desired font is selected (after variant +selector is used). On the other hand there are font modifiers which negates +the previous font modifier, for example `\cond`, `\extend`. You can reset +all modifiers to their initial value by the \^`\resetmod` command. + +You can open more font families by more \^`\fontfam` commands. Then the +general method to selecting the individual font is: + +\begtt \catcode`\<=13 +<family selector> <font modifiers> <variant selector> +\endtt +For example: \begtt -\rm normal font, \bf bold, \it italic. -\cond\currvar now condensed italics is active, -\rm condensed normal, \bf condensed bold. -\caps\rm condensed caps and small caps variant is used in regular variant -\bi condensed caps and small caps variant is used in bold-italic variant. -\resetmod\rm using the `\resetmod` font modifier we can return to -the normal state when no font modifier is active. +\fontfam [Heros] % Heros family is active here, default \rm variant. +\fontfam [Termes] % Termes family is active here, default \rm variant. +{\Heros \caps \cond \it The caps+condensed italics in Heros family is here.} +The Termes roman is here. \endtt -Of course, all font settings respect groups. The font modifiers keeps their -context until the group is closed or until another font modifier (which -negates previous setting) is used. In our example these two selectors are -independent, so there are four variants: normal, condensed, caps and -caps-condensed, all these variants are present in four standard -variants: regular, bold, italics, bold-italics. - -There is one special command `\currvar` which acts as variant selector. +There is one special command \^`\currvar` which acts as variant selector. It keeps the current variant and the font of such variant is -reloaded with respect to previously given font modifiers. +reloaded with respect to the current font context by previously given family +selector and font modifiers. -You can use the `\setfontsize{<sizespec>}` command in the same sense as -other font modifiers. It means that the command itself does nothing with the -fonts but following variant selectors reload fonts to desired size. For -example: +You can use the \^`\setfontsize` `{<sizespec>}` command in the same sense as +other font modifiers. It saves only information about font size to the font +context. See section~\ref[setfontsize]. Example: \begtt -\rm standard size \setfontsize{at14pt}\rm here is 14pt size \it italic is +\rm default size \setfontsize{at14pt}\rm here is 14pt size \it italic is in 14pt size too \bf bold too. \endtt -Note that much more comfortable is to resize fonts using OPmac-like command -`\typosize`, `\typoscale`. These commands prepare the right sizes for math -fonts too and re-calculates many internal parameters like `\baselineskip`. See -the section \ref[typosize] for more information. - - -\secc More than one font families loaded -%--------------------------------------- - -You can load more font families. Then you must to know the context (what -family is currently in use) and you can switch between families using main -family comand. For example, when Heros and Termes are loaded then: - -\begtt -\rm here is Termes because it is loaded last, \it italics in Termes but -\Heros \rm here is Heros font \it italics is in Heros too. -\endtt - -To select a font you can use (in this order): - -\begtt -\<main-family-command> \<font-modifiers> \<variant-selector-or-currvar> -\endtt - -You can use zero or more font modifiers, the `\setfontsize` command is a -font modifier too. Finally, the variant selector or `\currvar` loads -the desired font. - -The font modifiers (with an exception `\setfontsize`) are declared localy in -their font family as "family dependent". If you use it in the context of -another font family where it is not declared then warning is printed on the -terminal and nothing else happens. It is possible (and it is typical) that a -modifier with the same name is declared in more font families. Then such -modifiers are working in context of current used family. For example -`\LMfonts\caps\rm` or `\Termes\caps\rm` both loads small caps in specified -font family using different internal definitions. - -Maybe, one needs a context switching between `\rm`<-->`\bf` and -`\it`<-->`\bi`. This is done by `\em` and `\boldify` macros, see -section \ref[fonts]. +Much more comfortable way to resize fonts is using OPmac-like command +`\typosize`, `\typoscale`. +These commands prepare the right sizes for math +fonts too and re-calculates many internal parameters like `\baselineskip`. +See section~\ref[opmac-fonts] for more information. \secc Math Fonts %--------------- -Most font families are connected with a preferred unicode-math font. This -unicode-math is activated when the font family is loaded. If you don't prefer +Most font families are connected with a preferred Unicode-math font. This +Unicode-math is activated when the font family is loaded. If you don't prefer this and you are satisfied with 8bit math CM+AMS fonts preloaded in the -\OpTeX/ format then you can use command `\noloadmath` before you load a first +\OpTeX/ format then you can use command \^`\noloadmath` before you load a first font family. -If you want to use your specially selected UnicodeMath font then use -`\loadmath{[<font_file>]}` or `\loadmath{<font_name>}` before first +If you want to use your specially selected Unicode-math font then use +\^`\loadmath` `{[<font_file>]}` or \^`\loadmath` `{<font_name>}` before first `\fontfam` is used. -\secc Defining a font commands -%----------------------------- +\secc Declaring font commands +%---------------------------- -You can declare a "font switch" like `\font` primitive does it, -but you need not to know nothing about names of font files: - -\begtt -\fontdef \newswitch {<font-modifiers> <variant-selector>} -for example -\fontdef \titlefont {\setfontsize{at14pt}\bf} +The font switches can be declared by `\font` primitive or by \^`\fontdef` or +\^`\fontlet` macros. See the sections~\ref[fontdef] and~\ref[fontlet] +for more details. The general format for \^`\fontdef` is +\begtt \catcode`\<=13 +\fontdef\<font switch> {\<family selector> <font modifiers> \<variant selector>} \endtt -This example declares \title as a font switch: it selects the bold font at -14pt and other not mentioned parameters (font family and font modifiers) are -taken from outside context when `\fontdef` is in process. -The result is a "definitive" font switch (internaly declared by `\font` primitive) -which does not respect any other current context when it is used. It means: +Such font switches should be used in `\output` routine (headers, footers) for +example. We need fixed sizes here. But they are less usable in common +text. For example the document includes notices in smaller font. +When the notice is started then we want +to do all variants smaller: `\rm`, `\it`, `\bf`, etc. +It means that the smaller font for notices should be initialized by +`\setfontsize{at9pt}\rm` for example. If you want a \"notices font selector" +then you can do `\def\noticefont{\setfontsize{at9pt}\rm}`. This font +selector does not change the `\baselineskip`. If you want to do this then +put different `\baselineskip` setting to your definition. But you must not +forget that the end of group before `\par` is a typical mistake of \TeX/ +users: the last paragraph is in smaller font but in normal baselineskip, +because `\baselineskip` setting is taken into account when `\par` +command is processed. + +Somewhat more complicated task is the \"title font selector", because titles are +not only bigger but they are typically in bold variant. When the user puts +`{\it...}` into the title then he/she expects bold italic here, no normal +italic. You can remember the great song by John Lennon \"Let It Be" and +define: \begtt -\sizespec{at8pt}\rm small roman font \titlefont bold big font \it italics -small font. +\def\titlefont{\setfontsize{at14pt}\bf \let\it\bi} +... +{\titlefont here we have bold 14pt font and {\it here} was bold 14pt italics} \endtt -Such font switches sould be used in `\output` routine (headers, footers) for -example. But it should be less usable in common text. For example when -`\titlefont` defined above is used for titles, you cannot change a font -variant (to `\it`, for example). So, better idea to declare a "title font" -is to use normal `\def` instead `\fontdef` - +You can declare a new variant slector by the \^`\famvardef` macro. This +macro has similar syntax as \^`\fontdef`: +\begtt \catcode`\<=13 +\famvardef\<new variant selector> {<font modifiers> \<variant selector>} +\endtt +% +The `\<new variant selector>` should be used in the same sense as `\rm`, +`\bf` etc. It can be used as the final command in the +`\fontdef` or `\famvardef` declarators +too. When the `\<new variant selector>` is used in normal text then it does +following steps: pushes current font context to a stack, modifies font +context by declared `<font modifiers>`, runs following `\<variant selector>`. +It selects a font. Then pops the stack. The font context have its original +values but new font is selected. + +The \^`\famvardef` creates the `\<new variant selector>` family dependent. +When the selector is used in another family than it is defined then warning is +printed on the terminal \"<var selector> is undeclared in current family" +and nothing happens. But you can declare the same variant selector by +\^`\famvardef` macro in the context of new family. Then the same command +will be do different work depending on the current font family. + +Suppose that the selected font family provides the font modifier `\medium` for +mediate weight of fonts but supports only basic variant selectors `\rm`, `\bf`, `\it`, +and `\bi`. Then you can declare: \begtt -\def\titlefont{\setfontsize{at14pt}\bf \let\it\bi} % Let it be (John Lennon) -... -{\titlefont here we have bold 14pt font and {\it here} was bold 14pt italics} +\famvardef \mr {\medium\rm} +\famvardef \mi {\medium\it} \endtt +Now, you can use six independent variant selectors `\rm`, `\bf`, `\it`, +`\bi`, `\mr` and `\mi` in the selected font family. -There are four standard variant selectors, but you can declare new variant -selector by `\famvardef` command: +A `\<family selector>` can be written before `<font modifiers>` in the +`\famvardef` parameter. Then the `\<new variant selector>` is declared in +the current family but it can use fonts from another family represented by +the `\<family selector>`. +When you are mixing fonts from more families then you probably run +into problem with incompatible ex-heights. This problem can be solved using +\^`\setfontsize` and \^`\famvardef` macros: \begtt -\famvardef \selector {<font-modifiers> <variant-selector>} +\fontfam[Heros] \fontfam[Termes] + +\def\exhcorr{\setfontsize{mag.88}} +\famvardef\rmsans{\Heros\exhcorr\rm} +\famvardef\itsans{\Heros\exhcorr\rm} + +Compare ex-height of Termes \rmsans with Heros \rm and Termes. \endtt -If such `\selector` is used, then it takes the current context of font family and -font modifiers, opens a group, locally adds the defined font modifiers, -applies variant selector (loads the font now), closes the group but keeps -the selected font and use it. Moreover, such `\selector` is declared as -family-dependent in the same sense as font modifiers. +There exists analogical declarator `\moddef` for declaration family dependent +font modifiers. It is described in detail the section~\ref[fontfamfiles]. -\secc Example of modifying font features -%--------------------------------------- +\secc Modifying font features +%---------------------------- -Each OTF font provides "font features". You can list these font features +Each OTF font provides \"font features". You can list these font features by `otfinfo -f font.otf`. For example LinLibertine fonts provide `frac` font feature. If it is active then fractions like 1/2 are printed in a special form. -The macro `\setff{<feature>}` acts like family independent font modifier and +The font features are part of the font context data. +The macro \^`\setff` `{<feature>}` acts like family independent font modifier and prepares a new <feature>. You must use a variant selector in order to reinitialize the font with the new font feature. For example -`\setff{+frac}\rm` or `\setff{+frac}\currvar`. You can declare a new variant +\^`\setff``{+frac}\rm` or \^`\setff``{+frac}`\^`\currvar`. You can declare a new variant selector too: \begtt @@ -398,48 +586,50 @@ selector too: \endtt If the used font does not supports given font feature then font is realoaded -without warning nor error. Silently: font feature is not activated. +without warning nor error, silently. The font feature is not activated. The `onum` font feature (old style digits) is connected to `\caps` macro for -Caps+SmallCaps variant in \OpTeX/ font-definition-files. So you need not to -create a new modifier, just use `{\caps\currvar 012345}`. +Caps+SmallCaps variant in \OpTeX/ font family files. So you need not to +create a new modifier, just use `{\caps`\^`\currvar`` 012345}`. \secc Special font modifiers %--------------------------- -Despite the font modifiers declared in the font-file (and dependent on -the font family), we have following font modifiers: +Despite the font modifiers declared in the font family file (and dependent on +the font family), we have following font modifiers (independent of font +family): -\begtt -\setfontsize{<sizespec>} % sets the font size -\setff{<font_feature>} % adds the font feature +\begtt \catcode`\<=13 +\setfontsize{<sizespec>} % sets the font size +\setff{<font feature>} % adds the font feature \setfontcolor{<color>} % sets font color -\setletterspace{<number>} % sets letter spacing -\setwordspace{<scaling>} % modifies word spacing +\setletterspace{<number>} % sets letter spacing +\setwordspace{<scaling>} % modifies word spacing \endtt -The `\setfontsize` command is described in section \ref[fontsize]. -The `\setff` command was described in previous subsection. +The \^`\setfontsize` command is described in the section \ref[setfontsize]. +The \^`\setff` command was described in previous subsection. -`\setfontcolor{<color>}` specifies the color and the opacity of the text. +\^`\setfontcolor` `{<color>}` specifies the color and the opacity of the text. The <color> parameter should be in hexadecimal format of four bytes `<red><green><blue><opacity>`, for example `FF0080FF` means full red, zero green, half blue and full opacity. You can use names `red`, `green`, `blue`, -`yellow`, `cyan`, `magenta`, `white`, `grey`, `lgrey` instead of the hexadecimal -specification. The emtpy parameter <color> means default black color. +`yellow`, `cyan`, `magenta`, `white`, `grey`, `lgrey` (without backslash) +instead of the hexadecimal specification. +The empty parameter `<color>` means default black color. That colors of fonts are implemented using \LuaTeX/ internal font feature. This is different approach than using colors in section \ref[colors]. -`\setletterspace{<number>}` specifies letter spacing of the font. The -<number> is decimal number without unit. The unit is supposed as 1/100 of +\^`\setletterspace` `{<number>}` specifies letter spacing of the font. The +`<number>` is decimal number without unit. The unit is supposed as 1/100 of the font size. I.e. `2.5` means 0.25 pt when the font is at 10 pt size. The -empty parameter <num> means no letter spacing which is default. +empty parameter `<number>` means no letter spacing which is default. -`\setwordspace{<scaling>}` scale the default interword space (defined in the -font) and its stretching and shrinking parameters by given <scaling> -factor. For example `\setwordspace{2.5}` multiplies interword space by 2.5. +\^`\setwordspace` `{<scaling>}` scales the default inter word space (defined in the +font) and its stretching and shrinking parameters by given `<scaling>` +factor. For example `\setwordspace{2.5}` multiplies inter word space by 2.5. If you need another font transformations, you can use `\setff` with following font features provided by Lua\TeX/: @@ -450,145 +640,30 @@ with following font features provided by Lua\TeX/: \setff{extend=1.2}\rm % font is extended by a linear transformation. \endtt -Use font transformations mentioned above and `\setletterspace`, -`\setwordspace` with care. The best setting of these values is default +Use font transformations mentioned above and \^`\setletterspace`, +\^`\setwordspace` with care. The best setting of these values is default setting in every font, of course. If you really needs to set a different -letter spacing then it is strongly reccomended to add `\setff{-liga}` in +letter spacing then it is strongly recommended to add `\setff{-liga}` in order to disable ligatures. And setting a positive letter spacing probably -needs to scale interword spacing too. +needs to scale inter word spacing too. All mentioned font modifiers (with the exception of `\setfontsize`) work only -with Unicode fonts loaded by `\fontfam`. +with Unicode fonts loaded by \^`\fontfam`. +\secc[fontfamfiles] How to create the font family file +%------------------------------------------------------ -\secc Example of usage more vaiants -%---------------------------------- +\printdoctail f-heros.opm -Suppose we have load Heros family where \cond font modifier is declared. -Then you can define: +\printdoctail f-lmfonts.opm -\begtt - \famvardef \rmcond {\cond\rm} - \famvardef \bfcond {\cond\bf} - \famvardef \itcond {\cond\it} - \famvardef \bicond {\cond\bi} -\endtt - -Now, you can select between eight variants. But the context between similar -variants like `\bf`--`\bfcond` is lost. Maybe you will find more usefull to -create only a two cond--nocond simple macros which respect the current variant. -And use only four standard variant selectors: - -\begtt - \def\useCond {\cond\currvar} \def\useNormal {\nocond\currvar} - \Heros\rm - here is rm-normal \bf here is bold-normal \useCond here is bold-condensed - \it here is italics-condensed \useNormal here is italics-normal. -\endtt - -Another example of decalaration of `\mr` (medium-regular) and `\mi` -(medium-italics) variant selectors is in the file f-lido.opm. - - -\secc Example of usage more than one family -%------------------------------------------ +\secc How to register the font family in the Font Selection System +%--------------------------------------------------------------- -Supose we have load Termes and Heros families. Then you can define - -\begtt - \def\useTermes {\Termes\currvar} % switch to Termes with respect current variant - \def\useHeros {\Heros\currvar} % switch to Heros with respect curent variant -\endtt - -Or you can declare font selectors: - -\begtt - \fontdef \titlefont {\setfontsize{at14pt}\Heros\bf} - \times\rm ..... normal text in Times - \titlefont .... Titles in Heros. -\endtt - -If you are mixing fonts from various font families then the ex height can -be different and optical unfit. You can compensate exheight of such fonts -by `mag` keyword in the `\setfontsize` macro. For example by: - -\begtt - \Termes - \famvardef \sansfont {\setfontsize{mag.9}\Heros\currvar} - \rm here is text in Termes \sansfont and text in Heros with compatible ex-height. -\endtt - - -\secc \code{\\fontfam} processing in detail -%------------------------------------------ - -The `\fontfam` macro lists all declared families if parameter is empty or -`?`. If not, then `\fontfam` transforms the given parameter to lowercase and -without spaces. If exists the file `f-<parameter>.opm` then it is read. If -does not exists such file then `\fontfam` internally lists the families -declared by `\_faminfo` and `\_famalias`, firstly from `fams-ini.opm` file -and secondly from `fams-local.opm` (if such file exists). The last -declaration from this internal list (which mathes the given <parameter>) -wins. If the parameter does not match then font-macro-file is not found and -the warning is printed and no new family is loaded. - -When the font-macro-file is found, then `\fontfam` tries an existence of fonts in the -system. If they does not exist, a warning on the terminal is printed and no -family is loaded. - -Note, that `fams-local.opm` has higher precedence that internal -`fams-ini.file`. You can declare families with the same name as internal -names and your declaration wins. - - -\secc Others - -You can use `\isfont {<fontname>}\iftrue` or `\isfont {<fontname>}\iffalse` -to test if the specified font is present in your system. - -The macro `\initunifonts` should be used before usage of first `\font` primitive -when you need to lodad Unicode fonts directly wihout support of the `\fontfam` or -`\loadmath` \"high level" macros\fnote -{The `\initunifonts` macro initializes an extension features of the -\code{\\font} primitive using Lua code. Without this only 8\,bit fonts can be -loaded.}. - -The `\boldify` macro can be used for titles. It sets `\it` to `\bi` and -`\rm` to `\bf`. It means that user can write `{\it something}` in the title -and the result is the same as `{\bi something}`. Math formulae are in bold -variant too. The `\boldify` macro has local validity like others font -modifiers. Example: - -\begtt -{\boldify\typosize[14/16] Title in {\it bold}\par} -\endtt - - - -\secc Implementation notes -%------------------------- - -TODO ... - -The family-dependend macros are declared by \moddef and \famvardef. The -following trick is used: - -\begtt - \protected\def\macro{\_famdepend\macro{_f:\_currfamily:macro}}% - \sdef{_f:currfamily:macro}{... definition body ...}% -\endtt - -The `\_famdepend\macro{csname}` runs `\csname` if it is defined else it writes -a warning. - -If you want to declare macros wit the same feature but wit a parameter, for -example, you have to do: - -\begtt - \protected\def\macro{\famdepend\macro{_f:\_currfamily:macro}}% - \sdef{_f:currfamily:macro}#1{... definition body ...}% -\endtt +\printdoctail fams-ini.opm -Of course, you must to do some `\edef...\noexpand` tricks but this is an -implementation detail. +\endinput +2020-04-18 \_tryloadfamslocal introduced + \_fontdecl -> \_famdecl with different concept +2020-03-18 released diff --git a/Master/texmf-dist/tex/luatex/optex/graphics.opm b/Master/texmf-dist/tex/luatex/optex/graphics.opm index 92a1a7a804f..bf83817b91d 100644 --- a/Master/texmf-dist/tex/luatex/optex/graphics.opm +++ b/Master/texmf-dist/tex/luatex/optex/graphics.opm @@ -1,18 +1,18 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \inspic {Graphics <2020-03-29>} % preloaded in format +\_codedecl \inspic {Graphics <2020-04-12>} % preloaded in format \_doc ----------------------------- - `\inspic` accepts old syntax `\inspic <filename><space>` + \`\inspic` accepts old syntax `\inspic <filename><space>` or new syntax `\inspic{<filename>}`. So, we need to define - two auxiliary macros `\_inspicA` and `\_inspicB`. + two auxiliary macros \`\_inspicA` and \`\_inspicB`. You can include more `\pdfximage` parameters (like `page<number>`) - in the `\_picparams` macro. + in the \`\_picparams` macro. All `\inspic` macros are surrounded in `\hbox` in order user can write `\moveright\inspic ...` or something similar. - \_cod \_fin ----------------------- + \_cod ----------------------------- \_def\_inspic{\_hbox\_bgroup\_isnextchar\_bgroup\_inspicB\_inspicA} \_def\_inspicA #1 {\_inspicB {#1}} @@ -27,13 +27,13 @@ \_public \inspic ; \_doc ----------------------------- - Inkscape is able to save a picture to `*.pdf` file and labels for the ficture - to `*.pdf_tex` file. The second file is in \LaTeX/ format and it is intended to read - immediately it after `*.pdf` in included in order to place labels of this ficture in - the same font as document is printed. - We need to read this \LaTeX/ file by plain \TeX/ macros when `\inkinspic` is used. - These macros are stored in the `\_inkdefs` toknes list and it is used - localy in the group. The solution is borrowed from OPmac trick 0032. + Inkscape is able to save a picture to `*.pdf` file and labels for the picture + to `*.pdf_tex` file. The second file is in \LaTeX/ format (unfortunately) + and it is intended to read immediately it after `*.pdf` in included + in order to place labels of this ficture in the same font as document is printed. + We need to read this \LaTeX/ file by plain \TeX/ macros when \`\inkinspic` is used. + These macros are stored in the \`\_inkdefs` toknes list and it is used + locally in the group. The solution is borrowed from OPmac trick 0032. \_cod ----------------------------- \_def\_inkinspic{\_hbox\_bgroup\_isnextchar\_bgroup\_inkinspicB\_inkinspicA} @@ -67,9 +67,10 @@ \_public \inkinspic ; \_doc ---------------------------- - `\pdfscale` and `\pdfrotate` macros are implemented by `\pdfsetmatrix` - primitive. or rotating we need to knos values of sin, cos function. - We use Lua code for this. + \`\pdfscale``{<x-scale>}{<y-scale>}` and \`\pdfrotate``{<degrees>}` + macros are implemented by `\pdfsetmatrix` + primitive. We need to know values of sin, cos function in + the `\pdfrotate`. We use Lua code for this. \_cod ---------------------------- \_def\_pdfscale#1#2{\_pdfsetmatrix{#1 0 0 #2}} @@ -85,10 +86,12 @@ \_public \pdfscale \pdfrotate ; \_doc ----------------------------- - The `\transformbox` is copied from OPmac trick 0046. The `\rotbox` is a - combination of `\rotsimple` from OPmac trick 0101 and `\transformbox`. + The \`\transformbox``{<transformation>}{<text>}` + is copied from OPmac trick 0046.\nl + The \`\rotbox``{<degrees>}{<text>}` is a combination of + `\rotsimple` from OPmac trick 0101 and the `\transformbox`. Note, that `\rotbox{-90}` puts the rotated text to the height of the outer - box (depth is zero) because code from `\rotsimple` is precessed. + box (depth is zero) because code from `\rotsimple` is processed. But `\rotbox{-90.0}` puts the rotated text to the depth of the outer box (height is zero) because `\transformbox` is processed. @@ -143,17 +146,20 @@ \_public \transformbox \rotbox ; \_doc --------------------------- - The `\_scantwodimens` scans two objects with the syntactic rule <dimen> - and returns `{<number>}{<number>}` in sp unit. - - The `\puttext <right> <up>{<text>}` puts the <text> to desired place: + \`\_scantwodimens` scans two objects with the syntactic rule `<dimen>` + and returns `{<number>}{<number>}` in `sp` unit. + \nl + \`\puttext` `<right> <up>{<text>}` puts the `<text>` to desired place: From current point moves <down> and <right>, puts the <text> and returns - back. The cuuren tpoint is unchanged after this macro ends. - - The `\putpic <right> <up> <width> <height> {<image-file>}` + back. The current point is unchanged after this macro ends. + \nl + \`\putpic` `<right> <up> <width> <height> {<image-file>}` does `\puttext` with the image scaled to desired <width> and <height>. If <with> or <height> is zero, natural dimension is used. - The `\nospec` is a shortcut to such natural dimension. + The \`\nospec` is a shortcut to such natural dimension. + \nl + \`\backgroundpic``{<image-file>}` puts the image to + the background of each page. It it used in the slides style, for example. \_cod --------------------------- \_def\_scantwodimens{% @@ -184,32 +190,14 @@ \_public \puttext \putpic \backgroundpic ; \_doc ----------------------------- - You can use expandable `\_bp{<dimen>}` convertor from - \TeX/ `<dimen>` (or from an expression accepted by - `\dimexpr` primitive) to a decimal value in big points - (used as natural unit in the PDF format). So, you can write, for example: - \begtt - \pdfliteral{q \_bp{.3\hsize-2mm} \_bp{2mm} m 0 \_bp{-4mm} l S Q} - \endtt - You can use expandable `\_expr{<expression>}` for analogical purposes. - The `<expression>` can include `+-*/()` and decimal numbers in common syntax. - \_cod ----------------------------- - -\_def\_decdigits{3} % digits after decimal point in \_bp and \_expr outputs. -\_def\_pttopb{% - \_directlua{tex.print(string.format('\_pcent.\_decdigits f', - token.scan_dimen()/65781.76))}% pt to bp conversion -} -\def\_bp#1{\_ea\_pttopb\_dimexpr#1\_relax} -\def\_expr#1{\_directlua{tex.print(string.format('\_pcent.\_decdigits f',#1))}} - - \_doc ----------------------------- - `\)circle<x><y>` creates an ellipse with `<x>` axis and `<y>` axix. + \`\_circle``{<x>}{<y>}` creates an ellipse with `<x>` axis and `<y>` axix. The origin is in the center. - `\_oval<x><y><roudness>` creates an oval with `<x>`, `<y>` size and with + \nl + \`\_oval``{<x>}{<y>}{<roudness>}` creates an oval with `<x>`, `<y>` size and with given `<roundness>`. The real size is bigger by 2`<roundness>`. The - orgigin is at the left bottom corner. - `\_mv<x><y>{<curve>}` moves current point to `<x>`, `<y>`, crates the + origin is at the left bottom corner. + \nl + \`\_mv``{<x>}{<y>}{<curve>}` moves current point to `<x>`, `<y>`, crates the `<curve>` and retuns back the current point. All these macros are fully expandable and they can be used in the `\pdfliteral` argument. @@ -236,8 +224,14 @@ \def\_mv#1#2#3{1 0 0 1 \_expr{#1} \_expr{#2} cm #3 1 0 0 1 \_expr{-(#1)} \_expr{-(#2)} cm} \_doc ----------------------------- - The `\inoval` is an example of `\_oval` usage. - The `\incircle` is an example of `\_circle` usage. + The \`\inoval``{<text>}` is an example of \^`\_oval` usage.\nl + The \`\incircle``{<text>}` is an example of \^`\_circle` usage.\nl + The \`\ratio`, \`\lwidth`, \`\fcolor`, \`\lcolor`, \`\shadow` and \`\overlapmargins` + are parameters, they can be set by user in optional brackets `[...]`. + For example `\fcolor=\Red` does `\_let\_fcolorvalue=\Red` and it means + filling color.\nl + The \`\_setflcolor` uses the \^`\_fillstroke` macro to separate filling + color and drawing color. \_cod ----------------------------- \_newdimen \_lwidth @@ -256,7 +250,6 @@ \_def\_fillstroke##1##2{##2}% \_edef#1{#1\_space\_lcolorvalue\_space}% } - \_optdef\_inoval[]{\_vbox\_bgroup \_roundness=2pt \_fcolor=\Yellow \_lcolor=\Red \_lwidth=.5bp \_shadow=N \_overlapmargins=N \_hhkern=0pt \_vvkern=0pt @@ -322,15 +315,14 @@ } \_def\_circlet#1#2#3{\_circle{#1}{#2}} -\_public - \inoval \incircle \ratio \lwidth \fcolor \lcolor \shadow \overlapmargins ; +\_public \inoval \incircle \ratio \lwidth \fcolor \lcolor \shadow \overlapmargins ; \_doc ----------------------------- A shadow effect is implemented here. The shadow is equal to the silhouette of the given path in gray-transparent color shifted by - `\shadowmoveto` vector and with blurred boundary. - A waistline with the width 2*`\shadowb` around the boundary is blurred. - The `\shadowlevels` levels of transparent shapes is used for creating + \`\_shadowmoveto` vector and with blurred boundary. + A waistline with the width 2*\`\_shadowb` around the boundary is blurred. + The \`\shadowlevels` levels of transparent shapes is used for creating this effect. The `\shadowlevels+1/2` level is equal to the shifted given path. \_cod ----------------------------- @@ -342,9 +334,9 @@ \_doc ----------------------------- The `\_pdfpageresources` primitive is used to define transparency. - It does not work when used in a box. So, we use it at begining of - output routine. The modification of output routine is done only once - when the shadow effect is used first. + It does not work when used in a box. So, we use it at the begining of + the output routine. The modification of the output routine is done + using \`\_insertshadowresources` only once when the shadow effect is used first. \_cod ----------------------------- \_def\_insertshadowresources{% @@ -359,6 +351,11 @@ }% \_global\_let\_insertshadowresources=\_relax } + + \_doc ----------------------------- + The \`\_doshadow``{<curve>}` does the shadow effect. + \_cod ----------------------------- + \_def\_doshadow#1{\_vbox{% \_insertshadowresources \_tmpnum=\_numexpr (\_shadowlevels-1)/2 \_relax @@ -383,12 +380,12 @@ }} \_doc ----------------------------- - A generic macro `\clipinpath{<x>}{<y>}{<curve>}{<text>}` declares - a clipping path by <curve> shifted by <x>, <y>. The <text> is typesset + A generic macro \`\_clipinpath``<x> <y> <curve> <text>` declares + a clipping path by the `<curve>` shifted by the `<x>`, `<y>`. The `<text>` is typeset when such clipping path is active. Dimensions are given by bp without the unit here. - Macros `\clipinoval <x> <y> <width> <height> {<text>}` and - `\clipincircle <x> <y> <width> <height> {<text>}` are defined here. - These marcos read normal \TeX/ dimensions in their parameters. + The macros \`\clipinoval` `<x> <y> <width> <height> {<text>}` and + \`\clipincircle` `<x> <y> <width> <height> {<text>}` are defined here. + These macros read normal \TeX/ dimensions in their parameters. \_cod ----------------------------- \_def\_clipinpath#1#2#3#4{% #1=x-pos[bp], #2=y-pos[bp], #3=curve, #4=text @@ -417,6 +414,10 @@ \_def\_clipincircleB#1#2{% \_ea\_clipinpath\_tmp{\_circle{#1/65781.76}{#2/65781.76}}% } +\_public \clipinoval \clipincircle ; + \_endcode % ------------------------------------- +2020-04-12: \_public \clipinoval \clipincircle ; added, bug fixed + diff --git a/Master/texmf-dist/tex/luatex/optex/hi-syntax.opm b/Master/texmf-dist/tex/luatex/optex/hi-syntax.opm new file mode 100644 index 00000000000..d7a3c4d17f5 --- /dev/null +++ b/Master/texmf-dist/tex/luatex/optex/hi-syntax.opm @@ -0,0 +1,223 @@ +%% This is part of OpTeX project, see http://petr.olsak.net/optex + +\_codedecl \hisyntax {Syntax highlithing of verbatim listings <2020-04-04>} % preloaded in format + + \_doc ----------------------------- + The following macros `\replfromto` and `\replthis` manipulate with the + verbatim text which has been read already and stored in the `\_tmpb` macro. + + The \`\replfromto` `{<from>}{<to>}{<what>}` finds first `<from>` then the + first `<to>` following by `<from>` pattern and the + `<text>` between them is packed to `#1`. + Then `<from><text><to>` is replaced by `<what>`. The `<what>` parameter + can use `#1` which is replaced by the `<text>`. + + The `\replfromto` continues by finding next `<from>`, then, next `<to>` + repeatedly over the whole verbatim text. If the verbatim text is ended by + opened `<from>` but not closing by `<to>` then `<to>` is appended to the + verbatim text automatically and the last part of verbatim text is replaced too. + + First two parameters are expanded before usage of `\replfromto`. You can + use `\csstring\%` or something else here. + \_cod ----------------------------- + +\_def\_replfromto #1#2{\_edef\_tmpa{{#1}{#2}}\_ea\_replfromtoE\_tmpa} +\_def\_replfromtoE#1#2#3{% #1=from #2=to #3=what to replace + \_def\_replfrom##1#1##2{\_addto\_tmpb{##1}% + \_ifx\_end##2\_ea\_replstop \_else \_afterfi{\_replto##2}\_fi}% + \_def\_replto##1#2##2{% + \_ifx\_end##2\_afterfi{\_replfin##1}\_else + \_addto\_tmpb{#3}% + \_afterfi{\_replfrom##2}\_fi}% + \_def\_replfin##1#1\_end{\_addto\_tmpb{#3}\_replstop}% + \_edef\_tmpb{\_ea}\_ea\_replfrom\_tmpb#1\_end#2\_end\_end\_relax +} +\_def\_replstop#1\_end\_relax{} +\_def\_finrepl{} + + \_doc ----------------------------- + The \`\replthis` `{<pattern>}{<what>}` replaces each `<pattern>` by `<what>`. + Both parameters of `\replthis` are expanded first. + \_cod ----------------------------- + +\_def\_replthis#1#2{\_edef\_tmpa{{#1}{#2}}\_ea\_replstring\_ea\_tmpb \_tmpa} + +\_public \replfromto \replthis ; + + \_doc ----------------------------- + The patterns `<from>`, `<to>` and `<pattern>` are not found when they are + hidden in braces `{...}`. Example: + \begtt + \replfromto{/*}{*/}{\x C{/*#1/*}} + \endtt + replaces all C comments by `\x C{...}`. The patterns inside `{...}` are + not used by next usage of `\replfromto` or `\replthis` macros. + + The \`\_xscan` macro does replacing `\x` by `\z` in the post-processing + phase. The `\x <letter>{<text>}` expands to `\_xscan {<letter>}<text>^^J^`. + If `#3` is `\_end` then it signals that something wrong happens, the + `<from>` was not terminated by legal `<to>` when `\replfromto` did work. + We must to fix it by the \`\_xscanR` macro. + \_cod ----------------------------- + +\_def\_xscan#1#2^^J#3{\_ifx\_end#3 \_ea\_xscanR\_fi + \z{#1}{#2}% + \_ifx^#3\_else ^^J\_afterfi{\_xscan{#1}#3}\_fi} +\_def\_xscanR#1\_fi#2^{^^J} + + \_doc ----------------------------- + The \`\hicolor` `<letter> <color>` defines `\_z<letter>{<text>}` + as `{<color><text>}`. It should be used in the context of + `\x <letter>{<text>}` macros. + \_cod ----------------------------- + +\_def\_hicolor #1#2{\_sdef{_z:#1}##1{{#2##1}}} + + \_doc ----------------------------- + The \`\hisyntax``{<name>}` re-defines default \^`\_prepareverbdata``<macro><verbtext>` + in order to it does more things: + It saves `<verbtext>` to `\_tmpb`, appends `\n` around spaces and + `^^J` characters in pre-processing phase, it opens `hisyntax-<name>.opm` + file if `\_hisyntax<name>` is not defined. Then `\_the\_isyntax<name>` + is processed. Finally, the post-processing phase is realized by setting + appropriate values to `\x` and `\y` macros and doing + `\_edef\_tmpb{\_tmpb}`. + \_cod ----------------------------- + +\_def\_hisyntax#1{\_def\_prepareverbdata##1##2{% + \_let\n=\relax \_def\t{\n\noexpand\t\n}\_let\_start=\_relax + \_adef{ }{\n\ \n}\_edef\_tmpb{\_start^^J##2\_end}% + \_replthis{^^J}{\n^^J\n}\_replthis{\n\_end}{\_end}% + \_let\x=\_relax \_let\y=\_relax \_let\z=\_relax \_let\t=\_relax + \_endlinechar=`\^^M + \_lowercase{\_def\_tmpa{#1}}% + \_ifcsname _hialias:\_tmpa\_endcsname \_edef\_tmpa{\_cs{_hialias:\_tmpa}}\_fi + \_ifx\_tmpa\_empty \_else + \_unless \_ifcsname _hisyntax\_tmpa\_endcsname + \_isfile{hisyntax-\_tmpa.opm}\_iftrue \_opinput {hisyntax-\_tmpa.opm} \_fi\_fi + \_ifcsname _hisyntax\_tmpa\_endcsname + \_ifcsname hicolors\_tmpa\endcsname + \_cs{_hicolors\_tmpa}=\_cs{hicolors\_tmpa}% + \_else + \_if^\_the\_hicolors^\_else + \_ifcsname _hicolors\_tmpa\_endcsname + \_global\_cs{_hicolors\_tmpa}=\_hicolors \_global\_hicolors={}% + \_fi\_fi\_fi + \_ea\_the \_csname _hisyntax\_tmpa\_endcsname % \_the\_hisyntax<name> + \_else\_opwarning{Syntax highlighting "\_tmpa" undeclared (no file hisyntax-\_tmpa.opm)} + \_fi\_fi + \_replthis{\_start\n^^J}{}\_replthis{^^J\_end}{^^J}% + \_def\n{}% + \_def\x####1####2{\_xscan{####1}####2^^J^}% + \_def\y####1{\_ea \_noexpand \_csname ####1\_endcsname}% + \_edef\_tmpb{\_tmpb}% + \_def\z####1{\_cs{_z:####1}}% + \_def\t{\_hskip \_dimexpr\_tabspaces em/2\_relax}% + \_localcolor +}} +\_public \hisyntax \hicolor ; + + \_doc ----------------------------- + Aliases for languages can be declared like this. + When `\hisyntax{xml}` is used then this is the same as `\hisyntax{html}`. + \_cod ----------------------------- + +\_sdef{_hialias:xml}{html} +\_sdef{_hialias:json}{c} + +\_endcode % ------------------------------------------- + +The user can write + +\begtt \adef/{\_csstring\\} +\begtt \hisytnax{C} +... +/endtt +\endtt +and the code is colorized by C syntax. +The user can write `\everytt={\hisyntax{C}}` and all verbatim listings are +colorized. + +The \^`\hisyntax``{<name>}` reads the file `hisyntax-<name>.opm` where the +colorization is declared. The parameter `<name>` is case insensitive and the +file name must include it in lowercase letters. For example the file +`hisyntax-c.opm` looks like: + +\printdoc hisyntax-c.opm + +\OpTeX/ provides `hisyntax-{c,python,tex,html}.opm` files. +You can take inspiration from these files and declare more languages. + +User can re-declare colors by `\hicolors={...}` This value has precedence +before `\_hicolors<name>` values declared in the `hicolors-<name>.opm` file. +What exactly to do: copy `\_hicolors<name>={...}` +from `hicolors-<name>.opm` to your document, +rename it as `\hicolors={...}` and do you own colors modifications. + +Another way to set non-default colors is to declare +`\newtoks\hicolors<name>` (without the `_` prefix) and set the colors palette here. +It has precedence before `\_hicolors<name>` (with the `_` prefix) declared in +the `hicolors-<name>.opm` file. +This is useful when there are more hi-syntax languages used in one document. + +\medskip +\noindent{\bf Notes for hi-syntax macro writers} + +The file `hisyntax-<name>.opm` is read only once in the \TeX/ group. +If there are definitions then they must be declared as global. + +The `hisyntax-<name>.opm` file must (globally) declare `\_hisyntax<name>` tokens string +where the action over verbatim text is declared typically by `\replfromto` or +`\replthis` macros. + +The verbatim text is preparared by {\em pre-processing phase}, then the +`\_hisyntax<name>` is applied and then {\em post-processing phase} does final +corrections. Finally, the verbatim text is printed line by line. + +The pre-processing phase does: + +\begitems +* Each space is replaced by {\visiblesp`\n\ \n`}, so `\n<word>\n` should be a pattern to + finding whole words (no subwords). The `\n` control sequence is removed in + the post-processing phase. +* Each end of line is repersented by `\n^^J\n`. +* The `\_start` control sequence is added before the verbatim text and `\_end` control + sequence is appended to the end of the verbatim text. These control + sequences are removed in post-processing phase. +\enditems + +There are special macros working only in a group when processing the verbatim +text. + + +\begitems +* `\n` means noting but it should be used as a boundary of words as mentioned above. +* `\t` means a tabelator. It is prepared as `\n\t\n` because it can be at + the boundary of a word. +* `\x <letter>{<text>}` can be used as replacing text. Suppose the example + \begtt + \replfromto{/*}{*/}{\x C{/*#1*/}} + \endtt + This replaces all C comments `/*...*/` by `\x C{/*...*/}`. But the + C comments may span more lines, i.e. the `^^J` should be inside it. + + The macro `\x <letter>{<text>}` is replaced by one or more + `\z <letter>{<text>}` in post-processing phase where each parameter `<text>` of + `\z` keeps inside one line. Inside-line parameters are represented + by `\x C{<text>}` and they are replaced to `\z C{<text>}` without any change. + But: + \begtt \catcode`\<=13 + \x C{<text1>^^J<text3>^^J<text3>} + is replaced by + \z C{<text1>}^^J\z C{<text2>}^^J\z C{<text3>} + \endtt + The `\z <letter>{<text>}` is expanded to `\_z:<letter>{<text>}` and if + `\hicolor <letter> <color>` is declared then + `\_z:<letter>{<text>}` expands to `{<color><text>}`. So, required color is + activated at all lines (separatelly) where C comment spans. +* `\y {<text>}` is replaced by `\<text>` in the post processing phase. It should + be used for macros without a parameter. You cannot use unprotected macros + as replacement text before the post-processing phase, because the post-processing + phase is based on expansion whole verbatim text. +\enditems + diff --git a/Master/texmf-dist/tex/luatex/optex/hisyntax-c.opm b/Master/texmf-dist/tex/luatex/optex/hisyntax-c.opm new file mode 100644 index 00000000000..fa1b9e641e8 --- /dev/null +++ b/Master/texmf-dist/tex/luatex/optex/hisyntax-c.opm @@ -0,0 +1,66 @@ +%% This is part of OpTeX project, see http://petr.olsak.net/optex + +\_codedecl \_hisyntaxc {Syntax highlighting for C sources <2020-04-03>} + +\_newtoks \_hisyntaxc \_newtoks \_hicolorsc + +\_global\_hicolorsc={% colors for C language + \_hicolor K \Red % Keywords + \_hicolor S \Magenta % Strings + \_hicolor C \Green % Comments + \_hicolor N \Cyan % Numbers + \_hicolor P \Blue % Preprocessor + \_hicolor O \Blue % Non-letters +} +\_global\_hisyntaxc={% + \_the\_hicolorsc + \_let\c=\_relax \_let\e=\_relax \let\o=\_relax + \_replfromto {/*}{*/} {\x C{/*#1*/}}% /*...*/ + \_replfromto {//}{^^J} {\z C{//#1}^^J}% //... + \_replfromto {\_string#}{^^J} {\z P{\##1}^^J}% #include ... + \_replthis {\_string\"} {{\_string\"}}% \" protected inside strings + \_replfromto {"}{"} {\x S{"#1"}}% "..." + % + \_edef\_tmpa {()\_string{\_string}+-*/=[]<>,:;\_pcent\_string&\_string^|!?}% non-letters + \ea \_foreach \_tmpa + \_do {\replthis{#1}{\n\o#1\n}} + \_foreach % keywords + {auto}{break}{case}{char}{continue}{default}{do}{double}% + {else}{entry}{enum}{extern}{float}{for}{goto}{if}{int}{long}{register}% + {return}{short}{sizeof}{static}{struct}{switch}{typedef}{union}% + {unsigned}{void}{while} + \_do {\replthis{\n#1\n}{\z K{#1}}} + \_replthis{.}{\n.\n} % numbers + \_foreach 0123456789 + \_do {\replfromto{\n#1}{\n}{\c#1##1\e}} + \_replthis{\e.\c}{.} + \_replthis{\e.\n}{.\e} + \_replthis{\n.\c}{\c.} + \_replthis{e\e\o+\c}{e+}\_replthis{e\e\o-\c}{e-} + \_replthis{E\e\o+\c}{E+}\_replthis{E\e\o-\c}{E-} + \def\o#1{\z O{#1}} + \def\c#1\e{\z N{#1}} +} + +\_endcode %------------------------------------------------ + + +Each `hisyntax-<name>.opm` file must declare the token list +`\_hisyntax<name>` using `\newtoks` and must ceclare the syntax declaration +in it. The second cotken list `\_hicolors<name>` is optional but recommended. +User can re-declare his/her own colors by `\hicolors` which has precedence +before `\_hicolors<name>`. + +The public variants can be deacred if you want to give these token lists to +the user name space. But it is not explicitly needed. + +All settings must be global here, because the file is typically read inside +a group and we need not to read it repeatedly in before each code chunk +again and again. + +Note that `\foreach` is used to each non-letters (expanded via \string +because we needn't to treate with active or special TeX characters). The +keyword are applied in the `\foreach` loop too. + +See `hi-sytax.opm` for more information about `\hicolor`, `\replfromto` and +`\replthis` macros. diff --git a/Master/texmf-dist/tex/luatex/optex/hisyntax-html.opm b/Master/texmf-dist/tex/luatex/optex/hisyntax-html.opm new file mode 100644 index 00000000000..f34aafe66f2 --- /dev/null +++ b/Master/texmf-dist/tex/luatex/optex/hisyntax-html.opm @@ -0,0 +1,31 @@ +%% This is part of OpTeX project, see http://petr.olsak.net/optex + +\_codedecl\_hisyntaxhtml {Syntax highlighting for html or xml sources <2020-04-03>} + +\_newtoks\_hisyntaxhtml \_newtoks\_hicolorshtml + +\_global\_hicolorshtml={% colors in html codes + \_hicolor A \Cyan % <, > and parameters + \_hicolor T \Red % tag names + \_hicolor C \Green % comments + \_hicolor E \Blue % HTML entities + \_hicolor S \Magenta % strings in parameters +} +\_global\_hisyntaxhtml={ + \_the\_hicolorshtml + \_replfromto{<!--}{-->}{\x C{<!--#1-->}} + \_replthis{<}{\y{_hitaghtml}} + \_replthis{\_string&}{\y{_hientityhtml}} +} +\_gdef\_hitaghtml#1>{\_hitaghtmlA#1\ >} +\_gdef\_hitaghtmlA#1\ #2>{\z A{<}\z T{#1}\_def\_tmpb{#2^}% + \_if^\_tmpb + \_else \_space + \_replthis{\ ^}{}\_replfromto{"}{"}{\_histringhtml{"##1"}}\z A{\_tmpb}\_fi + \z A{>}% +} +\_gdef\_histringhtml#1{\_visiblesp \z S{#1}} +\_gdef\_hientityhtml#1;{\z E{\}} + +\_endcode %------------------------------------------------ + diff --git a/Master/texmf-dist/tex/luatex/optex/hisyntax-python.opm b/Master/texmf-dist/tex/luatex/optex/hisyntax-python.opm new file mode 100644 index 00000000000..6ee63685af8 --- /dev/null +++ b/Master/texmf-dist/tex/luatex/optex/hisyntax-python.opm @@ -0,0 +1,82 @@ +%% This is part of OpTeX project, see http://petr.olsak.net/optex + +\_codedecl \_hisyntaxpython {Syntax highlighting for Python sources <2020-04-04>} + +\_newtoks \_hisyntaxpython \_newtoks \_hicolorspython + +\_global\_hicolorspython={% colors for Python language + \_hicolor M \Orange % Multi line strings + \_hicolor S {\_visiblesp \Grey} % Single line strings + \_hicolor C \Green % Comments + \_hicolor K \LightBlue % Keywords + \_hicolor O \Blue % Operators + \_hicolor N \Red % Numbers + \_hicolor D \Magenta % def names + \_hicolor L \Black % class names + \_hicolor R \Magenta % Decorators +} +\_global\_hisyntaxpython={% + \_the\_hicolorspython + \_let\s=\_relax \_let\c=\_relax \_let\e=\_relax \let\o=\_relax + \_replthis{\_string\"}{{\_string\"}} % protect \", \' + \_replthis{\_string\'}{{\_string\'}} + % + \_replfromto{\string#}{^^J}{\z C{\##1}^^J} % comments + % + \_replthis{'''}{\_noexpand\_hipystr0{'''}M} % search string marks + \_replthis{"""}{\_noexpand\_hipystr1{"""}M} + \_replthis{"}{\_noexpand\_hipystr2{"}S} + \_replthis{'}{\_noexpand\_hipystr3{'}S} + \_edef\_tmpb{\_tmpb} % realize string marks + % + \_foreach {br}{Br}{bR}{BR}{rb}{rB}{Rb}{RB}uUrRbB % string prefixes + \_do {\_replthis{#1\s}{\_noexpand\_hipystrpre#1}} + \_def\s{} + \_edef\_tmpb{\_tmpb} + % + \_edef \_tmpa {+-*./=<>()[]:,;!|\_pcent % operators + \_string{\_string}@\_string&\_string~\_string^} + \_ea\_foreach \_tmpa + \_do {\_replthis{#1}{\n\o#1\n}} + % + \_foreach % keywords + {and}{as}{assert}{async}{await}{break}{continue}{del}{elif}{else}{except}% + {exec}{False}{finally}{for}{from}{global}{if}{import}{in}{is}{lambda}{None}% + {nonlocal}{not}{or}{pass}{print}{raise}{return}{True}{try}{while}{with}{yield}% + \_do {\replthis{\n#1\n}{\z K{#1}}} + \_replfromto{\n def\n}{\n\o(\n}{\z K{def}\x D{#1}\n\o(\n} + \_replfromto{\n class\n}{\n\o(\n}{\z K{class}\x L{#1}\n\o(\n} + % + \_foreach 0123456789 % numbers + \_do {\_replfromto{\n#1}{\n}{\c#1##1\e}} + % + \_replthis{\e\o.\c}{.} + \_replthis{\e\o.\n}{.\e} + \_replthis{\n\o.\c}{\c.} + \_replthis{e\e\o+\c}{e+}\_replthis{e\e\o-\c}{e-} + \_replthis{E\e\o+\c}{E+}\_replthis{E\e\o-\c}{E-} + \_replthis{\e j}{j\e} + % + \_replfromto{\n\o@\n}{^^J}{\z R{#1}^^J} % decorators + % + \def\o#1{\z O{#1}} + \def\c#1\e{\z N{#1}} +} + +\_gdef\_hipystr#1#2#3#4\_hipystr#5#6#7{% + \_ifx#1#5\s\x#3{#2#4#2}% + \_else \_afterfi{\_hipystr#1{#2}#3#4#6}\_fi +} +\_gdef\_hipystrpre#1\x#2{\x#2{#1}\x#2} + +\_ifx\LightBlue\_undefined \_gdef\LightBlue {\_setcmykcolor{1 0.43 0 0}}\_fi +\_ifx\Orange\_undefine \_gdef\Orange {\setcmykcolor{0 0.64 1 0}}\_fi + +\_endcode %------------------------------------------------ + +This code was greatly inspired by the OPMac hisyntax macros for Python: + + https://gitlab.fit.cvut.cz/krajnpet/PySyntax + +created by Petr Krajnik. + diff --git a/Master/texmf-dist/tex/luatex/optex/hisyntax-tex.opm b/Master/texmf-dist/tex/luatex/optex/hisyntax-tex.opm new file mode 100644 index 00000000000..afa09ca8219 --- /dev/null +++ b/Master/texmf-dist/tex/luatex/optex/hisyntax-tex.opm @@ -0,0 +1,38 @@ +%% This is part of OpTeX project, see http://petr.olsak.net/optex + +\_codedecl\_hisyntaxtex {Syntax highlighting for TeX sources <2020-04-03>} + +\_newtoks\_hisyntaxtex \_newtoks\_hicolorstex + +\_global\_hicolorstex={% colors in TeX codes + \_hicolor S \Blue % control sequences + \_hicolor B \Magenta % {, }, $ + \_hicolor C \Green % comments +} +\_global\_hisyntaxtex={ + \_the\_hicolorstex + \_replthis{\_string\%}{\y{_createcs}{\_csstring\%}} + \_replfromto{\_csstring\%}{^^J}{\x C{\_csstring\%#1}^^J} + \_replthis{\_string\\}{\y{_createcs}{\_csstring\\}} + \_replthis{\_string\{}{\y{_createcs}{\_csstring\{}} + \_replthis{\_string\}}{\y{_createcs}{\_csstring\}}} + \_replthis{\_string\$}{\y{_createcs}{\_csstring\$}} + \_replthis{\_csstring\\}{\y{_createcs}} + \_replthis{\_csstring\{}{\x B{\_csstring\{}} + \_replthis{\_csstring\}}{\x B{\_csstring\}}} + \_replthis{\_csstring\$}{\x B{\_csstring\$}} +} +\_gdef\_createcs#1{\_def\_csletters{#1}% + \_ifcat a\_noexpand#1\_afterfi{\_futurelet\_next\_createcsA}% + \_else \_ea\_createcsF \_fi +} +\_gdef\_createcsA{\ifcat a\_noexpand\_next \_ea\_createcsB \_else \_ea\_createcsF \_fi} +\_gdef\_createcsB#1{\_addto\_csletters{#1}\_futurelet\_next\_createcsA} +\_gdef\_createcsF{\z S{\_csstring\\\_csletters}} +\_gdef\_createbb{\_ea\_createcs\_csstring\\} + +\_endcode %------------------------------------------------ + +The `\_createcs` reads next tokens as the tokenizer does it until the name +of a control sequence is read. It is saved to the `\_csletters` macro and +the macro \_createcsF prints it. diff --git a/Master/texmf-dist/tex/luatex/optex/hyperlinks.opm b/Master/texmf-dist/tex/luatex/optex/hyperlinks.opm index 02b33600bd5..316e36745e9 100644 --- a/Master/texmf-dist/tex/luatex/optex/hyperlinks.opm +++ b/Master/texmf-dist/tex/luatex/optex/hyperlinks.opm @@ -1,16 +1,14 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \ulink {Hyperlinks <2020-03-15>} % preloaded in format - -\_newcount \_tocrefnum +\_codedecl \ulink {Hyperlinks <2020-04-22>} % preloaded in format \_doc ---------------------------- - `\dest[<type>:<spec>]` creates a destination of internal links. The - destination is declared by `<type>:<spec>`. If `\hyperlinks` are not - declared, then `\dest` does nothing else it is set to `\_destactive`. - The `\_destactive` is implemented by `\_pdfdest` primitive. It creates a box - in which the destination is shifted by `\_destheight`. The reason is that - the destination is exactly at top border of the PDF viewer but we want to se + \`\dest``[<type>:<spec>]` creates a destination of internal links. The + destination is declared in the format `<type>:<spec>`. If the \^`\hyperlinks` + command in not used, then `\dest` does nothing else it is set to `\_destactive`. + The \`\_destactive` is implemented by `\_pdfdest` primitive. It creates a box + in which the destination is shifted by \`\_destheight`. The reason is that + the destination is exactly at top border of the PDF viewer but we want to see the line where destination is. The destination box is positioned by different way dependent on current vertical or horizontal mode. \_cod ---------------------------- @@ -27,15 +25,16 @@ \_public \dest ; \_doc ---------------------------- - `\_link[<type>:<spec>]{<color>}{<text>}` creates an internal link to `\dest` + \`\link``[<type>:<spec>]{<color>}{<text>}` creates an internal link to \^`\dest` with the same `<type>:<spec>`. You can have more links with the same - `<type>:<spec>` but only one `\dest` in the document. If `\hyperlinks` are - not declared, then `\link` only prints <text> else it is set to `\_linkactive`. - The `\_linkactive` is implemented by `\_pdfstartlink...\_pdfendlink` + `<type>:<spec>` but only one `\dest` in the document. If \^`\hyperlinks` + command is not used, then `\link` only prints `<text>` else it is set to + `\_linkactive`. + The \`\_linkactive` is implemented by `\_pdfstartlink...\_pdfendlink` primitives. - - `\ilink[<type>:<spec>]{<text>}` is equivalent to `\_link` but <color> is - used from `\hyperlinks` decaration. + \nl + \`\ilink``[<type>:<spec>]{<text>}` is equivalent to `\_link` but + the `<color>` is used from \^`\hyperlinks` declaration. \_cod ---------------------------- \_protected\_def\_linkactive[#1:#2]#3#4{\_leavevmode\_pdfstartlink height.9em depth.3em @@ -43,14 +42,14 @@ } \_protected\_def\_link[#1]#2#3{\_leavevmode{#3}} \_protected\_def\_ilink[#1]#2{\_leavevmode{#2}} -\_public \ilink ; +\_public \ilink \link ; \_doc ---------------------------- - `\ulink[<url>]{<text>}` creates external link. It prints only <text> by default but - the `\hyperlinks` declaration defines it as `\_urlactive[url:<url>]{<text>}`. - The external link is created by `\_pdfstartlink...\pdfendlink` primitives. - The <url> is detokenized with `\escapechar=-1` before it is used, so - `\%`, `\#` etc. can be used in the <url>. + \`\ulink``[<url>]{<text>}` creates external link. It prints only te `<text>` by default but + the \^`\hyperlinks` declaration defines it as \`\_urlactive``[url:<url>]{<text>}`. + The external link is created by the `\_pdfstartlink...\pdfendlink` primitives. + The `<url>` is detokenized with `\escapechar=-1` before it is used, so + `\%`, `\#` etc. can be used in the `<url>`. \_cod ---------------------------- \_protected\_def\_urlactive[#1:#2]#3#4{\_leavevmode{\_escapechar=-1 @@ -64,9 +63,11 @@ \_doc ---------------------------- The `\_pdfstartlink` primitive uses `\_pdfborder{<type>}` in its parameter - (see `\_linkactive` or `\_urlactive` macros). The `\_pdfbordef{<type>}` + (see \^`\_linkactive` or \^`\_urlactive` macros). The \`\_pdfborder``{<type>}` expands to `attr{/C[? ? ?] /Border[0 0 .6]}` if the - `\<type>border` is defined. User can define it in + `\<type>border` (i.e.\ \`\refborder`, \`\citeborder`, \`\tocborder`, \`\pgborder`, + \`\urlborder`, \`\fntborder` or \`\fnfborder`) + is defined. User can define it in order to create colored frames around active links. For example `\def\tocborder{1 0 0}` causes red frames in TOC (not printed, only visible in PDF viewers). @@ -79,7 +80,7 @@ } \_doc ---------------------------- - `\hyperlinks{<ilink_color>}{<ulink_color>}` activates `\dest`, `\link`, + \`\hyperlinks``{<ilink_color>}{<ulink_color>}` activates `\dest`, `\link`, `\ilink`, `\ulink` in order they create links. These macros are redefined here to their \"active" version. \_cod ---------------------------- @@ -93,20 +94,21 @@ \_public \hyperlinks ; \_doc ---------------------------- - `\url{<url>}` does approximately the same as `\ulink[<url>]{<url>}`, but + \`\url``{<url>}` does approximately the same as \^`\ulink``[<url>]{<url>}`, but more work is done before the `\ulink` is processed. The link-version of <url> is saved to `\_tmpa` and the printed version in `\_tmpb`. The printed - version is modified in order to set a breakpoints in special places of the - <url>. For example `//` is replaced by `\_urlskip/\_urlskip/\_urlbskip` + version is modified in order to set a breakpoints to special places of the + `<url>`. For example `//` is replaced by `\_urlskip/\_urlskip/\_urlbskip` where `\urlskip` adds a small nobreakable glue between these two slashes and before them and `\_urlbskip` adds a breakable glue after them. - \_cod \_fin ---------------------- + \nl + The text version of the `<url>` is printed in \`\_urlfont`. + \_cod ---------------------------- \_def\_url#1{{% \_def\_tmpa{#1}\_replstring\_tmpa {\|}{}% - \_def\_tmpb{#1}\_replstring\_tmpb {\|}{\\|}% - {\_escapechar=-1 \_ea}\_ea\_edef\_ea\_tmpb\_ea{\detokenize\_ea{\_tmpb}}% - \_let\_tmpa=\_tmpb + {\_escapechar=-1 \_ea}\_ea\_edef\_ea\_tmpa\_ea{\detokenize\_ea{\_tmpa}}% + \_def\_tmpb{#1}\_replstring\_tmpb {\|}{\_urlbskip}% \_replstring\_tmpb {//} {{\_urlskip\_urlslashslash\_urlbskip}}% \_replstring\_tmpb {/} {{\_urlskip/\_urlbskip}}% \_replstring\_tmpb {.} {{\_urlskip.\_urlbskip}}% @@ -141,11 +143,15 @@ There are four types of the internal links and one type of external link: see also the end of this section. \enditems -The <tocrefnum>, <gpageno> and <bibnum> are numbers starting from one and -globally incremented by one in whole document. The registers `\_tocrefnum`, -`\_gpageno` and `\_bibnum` are used for these numbers. +The `<tocrefnum>`, `<gpageno>` and `<bibnum>` are numbers starting from one and +globally incremented by one in whole document. The registers \^`\tocrefnum`, +\^`\gpageno` and \^`\bibnum` are used for these numbers. When a chap/sec/secc title is prefixed by `\label[<label>]`, then both types of internal links are created at the same destination place: `toc:<tocrefnum>` and `ref:<label>`. +\_endinput + +2020-04-22 \| in \url: bug fixed +2020-03-15 introduced
\ No newline at end of file diff --git a/Master/texmf-dist/tex/luatex/optex/hyphen-lan.opm b/Master/texmf-dist/tex/luatex/optex/hyphen-lan.opm index d8d035a7e0a..94e87503c1c 100644 --- a/Master/texmf-dist/tex/luatex/optex/hyphen-lan.opm +++ b/Master/texmf-dist/tex/luatex/optex/hyphen-lan.opm @@ -4,24 +4,26 @@ \_doc ----------------------------- The <iso-code> means a shortcut of language name (mostly by ISO 639-1). - The following control sequences are used for language swithing: + The following control sequences are used for language switching: \begitems - * `\_lan:<number>` expands to <iso-code> of the language. + * `\_lan:<number>` expands to `<iso-code>` of the language. The number is internal number of languages used as a value of `\language` register. - * `\_ulan:<long-lang>` expands to <iso-code> too. This is transormation + * `\_ulan:<long-lang>` expands to `<iso-code>` too. This is transformation from long name of language (lowercase letters) to <iso-code>. - * `\_<iso-code>Patt` is the language <number> declared by `\chardef`. - * `\_<iso-code>lang` is language selector. It exists in two states + * `\_<iso-code>Patt` (for example `\_csPatt`) is the language `<number>` declared by `\chardef`. + * `\<iso-code>lang` + (for example \`\enlang`, \`\cslang`, \`\sklang`, \`\delang`, \`\pllang`) + is language selector. It exists in two states \begitems - * Initialization state: when `\_<iso-code>lang` is used first then it + * Initialization state: when `\<iso-code>lang` is used first then it must load the patterns into memory using Lua code. If it is done then - the `\_<iso-code>lang` re-defines itself to processing state. + the `\<iso-code>lang` re-defines itself to processing state. * Processing state: it only sets `\language=\_<iso-code>Patt`, i.e it selects the hyphenation patterns. It does a little more language-dependent work, as mentioned below. \enditems - * `\_langspecific:<isocode>` is processed by `\_<iso-code>lang` and it + * `\_langspecific:<isocode>` is processed by `\<iso-code>lang` and it should include language-specific macros declared by user or macro designer. \enditems The USenglish patters are preloaded first: @@ -39,10 +41,10 @@ \_input hyphen % en(USenglish) patterns from TeX82 \_doc ----------------------------- - `\preplang <iso-code> <long-lang> <number-cs> <number> <pre-hyph><post-hyph> - prepares the `\_<iso-code>lang` to its initialization state. Rougly + \`\preplang` `<iso-code> <long-lang> <number-cs> <number> <pre-hyph><post-hyph>` + prepares the\nl `\<iso-code>lang` to its initialization state. Roughly speaking, it does: - \begtt + \begtt \catcode`\<=13 \chardef\_<iso-code>Patt = <number> \def\_lan:<number> {<iso-code>} \def\_ulan:<long-lang> {<iso-code>} @@ -53,7 +55,8 @@ } \def\<iso-code>lang {\_<iso-code>lang} % public version \<iso-code>lang \endtt - You can see that `\_<iso-code>lang` runs `\_uselang` in processing state. + You can see that `\<iso-code>lang` runs \`\_loadpattrs` `<long-lang> <iso-code>` + in initialization state and \^`\_uselang` in processing state. \_cod ----------------------------- \_def\_preplang #1 #2 #3#4 #5 {% @@ -76,12 +79,12 @@ } \_doc ----------------------------- - `\_uselang{<iso-code>}\_<iso-code>Patt <pre-hyph><post-hyph>` + \`\_uselang``{<iso-code>}\_<iso-code>Patt <pre-hyph><post-hyph>`\nl sets `\language`, `\lefthyphenmin`, `\righthyphenmin` and runs `\frenchspacing`. This default language-dependent settings should be re-declared by `\_langspecific:<iso-code>` which is run finally (it is `\relax` by default, only `\_langspecific:en` runs - `\nonfrenchspacing`). + \^`\nonfrenchspacing`). \_cod ----------------------------- \_def\_uselang#1#2#3#4{\_language=#2\_lefthyphenmin=#3\_righthyphenmin=#4\_relax @@ -89,16 +92,18 @@ \_cs{_langspecific:#1}% } \_doc ----------------------------- - The `\_uselanguage` is defined here (for compatibility with e-plain users). + The \`\uselanguage` `{<long-lang>}` is defined here + (for compatibility with e-plain users). \_cod ----------------------------- \_def\_uselanguage#1{\_lowercase{\_cs{_\_cs{_ulan:#1}lang}}} +\_public \uselanguage ; \_doc ----------------------------- - The numbers for languages are declared as fixed contants (no + The numbers for languages are declared as fixed constants (no auto-generated). This concept is inspired from CSplain. There are typical numbers of languages in CSplain: 5=Czech in IL2, - 15=Czech in T1 nad 115=Czech in Unicode. We keep these constants + 15=Czech in T1 and 115=Czech in Unicode. We keep these constants but we load only Unicode patterns (greater than 100), of course. \_cod ----------------------------- @@ -162,18 +167,16 @@ \_preplang te Telugu \_tePatt 222 11 \_doc ----------------------------- - The `\_langlist` includes names of all languages which are ready to load + The \`\langlist` includes names of all languages which are ready to load and use their hyphenation patterns. This list is printed to terminal and - to log at ini\TeX/ state here. User can print `\_langlist` in the - document too. + to log at ini\TeX/ state here. It can be used when processing document too. \_cod ----------------------------- \message{Language hyph.patterns ready to load: \_langlist. Use \string\<shortname>lang to initialize language, \string\cslang\space for example} -\_public - \uselanguage \langlist ; +\_public \langlist ; \_endcode % --------------------------------------------- @@ -194,6 +197,6 @@ The example shows how to declare such language specific things. ... etc. \endtt -Note that you need not to set language specific words (like `\today`) -by this code. Another concept is used for such tasks. See `languages.opm` -for more details. +Note that you need not to set language specific phrases (like `\today`) +by this code. Another concept is used for such tasks. See the +section~\ref[langphrases] for more details. diff --git a/Master/texmf-dist/tex/luatex/optex/if-macros.opm b/Master/texmf-dist/tex/luatex/optex/if-macros.opm index 5e56503bd87..601c4fbee7c 100644 --- a/Master/texmf-dist/tex/luatex/optex/if-macros.opm +++ b/Master/texmf-dist/tex/luatex/optex/if-macros.opm @@ -1,15 +1,18 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \newif {Special if-macros, is-macros and loops <2020-02-27>} % preloaded in format +\_codedecl \newif {Special if-macros, is-macros and loops <2020-04-15>} % preloaded in format \_doc ---------------------------- - The `\newif` macro works like in plain \TeX. It means that + \secc Classical \code{\\newif} + The \`\newif` macro implements boolean value. + It works as in plain \TeX. It means that after `\newif\ifxxx` you can use `\xxxtrue` or `\xxxfalse` to set the boolean value and use `\ifxxx true\else false\fi` - to test this value. The defalut value is false. + to test this value. The default value is false. - The macro `\_newifi` enables to declare `\_ifxxx` and to use `\_xxxtrue` and - `\_xxxfalse`. This means that it is usable for _prefixed macros. + The macro \`\_newifi` enables to declare `\_ifxxx` and to use `\_xxxtrue` and + `\_xxxfalse`. This means that it is usable for internal name space + (`_`prefixed macros). \_cod ---------------------------- \_def\_newif #1{\_ea\_newifA \_string #1\_relax#1} @@ -24,57 +27,145 @@ \_sdef{_#1false}{\_let#2=\_iffalse}% \_let#2=\_iffalse } +\_public \newif ; \_doc ---------------------------- - The `\loop <codeA> \ifsomething <codeB> \repeat` loops `<codeA> <codeB>` + \secc Loops + The \`\loop` `<codeA> \ifsomething <codeB>` \`\repeat` loops `<codeA><codeB>` until `\ifsomething` is false. Then `<codeB>` is not executed and loop is - finished. This works like in plain \TeX, but implementation is soewhat + finished. This works like in plain \TeX, but implementation is somewhat better (you can use `\else` clause after the `\ifsomething`). There are public version `\loop...\repeat` and private version - `\_loop...\_repeat`. You canot mix both versions in one loop. + \`\_loop` ...\`\_repeat`. You cannot mix both versions in one loop. + + The `\loop` macro keeps its original plain TeX meaning. It is not + expandable and nested `\loop`s are possible only in a \TeX/ group. \_cod ---------------------------- -\_def \_loop #1\_repeat{\_def\_body{#1}\_iterate} +\_long\_def \_loop #1\_repeat{\_def\_body{#1}\_iterate} \_def \loop #1\repeat{\_def\_body{#1}\_iterate} \_let \_repeat=\_fi % this makes \loop...\if...\repeat skippable \_let \repeat=\_fi \_def \_iterate {\_body \_ea \_iterate \_fi} + \_doc ----------------------------- + \`\foreach` `<list>` \`\do` `{<what>}` + repeats `<what>` for each element of the + `<list>`. The `<what>` can include `#1` which is substituted by each + element of the `<list>`. The macro is expandable. + + \`\fornum` `<from>..<to>` \`\do` `{<what>}` or + \`\fornumstep` `<num>: <from>..<to>` \`\do` `{<what>}` + repeats `<what>` for each number from `<from>` to `<to>` (with step `<num>` + or with step one). The `<what>` can include `#1` which is substituted by + current number. The sequence `<from>..<to>` can be decreasing too. + The macro is expandable. + + Recommendation: it is better to + use private variants of \`\_foreach` and \`\_fornum`. + When the user writes `\input tikz` then `\foreach` macro is redefined! The + private variants use \`\_do` separator instead `\do` separator. + \_cod ----------------------------- + +\_newcount\_frnum % the numeric variable used in \fornum +\_def\_do{\_doundefined} % we need to ask \_ifx#1\_do ... + +\_long\_def\_foreach #1\_do#2{\_putforstack + \_immediateassignment\_def\_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 + }% + \_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 + \_afterfi{\_fornumB{#1}{#2}}\_fi +} +\_def\_afterfi#1#2\_fi{\_fi#1} + +\_def\foreach #1\do{\_foreach #1\_do} +\_def\fornum#1..#2\do{\_fornumstep 1:#1..#2\_do} +\_def\fornumstep#1:#2..#3\do{\_fornumstep #1:#2..#3\_do} + \_doc ---------------------------- - The macro `\isnextchar <char>{<codeA>}{<codeB>}` executes `<codeA>` if next - character is equal to <char>. Else the `<codeB>` is executed. The macro is - not expandable. + The `\foreach` and `\fornum` macros can be nested and arbitrary combined. + When they are nested then use `##1` for the variable of nested level, + `####1` for the variable of second nested level etc. Example: + \begtt + \foreach ABC \do {\fornum 1..5 \do {letter:#1, number: ##1. }} + \endtt + Implementation note: + we cannot use \TeX/-groups for nesting levels because we want to do the + macros expandable. We must implement a special for-stack which saves the + data needed by `\foreach` and `\fornum`. The \`\_putforstack` is used + when `\for*` is initialized and \`\_getforstack` is used when the + `\for*` macro ends. The \`\_forlevel` variable keeps the current nesting + level. If it is zero, then we need not save nor restore any data. \_cod ---------------------------- -\_long\_def\_isnextchar#1#2#3{\_begingroup\_toks0={\_endgroup#2}\_toks1={\_endgroup#3}% - \_let\_tmp=#1\_futurelet\_next\_isnextcharA -} -\_def\_isnextcharA{\_the\_toks\_ifx\_tmp\_next0\_else1\_fi\_space} +\_newcount\_forlevel +\_def\_putforstack{\_immediateassigned{% + \_ifnum\_forlevel>0 + \_sdef{_frnum:\_the\_forlevel\_ea}\_ea{\_the\_frnum}% + \_slet{_fbody:\_the\_forlevel}{_fbody}% + \_fi + \_advance\_forlevel by1 +}} +\def\_getforstack{\_immediateassigned{% + \_advance\_forlevel by-1 + \_ifnum\_forlevel>0 + \_slet{_fbody}{_fbody:\_the\_forlevel}% + \_frnum=\_cs{_frnum:\_the\_forlevel}\_space + \_fi +}} \_doc ---------------------------- - The macro `\isempty{<text>}\iftrue <codeA>\else <codeB>\fi` executes <codeA> - if <text> is empty and <codeB> if it is non-empty. You can use - `\isempty{<text>}\iffalse <codeB>\else <codeA>\fi` too. This macro is - expandable. + \secc Is-macros + There are a collection of macros + `\isempty`, `\istoksempty`, `\isequal`, `\ismacro`, `\isdefined`, `\isinlist` and `\isfile` + with common syntax: + \begtt \catcode`\<=13 + \issomething <params> \iftrue <codeA> \else <codeB> \fi + or + \issomething <params> \iffalse <codeB> \else <codeA> \fi + \endtt + The `\else` part is optional. The `<codeA>` is processed if + `\issomething<params>` generates true condition. The `<codeB>` + is processed if `\issomething<params>` generates false condition. - There are a collection of macros with commnon syntax: - `\issomething<params>\iftrue` or `\issomething<params>\iffalse`. - The `\iftrue` or `\iffalse` is a part of this syntax because we need to keep - skippable nested `\if` conditions. + The `\iftrue` or `\iffalse` is an integral part of this syntax + because we need to keep skippable nested `\if` conditions. - We read this `\iftrue` or `\iffalse` into unseparated parameter and repeat + Implementation note: + we read this `\iftrue` or `\iffalse` into unseparated parameter and repeat it because we need to remove an optional space before this command. + + \medskip\noindent + \`\isempty` `{<text>}\iftrue` + is true if the `<text>` is empty. This macro is expandable.\nl + \`\istoksempty` `<tokens variable>\iftrue` + is true if the `<tokens variable>` is empty. It is expandable. \_cod ---------------------------- -\_def \_isempty #1#2{\_ea\_ifx\_ea\_relax\_detokenize{#1}\_relax - \_else \_ea\_unless \_fi #2} -\_def \_isnoempty #1#2{\_ea\_ifx\_ea\_relax\_detokenize{#1}\_relax - \_ea\_unless \_fi #2} -\_def \_istoksempty #1{\_ea\_isempty\_ea{\_the#1}} +\_def \_isempty #1#2{\_if\_relax\_detokenize{#1}\_relax \_else \_ea\_unless \_fi#2} +\_def \_istoksempty #1#2{\_ea\_isempty\_ea{\_the#1}#2} +\_public \isempty \istoksempty ; \_doc ---------------------------- - `\isequal{<textA>}{<textB>}\iftrue` is true if the <textA> and <textB> are + \`\isequal` `{<textA>}{<textB>}\iftrue` + is true if the <textA> and <textB> are equal, only from strings point of view, category codes are ignored. The macro is expandable. \_cod ---------------------------- @@ -82,47 +173,85 @@ \_def\_isequal#1#2#3{\_directlua{% if "\_luaescapestring{\_detokenize{#1}}"=="\_luaescapestring{\_detokenize{#2}}" then else tex.print("\_nbb unless") end}#3} +\_public \isequal ; \_doc ---------------------------- - `\ismacro\macro{text}\iftrue` is true if macro is defined as {<text>}. + \`\ismacro` `\macro{text}\iftrue` is true if macro is defined as {<text>}. Category codes are ignored in this testing. The macro is expandable. \_cod ---------------------------- \_def\_ismacro#1{\_ea\_isequal\_ea{#1}} +\_public \ismacro ; \_doc ---------------------------- - `\isinlist\list{<text>}\iftrue` is true if the - `<text>` is included the macro body of the `\list`. - The catogory code are relevant here. THe macro is not expandable. + \`\isdefined` `{<csname>}\iftrue` is true if `\<csname>` is defined. + The macro is expandable. \_cod ---------------------------- \_def\_isdefined #1#2{\_ifcsname #1\_endcsname \_else \_ea\_unless \_fi #2} +\_public \isdefined ; \_doc ---------------------------- - `\isdefined{<csname>}\iftrue` is true if `\<csname>` is defined. + \`\isinlist` `\list{<text>}\iftrue` is true if the + `<text>` is included the macro body of the `\list`. + The category code are relevant here. The macro is not expandable. \_cod ---------------------------- \_long\_def\_isinlist#1#2{\_begingroup - \_long\_def\_tmp##1#2##2\_end/_{\_endgroup\_isnoempty{##2}}% + \_long\_def\_tmp##1#2##2\_end/_% + {\_endgroup\_if\_relax\_detokenize{##2}\_relax \_ea\_unless\_fi}% \_ea\_tmp#1\_endlistsep#2\_end/_% } +\_public \isinlist ; - \_doc ---------------------------- - `\isfile{<filename>}\iftrue` is true if the file <filename> exists and are + \_doc ----------------------------- + \`\isfile` `{<filename>}\iftrue` is true if the file <filename> exists and are readable by \TeX. - \_cod \_fin ---------------------- + \_cod ----------------------------- \_newread \_testin - \_def\_isfile #1{% \_openin\_testin ={#1}\_relax \_ifeof\_testin \_ea\_unless \_else \_closein\_testin \_fi } +\_public \isfile ; + + \_doc ----------------------------- + \`\isfont` `{<fontname or [fontfile]>}\iftrue` + is true if given font exists. The result of this testing + is saved to the \`\_ifexistfam`. + \_cod ----------------------------- + +\_newifi \_ifexistfam +\_def\_isfont#1#2{% + \_begingroup + \_suppressfontnotfounderror=1 + \_font\_testfont={#1}\_relax + \_ifx\_testfont\_nullfont \_def\_tmp{\_existfamfalse \_unless} + \else \_def\_tmp{\_existfamtrue}\_fi + \_ea \_endgroup \_tmp #2% +} +\_public \isfont ; + + \_doc ---------------------------- + The last macro \`\isnextchar` `<char>{<codeA>}{<codeB>}` + has different syntax than all others is-macros. + It executes `<codeA>` if next character is equal to <char>. + Else the `<codeB>` is executed. The macro is not expandable. + \_cod ---------------------------- + +\_long\_def\_isnextchar#1#2#3{\_begingroup\_toks0={\_endgroup#2}\_toks1={\_endgroup#3}% + \_let\_tmp=#1\_futurelet\_next\_isnextcharA +} +\_def\_isnextcharA{\_the\_toks\_ifx\_tmp\_next0\_else1\_fi\_space} + +\_public \isnextchar ; -\_public - \newif \isnextchar \isempty \isequal \ismacro \isdefined \isinlist \isfile ; \_endcode +2020-04-15 \fornumstep 3: 1..12 instead \fornum 1..12\step 3 +2020-04-15 \fornum, \foreach can be nested without groups +2020-04-01 implemented diff --git a/Master/texmf-dist/tex/luatex/optex/languages.opm b/Master/texmf-dist/tex/luatex/optex/languages.opm index 5bfa2febdc3..c56ec0cc122 100644 --- a/Master/texmf-dist/tex/luatex/optex/languages.opm +++ b/Master/texmf-dist/tex/luatex/optex/languages.opm @@ -3,12 +3,14 @@ \_codedecl \_mtext {Languages <2020-03-15>} % preloaded in format \_doc ----------------------------- - Only three words are generated by \OpTeX/ macros: \"Chapter", - \"Table", \"Figure" and \"Subject". These words can be generated depending - on the current value of `\language` register, if you use `\_mtext{chap}`, - `\_mtext{t}` or `\_mtext{f}`. If your macros generate more words then - you can define such words by `\sdef{_mt:<label>:<lang>}` where - <label> is a label for declared word and <lang> is language shortcut. + Only four words are generated by \OpTeX/ macros: \"Chapter", + \"Table", \"Figure" and \"Subject". These phrases can be generated depending + on the current value of `\language` register, if you use \`\_mtext``{<phrase-id>}`, + specially `\_mtext{chap}`, `\_mtext{t}`, `\_mtext{f}` or `\_mtext{subj}`. + If your macros generate more words then + you can define such words by `\sdef{_mt:<phrase-id>:<lang>}` where + `<phrase-id>` is a label for declared word and `<lang>` is language shortcut + (iso code). \_cod ----------------------------- \def\_mtext#1{\_trycs{_mt:#1:\_trycs{_lan:\_the\_language}{en}} @@ -20,8 +22,9 @@ \sdef{_mt:subj:en}{Subject} \sdef{_mt:subj:cs}{Věc} \sdef{_mt:subj:sk}{Vec} \_doc ----------------------------- - Using `\_langw <lang> <chapter> <table> <figure> <subject>` you can - declare these words more efectively. + Using \`\_langw` `<lang> <chapter> <table> <figure> <subject>` you can + declare these words more effectively: + \maxlines=13 \_cod ----------------------------- \_def \_langw #1 #2 #3 #4 #5 {% @@ -35,14 +38,14 @@ \_langw de Kapitel Tabelle Obrázek Subjekt \_langw es Capítulo Tabla Figura Sujeto \_langw fr Chaptire Tableau Figure Matière -\_langw gr Κεφάλαιο Πίνακας Σχήμα θέμα \_langw it Capitolo Tabella Fig. Soggetto \_langw pl Rozdział Tabela Ilustracja Temat +\_langw gr Κεφάλαιο Πίνακας Σχήμα θέμα \_langw ru Глава Таблица Рисунок Предмет \_langw sk Kapitola Tabuľka Obrázok Vec \_doc ----------------------------- - You can add more words as you wish. For eample `\today` macro: + You can add more words as you wish. For example \`\today` macro: \_cod ----------------------------- \_def \_monthw #1 #2 #3 #4 #5 #6 #7 {% @@ -71,14 +74,17 @@ \_doc ----------------------------- Quotes should be tagged by `\"<text>"` and `\'<text>'` if `\<iso-code>quotes` - is declared at beginning of the document. If not, then the control + is declared at beginning of the document (for example `\enquotes`). + If not, then the control sequences `\"` and `\'` are undefined. Remember, that they are used in 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 - <clqq>...<crqq> are normal quotes and <clq>...<crq> are alternative quotes. - or use `\altquotes` to swap between meaning of these two types of quotes. + 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 + \`\enquotes`, \`\csquotes`, \`\dequotes`, \`\frquotes` etc. are defined here. \_cod ----------------------------- \_def \_enquotes {\_quoteschars “”‘’} @@ -98,9 +104,9 @@ \_doc ----------------------------- Sometimes should be usable to leave the markup `"such"` or `'such'` i.e.~without the first backslash. Then you can make the characters `"` and `'` active - by `\activequotes` macro and leave quotes without first backsash. - First, delare `\<iso-code>quotes`, then `\altwquotes` (if needed) and finally - `\activequotes`. + by the \`\activequotes` macro and leave quotes without first backslash. + First, declare `\<iso-code>quotes`, then \^`\altquotes` (if needed) and finally + \^`\activequotes`. \_cod ----------------------------- \def\_activequotes{\_ea\_activequotesA\"""\_ea\_activequotesA\'''} diff --git a/Master/texmf-dist/tex/luatex/optex/lists.opm b/Master/texmf-dist/tex/luatex/optex/lists.opm index 067fa4a7d96..fe349c3796e 100644 --- a/Master/texmf-dist/tex/luatex/optex/lists.opm +++ b/Master/texmf-dist/tex/luatex/optex/lists.opm @@ -1,13 +1,14 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \begitems {Lists: begitems, enditems <2020-03-18>} % preloaded in format +\_codedecl \begitems {Lists: begitems, enditems <2020-04-21>} % preloaded in format \_doc ----------------------------- - `\aboveliskip` is used above the list of items, - `\belowliskip` is used below the list of items and - `\interliskip` is used between items. - `\listskipA` is used as `\listskipamount` at level 1 of items. - `\listskipB` is used as `\listskipamount` at other levels. + \`\_aboveliskip` is used above the list of items,\nl + \`\_belowliskip` is used below the list of items and\nl + \`\_interliskip` is used between items.\nl + \`\_listskipA` is used as `\listskipamount` at level 1 of items.\nl + \`\_listskipB` is used as `\listskipamount` at other levels.\nl + \`\_setlistskip` sets the skip dependent on the current level of items \_cod ----------------------------- \_def\_aboveliskip {\_removelastskip \_penalty-100 \_vskip\_listskipamount} @@ -22,15 +23,20 @@ \_fi} \_doc ----------------------------- - The `\itemnum` is localy reset to zero in each group declared by + The \`\itemnum` is locally reset to zero in each group declared by `\begitems`. So nested lists are numbered independently. User can set initial value of `\itemnum` to another value after `\beitems` if he/she want. - + \nl Each level of nested lists is indented by new `\iindent` from left. Default item mark is `\_printitem`. - - The `\begitems` runs `\_aboveliskip` only if we are not near below a title, + \nl + The \`\begitems` runs `\_aboveliskip` only if we are not near below a title, where a vertical skip is placed already and where the `\penalty` 11333 is. + It activates `*` and defines it as \`\_startitem`. + \nl + The \`\enditems` runs `\_isnextchar\_par{}{\_noindent}` thus the next + paragraph is without indentation if there is no empty line between + the list and this paragraph (it is similar behavior as after display math). \_cod ----------------------------- \_newcount\_itemnum \_itemnum=0 @@ -46,15 +52,16 @@ \_printitem=\_defaultitem \_the\_everylist \_relax } -\_def\_enditems{\_par\_belowliskip\_egroup} +\_def\_enditems{\_par\_belowliskip\_egroup \_isnextchar\_par{}{\_noindent}} \_def\_startitem{\_par \_ifnum\_itemnum>0 \_interliskip \_fi \_advance\_itemnum by1 \_the\_everyitem \_noindent\_llap{\_the\_printitem}\_ignorespaces } +\_public \begitems \enditems \itemnum ; \_doc ---------------------------- - `\novspaces` sets `\listsipamount` to 0pt. + \`\novspaces` sets \`\listskipamount` to 0pt. \_cod ---------------------------- \_def\_novspaces {\_removelastskip \_listskipamount=0pt \_relax} @@ -62,8 +69,11 @@ \_doc ----------------------------- Various item marks are saved in `\_item:<letter>` macros. - You ca re-define then or define more such macros. - The `\style <letter>` does `\_printitem={\_item:<letter>}`. + You can re-define then or define more such macros. + The \`\style` `<letter>` does \`\_printitem``={\_item:<letter>}`. + More exactly: \^`\begitems` does `\_printitem=`\^`\defaultitem` first, + then \`\style` `<letter>` does \`\_printitem``={\_item:<letter>}` + when it is used and finally, `\_startitem` alias `*` uses `\_printitem`. \_cod ----------------------------- \_def\_style#1{% @@ -82,8 +92,8 @@ \_sdef{_item:X}{\_raise.2ex\_fullrectangle{1ex}\_kern.5em} \_doc ----------------------------- - `\_athe{<num>}` returns the <num>s lowercase letter from the alphabet. - `\_fullrectangle{<dimen>}` prints full rectangle with given <dimen>. + \`\_athe``{<num>}` returns the `<num>`s lowercase letter from the alphabet.\nl + \`\_fullrectangle``{<dimen>}` prints full rectangle with given `<dimen>`. \_cod ----------------------------- \_def\_fullrectangle#1{\_hbox{\_vrule height#1 width#1}} @@ -92,8 +102,9 @@ i\_or j\_or k\_or l\_or m\_or n\_or o\_or p\_or q\_or r\_or s\_or t\_or u\_or v\_or w\_or x\_or y\_or z\_else ?\_fi } -\_public \begitems \enditems \style \itemnum ; +\_public \style ; \_endcode % ------------------------------------- - +2020-04-21 \isnextchar\par added to \enditems +2020-03-18 introduced diff --git a/Master/texmf-dist/tex/luatex/optex/logos.opm b/Master/texmf-dist/tex/luatex/optex/logos.opm index 59f1cd87f17..91d4ef729d5 100644 --- a/Master/texmf-dist/tex/luatex/optex/logos.opm +++ b/Master/texmf-dist/tex/luatex/optex/logos.opm @@ -3,10 +3,11 @@ \_codedecl \TeX {Logos TeX, LuaTeX, etc. <2020-02-28>} % preloaded in format \_doc ---------------------------- - Despite plain \TeX/ each macro for logos ends by `\ignoreslash`. + Despite plain \TeX/ each macro for logos ends by \`\ignoreslash`. This macro ignores next slash if it is present. You can `use \TeX/ like this` for protecting the space following the logo. This is visually more comfortable. + The macros \`\TeX`, \`\OpTeX`, \`\LuaTeX`, \`\XeTeX` are defined. \_cod ---------------------------- \_protected\_def \_TeX {T\_kern-.1667em\_lower.5ex\_hbox{E}\_kern-.125emX\_ignoreslash} @@ -15,9 +16,14 @@ \_protected\_def \_XeTeX {X\_kern-.125em\_phantom E% \_pdfsave\_rlap{\_pdfscale{-1}{1}\_lower.5ex\_hbox{E}}\_pdfrestore \_kern-.1667em \_TeX} - \_doc------------------------------ - The `\_slantcorr` macro expands to slant-correction of current font. It is - used to shifting A if `\LaTeX` is in itallic. +\_def\_ignoreslash {\_futurelet\_next \_ignoreslashA} +\_def\_ignoreslashA {\_ifx\_next/\_ea\_ignoreit\_fi} + +\_public \TeX \OpTeX \LuaTeX \XeTeX \ignoreslash ; + + \_doc ----------------------------- + The \`\_slantcorr` macro expands to slant-correction of current font. It is + used to shifting A if the \`\LaTeX` logo is in italic. \_cod ----------------------------- \_protected\_def \_LaTeX{\_tmpdim=.42ex L\_kern-.36em \_kern \_slantcorr % slant correction @@ -25,29 +31,32 @@ \_kern-.15em \_kern-\_slantcorr \_TeX} \_def\_slantcorr{\_ea\_ignorept \_the\_fontdimen1\_font\_tmpdim} -\_def\_ignoreslash {\_futurelet\_next \_ignoreslashA} -\_def\_ignoreslashA {\_ifx\_next/\_ea\_ignoreit\_fi} +\_public \LaTeX ; + + \_doc ----------------------------- + \`\OPmac`, \`\CS` and \`\csplain` logos. + \_cod ----------------------------- \_def\_OPmac{\_leavevmode \_lower.2ex\_hbox{\_thefontscale[1400]O}\_kern-.86em P{\_em mac}\_ignoreslash} \_def\_CS{$\_cal C$\_kern-.1667em\_lower.5ex\_hbox{$\_cal S$}\_ignoreslash} \_def\_csplain{\_CS plain\_ignoreslash} -\_def\_ignslash#1{\_ifx/#1\_else #1\_fi} + +\_public \OPmac \CS \csplain ; \_doc ---------------------------- - The expandable versions of logos used in Outlines needs the expandablle - `\_ingnslash` (instead of `\_ignoreslash`). + The expandable versions of logos used in Outlines needs the expandable + \`\ingnslash` (instead of the \^`\ignoreslash`). \_cod \_fin ---------------------- +\_def\_ignslash#1{\_ifx/#1\_else #1\_fi} \_regmacro {}{}{% conversion for PDF outlines \_def\TeX{TeX\_ignslash}\_def\OpTeX{OpTeX\_ignslash}% \_def\LuaTeX{LuaTeX\_ignslash}\_def\XeTeX{XeTeX\_ignslash}% \_def\LaTeX{LaTeX\_ignslash}\_def\OPmac{OPmac\_ignslash}% \_def\CS{CS}\_def\csplain{csplain\_ignslash}% } -\_public - \TeX \OpTeX \LuaTeX \XeTeX \LaTeX \OPmac \CS \csplain - \ignoreslash \ignoreit \ignorept ; +\_public \ignslash ; \_endcode diff --git a/Master/texmf-dist/tex/luatex/optex/luatex-ini.opm b/Master/texmf-dist/tex/luatex/optex/luatex-ini.opm index 315836cab11..0f463c5d03f 100644 --- a/Master/texmf-dist/tex/luatex/optex/luatex-ini.opm +++ b/Master/texmf-dist/tex/luatex/optex/luatex-ini.opm @@ -133,4 +133,4 @@ \_endcode -Common pdf\TeX/ primitives equivalnets are declared here. Initial values is set. +Common pdf\TeX/ primitives equivalents are declared here. Initial values are set. diff --git a/Master/texmf-dist/tex/luatex/optex/makeindex.opm b/Master/texmf-dist/tex/luatex/optex/makeindex.opm index 2a783d8895f..f7fb3b59204 100644 --- a/Master/texmf-dist/tex/luatex/optex/makeindex.opm +++ b/Master/texmf-dist/tex/luatex/optex/makeindex.opm @@ -3,23 +3,23 @@ \_codedecl \makeindex {Makeindex and sorting <2020-04-26>} % loaded in format \_doc ----------------------------- - `\makeindex` implements sorting algorithm at \TeX/ macrolanguage level. + \^`\makeindex` implements sorting algorithm at \TeX/ macro-language level. You need not any external program. - There are two passes in sorting algorith. Primary pass does not + There are two passes in sorting algorithm. Primary pass does not distinguish between a group o letters (typically non-accented and accented). If the result of comparing two string is equal in primary pass - then secondary pass is started. It distinguish betveen variously accented + then secondary pass is started. It distinguish between variously accented letters. Czech rules, for example says: not accented before dieresis - before acute before circumflrex before ring. At less priority: lowercase - letters maut be before uppercase letters. + before acute before circumflex before ring. At less priority: lowercase + letters must be before uppercase letters. - The `\_sortingdata<iso-code>` implements these rules for the language + The \`\_sortingdata``<iso-code>` implements these rules for the language <iso-code>. The groups between commas are not distinguished in the first pass. The second pass distinguishes all characters mentioned in the `\_sortingdata<iso-code>` (commas are ignored). The order of letters in the `\_sortingdata<iso-code>` macro is significant for sorting algorithm. - The Czech rules are implemented here: + The Czech rules (`cs`) are implemented here: \_cod ----------------------------- \_def \_sortingdatacs {% @@ -59,16 +59,16 @@ } \_doc ----------------------------- - Characters ignored by sorting algorithm are declared in `\_ignoredchars<iso-code>`. + Characters ignored by sorting algorithm are declared in \`\_ignoredchars``<iso-code>`. The compound characters (two or more characters interpreted as one character in sorting algorithm) is mapped to single invisible characters - in `\_compoundchars<iso-code>`. Czech rules declares ch or Ch or CH as - a single letter sorted between H and I. See `\_sortingdatacs` above where + in \`\_compoundchars``<iso-code>`. Czech rules declares ch or Ch or CH as + a single letter sorted between H and I. See \`\_sortingdatacs` above where these declared characters are used. The characters declared in `\_ignoredchars` are ignored in first pass - without additional condidion. All characters are taken into acount in - second pass: ASCII characters with code $<65$ are sorted first if they + without additional condition. All characters are taken into account in + second pass: ASCII characters with code $\lq65$ are sorted first if they are not mentioned in the `\_sortingdata<iso-code>` macro. Others not mentioned characters have undefined behavior during sorting. \_cod ----------------------------- @@ -81,13 +81,13 @@ includes Slovak letters too. Compound characters are the same. English sorting rules can be defined by `\_sortingdatacs` too because English alphabet is subset of Czech and Slovak alphabets. Only - difference: `\_compoundcharsen` is empty in English rules. + difference: \`\_compoundcharsen` is empty in English rules. You can declare these macros for more languages, if you wish to use `\makeindex` with sorting rules in respect to your language. Note: if you need to map compound characters to a character, don't use `^^I` or `^^M` because these characters have very specific category code. - And use space to separate more mappings, like in `\_compoundcharscs`. + And use space to separate more mappings, like in \`\_compoundcharscs` above. \_cod ----------------------------- \_let \_sortingdatask = \_sortingdatacs @@ -98,8 +98,8 @@ \_let \_ignoredcharsen = \_ignoredcharscs \_doc ----------------------------- - Preparing to primary pass is implemented here. It is called from `\makeindex` - macro and all processing of sorting is in a group. + Preparing to primary pass is implemented by the \`\_setprimarysorting` macro. + It is called from `\makeindex` macro and all processing of sorting is in a group. \_cod ----------------------------- \_def\_setprimarysorting {% @@ -126,7 +126,7 @@ } \_doc ----------------------------- - Preparing to secondary pass is implemented here: + Preparing to secondary pass is implemented by the \`\_setsecondarysorting` macro. \_cod ----------------------------- \_def\_setsecondarysorting {% @@ -139,9 +139,11 @@ \_doc ----------------------------- Strings to be sorted are prepared in `\,<string>` control sequences (in order to save `\TeX` memory). - The `\_preparesortstring \,<string>` converts <string> to `\_tmpb` - with respect to the data initialized in `\_setprimarysorting` or - `\_setsecondarysortting`. + The \`\_preparesorting` `\,<string>` converts `<string>` to `\_tmpb` + with respect to the data initialized in \^`\_setprimarysorting` or + \^`\_setsecondarysorting`.\nl + The compoud characters are converted to single characters by the + \`\_docompound` macro. \_cod ----------------------------- \_def \_preparesorting #1{% @@ -156,18 +158,18 @@ \_def \_ignorefirst#1{} \_doc ----------------------------- - Macro `\_isAleB \,<string1> \,<string2>` returns the result of comparison - of given two strings to `\_ifAleB` control sequence. Usage: - `\isAleB \,<string1> \,<string2>` \_ifAleB ... \_else ... \_fi` + Macro \`\_isAleB` `\,<string1> \,<string2>` returns the result of comparison + of given two strings to \`\_ifAleB` control sequence. Usage: + `\isAleB \,<string1> \,<string2> \_ifAleB ... \_else ... \_fi` The converted strings (in respect of the data prepared for first pass) - must be saved as valuses of `\,<string1>` and `\,<string2>` macros. + must be saved as values of `\,<string1>` and `\,<string2>` macros. The reason is speed: we don't want to convert them repeatedly in each comparison. - - The auxiliary macro - `\_testAleB <converted string1>&\_relax<converted-string2>\_relax \,<string1>\,<string2>` + \nl + The macro + \`\_testAleB` `<converted string1>&\_relax<converted-string2>\_relax \,<string1>\,<string2>`\nl does the real work. It reads first character from both converted strings, compares them - and if it is equal then calls iself recursively else gives result. + and if it is equal then calls itself recursively else gives result. \_cod ----------------------------- \_newifi \_ifAleB @@ -198,9 +200,9 @@ } \_doc ----------------------------- - Merge sort is very efectively implemented by \TeX/ macros. The following + Merge sort is very effectively implemented by \TeX/ macros. The following code is created by my son Miroslav. - The `\_mergesort` macro expects that all items in `\_iilist` are separated + The \`\_mergesort` macro expects that all items in `\_iilist` are separated by comma when it starts. It ends with sorted items in `\_iilist` without commas. So `\_dosorting` macro must prepare commas between items. \_cod ----------------------------- @@ -235,18 +237,20 @@ \_def\_gobbletoend #1\_end{} \_doc ----------------------------- - The `\_dosorting \list` macro redefines `\list` as sorted `\list`. + The \`\_dosorting` `\list` macro redefines `\list` as sorted `\list`. The `\list` have to include control sequences in the form `\<c><string>`. - These control sequences will be sorted in respect to <strings> wihout + These control sequences will be sorted in respect to <strings> without change of meanings of these control sequences. Their meanings are irrelevant when sorting. The first character <c> in `\<c><string>` should be whatever. It does not influence the sorting. \OpTeX/ uses comma at this place for sorting indexes: `\,<word1> \,<word2> \,<word3> ...`. - The actual language is used for sorting data. If the `\_sortinglang` macro - is defined as <iso-code> then it has precedence and actual languge is not used. - Moreover, if you specify `\_asciisortingtrue` then ASCII sorting will be processed - and all language sorting data will be ignored. + The actual language (chosen for hyphenation patterns) is used for + sorting data. If the `\_sortinglang` macro + is defined as `<iso-code>`(for example `\def\sortinglang{de}`) + then this has precedence and actual language is not used. + Moreover, if you specify \`\_asciisortingtrue` then ASCII + sorting will be processed and all language sorting data will be ignored. \_cod ----------------------------- \_newifi \_ifasciisorting \_asciisortingfalse @@ -273,9 +277,9 @@ } \_doc ----------------------------- - The `\makeindex` prints the index. First, it sorts the `\_iilist` + The \`\makeindex` prints the index. First, it sorts the `\_iilist` second, it prints the sorted `\_iilist`, each item is printed - using `\_printindexitem`. + using \^`\_printindexitem`. \_cod ----------------------------- \_def\_makeindex{\_par @@ -291,10 +295,10 @@ \_public \makeindex ; \_doc ----------------------------- - The `\_printindexitem \,<word>` prints one item to the index. + The \`\_printindexitem` `\,<word>` prints one item to the index. If `\_,<word>` is defined then this is used instead real <word> (this exception is declared by `\iis` macro). Else <word> is printed by - `\_printii`. Finaly, `\_printiipages` prints the value of `\,<word>`, + \^`\_printii`. Finally, \^`\_printiipages` prints the value of `\,<word>`, i.e. the list of pages. \_cod ----------------------------- @@ -308,16 +312,17 @@ } \_doc ----------------------------- - `\printii <word>&` does more intelligent work because we are working with + \`\_printii` `<word>&` does more intelligent work because we are working with words in the form `<main-word>/<sub-word>/<sub-sub-word>`. - The `\everyii` tokens register is applied before `\noindent`. User can + The \^`\everyii` tokens register is applied before `\noindent`. User can declare something special here. - The `\_newiiletter{<letter>}` macro is empty by default. It is invoked if first + The \`\_newiiletter``{<letter>}` macro is empty by default. It is invoked if first letter of index entries is changed. You can declare a design between index entries here. You can try, for example: \begtt - \def\_newiiletter#1#2{\bigskip\hbox{\setfontsize{at15pt}\bf\uppercase{#1}}\medskip} + \def\_newiiletter#1#2{% + \bigskip \hbox{\setfontsize{at15pt}\bf\uppercase{#1}}\medskip} \endtt \_cod ----------------------------- @@ -338,14 +343,14 @@ \_def\_previi{} % previous index item \_doc ----------------------------- - `\printiipages <pglist>&` gets <pglist> in the form + \`\_printiipages` `<pglist>&` gets `<pglist>` in the form `<pg>:<type>,<pg>:<type>,...<pg>:<type>` and it converts them to - <pg>, <pg>, <from>--<to>, <pg> etc. The same pages must be printed only once - and continuos consequnces of pages must be comprimed to the form <from>-<to>. + `<pg>, <pg>, <from>--<to>, <pg>` etc. The same pages must be printed only once + and continuous consequences of pages must be compressed to the form <from>-<to>. Moreover, the consequence is continuous only if all pages have the same <type>. Empty <type> is most common, pages with `b` <type> must be printed as bold - and with `i` <type> as italics. - Moreover, the <pg> meioned here are <gpageno>, but we have to print + and with `i` `<type>` as italics. + Moreover, the `<pg>` mentioned here are <gpageno>, but we have to print <pageno>. The following macros solves these tasks. \_cod ----------------------------- @@ -375,7 +380,7 @@ \_def\_usepgdash{\_hbox{--}} % dash in the <from>--<to> form \_doc ----------------------------- - You can re-define `\_pgprint <gpageno>:{<iitype>}` + You can re-define \`\_pgprint` `<gpageno>:{<iitype>}` if you need to implement more <iitypes>. \_cod ----------------------------- @@ -390,23 +395,23 @@ \_def\_pgu#1{\_leavevmode\_vtop{\_hbox{#1}\kern.3ex\_hrule}} \_doc ----------------------------- - The `\iindex{<word>}` puts one <word> to the index. It writes - `\_Xindex{<word>}{<iitype>}` to the `.ref` file. - All othes variants of indexing macros expands internally to `\_iindex`. + The \`\iindex``{<word>}` puts one <word> to the index. It writes + \^`\_Xindex``{<word>}{<iitype>}` to the `.ref` file. + All othes variants of indexing macros expands internally to `\iindex`. \_cod ----------------------------- -\_def\_iindex#1{\_openref{\def~{ }% - \edef\_act{\_noexpand\_wref\_noexpand\_Xindex{{#1}{\_iitypesaved}}}\_act}} +\_def\_iindex#1{\_isempty{#1}\_iffalse\_openref{\def~{ }% + \edef\_act{\_noexpand\_wref\_noexpand\_Xindex{{#1}{\_iitypesaved}}}\_act}\_fi} \_public \iindex ; \_doc ----------------------------- - The `\_Xindex{<word>}{<iitype>}` stores `\,<word>` to the `\_iilist` if - there is first occurence of the <word>. The list of pages where <word> - occurs, is the value of the macro `\,<word>`, so the <gpageno>:<iitype> - is appedned to this list. - Moreower, we need a mapping from <gpageno> to <pageno>, because we print - <pageno> in the index, but hyperlinks are implemented by <gpageno>. - So, the macro `\_pgi:<gpageno>` is defined as <pageno>. + The \`\_Xindex``{<word>}{<iitype>}` stores `\,<word>` to the `\_iilist` if + there is first occurrence of the <word>. The list of pages where `<word>` + occurs, is the value of the macro `\,<word>`, so the `<gpageno>:<iitype>` + is appended to this list. + Moreower, we need a mapping from <gpageno> to `<pageno>`, because we print + `<pageno>` in the index, but hyperlinks are implemented by `<gpageno>`. + So, the macro `\_pgi:<gpageno>` is defined as `<pageno>`. \_cod ----------------------------- \_def \_iilist {} @@ -420,10 +425,13 @@ } \_doc ----------------------------- - The implementation of macros `\ii`, `\iid`, `\iis` follows. + The implementation of macros \`\ii`, \`\iid`, \`\iis` follows. Note that `\ii` works in horizontal mode on order to the `\write` whatsit is not broken from the following word. If you need to keep vertical mode, - use `\_iindex{<word>}` directly. + use \^`\iindex``{<word>}` directly. + \nl + The \`\iitype` `{<type>}` saves the `<type>` to the \`\_iitypesaved` macro. It is + used in the \^`\iindex` macro. \_cod ----------------------------- \_def\_ii #1 {\_leavevmode\_def\_tmp{#1}\_iiA #1,,\_def\_iitypesaved{}} @@ -448,4 +456,5 @@ \_endcode % ------------------------------------- - +2020-04-21 \isempty \iffalse ... \fi added to \iindex +2020-03-26 introduced diff --git a/Master/texmf-dist/tex/luatex/optex/maketoc.opm b/Master/texmf-dist/tex/luatex/optex/maketoc.opm index 6ab711657ec..c1eddc802c8 100644 --- a/Master/texmf-dist/tex/luatex/optex/maketoc.opm +++ b/Master/texmf-dist/tex/luatex/optex/maketoc.opm @@ -1,24 +1,22 @@ -%% This is part of OpTeX project, see http://petr.olsak.net/optex +% This is part of OpTeX project, see http://petr.olsak.net/optex \_codedecl \maketoc {Macros for maketoc <2020-03-12>} % preloaded in format \_doc ------------------------------------ - `\_Xtoc{<level>}{<type>}{<number>}{<text>}` (in `.ref` file) reads the - specified data and saves it to the `\_toclist` as: - - \begtt - \_tocline{<level>}{<type>}{<number>}{<text>}{<gpageno>}{<pageno>} + \`\_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: - <level>: 0 reserved, 1: chapter, 2: section, 3: subsection - <type>: the type of the level, i.e. chap, sec, secc - <number>: the number of the chapter/section/subsection in the format 1.2.3 - <text>: the title text - <gpageno>: the page number numbered from 1 independently of pagination - <pageno>: the page number used in the pagination - \endtt - + \begitems + * `<level>`: 0 reserved, 1: chapter, 2: section, 3: subsection + * `<type>`: the type of the level, i.e. chap, sec, secc + * `<number>`: the number of the chapter/section/subsection in the format 1.2.3 + * `<title>`: the title text + * `<gpageno>`: the page number numbered from 1 independently of pagination + * `<pageno>`: the page number used in the pagination + \enditems The last two parameters are restored from previous - `\_Xpage{<pageno>}{<gpageno>}`, data are saved in the `\_currpage` macro. + \^`\_Xpage``{<pageno>}{<gpageno>}`, data were saved in the \^`\_currpage` macro. \_cod ------------------------------------ \_def\_toclist{} @@ -30,56 +28,62 @@ } \_doc ------------------------------------ - `\_tocline{<level>}{<type>}{<number>}{<text>}{<gpageno>}{<pageno>}` prints + \`\_tocline``{<level>}{<type>}{<number>}{<title>}{<gpageno>}{<pageno>}` prints the record to the table of contents. It opens group, reduces `\_leftskip`, - `\_rightskip`, runs the `\everytocline` (user can customise the design of TOC - here) and runs `\_tocl:<level> {<number>}{<text>}{<page>}` macro. + `\_rightskip`, runs the \^`\everytocline` (user can customise the design of TOC + here) and runs `\_tocl:<level> {<number>}{<title>}{<pageno>}` macro. This macro starts with vertical mode, - inserts one record with given <level> and ends in horizontal mode. Then - `\_tocline` appends `\_nobreak \_hskip-2\_iindent\_null \_par`. This causes + inserts one record with given `<level>` and it should end by \^`\_tocpar` + which returns to hrizontal mode. The `\_tocpar` + appends `\_nobreak \_hskip-2\_iindent\_null \_par`. This causes that the last line of the record is shifted outside the margin given by - `\_rightskip`. A typical record (with long <text>) looks like: + `\_rightskip`. A typical record (with long `<title>`) looks like: \begtt - | | + | | \llap{<number>} text text text text text text text text text text text text .................... <pageno> \endtt - Margins given by `\leftskip` and `\rightskip` are denoted by `|` in the examle above. + \nl + \`\tocrefnum` is global counter of all TOC records (used by hyperlinks). \_cod ------------------------------------ -\def\_tocline#1#2#3#4#5#6{% +\_newcount \_tocrefnum +\_def\_tocline#1#2#3#4#5#6{% \_advance\_tocrefnum by1 \_bgroup \_leftskip=\_iindent \_rightskip=2\_iindent \_ifischap \_advance\_leftskip by \_iindent \_fi - \_def\_pg{\_ilink[pg:#5]}% + \_def\_pgn{\_ilink[pg:#5]}% \_the\_everytocline \_ifcsname _tocl:#1\_endcsname - \_cs{_tocl:#1}{#3}{#4}{#6}\_nobreak \_hskip-2\_iindent\_null \_par + \_cs{_tocl:#1}{#3}{#4}{#6}\_par \_fi \_egroup } +\_public \tocrefnum ; \_doc ----------------------------------- - You can re-define default macros for each level of tocline if you want: + You can re-define default macros for each level of tocline if you want.\nl + Parameters are `{<number>}{<title>}{<pageno>}`. \_cod ----------------------------------- -\_sdef{_tocl:1}#1#2#3{\_nofirst\_bigskip \_bf\_llaptoclink{#1}{#2}\_hfill \_pg{#3}} -\_sdef{_tocl:2}#1#2#3{\_llaptoclink{#1}{#2}\_tocdotfill \_pg{#3}} +\_sdef{_tocl:1}#1#2#3{\_nofirst\_bigskip \_bf\_llaptoclink{#1}{#2}\_hfill \_pgn{#3}\_tocpar} +\_sdef{_tocl:2}#1#2#3{\_llaptoclink{#1}{#2}\_tocdotfill \_pgn{#3}\_tocpar} \_sdef{_tocl:3}#1#2#3{\_advance\_leftskip by\_iindent \_cs{_tocl:2}{#1}{#2}{#3}} \_doc ----------------------------------- The auxiliary macros are: \begitems - * `\_llaptoclink<text>` does `\_noindent\_llap{<linked text>}`. - * `\_tocdotfill` creates dots in the TOC. - * `\_nofirst\macro` applies the `\macro` only if we don't print the first + * \`\_llaptoclink``<text>` does `\_noindent\_llap{<linked text>}`. + * \`\_tocdotfill` creates dots in the TOC. + * \`\_nofirst``\macro` applies the `\macro` only if we don't print the first record of the TOC. - * `\_pg{<pageno>}` creates <pageno> as link to real <gpage> saved in `#6` - of `\tocline`. + * \`\_tocpar` finalizes one TOC recors whith rlapped `<pageno>`. + * \`\_pgn``{<pageno>}` creates <pageno> as link to real `<gpage>` saved in `#6` + of \^`\_tocline`. This is temporarily defined in the \^`\_tocline`. \enditems \_cod ---------------------------------- @@ -87,10 +91,11 @@ \_llap{\_ilink[toc:\_the\_tocrefnum]{\_enspace#1\_kern.4em}\kern.1em}} \_def\_tocdotfill{\_nobreak\_leaders\_hbox to.8em{\_hss.\_hss}\_hskip 1em plus1fill\_relax} \_def\_nofirst #1{\_ifnum \_lastpenalty=11333 \_else #1\_fi} +\_def\_tocpar{\_nobreak \_hskip-2\_iindent\_null \_par} \_doc ----------------------------------- - `\maketoc` prints warning if TOC data is empty, lse it creates TOC by - running `\_toclist` + \`\maketoc` prints warning if TOC data is empty, else it creates TOC by + running \^`\_toclist` \_cod ---------------------------------- \_def\_maketoc{\_par \_ifx\_toclist\_empty @@ -102,9 +107,9 @@ } \_doc ----------------------------------- - `\regmacro` appends its parameters to `\_regtoc`, `\_regmark` and - `\_regoul`. These token lists are used in `\maketoc`, `\_begoutput` and - `\pdfunidef`. + \`\regmacro` appends its parameters to \`\_regtoc`, \`\_regmark` and + \`\_regoul`. These token lists are used in \^`\maketoc`, \^`\_begoutput` and + \^`\pdfunidef`. \_cod \_fin ----------------------------- \_newtoks \_regtoc \_newtoks \_regmark \_newtoks \_regoul @@ -112,8 +117,10 @@ \_def\_regmacro #1#2#3{% \_toksapp\_regtoc{#1}\_toksapp\_regmark{#2}\_toksapp\_regoul{#3}% } - \_public \maketoc \regmacro ; \_endcode +2020-04-23 \_tocpar introduced (incompatible change) +2020-04-22 \_pg -> \_pgn (incompatible change) +2020-03-12 introduced
\ No newline at end of file diff --git a/Master/texmf-dist/tex/luatex/optex/margins.opm b/Master/texmf-dist/tex/luatex/optex/margins.opm index 72c769f672a..a02bf3e57a2 100644 --- a/Master/texmf-dist/tex/luatex/optex/margins.opm +++ b/Master/texmf-dist/tex/luatex/optex/margins.opm @@ -2,6 +2,14 @@ \_codedecl \margins {Macros for margins setting <2020-03-14>} % preloaded in format + \_doc ---------------------------- + \`\margins``/<pg> <fmt> (<left>,<right>,<top>,<bot>)<unit>` + takes its parameters, does calculation and sets `\hoffset`, `\voffset`, + `\hsize` and `\vsize` registers. Note that \OpTeX/ sets the page origin at + the top left corner of the paper, no at the obscure position 1\,in, 1\,in. + It is much more comfortable for macro writers. + \_cod ---------------------------- + \_newdimen\_pgwidth \_newdimen\_pgheight \_pgwidth=0pt \_newdimen\_shiftoffset @@ -41,10 +49,21 @@ } \_def\_setpagedimensC #1=#2:#3 {#1=#2\_ifx^#3^\_tmp\_else#3\_fi\_relax\_truedimen#1} +\_public \margins ; + + \_doc ---------------------------- + The common page dimensions are defined here. + \_cod ---------------------------- + \_sdef{_pgs:a3}{(297,420)mm} \_sdef{_pgs:a4}{(210,297)mm} \_sdef{_pgs:a5}{(148,210)mm} \_sdef{_pgs:a3l}{(420,297)mm} \_sdef{_pgs:a4l}{(297,210)mm} \_sdef{_pgs:a5l}{(210,148)mm} \_sdef{_pgs:b5}{(176,250)mm} \_sdef{_pgs:letter}{(8.5,11)in} + \_doc ---------------------------- + \`\magscale` `[<factor>]` does `\mag=<factor>` and recalculates page + dimensions to their true values. + \_cod ---------------------------- + \_def\_trueunit{} \_def\_magscale[#1]{\_mag=#1\_def\_trueunit{true}% \_ifdim\_pgwidth=0pt \_else \_truedimen\_pgwidth \_truedimen\_pgheight \_fi @@ -52,84 +71,8 @@ } \_def\_truedimen#1{\_ifx\_trueunit\_empty \_else#1=\_ea\_ignorept\_the#1truept \_fi} -\_public - \margins \magscale ; +\_public \magscale ; \_endcode % ----------------------------------------- -\sec Setting the margins -%%%%%%%%%%%%%%%%%%%%%%%% - -OPmac declares paper formats a4, a4l (landscape~a4), a5, a5l, b5, letter and -user can declare another own format by "\sdef": - -\begtt -\sdef{_pgs:b5l}{(250,176)mm} -\sdef{_pgs:letterl}{(11,8.5)in} -\endtt - -The "\margins" command declares margins of the document. This command have -the following parameters: - -\begtt -\margins/<pg> <fmt> (<left>,<right>,<top>,<bot>)<unit> - example: -\margins/1 a4 (2.5,2.5,2,2)cm -\endtt - -Parameters are: - -\begitems -* <pg> \dots\ "1" or "2" specifies one-page or two-pages design. -* <fmt> \dots\ paper format (a4, a4l, a5, letter, etc. or user defined). -* <left>, <right>, <top>, <bot> \dots\ gives the amount of left, right, - top and bottom margins. -* <unit> \dots\ unit used for values <left>, <right>, <top>, <bot>. -\enditems - -Each of the parameters <left>, <right>, <top>, <bot> can be empty. -If both <left> and <right> are nonempty then "\hsize" is set. Else "\hsize" -is unchanged. If both <left> and <right> are empty then typesetting area is -centered in the paper format. The analogical rule works when <top> or <bot> -parameter is empty ("\vsize" instead "\hsize" is used). Examples: - -\begtt -\margins/1 a4 (,,,)mm % \hsize, \vsize untouched, - % typesetting area centered -\margins/1 a4 (,2,,)cm % right margin set to 2cm - % \hsize, \vsize untouched, vertically centered -\endtt - -If "<pg>=1" then all pages have the same margins. If "<pg>=2" then the -declared margins are true for odd pages. The margins at the even pages are -mirrored in such case, it means that <left> is replaced by <right> and vice -versa. - -The "<fmt>" can be in the form "(<width>,<height>)<unit>" where "<unit>" is -optional. If it is missing then "<unit>" after margins specification is -used. For example: - -\begtt -\margins/1 (100,200) (7,7,7,7)mm -\endtt -% -declares the paper 100$\times$200\,mm with all four margins 7\,mm. The spaces -before and after "<fmt>" parameter are necessery. - -The command "\magscale[<factor>]" scales the whole typesetting area. The -fixed point of such scaling is the so called the ``Knuth's point'': 1in -below and 1in right of paper sides. Typesetting (breakpoints etc.) is -unchanged. All units are relative after such scaling. Only paper formats -dimensions stays unscaled. Example: - -\begtt -\margins/2 a5 (22,17,19,21)mm -\magscale[1414] \margins/1 a4 (,,,)mm -\endtt -% -The first line sets the "\hsize" and "\vsize" and margins for final -printing at a5 format. The setting on the second line centers the scaled -typesetting area to the true a4 paper while breaking points for paragraphs -and pages are unchanged. It may be usable for -review printing. After review is done, the second line can be commented out. diff --git a/Master/texmf-dist/tex/luatex/optex/math-macros.opm b/Master/texmf-dist/tex/luatex/optex/math-macros.opm index 6ad97618ff8..14b4a69e411 100644 --- a/Master/texmf-dist/tex/luatex/optex/math-macros.opm +++ b/Master/texmf-dist/tex/luatex/optex/math-macros.opm @@ -2,34 +2,53 @@ \_codedecl \sin {Math macros plus mathchardefs <2020-03-14>} % preloaded in format -%% The character _ as subscript prefix: - -\catcode`\_ = 8 -\let\sb = _ -\catcode`\_ = 13 -\let _ = \sb -\catcode`\_ = 11 + \_doc ----------------------------- + The category code of the character `_` remains as letter (11) and the mathocode + of it is `"8000`. + It means that it is active character in math mode. It is defined as subscript prefix. + + There is a problem: The `x_n` is tokenized as `x`, `_`, `n` and it works + without problem. But `\int``_a^b` is tokenized as `\int``_a`, `^`, `b`. The + control sequence `\int``_a` isn't defined. We must write `\int _a^b`. + + The lua code presented here solves this problem. But you cannot set our own + control sequence in the form `\<word>_` or `\<word>_<one-letter>` (where + <word> is sequence of letters) because such control sequences are + unacessible: proprocessor rewrites it. + + The \`\mathsbon` macro activates the rewritting rule `\<word>_<nonleter>` to + `\<word> _<nonletter>` and + `\<word>``_<letter><nonletter>` to `\<word> _<letter><nonletter>` at input + processor level. The \`\mathsboff` deactivates it. + You can ask by \`\_ifmathsb` if this feature is activated or deactivated. + By default, is is activated in the `\everyjob`. + \_cod ----------------------------- + +\catcode`\_ = 8 \let\sb = _ +\catcode`\_ = 13 \let _ = \sb +\catcode`\_ = 11 \_private \sb ; -% \int_a^b -> \int _a^B, \max_M -> \max _M etc. In general: -% let <word> be a word. Then \<word>_ or \<word>_<one-letter> -% (in both cases terminated by non-leter) will be rewritten to -% \<word> _ or \<word> _<one-letter> in preprocessor. - +\_newifi\_ifmathsb \_mathsbfalse \_def \_mathsbon {% - \directlua{ + \_directlua{ callback.register("process_input_buffer", function (str) return string.gsub(str.." ", "(\_nbb[a-zA-Z]+)_([a-zA-Z]?[^_a-zA-Z])", "\_pcent 1 _\_pcent 2") - end) -}} + end) }% + \_global\_mathsbtrue +} \_def \_mathsboff {% - \directlua{ callback.register("process_input_buffer", nil) }% + \_directlua{ callback.register("process_input_buffer", nil) }% + \_global \_mathsbfalse } \_public \mathsboff \mathsbon ; - -%% Mathcodes prom plainTeX: + \_doc ----------------------------- + All mathcodes are set to equal values as in plain\TeX/. + But all encoding-dependend declarations (like these) will be set + to different values when Unicode-math font is used. + \_cod ----------------------------- \_mathcode`\^^@="2201 % \cdot \_mathcode`\^^A="3223 % \downarrow @@ -99,7 +118,16 @@ \_delcode`\|="26A30C \_delcode`\\="26E30F -%% \mathchardef's from plainTeX: + \_doc ----------------------------- + All control sequences declared by `\mathchardef` are supposed (by default) + only for public usage. It means that they are delcared without `_` prefix. + If such sequences are used in internal \OpTeX/ macro then their internal + prefixed form is declared using `\_private` macro.\nl + These encoding dependent declarations will be set to different values + when Unicode-math font is loaded.\nl + The declared sequences for math symbols are not hyperlinked in this documentation. + \maxlines=15 + \_cod ----------------------------- \_mathchardef\alpha="010B \_mathchardef\beta="010C @@ -268,7 +296,10 @@ \_mathchardef\rightharpoonup="312A \_mathchardef\rightharpoondown="312B -%% Math rm texts: + \_doc ----------------------------- + The math functions like log, sin, cos are declared in tha same way as in + plain\TeX/, but they are `\protected` in \OpTeX/. + \_cod ----------------------------- \_protected\_def\log {\_mathop{\_rm log}\_nolimits} \_protected\_def\lg {\_mathop{\_rm lg}\_nolimits} @@ -303,7 +334,13 @@ \_protected\_def\gcd {\_mathop{\_rm gcd}} \_protected\_def\deg {\_mathop{\_rm deg}\_nolimits} -%% PlainTeX macros: + \_doc ----------------------------- + These macros are defined similarly as in plain\TeX. Only internal macro + names from plain\TeX/ with `@` character are re-written in more readable + form.\nl + \`\sp` is alternative for `^`. The \`\sb` alternative for `_` was defined + at the line 27 of the file `math-macros.opm`. + \_cod ----------------------------- \_let\_sp=^ \public \sp ; % \sb=_ , defined at beginning of this file @@ -313,9 +350,12 @@ \_protected\_def\>{\_mskip\_medmuskip} \let\_medsk = \> \_protected\_def\;{\_mskip\_thickmuskip} \let\_thicksk = \; \_protected\_def\!{\_mskip-\_thinmuskip} \let\_thinneg = \! - %\_def\*{\discretionary{\thinspace\the\textfont2\char2}{}{}} % obsolete + \_doc ----------------------------- + Active \`\prime` character is defined here. + \_cod ----------------------------- + {\_catcode`\'=\active \_gdef'{^\_bgroup\_primes}} % primes dance \_def\_primes{\_prime\_isnextchar'{\_primesA}% {\_isnextchar^{\_primesB}{\_egroup}}} @@ -323,6 +363,13 @@ \_def\_primesB #1#2{#2\egroup} \_private \prime ; + \_doc ----------------------------- + \`\big`, \`\Big`, \`\bigg`, \`\Bigg`, \`\bigl`, \`\bigm`, \`\bigr`, \`\Bigl`, \`\Bigm`, + \`\Bigr`, \`\biggl`, \`\biggm`, \`\biggr`, \`\Biggl`, \`\Biggm`, \`\Bigg`, \`\Biggr` + are based on the \`\_scalebig` macro because we need the dependency on + the various sizes of the fonts. + \_cod ----------------------------- + %{\catcode`\^^Z=\active \gdef^^Z{\not=}} % ^^Z is like \ne in math %obsolete \_def\_scalebig#1#2{{\_left#1\_vbox to#2\_fontdimen6\_textfont1{}% @@ -345,9 +392,11 @@ \_protected\_def\_Biggl{\_mathopen\_Bigg} \_protected\_def\_Biggm{\_mathrel\_Bigg} \_protected\_def\_Biggr{\_mathclose\_Bigg} -\_public - \bigl \bigm \bigr \Bigl \Bigm \Bigr \biggl \biggm \biggr \Biggl \Biggm - \Biggr ; +\_public \bigl \bigm \bigr \Bigl \Bigm \Bigr \biggl \biggm \biggr \Biggl \Biggm \Biggr ; + + \_doc ----------------------------- + Math relations defined by the \`\jointrel` plain \TeX/ macro: + \_cod ----------------------------- \_protected\_def\_joinrel{\_mathrel{\_mkern-2.5mu}} % -3mu in plainTeX \_protected\_def\relbar{\_mathrel{\_smash-}} % \_smash, because - has the same height as + @@ -371,6 +420,10 @@ \longrightarrow \Longleftrightarrow ; \_public \joinrel ; + \_doc ----------------------------- + \`\ldots`, \`\cdots`, \`\vdots`, \`\ddots` from plain \TeX/ + \_cod ----------------------------- + \_mathchardef\_ldotp="613A % ldot as a punctuation mark \_mathchardef\_cdotp="6201 % cdot as a punctuation mark \_mathchardef\_colon="603A % colon as a punctuation mark @@ -386,6 +439,10 @@ \_public \ldots \cdots \vdots \ddots ; + \_doc ----------------------------- + Math accents (encoding dependent declarations). + \_cod ----------------------------- + \_protected\_def\acute{\_mathaccent"7013 } \_protected\_def\grave{\_mathaccent"7012 } \_protected\_def\ddot{\_mathaccent"707F } @@ -399,6 +456,10 @@ \_protected\_def\widetilde{\_mathaccent"0365 } \_protected\_def\widehat{\_mathaccent"0362 } + \_doc ----------------------------- + \`\overrightarrow`, \`\overleftarrow`, \`\overbrace`, \`\underbrace`, \`\skew` macros. + \_cod ----------------------------- + \_def\_math{\_mathsurround0pt } \_protected\_def\_overrightarrow #1{\_vbox{\_math\_ialign{##\_crcr \_rightarrowfill\_crcr\_noalign{\_kern-.1em \_nointerlineskip} @@ -418,6 +479,10 @@ \_public \overrightarrow \overleftarrow \overbrace \underbrace \skew ; + \_doc ----------------------------- + Macros based on `\delimiter`, `\*witdelims` and `\radical` primitives. + \_cod ----------------------------- + \_protected\_def\lmoustache{\_delimiter"437A340 } % top from (, bottom from ) \_protected\_def\rmoustache{\_delimiter"537B341 } % top from ), bottom from ( \_protected\_def\lgroup{\_delimiter"462833A } % extensible ( with sharper tips @@ -449,6 +514,11 @@ \_protected\_def\_sqrt{\_radical"270370 } \_public \sqrt ; + \_doc ----------------------------- + \`\mathpalette`, \`\vphantom`, \`\hphantom`, \`\phantom`, \`\mathstrut`, and + \`\smash` macros from plain \TeX. + \_cod ----------------------------- + \_def\_mathpalette#1#2{\_mathchoice{#1\_displaystyle{#2}}% {#1\_textstyle{#2}}{#1\_scriptstyle{#2}}{#1\_scriptscriptstyle{#2}}} \_newbox\_rootbox @@ -477,6 +547,11 @@ \_def\_finsmash{\_ht0=0pt \_dp0=0pt \_box0 } \_public \mathpalette \vphantom \hphantom \phantom \mathstrut \smash ; + \_doc ----------------------------- + \`\cong`, \`\notin`, \`\rightleftharpoons`, \`\buildrel`, \`\doteq`, \`\bmod` + and \`\pmod` macros from plain \TeX/. + \_cod ----------------------------- + \_protected\_def\_cong{\_mathrel{\_mathpalette\_overeq\_sim}} % congruence sign \_def\_overeq#1#2{\_lower.05em\_vbox{\_lineskiplimit\_maxdimen\_lineskip=-.05em \_ialign{$\_math#1\_hfil##\_hfil$\_crcr#2\_crcr=\_crcr}}} @@ -495,6 +570,10 @@ \_protected\_def\_pmod#1{\_allowbreak\_mkern18mu({\_rm mod}\_thinsk\_thinsk#1)} \_public \bmod \pmod ; + \_doc ----------------------------- + \`\cases`, \`\matrix`, \`\pmatrix` and \`\bordermatrix` macros from plain \TeX/ + \_cod ----------------------------- + \_protected\_def\_cases#1{\_left\{\_thinsk\_vcenter{\_normalbaselines\_math \_ialign{$##\_hfil$&\_quad##\_hfil\_crcr#1\_crcr}}\_right.} \_protected\_def\_matrix#1{\_null\_thinsk\_vcenter{\_normalbaselines\_math @@ -518,6 +597,11 @@ \_null\_thicksk\_vbox{\_kern\_ht1 \_box2}\_endgroup} \_public \cases \matrix \pmatrix \bordermatrix ; + \_doc ----------------------------- + \`\openup`, \`\eqalign`, \`\displaylines` and \`\eqalignno` macros from + plain \TeX/. + \_cod ----------------------------- + \_def\_openup{\_afterassignment\_openupA\_dimen0=} \_def\_openupA{\_advance\_lineskip by\_dimen0 \_advance\_baselineskip by\_dimen0 @@ -546,7 +630,10 @@ #1\_crcr}} \_public \openup \eqalign \displaylines \eqalignno ; -%% Mathchardefs for AMS fonts: + \_doc ----------------------------- + These macros are inspired from `ams-math.tex` file. + \maxlines=15 + \_cod ----------------------------- \_def\_amsafam{4} \_def\_amsbfam{5} @@ -785,12 +872,17 @@ \_let\circledslash\oslash \_let\circleddot\odot -% \not redefined: -% \not< becomes \_nless -% \not> becomes \_ngtr -% if \_notXXX is defined, \not\XXX becomes \_notXXX; -% if \_nXXX is defined, \not\XXX becomes \_nXXX; -% otherwise, \not\XXX is done in the usual way. + \_doc ----------------------------- + The \`\not` macro is re-defined to be mote inteligent than in plain + \TeX/. The macro follows this rule: + \begtt + \not< becomes \_nless + \not> becomes \_ngtr + if \_notXXX is defined, \not\XXX becomes \_notXXX; + if \_nXXX is defined, \not\XXX becomes \_nXXX; + otherwise, \not\XXX is done in the usual way. + \endtt + \_cod ----------------------------- \_mathchardef \_notchar "3236 @@ -811,6 +903,12 @@ \nLeftrightarrow \nleftrightarrow \nexists ; \_public \not ; + \_doc ----------------------------- + The \`\mathbox``{<text>}` macro is copied from OPmac trick 078. + It behaves like `\hbox{<text>}` but the `<text>` is scaled to smaller + size if it is used in scriptstye or scriptscript style. + \_cod ----------------------------- + \_def\_mathbox#1{{\_mathchoice{\_mathboxA\_displaystyle[]{#1}}{\_mathboxA\_textstyle[]{#1}} {\_mathboxA\_textstyle[700]{#1}}{\_mathboxA\_textstyle[500]{#1}}}} \_def\_mathboxA#1[#2]#3{\_hbox{\_everymath={#1}\_if^#2^\_else\_typoscale[#2/]\_relax\_fi #3}} @@ -818,55 +916,3 @@ \_endcode %--------------------------------------------------- -\secc The character `_` as subscript prefix -%------------------------------------------ - -The category code of `_` remains as letter (11) and the mathocode of `_` is -`"8000`. It means that it is active character in math mode. It is defined as -subscript prefix. - -There is a problem: The `x_n` is tokenized as `x`, `_`, `n` and it works -without problem. But `\int_a^b` is tokenized as `\int_a`, `^`, `b`. The -control sequence `\int_a` isn't defined. We m,aut write `\int _a^b`. - -The lua code presented here solves this problem. But you cannot set our own -control sequence in the form `\<word>_` or `\<word>_<one-letter>` (where -<word> is sequence of letters) because such contol sequences are -unacessible: proprocessor rewrites them. - - -\secc Mathcodes from plain\TeX/ -%------------------------------ - -All mathcodes are set to equal values as in plain\TeX/. - - -\secc Mathchardef from plain\TeX/ -%-------------------------------- - -All control sequences declared by `\mathchardef` are supposed (by default) -only for public usage. It means that they are delcared without `_` prefix. -If such sequences are used in internal \OpTeX/ macro then their internal -prefixed form is declared using `\_private` macro only if it is explicitly -needed. - - -\secc Math rm texts -%------------------ - -The math functions like log, sin, cos are declared in tha same way as in -plain\TeX/, but they are `\protected`. - - -\secc Plain\TeX/ macros -%---------------------- - -These macros are defined similarly as in plain\TeX. Only internal macro -names from plain\TeX/ with `@` character are we-written in more readable -form. - -\secc Matchchardefs from AMS fonts -%--------------------------------- - -These macros are inspired from `ams-math.tex` file. - diff --git a/Master/texmf-dist/tex/luatex/optex/math-preload.opm b/Master/texmf-dist/tex/luatex/optex/math-preload.opm index 5251f09424c..b367a70d26e 100644 --- a/Master/texmf-dist/tex/luatex/optex/math-preload.opm +++ b/Master/texmf-dist/tex/luatex/optex/math-preload.opm @@ -1,8 +1,13 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \normalmath {Math fonts CM + AMS preloaded <2020-02-25>} % preloaded in format +\_codedecl \normalmath {Math fonts CM + AMS preloaded <2020-04-14>} % preloaded in format -% Only few text fonts are preloaded: + \_doc ------------------------------ + We have two math macros \`\normalmath` for normal shape of all math + symbols and \`\boldmath` for bold shape of all math symbos. The second one + can be used in bold titles, for example. + These macros load all fonts from all given math font families. + \_cod ------------------------------ \_def\_normalmath{% \_loadmathfamily 0 cmr % CM Roman @@ -36,11 +41,23 @@ } \count18=11 % families declared by \newfam are 12, 13, ... +\_def \normalmath {\_normalmath} \_def\boldmath {\_boldmath} + + \_doc ----------------------------- + The classical math family selectors + \`\mit`, \`\cal`, \`\bbchar`, \`\frak` and \`\script` + are defined here. + The \`\rm`, \`\bf`, \`\it`, \`\bi` and \`\tt` does two things: + they are variant selectors for text fonts and math family selectors for math fonts. + The idea was adapted from plain \TeX/. + \_cod ----------------------------- + \_chardef\_bffam = 8 \_chardef\_bifam = 9 \_chardef\_ttfam = 10 \_chardef\_itfam = 11 +\_protected\_def \_rm {\_tryloadrm \_tenrm \_fam0 } \_protected\_def \_bf {\_tryloadbf \_tenbf \_fam\_bffam} \_protected\_def \_it {\_tryloadit \_tenit \_fam\_itfam} \_protected\_def \_bi {\_tryloadbi \_tenbi \_fam\_bifam} @@ -52,6 +69,13 @@ \_protected\_def \_frak {\_fam7 } % fraktur \_protected\_def \_script {\_fam6 } % more extensive script than \cal +\_public \rm \bf \it \bi \tt \mit \cal \bbchar \frak \script ; + + \_doc ----------------------------- + The optical sizes of Computer Modern fonts, AMS and other fonts + are declared here. + \_cod ----------------------------- + %% CM math fonts, optical sizes: \_regtfm cmmi 0 cmmi5 5.5 cmmi6 6.5 cmmi7 7.5 cmmi8 8.5 cmmi9 9.5 @@ -70,7 +94,6 @@ \_regtfm cmti 0 cmti7 7.5 cmti8 8.5 cmti9 9.5 cmti10 11.1 cmti12 * \_regtfm cmtt 0 cmtt10 11.1 cmtt12 * - %% AMS math fonts, optical sizes: \_regtfm msam 0 msam5 5.5 msam6 6.5 msam7 7.5 msam8 8.5 msam9 9.5 msam10 * @@ -93,7 +116,26 @@ \_regtfm bbisans 0 ecso0500 5.5 ecso0600 6.5 ecso0700 7.5 ecso0800 8.5 ecso0900 9.5 ecso1000 11.1 ecso1200 * -%% macros: + \_doc ----------------------------- + \`\_loadmathfamily` `<number> <font>` loads one math family, i.\,e.\ + the triple of fonts in the text size, script size and script-script size. + The `<font>` is `<font-id>` used in the `\_regtfm` parameter or + the real TFM name. The family is saved as `\fam<number>`. + \nl + \`\_setmathfamily` `<number> \<font-switch>` loads one math family + like `\_loadmathfamily` does it. But the second parameter is a + `\<font-switch>` declared previously by the `\font` primitive. + \nl + The font family is loaded at \`\_sizemtext`, \`\_sizemscript` and + \`\_sizemsscript` sizes. These sizes are set by the + \`\setmathsizes` `[<text-size>/<script-size>/<scriptscript-size>]` macro. + These parameters are given in the \`\ptmunit` unit, it is set to + 1\`\ptunit` and it is set to 1\,pt by defaut. + \nl + \`\_corrmsizes` should be used in the \^`\normalmath` and \^`\boldmath` + macros if you need a size correction when a selected math family is + loaded. It is similar as ex-height correction but for math fonts. + \_cod ----------------------------- \_def\_corrmsizes{\_ptmunit=1\_ptunit\_relax} % for corrections of sizes in diferent fomts @@ -111,6 +153,22 @@ \_optsize=\_sizemsscript \_fontlet#2=#2 at\_optsize \_scriptscriptfont#1=#2% \_optsize=\_optsizesave \_let#2=\_mF } +\_def\_setmathsizes[#1/#2/#3]{% + \_def\_sizemtext{#1\_ptmunit}\_def\_sizemscript{#2\_ptmunit}% + \_def\_sizemsscript{#3\_ptmunit}% +} +\_newdimen\_ptunit \_ptunit=1pt +\_newdimen\_ptmunit \_ptmunit=1\_ptunit + +\_public \setmathsizes \ptunit \ptmunit ; + + \_doc ----------------------------- + The \`\_setmathdimens` macro is used in \^`\normalmath` or \^`\boldmath` + macros. It makes math dimensions dependent on the font size (plain \TeX/ sets + them only for 10\,pt typesetting). The `\skewchar` of some math families are + set here too. + \_cod ----------------------------- + \_def\_setmathdimens{% PlainTeX sets these dimens for 10pt size only: \_delimitershortfall=0.5\_fontdimen6\_textfont3 \_nulldelimiterspace=0.12\_fontdimen6\_textfont3 @@ -119,35 +177,42 @@ \_skewchar\_scriptscriptfont1=127 \_skewchar\_textfont2=48 \_skewchar\_scriptfont2=48 \_skewchar\_scriptscriptfont2=48 + \_skewchar\_textfont6=127 \_skewchar\_scriptfont6=127 + \_skewchar\_scriptscriptfont6=127 } -%% \setmathsizes: - -\_def\_setmathsizes[#1/#2/#3]{% - \_def\_sizemtext{#1\_ptmunit}\_def\_sizemscript{#2\_ptmunit}% - \_def\_sizemsscript{#3\_ptmunit}% -} -\_newdimen\_ptunit \_ptunit=1pt -\_newdimen\_ptmunit \_ptmunit=1\_ptunit + \_doc ----------------------------- + Finaly, we preload a math fonts colleciton in [10/7/5] sizes + when the format is generated. This is done when + `\_suppressfontnotfounderror=1` because we need not errors when format is + generated. Maybe there are not all fonts in the \TeX/ distribution + installed. + \_cod ----------------------------- \_suppressfontnotfounderror=1 \_setmathsizes[10/7/5]\_normalmath \_suppressfontnotfounderror=0 -\_public - \setmathsizes \bf \it \bi \tt \mit \cal \bbchar \frak \script \ptunit ; - -\_def \normalmath {\_normalmath} \_def\boldmath {\_boldmath} \_endcode %--------------------------------------------------- The Computer Modern and AMS fonts are preloaded here in classical math-fam -concept, where each math family includes three fonts with max 256 characters. +concept, where each math family includes three fonts with max 256 characters +(typically 128 characters). + +On the other hand, when \^`\fontfam` macro is used in the document then text +font family and appropriate math family is loaded with Unicoded fonts, i.e. +Unicoded-math is used. It re-defines all settings given here. -On the other hand, when `\fontfam` macro is used in the document then text -font family and appropriate math family is loaded with unicoded fonts, i.e. -unicoded math is used. +The general rule of usage the math fonts in different sizes in \OpTeX/ says: set three +sizes by the macro +\^`\setmathsizes` `[<text-size>/<script-size>/<scriptscript-size>]` and then +load all math fonts in given sizes by \^`\normalmath` or \^`\boldmath` macros. +For example +\begtt +\setmathsizes[12/8.4/6]\normalmath ... math typesetting at 12 pt is ready. +\endtt -The code here is inspired by `ams-math.tex file`. +\_endinput -
\ No newline at end of file +2020-04-14: \skewchar\fam6 added diff --git a/Master/texmf-dist/tex/luatex/optex/math-unicode.opm b/Master/texmf-dist/tex/luatex/optex/math-unicode.opm index fe823b96f4a..a2c455f2518 100644 --- a/Master/texmf-dist/tex/luatex/optex/math-unicode.opm +++ b/Master/texmf-dist/tex/luatex/optex/math-unicode.opm @@ -2,6 +2,20 @@ \_codedecl \loadmath {Unicode Math fonts <2020-02-25>} % preloaded in format + \_doc ----------------------------- + \`\loadmath` `{<Unicode-math font>}` loads given font. It does: + \begitems + * define \`\_unimathfont` as `<Unicode-math font>`, + * redefine `\normalmath` and `\boldmath` macros to their Unicode counterparts, + * load the `\_unimathfont` by `\normalmath`, + * print information about loaded font on the terminal, + * redefine all encoding dependent setting by `\input unimath-codes.opm`, + * protect new loading by setting \`\_ifmathloading` to false. + \enditems + \`\noloadmath` disallows Unicode-math loading by \`\_mathloadingfalse`.\nl + \`\doloadmath` allows Unicode-math loading by \`\_mathloadingtrue`. + \_cod ----------------------------- + \_newifi \_ifmathloading \_mathloadingtrue \_def\_noloadmath{\_mathloadingfalse} @@ -17,10 +31,20 @@ \_let\_normalmath = \_normalunimath \_let\_boldmath = \_boldunimath \_normalmath \_wterm {MATH-FONT: "#1" -- unicode math prepared.}% - \_setctable\_optexcatcodes \_input unimath-codes.opm \_restorectable + \_opinput {unimath-codes.opm}% \_mathloadingfalse \_fi\_fi} +\_public \loadmath \noloadmath \doloadmath ; + + \_doc ----------------------------- + \`\loadboldmath` `{<bold-font>} \to {<normal-font>}` + defines \`\_unimathboldfont` as `<bold-font>` only if `\_unimathfont` is + defined as `<normal-font>`. It is used when `\boldmath` macro is run. + When no `\_unimathboldfont` is defined then the `\boldmath` macro + use \"fake bold" generated by `embolden` \LuaTeX/ font feature. + \_cod ----------------------------- + \_def\_loadboldmath#1#2\to #3{% \_def\_tmp{#3}\_ifx\_unimathfont\_tmp % do work only if #3 is loaded as normal Math \_isfont"#1"\_iffalse @@ -30,10 +54,19 @@ \_wterm {MATH-FONT: "#1" -- unicode math bold prepared.}% \_fi\_fi} +\_public \loadboldmath ; + + \_doc ----------------------------- + The Unicode version of the \^`\normalmath` and \^`\boldmath` macros + are defined here as \`\_normalunimath` and \`\_boldunimath` macros. + They are using \`\_setunimathdimens` in similar sense as + \^`\_setmathdimens`. + \_cod ----------------------------- + \_def\_normalunimath{% \_loadumathfamily 1 {\_unimathfont}{} % Base font \_loadmathfamily 4 rsfs % script - \_setmathdimens + \_setunimathdimens }% \_def\_boldunimath{% \_ifx\_unimathboldfont \_undefined @@ -42,9 +75,26 @@ \_loadumathfamily 1 {\_unimathboldfont}{} % Base real bold font \_fi \_loadmathfamily 4 rsfs % script - \_setmathdimens + \_setunimathdimens }% +\_def\_setunimathdimens{% PlainTeX sets these dimens for 10pt size only: + \_delimitershortfall=0.5\_fontdimen6\_textfont3 + \_nulldelimiterspace=0.12\_fontdimen6\_textfont3 + \_scriptspace=0.05\_fontdimen6\_textfont3 +} + \_doc ----------------------------- + \`\_loadumathfamily` `<number> {<font>}{<font features>}` + loads the given Unicode-math fonts in three sizes given by the + \^`\setmathsizes` macro and sets it as the math family `<number>`. + The `<font features>` are added to the default + \`\_mfontfeatures` and to the size dependent features `+ssty=0` + if script size is asked or `+ssty=1` if scriptscriptsize is asked. + If the fath family 1 is loaded then the family 2 and 3 is set by the same + font because \TeX/ needs to read dimension information about generating + math formulae from these three math families. All information needed by + \TeX/ is collected in single Unicode-math font. + \_cod ----------------------------- \_def\_umathname#1#2{"#1:\_mfontfeatures#2"} \_def\_mfontfeatures{mode=base;script=math;} @@ -55,11 +105,40 @@ \_ifnum#1=1 \_textfont2=\_mF \_textfont3=\_mF \_fi \_optsize=\_sizemscript \_font\_mF=\_umathname{#2}{+ssty=0;#3} at\_optsize \_scriptfont#1=\_mF \_ifnum#1=1 \_scriptfont2=\_mF \_scriptfont3=\_mF \_fi - \_optsize=\_sizemsscript \_font\_mF=\_umathname{#2}{+ssty=1;#3} at\_optsize \_scriptscriptfont#1=\_mF + \_optsize=\_sizemsscript \_font\_mF=\_umathname{#2}{+ssty=1;#3} at\_optsize\_scriptscriptfont#1=\_mF \_ifnum#1=1 \_scriptscriptfont2=\_mF \_scriptscriptfont3=\_mF \_fi \_optsize=\_optsizesave \_relax } + \_doc ----------------------------- + Unicode math font includes all typical math alphabets together, user needs not to + load more \TeX/ math families. These math aphabets are encoded by + different parts of Unicode table. We need auxiliary macros for setting + mathcodes by selected math alphabet. + \nl + \`\_umathrange` `{<from->-<to>}\<first>` sets `\Umathcode`s + of the characters in the interval `<from>-<to>` to `\<first>`, + `\<first>+1`, `\<first>+2` + etc., but \`\_umathcharholes` are skipped + (`\_umathcharholes` are parts of the Unicode table not designed for math + alphabets but they causes that the math alphabets are + not continuously spread out in the table; I mean that the + designers were under the influence of drugs when they created + this part of the Unicode table). + The `<from>-<to>` clause includes normal letters like `A-Z`. + \nl + \`\_umahrangegreek` `\<first>` is the same as + `\_umathrange {<alpha>-<omega>}\<first>`. + \nl + \`\_umahrangeGREEK` `\<first>` is the same as + `\_umathrange {<Alpha>-<Omega>}\<first>`. + \nl + \`\_greekdef` `<control sequences> \_relax` defines each control sequence + as a normal character with codes `\_umathnumB`, `\_umathnumB+1`, + `\_umathnumB+2` etc. It is used for redefinig the contol sequences for + math Greek `\alpha`, `\beta`, `\gamma` etc. + \_cod ----------------------------- + \_newcount\_umathnumA \_newcount\_umathnumB \_def\_umathcorr#1#2{\_ea#1\_ea{\_the#2}} @@ -95,19 +174,16 @@ \_expandafter\_greekdef \_fi } -\_public - \loadmath \loadboldmath \noloadmath \doloadmath ; - \_endcode --------------------------------------------- -The `\loadmath` macro loads math fonts and sets math-codes using \input -unimath-codes.opm. If UnicodeMath font is loaded then `\_mathloadingfalse` -is set, so new UnicodeMath font isn't loaded until `\domathload` is used. +The \^`\loadmath` `{<Unicode-math font>}` macro loads math fonts and +redefines all default math-codes using `\input unimath-codes.opm`. +If Unicode-math font is loaded then \^`\_mathloadingfalse` +is set, so new UnicodeMath font isn't loaded until \^`\doloadmath` is used. -`\loadadboldmath{<bold-font>} \to {<normal-font>}` loads bold variant only -if <normal-font> was sucessully loaded. For example: +\^`\loadboldmath` `{<bold-font>} \to {<normal-font>}` loads bold variant only +if `<normal-font>` was sucessully loaded by the `\loadmath`. For example: \begtt \loadmath {[xitsmath-regular]} @@ -115,24 +191,46 @@ if <normal-font> was sucessully loaded. For example: \endtt You can combine more fonts, if you register them to another -math families (5, 6, 7, etc.) in \normalmath macro. +math families (5, 6, 7, etc.) in the `\normalmath` macro. -The default value of \normalmath shows a combination of base Unicode Math -font with 8bit Math font at family 4. See definition of \script macro where -\fam4 is used. Of course, we need to set \rmvariables too, because 8bit font +The default value of `\normalmath` shows a combination of base Unicode Math +font with 8bit Math font at family 4. See definition of `\script` macro where +`\fam4` is used. Of course, we need to set `\rmvariables` too, because 8bit font accepts only codes less than 255. -See http://tex.stackexchange.com/questions/308749/ for more technical details. +See \url{http://tex.stackexchange.com/questions/308749/} for more technical details. + +The \^`\loadmath` macro was succesfully tested on: + +\begtt +\loadmath{[XITSMath-Regular]} ... XITS MATH +\loadmath{[latinmodern-math]} ... Latin Modern Math +\loadmath{[texgyretermes-math]} ... TeXGyre Termes Math +\loadmath{[texgyrebonum-math]} ... TeXGyre Bonum Math +\loadmath{[texgyrepagella-math]} ... TeXGyre Pagella Math +\loadmath{[texgyreschola-math]} ... TeXGyre Schola Math +\loadmath{[texgyredejavu-math]} ... TeXGyre DeJaVu Math +\loadmath{[LibertinusMath-Regular]} ... Libertinus Math +\loadmath{[FiraMath-Regular]} ... Fira Math +\loadmath{[Asana-Math]} ... Asana Math +\endtt + +\secc Unicode-math macros preloaded in the format + +\printdoc math-unicode.opm + +\secc Macros and codes set when \code{\\loadmatfont} is processed + +The file `unimath-codes.opm` is loaded when the \^`\loadmath` is used. The +macros here redefines globally all encoding dependent settings declared in +the section~\ref[math-macros]. + +\printdoc unimath-codes.opm +\printdoctail unimath-codes.opm + + --------------------- +\_endinput -\loadmath{[XITSMath-Regular]} ... XITS MATH^^J -\loadmath{[latinmodern-math]} ... Latin Modern Math^^J -\loadmath{[texgyretermes-math]} ... TeXGyre Termes Math^^J -\loadmath{[texgyrebonum-math]} ... TeXGyre Bonum Math^^J -\loadmath{[texgyrepagella-math]} ... TeXGyre Pagella Math^^J -\loadmath{[texgyreschola-math]} ... TeXGyre Schola Math^^J -\loadmath{[texgyredejavu-math]} ... TeXGyre DeJaVu Math^^J -\loadmath{[LibertinusMath-Regular]} ... Libertinus Math^^J -\loadmath{[FiraMath-Regular]} ... Fira Math^^J -\loadmath{[Asana-Math]} ... Asana Math^^J +2020-04-15 \_setmathdimens -> \_setuniathdimens +2020-02-25 implemented diff --git a/Master/texmf-dist/tex/luatex/optex/more-macros.opm b/Master/texmf-dist/tex/luatex/optex/more-macros.opm index 4f4c4d113bc..64cbcd84c95 100644 --- a/Master/texmf-dist/tex/luatex/optex/more-macros.opm +++ b/Master/texmf-dist/tex/luatex/optex/more-macros.opm @@ -2,19 +2,45 @@ \_codedecl \eoldef {OpTeX useful macos <2020-03-15>} % preloaded in format -\_newcatcodetable \_optexcatcodes -\_savecatcodetable\_optexcatcodes + \_doc ----------------------------- + We define \`\opinput` `{<file name>}` macro which + does `\input {<file name>}` but catocodes are set to normal catcodes + (like \OpTeX/ initializes them) and the catodes setting is return back to + the current values when the file is read. You can use `\optinput` + in any situation inside the document and you will be sure that the file + is read correctly with correct catcode settings. + + In order to achieve this, we declare \`\optexcatcodes` catcode table + and \`\plaintexcatocdes`. They save the commonly used catcode tables. + Note that `\catcodetable` is a part of \LuaTeX/ extension. + The catcodetable stack is implemented by \OpTeX/ macros. + The \`\setctable` `<catcode table>` pushes + current catcode table to the stack and activates catcodes from + the `<catcode table>`. The \`\restorectable` returns to the saved catocdes + from the catcode table stack. So, the `\opinput` macro can be implemented simply: + \_cod ----------------------------- -\_def\_normalcatcodes {\_catcodetable\_optexcatcodes \_savecatcodetable0 \_catcodetable0 } +\_def\_opinput #1{\_setctable\_optexcatcodes \_input "#1" \_restorectable} +\_newcatcodetable \_optexcatcodes \_newcatcodetable \_plaintexcatcodes -\_public - \optexcatcodes \plaintexcatcodes ; +\_public \optexcatcodes \plaintexcatcodes \opinput ; + +\_savecatcodetable\_optexcatcodes {\_catcode`_=8 \savecatcodetable\plaintexcatcodes} -% \catcodetable stack -% use \setctable<num> ... \setctable<num> ... \restorectable ... \restorectable + \_doc ----------------------------- + The implementation of the catcodetable stack follows. + + The current catodes are + managed in the `\catcodetable0`. If the `\setctable` is used first (or at + the outer level of the stack), then the `\catcodetable0` is pushed to the + stack and the current table is re-set to the given `<catcode table>`. + The numbers of these tables are stacked to the \`\_ctablelist` macro. + The `\restorectable` reads the last saved catcode table number from the + `\_ctablelist` and uses it. + \_cod ----------------------------- \_newcount\_currctable \_currctable=0 \_catcodetable0 @@ -30,10 +56,32 @@ } \_def\_ctablelist{.} -\_def\_opinput #1{\_setctable\_optexcatcodes \_input "#1" \_restorectable} +\_public \setctable \restorectable ; + \_doc ----------------------------- + When a special macro is defined with different catcodes then + \`\normalcatcodes` can be used at the end of such definition. + The normal catcodes are restored. + The macro reads + catcodes from `\optecatodes` table and sets it to the main catcode table 0. + \_cod ----------------------------- -% \optdef \foo [opt-default] #1#2{...\the\opt...}, usage \foo {}{} or \foo [opt] {}{} +\_def\_normalcatcodes {\_catcodetable\_optexcatcodes \_savecatcodetable0 \_catcodetable0 } +\_public \normalcatodes ; + + \_doc ----------------------------- + The declarator \`\optdef``\macro [<opt default>] <params>{<replacement text>}` + defines the `\macro` with the optional parameter followed by normal parameters + declared in `<params>`. The optional parameter must be used as the first + first parameter in brackets `[...]`. If it isn't used then <opt default> + is taken into account. The `<replacement text>` can use `\the\opt` + because optional parameter is saved to the \`\opt` tokens register. + Note the difference from \LaTeX/ concept where the optional parameter is + in `#1`. \OpTeX/ uses `#1` as the first normal parameter (if declared). + + The \`\_nospaceafter` ignores the following optional space at expand + processor level using the negative `\romannumeral` trick. + \_cod ----------------------------- \_def\_optdef#1[#2]{% \_def#1{\_opt={#2}\_isnextchar[{\_cs{_oA:\_string#1}}{\_cs{_oB:\_string#1}}}% @@ -41,25 +89,47 @@ \_sdef{_oB:\_string#1\_nospaceafter}% } \_def\_nospaceafter#1{\_ea#1\_romannumeral-`\.} - \_newtoks\_opt -% \eoldef \foo #1{thex to end of line is: #1} +\_public \opt \optdef ; + + \_doc ----------------------------- + The declarator \`\eoldef``\macro #1{<replacement text>}` defines a `\macro` + which scans its parameter to the end of the current line. + This is the parameter `#1` which can be used in the `<replacement text>`. + The catcode of the `\endlinechar` is reset temporarily when the parameter is scanned. + + The macro defined by `\eoldef` cannot be used with its parameter inside + other macros because the catcode dancing is not possible here. But the + \`\bracedparam``\macro{<parameter>}` can be used here. The `\bracedparam` + is a prefix which re-sets temporarily the `\macro` to a `\macro` with + normal one parameter. + + The \`\skiptoeol` macro reads the text to the end of the current line + and ignores it. + \_cod ----------------------------- \_def\_eoldef #1{\_def #1{\_begingroup \_catcode`\^^M=12 \_eoldefA #1}% \_ea\_def\_csname _\_csstring #1:M\_endcsname} \_catcode`\^^M=12 % \_def\_eoldefA #1#2^^M{\_endgroup\_csname _\_csstring #1:M\_endcsname{#2}}% \_normalcatcodes % -\_eoldef\_skiptoeol#1{} +\_eoldef\_skiptoeol#1{} \_def\_bracedparam#1{\_ifcsname _\_csstring #1:M\_endcsname \_csname _\_csstring #1:M\_ea \_endcsname \_else \_csname __in\_csstring #1:M\_ea \_endcsname \_fi } +\_public \eoldef \skiptoeol \bracedparam ; - -\_public \opt \optdef \eoldef \skiptoeol ; + \_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 + `<textA>` are not replaced if they are \"hidden" in braces, for example + `...{...<textA>...}...`. The category codes in the `<textA>` must exactly + match. + \_cod ----------------------------- \_catcode`!=3 \_catcode`?=3 \_def\_replstring #1#2#3{% \replstring #1{stringA}{stringB} @@ -70,69 +140,77 @@ \_long\_def\_replacestringsA##1?{\_def #1{##1}}\_ea\_replacestringsA #1} \_normalcatcodes -\_def\_remfirstunderscore#1{\_ea\_remfirstunderscoreA#1\_relax#1} -\_def\_remfirstunderscoreA#1#2\_relax#3{\_if _#1\_def#3{#2}\_fi} - -\_ea\_def \_ea\_meaningsepare \_ea#\_ea1\_string m#2:#3->#4^{{#1}{#3}{#4}} +\_public \replstring ; -% \keepinputnames ... \input foo ... \lastinputname -> foo + \_doc ----------------------------- + The \`\catcode` primitive is redefined here. Why? + There is very common cases like \code{\\catcode`}`<something>` + or `\catcode"<number>` but these characters + \code{\`} or \code{"} can be set as active (typically by `\activettchar` macro). + Nothing problematic happens if re-defined `\catcode` is used in this case. -\_def\_keepinputnames{\_directlua{% - callback.register("find_read_file", - function (id, name) - input_file_name = name - return name - end) -}} -\_def\_lastinputname{\_directlua{tex.print(input_file_name)}} + If you really need primitive `\catcode` then you can use `\_catcode`. + \_cod ----------------------------- \def\catcode{\_catcode\_string} % more robust in cases \catcode` or \catcode" -% \removespaces text with spaces {} -> textwithspaces + \_doc ----------------------------- + The \`\removespaces` `<text with spaces >{}` expands to <textwithoutspaces>. + \nl + The `\_ea`\`\ignorept``\the<dimen>` expands to a decimal + number `\the<dimen>` but without `pt` unit. + \nl + The \`\ignoreit``<token>` just ignores the `<token>`. + \_cod ----------------------------- \_def\_removespaces #1 {\_isempty{#1}\_iffalse #1\_ea\_removespaces\_fi} +\_ea\_def \_ea\_ignorept \_ea#\_ea1\detokenize{pt}{#1} +\_def\_ignoreit#1{} - \_doc ---------------------------- - `\trycs{<csname>}{<text>} expands to \<csname> if it is defined else to <text>. - \_cod ---------------------------- +\public \removespaces \ignorept \ignoreit ; + + \_doc ----------------------------- + You can use expandable \`\bp``{<dimen>}` convertor from + \TeX/ `<dimen>` (or from an expression accepted by + `\dimexpr` primitive) to a decimal value in big points + (used as natural unit in the PDF format). So, you can write, for example: + \begtt + \pdfliteral{q \_bp{.3\hsize-2mm} \_bp{2mm} m 0 \_bp{-4mm} l S Q} + \endtt + You can use expandable \`\expr``{<expression>}` for analogical purposes. + It expands to the value of the `<expression>` at expand processor level + with \`\_decdigits` digits after decimal point. + The `<expression>` can include `+-*/()` and decimal numbers in common syntax. + + The usage of prefixed versions \`\_expr` or \`\_bp` is more recommended + because user can re-define the control sequences `\expr` or `\bp`. + \_cod ----------------------------- + +\_def\_decdigits{3} % digits after decimal point in \_bp and \_expr outputs. +\_def\_pttopb{% + \_directlua{tex.print(string.format('\_pcent.\_decdigits f', + token.scan_dimen()/65781.76))}% pt to bp conversion +} +\def\_bp#1{\_ea\_pttopb\_dimexpr#1\_relax} +\def\_expr#1{\_directlua{tex.print(string.format('\_pcent.\_decdigits f',#1))}} -\_def \_trycs#1#2{\_ifcsname #1\_endcsname \_csname #1\_endcsname \_else #2\_fi} +\_public \expr \bp ; \_doc ------------------ - The pair {`\_doc ... \cod`} is used for documenting macros and to - printing the third part of main \OpTeX/ documentation: The - implementation. The syntax is: + The pair {\`\_doc` ... \`\_cod`} is used for documenting macros and to + printing the technical documentation of the \OpTeX/. The syntax is: {\begtt \_doc <ignored text> <documentation> \_cod <ignored text> - \endtt} - The last {\_cod} in the file must be followed by `\_fin`. This is a - signal, that the following code does not ends by next `\_doc` but by - {`\_endcode`} command. The {`\_doc...\cod`} is redefined in macros used - for documentation printing. - - The <documentation> (and <ignored text> too) must be <balanced text>. - It means that you canot document only `{` but you must document `}` too. + \endtt + } + The `<documentation>` (and `<ignored text>` too) must be `<balanced text>`. + It means that you cannot document only the `{` but you must document the `}` too. \_cod ------------------ \_long\_def\_doc #1\_cod {\_skiptoeol} -\_ea \_def \_ea\_ignorept \_ea#\_ea1\detokenize{pt}{#1} -\_def\_ignoreit#1{} - -\public - \setctable \restorectable - \normalcatodes \opt \optdef \eoldef \bracedparam \replstring - \keepinputnames \lastinputname \removespaces \trycs - \ignorept \ignoreit ; - \_endcode % ------------------------------------- - -The `\ignoreit` macro ignores next token. The \ignorept macro used ike this: -\begtt -\ea\ignorept \the\dimen... -\endtt -consumes the "pt" phrase appended to dimen value by `\the`. diff --git a/Master/texmf-dist/tex/luatex/optex/multicolumns.opm b/Master/texmf-dist/tex/luatex/optex/multicolumns.opm index cf4d26bbb4f..c593f725522 100644 --- a/Master/texmf-dist/tex/luatex/optex/multicolumns.opm +++ b/Master/texmf-dist/tex/luatex/optex/multicolumns.opm @@ -5,7 +5,8 @@ \_doc ----------------------------- This code is documented in detail in the \"\TeX/book naruby", pages 244--246, free available, \url{http://petr.olsak.net/tbn.html}, but in Czech. - Roughly speaking, macros complete all material between `\begmulti` and `\endmulti` + Roughly speaking, macros complete all material between + \`\begmulti``<num-columns>` and \`\endmulti` into one `\vbox 6`. Then the macro measures the amount of free space at the current page using `\pagegoal` and `\pagtotal` and does `\vsplit` of `\vbox 6` to columns with height of such free space. This is done only if we have @@ -49,6 +50,11 @@ \_else \_balancecolumns \_fi % only balancing \_multiskip\_egroup } + + \_doc ----------------------------- + Splitting columns... + \_cod ----------------------------- + \_def\_makecolumns{\_bgroup % full page, destination height: \dimen1 \_vbadness=20000 \_setbox1=\_hbox{}\_tmpnum=0 \_loop \_ifnum\_Ncols>\_tmpnum @@ -75,6 +81,11 @@ \_else \_balancecolumns % last balancing \_fi \_fi } + + \_doc ----------------------------- + Final balancing of the columns. + \_cod ----------------------------- + \_def\_balancecolumns{\_bgroup \_setbox7=\_copy6 % destination height: \dimen0 \_ifdim\_dimen0>\_baselineskip \_else \_dimen0=\_baselineskip \_fi \_vbadness=20000 diff --git a/Master/texmf-dist/tex/luatex/optex/optex.ini b/Master/texmf-dist/tex/luatex/optex/optex.ini index 31d5f5171ae..7c1083c791a 100644 --- a/Master/texmf-dist/tex/luatex/optex/optex.ini +++ b/Master/texmf-dist/tex/luatex/optex/optex.ini @@ -1,7 +1,7 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex %% OpTeX ini file -%% Petr Olsak <started from: Jan. 2020> +%% Petr Olsak <project started from: Jan. 2020> % Catcodes: @@ -21,7 +21,8 @@ % OpTeX version -\def\optexversion{Alpha 0.08 Mar 2020} +\def\optexversion{Beta 0.10 Apr 2020} +\def\fmtname{OpTeX} % Engine testing: @@ -39,7 +40,6 @@ \let\_endcode =\endinput \def \_codedecl #1#2{\message{#2^^J}}% information about .opm file \long\def\_doc#1\_cod#2 {} % skip documentation -\let\_fin=\relax % Initialization: @@ -47,7 +47,7 @@ \input prefixed.opm % prefixed primitives and code syntax \input luatex-ini.opm % luaTeX initialization -\input basics-macros.opm % basic macros +\input basic-macros.opm % basic macros \input alloc.opm % allocators for registers \input if-macros.opm % special \if-macros, \is-macros and loops \input parameters.opm % parameters setting @@ -60,18 +60,19 @@ \input math-macros.opm % basic macros for math plus mathchardefs (todo: x) \input math-unicode.opm % macros for loading UnicodeMath fonts (todo: x) \input fonts-opmac.opm % font managing macros from OPmac (todo: doc) -\input maketoc.opm % maketoc -\input outlines.opm % PDF outlines (todo: x) -\input pdfuni-string.opm % PDFunicode strings for outlines (todo: x) \input output.opm % output routine \input margins.opm % macros for margins setting (todo: texdoc) \input colors.opm % colors \input ref-file.opm % ref file \input references.opm % references \input hyperlinks.opm % hyperlinks +\input maketoc.opm % maketoc +\input outlines.opm % PDF outlines (todo: x) +\input pdfuni-string.opm % PDFunicode strings for outlines (todo: x) \input sections.opm % titles, chapters, sections \input lists.opm % lists, \begitems, \enditems \input verbatim.opm % verbatim +\input hi-syntax.opm % syntax highlighting of verbatim listimgs \input graphics.opm % graphics \input table.opm % table macro \input multicolumns.opm % more columns by \begmulti ...\endmulti @@ -91,36 +92,8 @@ \_mathsbon % replaces \int_a^b to \int _a^b \_inputref % inputs \jobname.ref if exists } -\let\loadmathfonts=\relax % TODO: unicode-math \_dump \_endcode % ------------------------------ -TODO: -- re-implement macros from opmac-rest.opm -- re-implement usebib, bib-style.opm -- add modules support (for example opmac-bib) -- write more and better documentation -- ... - -DOC: -- optex-doc.tex optex-doc.pdf -- about Font selection system: ....... files: fonts-select.opm, fonts-opmac.opm, - fonts-resize.opm, f-heros.opm, f-lmfonts.opm - fams-ini.opm -- about user/internal name spaces .... files: prefixed.opm, math-macros.opm -- additional doc is in more files... - -NOTES FOR TESTERS: -- We don't want to keep absolutely backward compatibility. For example obscurities like - \z@, \p@, \f@@t are not supported. -- The page origin is at left upper corner of the paper (no at 1in, 1in coordinates). -- The default papersize is A4 with 2cm margins (no letter with 1in margins]. - Use \margins macro to change these parameters. -- Only few 8bit fonts are preloaded in format. Use \fontfam[LMfonts] (or select another - fonts family by \fontfam[?]) at beginning of document. Unicode fonts will be loaded. -- The accents macros \v, \' are undefined, Use native characters š,č,é, etc. - If you expicitly needs this old feature, use \oldaccents macro. -- The font switchers like \_tenrm, \_tenbf have only internal names, i.e - \tenrm, \tenbf are undefined. diff --git a/Master/texmf-dist/tex/luatex/optex/others.opm b/Master/texmf-dist/tex/luatex/optex/others.opm index 6c656ec0e0e..dc4956b0a34 100644 --- a/Master/texmf-dist/tex/luatex/optex/others.opm +++ b/Master/texmf-dist/tex/luatex/optex/others.opm @@ -1,12 +1,17 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \uv {Miscenaleous <2020-03-14>} % preloaded in format +\_codedecl \uv {Miscenaleous <2020-04-02>} % preloaded in format -% You can write \useOpTeX at begining of your document + \_doc ---------------------------- + \`\useOpTeX` and \`\useoptex` are declared as `\relax`. + \_cod ---------------------------- \_let \useOpTeX = \_relax \_let \useoptex = \_relax -% lastpage/totalpages + \_doc ---------------------------- + The \`\lastpage` and \`\totalpages` get the information from the + \^`\_currpage`. The \^`\_Xpage` from `.ref` file sets the \^`\_currpage`. + \_cod ---------------------------- \_def\_totalpages {\_openref\_ea\_lastpageA\_currpage} \_def\_lastpage {\_openref\_ea\_lastpageB\_currpage} @@ -15,6 +20,14 @@ \_def\_currpage {{0}{?}} \_public \lastpage \totalpages ; + \_doc ---------------------------- + We need \`\uv`, \`\clqq`, \`\crqq`, \`\flqq`, \`\frqq`, \`\uslang`, \`\ehyph` + \`\chyph`, \`\shyph`, for backward compatibility with \csplain. + Codes are set according to Unicode, because we are using Czech only in Unicode + when \LuaTeX/ is used. + \_cod ---------------------------- + + % for compatibility with csplain: \_chardef\clqq=8222 \_chardef\crqq=8220 @@ -27,32 +40,36 @@ \_let\chyph=\cslang \_let\shyph=\sklang \_let\csUnicode=\csPatt \_let\czUnicode=\csPatt \_let\skUnicode=\skPatt -% classical \ten* macros (keeps only preloaded fonts!) + \_doc ---------------------------- + The \`\letfont` was used in \csplain/ instead of `\fontlet`. + \_cod ---------------------------- \_let \letfont = \_fontlet -\_let \tenrm = \_tenrm \_let \tenbf = \_tenbf -\_let \tenit = \_tenit \_let \tenbi = \_tenbi -\_let \tentt = \_tentt -% non breaking space in Unicode + \_doc ---------------------------- + Non breaking space in Unicode. + \_cod ---------------------------- \let ^^a0=~ -% TikZ needs these control sequences: + \_doc ---------------------------- + TikZ needs these control sequences. + \_cod ---------------------------- \ea\toksdef \csname toks@\endcsname=0 \ea\let \csname voidb@x\endcsname=\_voidbox -% another \tmpnum and \tmpdim are declared for user macros, no the same as private: - -\newcount\tmpnum % auxiliary count -\newdimen\tmpdim % auxiliary dimen - -% We don't want to read opmac.tex unless \input opmac is specified: + \_doc ---------------------------- + We don't want to read `opmac.tex` unless `\input opmac` is specified. + \_cod ---------------------------- \def\OPmacversion{OpTeX} -% Lorem ipsum. Usage \lipsum[3] or \lipsum[112-121], max=150 + \_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`. + \_cod ---------------------------- \_def \_lipsum {% {\_long\_def\ProvidesFile##1[##2]##3{\_ifx\_par##3\_relax\_else \_ea##3\_fi}\_tmpnum=0 @@ -65,7 +82,7 @@ \_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 + \_loop \_csname lips:\_the\_tmpnum\_endcsname \par % \par is better here \_ifnum\_tmpnum<\_tmp \_advance\_tmpnum by1 \_repeat } \def\lipsum {\_lipsum} @@ -73,6 +90,3 @@ \_endcode -These codes are usable only after Unicode font is loaded using \fontfam. -If you don't use Unicode fonts then more characters from Czech language stay -unavailable (ř, ů, for example). See the notice in `fonts-preoad.opm`. diff --git a/Master/texmf-dist/tex/luatex/optex/outlines.opm b/Master/texmf-dist/tex/luatex/optex/outlines.opm index 90e9a4a0aa1..a66c3161294 100644 --- a/Master/texmf-dist/tex/luatex/optex/outlines.opm +++ b/Master/texmf-dist/tex/luatex/optex/outlines.opm @@ -1,6 +1,6 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \pdfunidef {PDF outlines <2020-03-12>} % preloaded in format +\_codedecl \outlines {PDF outlines <2020-03-12>} % preloaded in format \_def\_outlines#1{\_pdfcatalog{/PageMode/UseOutlines}\_openref \_ifx\_toclist\_empty @@ -50,9 +50,7 @@ \_pdfunidef\_tmp{#1}% \_pdfoutline goto name{oul:\_the\_oulnum} count0 {\_tmp}\_relax } - -\_public - \outlines \insertoutline ; +\_public \outlines \insertoutline ; \_endcode % ---------------------------- @@ -62,27 +60,27 @@ outlines. But we know only the level of each outline. The required data should be calculated from TOC data. We use two steps over TOC data saved in the `\_toclist` where each record is represented by one `\_tocline`. -First step, the `\outline` macro sets `\_tocline` to `\_outlineA` and +First step, the \`\outlines` macro sets `\_tocline` to \`\_outlinesA` and calculates the number of direct descendants of each record. Second step, -the `\outline` macro sets `\_tocline` to `\_codlineB` and it uses prepared -data and crete outlines. +the `\outlines` macro sets `\_tocline` to \`\_outlinesB` and it uses prepared +data and create outlines. Each ouline is mapped to the control sequence of the type `\_ol:<num>` or `\_ol:<num>:<num>` or `\_ol:<num>:<num>:<num>` or etc. The first one is reserved for level 0, the second one for level 1 (chapters), third one for level 2 (sections) etc. The number of direct descentants will be stored -in these macros after first step i finished. Each new outline of given level -incerases the <num> at given level. When the first step is processed then +in these macros after first step is finished. Each new outline of given level +increases the `<num>` at given level. When the first step is processed then (above that) the `\_ol:..` sequence of the parent inceases its value too. The `_ol:...` sequences are implemented by `\_ol:\_count0:\_count1:\count2` etc. -For example, when section (level 2) is processed in the fisrst step then we do: +For example, when section (level 2) is processed in the first step then we do: \begtt \advance \count2 by 1 - % incerases the mapping pointer of the type + % increases the mapping pointer of the type % \_ol:<\_count0:\_count1:\_count2> of this section \advance \<_ol:\_count0:\_count1> by 1 - % incerases the number of descendants connected + % increases the number of descendants connected % to the parent of this section. \endtt @@ -90,10 +88,10 @@ When second step is processed, then we only read the stored data about the number of descentants. Ad we use it in `count` parameter of `\_pdfoutline` primitive. -For linking we use the same links as in TOC, i.e. the `toc:\_the\_tocrefnum` +For linking, we use the same links as in TOC, i.e. the `toc:\_the\_tocrefnum` labels are used. -`\insertoutline {<text>}` inserts one outline with zero direct descendants. +\`\insertoutline` `{<text>}` inserts one outline with zero direct descendants. It creates link destination of the type `oul:<num>` into the document -(where `\isertoutline` is used) and the link itself is created too in the +(where \^`\insertoutline` is used) and the link itself is created too in the outline. diff --git a/Master/texmf-dist/tex/luatex/optex/output.opm b/Master/texmf-dist/tex/luatex/optex/output.opm index a10779e7a87..f1c250f5b85 100644 --- a/Master/texmf-dist/tex/luatex/optex/output.opm +++ b/Master/texmf-dist/tex/luatex/optex/output.opm @@ -3,24 +3,24 @@ \_codedecl \nopagenumbers {Output routine <2020-03-28>} % preloaded in format \_doc ----------------------------- - `\_optexouput` is default output routine. You can create another... + \`\_optexoutput` is default output routine. You can create another... \_cod ----------------------------- \_output={\_optexoutput} \_def \_optexoutput{\_begoutput \_shipout\_completepage \_endoutput} \_doc ----------------------------- - If you need another functionality implemented in output routine, you can - decalre `\addto\_begoutput{...}` or `\addto\_endoutput`. The settings + Default \`\_begoutput` and \`\_endoutput` is defined. + If you need another functionality implemented in the output routine, you can + \^`\addto``\_begoutput{...}` or \^`\addto``\_endoutput{...}`. The settings here is local in the `\output` group. - The `\_prepoffsets` can set `\hoffset` differently for left or right - page, it is re-defined by `\margins`, see \ref[margins] for more datail. + The \`\_prepoffsets` can set `\hoffset` differently for left or right + page. It is re-defined by the \^`\margins` macro.. - The `\_regmark` tokens list includes accumulated `#2` from `\regmacro`, - see section \ref[maketoc]. Logos and another macros are re-defined - here (locally) for their usage in headlines or footlines. - \endtt + The \^`\_regmark` tokens list includes accumulated `#2` from the \^`\regmacro`. + Logos and another macros are re-defined here (locally) for their usage + in headlines or footlines. \_cod ----------------------------- \_def \_begoutput{\_incr\_gpageno @@ -33,22 +33,23 @@ \_def \_prepoffsets {} \_doc ----------------------------- - `\_gpageno` counts pages from one in whole document + \`\gpageno` counts pages from one in whole document \_cod ----------------------------- \_newcount\_gpageno \_public \gpageno ; \_doc ----------------------------- - The `\_completepge` is similar what plain \TeX/ does in its oupput routine. - New is only `\_backgroundbox`. It is `\vbox` with zero height with its - contents (from `\pgbackground`) llaped down. It is shifted directly to the + The \`\_completepage` is similar what plain \TeX/ does in its output routine. + New is only \`\_backgroundbox`. It is `\vbox` with zero height with its + contents (from \^`\pgbackground`) llaped down. It is shifted directly to the left-upper corner of the paper. - The `\_ensureblack` sets the typesetting of its parameter locally to `\Black` + The \`\_ensureblack` sets the typesetting of its parameter locally to `\Black` color. We needn't do this if colors are never used in the document. So, default value of the `\_ensureblack` macro is empty. But first usage of - color macros in the document re-defines `\_ensureblack`. + color macros in the document re-defines `\_ensureblack`. + See the section~\ref[colors] for more details. \_cod ----------------------------- \_def\_completepage{\_vbox{% @@ -63,8 +64,8 @@ \_def \_backgroundbox #1{\_moveleft\_hoffset\_vbox to0pt{\_kern-\voffset #1\_vss}} \_doc ----------------------------- - `\_makeheadline` creates `\vbox to0pt` with its contents (the `\headline`) - shifted by `\headlinedist` up. + \`\_makeheadline` creates `\vbox to0pt` with its contents (the \^`\headline`) + shifted by \^`\headlinedist` up. \_cod ----------------------------- \_def\_makeheadline {\_istoksempty \_headline \_iffalse @@ -75,7 +76,7 @@ } \_doc ----------------------------- - The `\_makefootline` appends the `\footline` to the page-body box. The + The \`\_makefootline` appends the \^`\footline` to the page-body box. \_cod ----------------------------- \_def\_makefootline{\_istoksempty \_footline \_iffalse @@ -85,9 +86,10 @@ } \_doc ----------------------------- - The `\_pagecontents` is similar as in plain \TeX/. The only differnece is - that `\_pagedest` is inserted at the top of `\_pagecontents` and - `\_ensureblack` is applied to `\_topins` and `\_footins` material. + The \`\_pagecontents` is similar as in plain \TeX/. The only differnece is + that the \`\_pagedest` is inserted at the top of `\_pagecontents` and + \^`\_ensureblack` is applied to the \^`\topins` and \^`\footins` material.\nl + The \`\_footnoterule` is defined here. \_cod ----------------------------- \_def\_pagecontents{\_pagedest % destination of the page @@ -96,14 +98,18 @@ \_ifvoid\_footins \_else % footnote info is present \_vskip\_skip\_footins \_ensureblack{\_footnoterule \_openfnotestack \_unvbox\_footins}\fi - \_ifraggedbottom \kern-\_dimen0 \_vfil \_fi + \kern-\_dimen0 \_vskip \_pgbottomskip } \_def \_pagedest {{\_def\_destheight{25pt}\_dest[pg:\_the\_gpageno]}} \_def \_footnoterule {\kern-3pt \hrule width 2truein \kern 2.6pt } \_doc ----------------------------- - The macros used in the context of the output routine + \`\pageno`, \`\folio`, \`\nopagenumbers`, \`\advancepageno` + and \`\normalbottom` + used in the context of the output routine from plain \TeX/ is defined here. + Only the \`\raggedbottom` macro is defined differently. We use the + \^`\pgbottomskip` register here which is set to 0\,pt by default. \_cod ----------------------------- \_countdef\_pageno=0 \_pageno=1 % first page is number 1 @@ -112,17 +118,20 @@ \_def \_advancepageno {% \_ifnum\_pageno<0 \_global\_advance\_pageno by-1 \_else \_incr\_pageno \_fi } % increase |pageno| -\_newifi\_ifraggedbottom -\_def \_raggedbottom {\_topskip=10pt plus60pt \_raggedbottomtrue} -\_def \_normalbottom {\_topskip=10pt \_raggedbottomfalse} % undoes \raggedbottom -\_public - \pageno \folio \nopagenumbers \advancepageno \raggedbottom \normalbottom ; +\_def \_raggedbottom {\_topskip=\_dimexpr\_topskip plus60pt \_pgbottomskip=0pt plus1fil\_relax} +\_def \_normalbottom {\_topskip=\_dimexpr\_topskip \_pgbottomskip=0pt\_relax} + +\_public \pageno \folio \nopagenumbers \advancepageno \raggedbottom \normalbottom ; \_doc ----------------------------- Macros for footnotes are the same as in plain \TeX. There is only one - difference: `\_vfootnote` is implemented as `\_opfootnote` with empty + difference: \`\vfootnote` is implemented as \`\_opfootnote` with empty parameter `#1`. This parameter should do a local settings inside - `\_footins` group and it does it when `\fnote` macro is used. + the \`\footins` group and it does it when `\fnote` macro is used.\nl + The `\_opfootnote` nor `\vfootnote` don't take the footnote text + as a parameter. This is due to user can do catcode settings (like inline + verbatim) in the footnote text. This idea is adapted from plain \TeX.\nl + The \`\footnote` and \`\footstrut` is defined as in plain \TeX/. \_cod ----------------------------- \_newinsert\_footins @@ -153,7 +162,9 @@ \footins \footnote \vfootnote \footstrut ; \_doc ----------------------------- - The `\_topins` macros are the same as in plain \TeX/. + The \`\topins` macros + \`\topinsert`, \`\midinsert`, \`\pageinsert`, \`\endinsert` + are the same as in plain \TeX/. \_cod ----------------------------- \_newinsert\_topins @@ -177,11 +188,10 @@ \_vbox to\_vsize {\_unvbox0 \_kern-\_dimen0}% depth is zero \_else \_box0 \_nobreak \_bigskip \_fi}\_fi\_endgroup} -\_public - \topins \topinsert \midinsert \pageinsert \endinsert ; +\_public \topins \topinsert \midinsert \pageinsert \endinsert ; \_doc ----------------------------- - The `\draft` macro is an example of usage `\_pgbackground` to create + The \`\draft` macro is an example of usage `\_pgbackground` to create water color marks. \_cod ----------------------------- @@ -202,32 +212,34 @@ \_endcode % ------------------------------------- -The output routine `\_optexoutput` is similar as in plain TeX. It does: +The output routine \^`\_optexoutput` is similar as in plain \TeX. It does: -\begitexm -* `\begoutput` which does: +\begitems +* \^`\_begoutput` which does: \begitems - * increments `\gpageno`, - * prints `\_Xpage{<gpageno>}{<pageno>}` to the `.ref` file (if `\openref` is active), sets `\hoffset` and + * increments \^`\gpageno`, + * prints `\_Xpage{<gpageno>}{<pageno>}` to the `.ref` file + (if \^`\openref` is active), * calculates `\hoffset`, - * sets local meaning of macros for headlines/footlines (see `\_regmacro`). + * sets local meaning of macros used in headlines/footlines (see \^`\regmacro`). \enditems -* `\shipout\_completepage, which is `\vbox` of -- +* `\shipout`\^`\_completepage`, which is `\vbox` of -- \begitems - * backrground box, if `\pgbackround` is non-empty, - * headline box, if `\headline` is nonempty, - * \vbox to\vsize of `\pagecontents` which cosnists of -- + * backrground box, if \^`\pgbackground` is non-empty, + * headline box by \^`\_makeheadline`, if the \^`\headline` is nonempty, + * `\vbox to\vsize` of \^`\_pagecontents` which cosnists of -- \begitems - * `\_pagedest`, the page destination `pg:<gpageno>` for hyperlinks is created here, - * `\_topins` box if non-empty (from `\topinsers`), + * \^`\_pagedest`, the page destination `pg:<gpageno>` for hyperlinks is created here, + * \^`\topins` box if non-empty (from \^`\topinsert`s), * `\box255` with completed vertical material from main vertical mode, - * `\_footnoterule` and `\_footins` box if nonempty (from `\fnote`, `\footnote`), + * \^`\_footnoterule` and \^`\footins` box if nonempty (from \^`\fnote`, \^`\footnote`), + * \^`\pgbottomskip` (default is 0\,pt). \enditems - * footline box, if `\footline` is nonempty + * footline box by `\_makefootline`, if the \^`\footline` is nonempty \enditems -* `\endoutput` which does: +* \^`\_endoutput` which does: \begitems - * increments `\pageno` using `\_advancepageno` - * runs `\_dosupereject` if needed. + * increments \^`\pageno` using \^`\advancepageno` + * runs output routine repeatedly if \^`\dosupereject` is activated. \enditems \enditems diff --git a/Master/texmf-dist/tex/luatex/optex/parameters.opm b/Master/texmf-dist/tex/luatex/optex/parameters.opm index 2a85a081596..bfaec21b4a3 100644 --- a/Master/texmf-dist/tex/luatex/optex/parameters.opm +++ b/Master/texmf-dist/tex/luatex/optex/parameters.opm @@ -3,6 +3,7 @@ \_codedecl \normalbaselineskip {Parameter settings <2020-03-17>} % preloaded in format \_doc ----------------------------- + \secc Primitive registers The primitive registers with the same default value as in plain \TeX/ follow: \_cod ----------------------------- @@ -48,13 +49,15 @@ \_doc ----------------------------- Note that `\topskip` and `\splittopskip` are changed when first - `\typosize` sets the main values (default font size and `\baselineskip`). + `\typosize` sets the main values (default font size and default + `\baselineskip`). \_cod ----------------------------- \_topskip=10pt % top edge of page-box to first baseline distance \_splittopskip=10pt \_doc ----------------------------- + \secc Plain \TeX/ registers Declared registers used in plain \TeX/ \_cod ----------------------------- @@ -71,24 +74,30 @@ \_def\_normalbaselines{\_lineskip=\_normallineskip \_baselineskip=\_normalbaselineskip \_lineskiplimit=\_normallineskiplimit} + \_def\_frenchspacing{\_sfcode`\.=1000 \sfcode`\?=1000 \sfcode`\!=1000 \sfcode`\:=1000 \sfcode`\;=1000 \sfcode`\,=1000 } \_def\_nonfrenchspacing{\_sfcode`\.=3000 \sfcode`\?=3000 \sfcode`\!=3000 \sfcode`\:=2000 \sfcode`\;=1500 \sfcode`\,=1250 } -\_public - \normalbaselines \frenchspacing \nonfrenchspacing + +\_public \normalbaselines \frenchspacing \nonfrenchspacing \smallskipamount \medskipamount \bigskipamount \normalbaselineskip \normallineskip \normallineskiplimit \jot \interdisplaylinepenalty \interfootnotelinepenalty ; \_doc ----------------------------- - Default `\baseline` setting is for 10pt fonts (like in plain \TeX/). - But `\typosize` and `\typoscale` re-declares it. - The `\nonfrenchspacing` is not set by default because - author of \OpTeX/ is living in Europe. + \secc Different settings than in plain \TeX/ + + Default \"baseline setting" is for 10\,pt fonts (like in plain \TeX/). + But `\typosize` and `\typoscale` macros re-declare it if another font size is used. + + The \`\nonfrenchspacing` is not set by default because + the author of \OpTeX/ is living in the Europe. + If you set `\enlang` hyphenation patterns then `\nonfrenchspacing` + is set. \_cod ----------------------------- -\_normalbaselines % baseline setting, +\_normalbaselines % baseline setting, 10 pt font size \_doc ----------------------------- Different values than in plain \TeX/ have following primitive registers. @@ -135,12 +144,12 @@ \_vsize=8.9in \_pagewidth=8.5 true in \_pageheight=11 true in + \_nonfrenchspacing } \_public \plaintexsetting ; \_doc ----------------------------- - The second part of this section includes parameters declared and used - in \OpTeX/ macros. + \secc \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. @@ -150,19 +159,19 @@ `\_printsecc` from `sections.opm` file to your macro file and re-define them. Notice for OPmac users: there is important difference: all "string-like" - parameters are token lists (OPmac uses macros for them). The reason of + parameters are token lists in \OpTeX/ (OPmac uses macros for them). The reason of this difference: if user sets parameter by unprotected control sequence, an \OpTeX/ macro can read {\em the same data} using protected control sequence. - If user re-defines such unprotected control equance (because he/she does + If user re-defines such unprotected control sequence (because he/she does know about it) then nothing bad happens. - The `\picdir` tokens list can include a directory where image files + The \`\picdir` tokens list can include a directory where image files (loaded by `\inspic`) are saved. Empty `\picdir` (default value) means - that image files are in current directory (or somwhere in the \TeX/ + that image files are in the current directory (or somewhere in the \TeX/ system where \LuaTeX/ is able to find them). If you set non-empty value to the `\picdir`, then it must end by `/` character, for example `\picdir={img/}` means that there exists a directory `img` in your - current direcory and the image files are stored here. + current directory and the image files are stored here. \_cod ----------------------------- \_newtoks\_picdir @@ -170,10 +179,10 @@ \_doc ----------------------------- You can control the dimesions of included images by - the parameters `\picwidth` (which is equivalent to `\picw`) and - `\picheight`. By default these parameters are set to zero: the native + the parameters \`\picwidth` (which is equivalent to \`\picw`) and + \`\picheight`. By default these parameters are set to zero: the native dimension of the image is used. If only `\picwidth` has a nonzero value, - then this is width of the image (height is calulated automaticaly in + then this is the width of the image (height is calculated automatically in order to respect the aspect of the image). If only `\picheight` has a nonzero value then height is given, width is calculated. If both parameters are non-zero, the height and width are given and the aspect @@ -189,10 +198,11 @@ \_public \picwidth \picheight ; \_doc ----------------------------- - The `\everytt` is token list used in `\begtt`...`\endtt` environment and + The \`\everytt` is token list used in + `\begtt`...`\endtt` environment and in the verbatim group opened by `\verbinput` macro. You can include a code which is processed inside the group after basic settings were done - On the other hand, it is processed before scanner of verbatm text is started. + On the other hand, it is processed before scanner of verbatim text is started. Your macros should influence scanner (catcode settings) or printing process of the verbatim code or both. @@ -201,7 +211,8 @@ `\everytt` for all verbatim environments in your document and use a code after `\begtt` locally only for this environment. - The `\everyintt` token list does similar work but acts in the in-line verbatim + The \`\everyintt` token list does similar work + but acts in the in-line verbatim text processed by a pair of `\activettchar` characters or by `\code{<text>}`. You can set `\everyintt={\Red}` for example if you want in-line verbatim in red color. @@ -212,42 +223,80 @@ \_public \everytt \everyintt ; \_doc ----------------------------- - The `\ttline` is used in `\begtt`...`\endtt` environment or in the code + The \`\ttline` is used + in `\begtt`...`\endtt` environment or in the code printed by `\verbinput`. If `\ttline` is positive or zero, then the verbatim code have numbered lines from `\ttline+1`. The `\ttline` register is re-set to new value after a code piece is printed, so next - code pieces have numbered lines continuosly. If `\ttline=-1`, then + code pieces have numbered lines continuously. If `\ttline=-1`, then `\begtt`...`\endtt` lines are without numbers and `\verbinput` lines - shouws the line numbers of inputted file. If `\ttline<-1` then no line - numbers are printed. + shows the line numbers of inputted file. If `\ttline`\code{<-1} + then no line numbers are printed. \_cod ----------------------------- \_newcount\_ttline \_ttline=-1 % last line number in \begtt...\endtt \_public \ttline ; \_doc ----------------------------- - The `\ttindent` gives default indentation of verbatim lines printed by - `\begtt`...`\endtt` or by `\verbintupt`. - - The `\iindent` gives default indentations used in table of contents, + The \`\ttindent` gives default indentation + of verbatim lines printed by `\begtt`...`\endtt` pair or by + `\verbinput`. + \nl + The \`\ttshift` gives the amount of shift of all verbatim lines to right. + Despite to the \^`\ttindent`, it does not shift the line numbers, only + the text. + \nl + The \`\iindent` gives default indentations used in table of contents, captions, lists, bib references, - + \nl It is strongly recommended to re-set this value if you set `\parindent` - to another value than plain \TeX/ default 20pt. A good typesetted + to another value than plain \TeX/ default 20pt. A well typeset document should have the same dimension for all indentations, so you should say `\ttindent=\parindent` and `\iindent=\parindent`. \_cod ----------------------------- \_newdimen\_ttindent \_ttindent=\_parindent % indentation in verbatim +\_newdimen\_ttshift \_newdimen\_iindent \_iindent=\parindent -\_public \ttindent \iindent ; +\_public \ttindent \ttshift \iindent ; + + \_doc ----------------------------- + The tabelator `^^I` has its category code like space: it behaves as a + space in normal text. This is normal plain \TeX/ setting. + But in the multiline verbatim environment it + is active and expands to the `\hskip<dimen>` where `<dimen>` + is the width of \`\tabspaces` spaces. + Default `\tabspaces=3` means + that tabelator behaves like three spaces in multiline verbatim. + \_cod ----------------------------- + +\_newcount \_tabspaces \_tabspaces=3 +\_public \tabspaces ; + + \_doc ----------------------------- + If \`\hicolors` is non-empty then its contents is used instead + `\_hicolors<name>` declared in the file `hisyntax-<name>.opm`. + The user can give his/her preferences about colors for + syntax highlighting by this tokens list. + Full color set must be declared here. + \_cod ----------------------------- + +\_newtoks\_hicolors +\_public \hicolors ; \_doc ----------------------------- - The default item mark used between `\bgitems` and `\enditems` is bullet. - The `\everyitem` token list is applied in vertical mode - at the start of each item. - The `\everylist` token list is applied after group is openem by - `\begitems`. + The default item mark used between `\begitems` and `\enditems` is bullet. + The \`\defaultitem` tokens list declare this default item mark. + \nl + The \`\everyitem` tokens list is applied in vertical mode + at the start of each item. + \nl + The \`\everylist` tokens list is applied after group is opened by + \nl + The \`\ilevel` keeps the value of current nesting level of the items list. + \nl + The \`\listskipamount` gives vertical skip above and below the items list + if `\ilevel=1`. \_cod ----------------------------- \_newtoks\_defaultitem \_defaultitem={$\_bullet$\_enspace} @@ -258,7 +307,7 @@ \_public \defaultitem \everyitem \everylist \listskipamount \ilevel ; \_doc ----------------------------- - The `\tit` macro includes `\vglue\titskip` above the title of the document. + The `\tit` macro includes `\vglue`\`\titskip` above the title of the document. \_cod ----------------------------- \_newskip\_titskip \_titskip=40pt \_relax % \vglue above title printed by \tit @@ -266,7 +315,7 @@ \_doc ---------------------------- The `\begmulti` `\endmulti` pair creates more columns. The parameter - `\colsep` decares the space between columns. If $n$ columns are specidied + \`\colsep` declares the space between columns. If $n$ columns are specified then we have $n-1$ `\colseps` and $n$ columns in total `\hsize`. This gives definite result of columns width. \_cod ---------------------------- @@ -276,19 +325,19 @@ \_doc ----------------------------- Each line in the Table of contents is printed in a group. - The `\everytocline` tokens list is processed here before - the internal `\_tocl:<num>` macro which starts printig the line. + The \`\everytocline` tokens list is processed here before + the internal `\_tocl:<num>` macro which starts printing the line. \_cod ----------------------------- \_newtoks \_everytocline \_public \everytocline ; \_doc ----------------------------- - The `\bibtexhook` yokens list is used inside the group when `\usebib` command is + The \`\bibtexhook` tokens list is used inside the group when `\usebib` command is processed after style file is loaded and before printing bib-entries. You can re-define a behavior of style file here or you can modify the more declaration for printing (fonts, baselineskip, etc.) or you can - definie a specific macros used in your `.bib` file. + define a specific macros used in your `.bib` file. \_cod ----------------------------- \_newtoks\_bibtexhook @@ -298,31 +347,26 @@ \_public \everycaptiont \everycaptionf ; \_doc ----------------------------- - The `\everyii` tokens list is used before `\noindent` for each - index item when priting index. + The \`\everyii` tokens list is used before `\noindent` for each + Index item when printing the Index. \_cod ----------------------------- \_newtoks\_everyii \_public \everyii ; \_doc ----------------------------- - The `\_everyfnote` tokens list is used in the `\footinsert` group - in vertical mode before `\typoscale` and before - `\textindent{\_printfnotemark}` of the footnote text. - \_cod ----------------------------- - -\_newtoks\_everyfnote -\_public \everyfnote ; - - \_doc ----------------------------- - The `\everymnote` is used in the mnote group before `\noindent` which + The \`\everymnote` is used in the `\mnote` group before `\noindent` which immediately precedes marginal note text. - The `\mnotesize` is horizontal size of the marginal notes. - The `\mnoteindent` is horizontal space between body-text and marginal note. - The `\mnoteskip` is a dimen which denotes the vertical shift of mamrginal + \nl + 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. When marhinel note is printed the `\mnoteskip` register is set to - zero. Use it as an exception of marginal note position if the marginal + 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 ----------------------------- @@ -333,42 +377,52 @@ \_public \everymnote \mnotesize \mnoteindent \mnoteskip ; \_doc ----------------------------- - The `\table` parameters follows. Note that `\thistable` register should - be used for giving an exceptino for only one `\table` which follows. - It should change locally other parameters of `\table`. - On the other hand `\everytab` is used after `\vbox` parameters - (`\baselineskip` etc.) are set, it means that this can be used to re-assign - such prameters. + The `\table` parameters follows. The \`\thistable` tokens list + register should be used for giving an exception for only one `\table` + which follows. It should change locally other parameters of the `\table`. + It is reset to empty list after the table is printed. + \nl + The \`\everytable` tokens list register is applied in every table. + There is another difference between these two registers. + The `\thistable` is used first, then strut and baselineskip settings are + done, then `\everytable` is applied and then the table is printed. + \nl + \`\tabstrut` configures the height and depth of lines in the table. + You can declare `\tabstrut={}`, then normal baselineskip is used in the + table. This can be used when you don't use horizontal nor vertical + lines in tables. + \nl + \`\tabiteml` is applied before each item, + \`\tabitemr` is applied after each item of the table. + \nl + \`\tablinespace` is additional vertical space between horizontal rules + and the lines of the table. + \nl + \`\hhkern` gives the space between horizontal lines if they are doubled and + \`\vvkern` gives the space between such vertical lines. \_cod ----------------------------- \_newtoks\_everytable \_newtoks\_thistable \_newtoks\_tabiteml \_newtoks\_tabitemr \_newtoks\_tabstrut \_newdimen\_tablinespace \_newdimen\_vvkern \_newdimen\_hhkern -\_everytable={} % code used after settings in \vbox before table processing -\_thistable={} % code used when \vbox starts, is is removed after using it -\_tabiteml={\enspace} % left material in each column -\_tabitemr={\enspace} % right material in each column -\_tablinespace=2pt % additional vertical space before/after horizontal rules -\_vvkern=1pt % space between double vertical line and used in \frame -\_hhkern=1pt % space between double horizontal line and used in \frame +\_everytable={} % code used after settings in \vbox before table processing +\_thistable={} % code used when \vbox starts, is is removed after using it +\_tabstrut={\_strut} +\_tabiteml={\_enspace} % left material in each column +\_tabitemr={\_enspace} % right material in each column +\_tablinespace=2pt % additional vertical space before/after horizontal rules +\_vvkern=1pt % space between double vertical line and used in \frame +\_hhkern=1pt % space between double horizontal line and used in \frame \_public \everytable \thistable \tabiteml \tabitemr \tabstrut \tablinespace \vvkern \hhkern ; - \_doc ---------------------------- - You can declare `\tabstrut={}`, then normal baselineskip is used in the - table. We suppose that you don't use horizontal nor vertical lines in tables - with `\tabstrut={}` because this yeilds to bad result. - \_cod ---------------------------- - -\_tabstrut={\strut} % strut which declares lines distance in the table - \_doc ----------------------------- - The output routine uses token list `\headline` and `\footline` in the + 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`. - Assume that page-body text can be typesetted in different sizes and + Assume that page-body text can be typeset in different sizes and different fonts and we don't know in what font context the output routine - is invoked. So, it is strogly reccomended to declare fixed variants of + is invoked. So, it is strongly recommended to declare fixed variants of fonts at begining of your document. For example `\fontdef\rmfixed{\rm}`, `\fontdef\itfixed{\it}`. Then use them in headline and footline: \begtt @@ -383,11 +437,13 @@ \_doc ----------------------------- The distance between the `\headline` and the top of the page-text - is controlled by `\headlinedist`. The distance between bottom of - page-text and `\footline` is `\footlinedist`. More precisely: baseline of - hedadline and baseline of first line in page-text have distance - `\headlinedist+\topskip`. baseline of the last line in page-text and - baseline of footline have distance `\footlinedist`. + is controlled by the \`\headlinedist` register. + The distance between bottom of + page-text and `\footline` is \`\footlinedist`. + More precisely: baseline of + headline and baseline of first line in page-text have distance + `\headlinedist+\topskip`. The baseline of the last line in page-text and + the baseline of the footline have distance `\footlinedist`. Default values are inspired from plain \TeX/. \_cod ----------------------------- @@ -396,7 +452,16 @@ \_public \headlinedist \footlinedist ; \_doc ----------------------------- - The `\nextpages` token list can include settings which will be used at + The \`\pgbottomskip` is inserted to the page bottom + in the output routine. You can set a less tolerance here than + `\raggedbotom` does. By default, no tolerance is given. + \_cod ----------------------------- + +\_newskip \_pgbottomskip \_pgbottomskip=0pt \_relax +\_public \pgbottomskip ; + + \_doc ----------------------------- + The \`\nextpages` tokens list can include settings which will be used at next pages. It is processed at the end of output routine with `\globaldefs=1` prefix. The `\nextpages` is reset to empty after processing. Example of usage: @@ -411,7 +476,7 @@ \_public \nextpages ; \_doc ----------------------------- - The `\pgpackground` token list can include macros which generate a + The \`\pgbackground` token list can include macros which generate a vertical list. It is used as page background. The top-left corner of such `\vbox` is at the top-left corner of the paper. Example creates the background of all pages yellow: @@ -426,7 +491,7 @@ \_doc ----------------------------- The parameters used in `\inoval` and `\incircle` macros. The default values (documented in user manual) are set in the macros. - User can re-set thse values using tokens \ovalparams, \circleparams. + The user can re-set these values using tokens \`\ovalparams`, \`\circleparams`. \_cod ----------------------------- \_newtoks \_ovalparams @@ -452,22 +517,26 @@ controlled by {\em parameters}. The parameters are Both groups of registers have their type: number, dimension, skip, token list. -The registers are represented by their names (control sequences). If an user +The registers are represented by their names (control sequences). If the user re-defines such control sequence then the appropriate register exists steadily and build-in algorithms are using it without change. But user cannot access its value in such case. \OpTeX/ declares two control sequences -for each register: prefixed and un-prefixed. \OpTeX/ macros use only -prefixed variants of control sequernces. Users should use unprefixed variant +for each register: prefixed and unprefixed. \OpTeX/ macros use only +prefixed variants of control sequences. The user should use unprefixed variant with the same meaning and set or read values of registers using the -unprefixed variant. If an user re-defines the unprefixed variant then -\OpTeX/ macros still work without change. - -Examples mentioned here use unprefixed variants of register names but \OpTeX/ -macros use prefixed variants. - -There is only few parameters declared by \OpTeX/ macros. All are listed in -this section. This is desired feature of the \OpteX/. If you want to do more -changes wich cannot be controlled by parameters listed here then you can copy the -appropriate \OpTeX/ macro to your macro file and you can completely re-define it. - - +unprefixed variant. If the user re-defines the unprefixed control sequence of +a register then \OpTeX/ macros still work without change. + +%There is only few parameters declared by \OpTeX/ macros. All of them +%are listed in this section. This is desired feature of the \OpTeX/. +%If you want to do more +%changes wich cannot be controlled by parameters listed here then you +%can copy the appropriate \OpTeX/ macro to your macro file and you +%can completely re-define it. The typical examples are `\_printsomething` +%macros which declares the design of the document. + +\_endinput + +History: +2020-04-04 ... \tabspaces added +2020-04-03 ... \hicolors added diff --git a/Master/texmf-dist/tex/luatex/optex/pdfuni-string.opm b/Master/texmf-dist/tex/luatex/optex/pdfuni-string.opm index e993e61a756..33701522fbd 100644 --- a/Master/texmf-dist/tex/luatex/optex/pdfuni-string.opm +++ b/Master/texmf-dist/tex/luatex/optex/pdfuni-string.opm @@ -14,10 +14,11 @@ \_begingroup \_catcode`\\=12 \_let\\=\_bslash \_the\_regoul \_relax % \_regmacro alternatives of logos etc. - \_edef#1{#2}% + \_escapechar=-1 + \_edef#1{#2\empty}% + \_escapechar=`\\ \_ea\_edef \_ea#1\_ea{\_ea\_removeoutmath #1$\_end$}% $x$ -> x \_ea\_edef \_ea#1\_ea{\_ea\_removeoutbraces #1{\_end}}% {x} -> x - \_escapechar=-1 \_edef#1{\_detokenize\_ea{#1}}% \_replstring#1{ }{{ }}% text text -> text{ }text \_edef\_out{\\376\\377}% @@ -42,7 +43,6 @@ \_let\it=\_empty \_let\bi=\_empty \_let\tt=\_empty \_let\/=\_empty \_let~=\_space } - \public \pdfunidef ; \_endcode % -------------------------------- @@ -52,24 +52,27 @@ etc.). First one is PDFDocEncoding which is one-byte encoding, but most Czech or Slovak characters are missing here. The second encoding is PDFunicode encoding wich is implemented in this file. -This encoding is TeX-dicomfortable, because it looks like +This encoding is \TeX/-discomfortable, because it looks like +\begtt \376\377\000C\000v\000i\001\015\000e\000n\000\355\000\040\000j\000e\000\040 \000z\000\341\000t\001\033\001\176 +\endtt This example is real encoding of the string "Cvičení je zátěž". You can see that this is UTF-16 encoding (two bytes per character) with two starting 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. +a character is encoded by its real byte preceded by `\000`. -The pdfuni.tex macro implements the command - -\pdfunidef\macro{string} - -We implemented the octal string printing of one character using \directlua. +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. +`\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/Master/texmf-dist/tex/luatex/optex/plain-macros.opm b/Master/texmf-dist/tex/luatex/optex/plain-macros.opm index 18576c1ad72..60d4b6cc314 100644 --- a/Master/texmf-dist/tex/luatex/optex/plain-macros.opm +++ b/Master/texmf-dist/tex/luatex/optex/plain-macros.opm @@ -2,40 +2,51 @@ \_codedecl \magstep {Macros from plain TeX <2020-02-14>} % preloaded in format -\_chardef\_active = 13 + \_doc ----------------------------- + The \`\dospecials` works like in plain TeX but does nothing with `_`. + If you need to do the same with this character, you can re-define: + \begtt + \addto \dospecials{\do\_} + \endtt + \_cod ----------------------------- \_def\_dospecials {\do\ \do\\\do\{\do\}\do\$\do\&% \do\#\do\^\do\^^K\do\^^A\do\%\do\~} -\_public - \dospecials \active ; +\_chardef\_active = 13 + +\_public \dospecials \active ; + \_doc ----------------------------- + The shortcuts `\chardef\@one` is not defined in \OpTeX/. Use normal + numbers instead of such obscurities. + \nl + The \`\magstep` and \`\magstephalf` are + defined with `\space`, (no `\relax`), in order to be expandable. + \_cod ----------------------------- + \_def \_magstephalf{1095 } \_def \_magstep#1{\_ifcase#1 1000\_or 1200\_or 1440\_or 1728\_or 2074\_or 2488\_fi\_space} -\_public - \magstephalf \magstep ; - -\_def\_normalbaselines{\_lineskip=\_normallineskip - \_baselineskip=\_normalbaselineskip \_lineskiplimit=\_normallineskiplimit} -\_def\_frenchspacing{\_sfcode`\.=1000 \sfcode`\?=1000 \sfcode`\!=1000 - \sfcode`\:=1000 \sfcode`\;=1000 \sfcode`\,=1000 } -\_def\_nonfrenchspacing{\_sfcode`\.=3000 \sfcode`\?=3000 \sfcode`\!=3000 - \sfcode`\:=2000 \sfcode`\;=1500 \sfcode`\,=1250 } -\_public - \normalbaselines \frenchspacing \nonfrenchspacing ; +\_public \magstephalf \magstep ; -\_normalbaselines % baseline setting + \_doc ----------------------------- + Plain \TeX/ basic macros and control sequences. + \`\endgraf`, \`\endline`. + The `^^L` is not defined in \OpTeX/ because it is obsolete. + \_cod ----------------------------- \_def\^^M{\ } % control <return> = control <space> \_def\^^I{\ } % same for <tab> \_def\lq{`} \def\rq{'} -\_def\lbrack{[} \_def\rbrack{]} -\_chardef\active=13 +\_def\lbrack{[} \_def\rbrack{]} % They are only public versions. % \catcode`\^^L=\active \outer\def^^L{\par} % ascii form-feed is "\outer\par" % obsolete \_let\_endgraf=\_par \_let\_endline=\_cr -\_public - \endgraf \endline ; +\_public \endgraf \endline ; + + \_doc ----------------------------- + Plain \TeX/ classical \`\obeylines` and \`\obeyspaces`. + \_cod ----------------------------- % In \obeylines, we say `\let^^M=\par' instead of `\def^^M{\par}' % since this allows, for example, `\let\par=\cr \obeylines \halign{...' @@ -47,6 +58,14 @@ \_public \obeylines \obeyspaces ; + \_doc ----------------------------- + Spaces. + \`\thinspace`, \`\negthinspace`, \`\enspace`, \`\enskip`, + \`\quad`, \`\qquad`, \`\smallskip`, + \`\medskip`, \`\bigskip`, \`\nointerlineskip`, \`\offinterlineskip`, + \`\topglue`, \`\vglue`, \`\hglue`, \`\slash`. + \_cod ----------------------------- + \_protected\_def\_thinspace {\_kern .16667em } \_protected\_def\_negthinspace {\_kern-.16667em } \_protected\_def\_enspace {\_kern.5em } @@ -58,8 +77,8 @@ \_protected\_def\_bigskip {\_vskip\_bigskipamount} \_def\_nointerlineskip {\_prevdepth=-1000pt } \_def\_offinterlineskip {\_baselineskip=-1000pt \_lineskip=0pt \_lineskiplimit=\_maxdimen} -\_public - \thinspace \negthinspace \enspace \enskip \quad \qquad \smallskip + +\_public \thinspace \negthinspace \enspace \enskip \quad \qquad \smallskip \medskip \bigskip \nointerlineskip \offinterlineskip ; \_def\_topglue {\_nointerlineskip\_vglue-\_topskip\_vglue} % for top of page @@ -71,8 +90,15 @@ \_nobreak\_hskip\_skip0 \_spacefactor=\_count255 } \_protected\def~{\penalty10000 \ } % tie \_protected\_def\_slash {/\_penalty\_exhyphenpenalty} % a `/' that acts like a `-' -\_public - \topglue \vglue \hglue \slash ; + +\_public \topglue \vglue \hglue \slash ; + + \_doc ----------------------------- + Penalties macros: + \`\break`, \`\nobreak`, \`\allowbreak`, \`\filbreak`, \`\goodbreak`, + \`\eject`, \`\supereject`, \`\dosupereject`, + \`\removelastskip`, \`\smallbreak`, \`\medbreak`, \`\bigbreak`. + \_cod ----------------------------- \_protected\_def \_break {\_penalty-10000 } \_protected\_def \_nobreak {\_penalty10000 } @@ -90,28 +116,40 @@ \_removelastskip \_penalty-100 \_medskip \_fi} \_def \_bigbreak {\_par\_ifdim\_lastskip<\_bigskipamount \_removelastskip \_penalty-200 \_bigskip \_fi} -\_public - \break \nobreak \allowbreak \filbreak \goodbreak \eject \supereject \dosupereject + +\_public \break \nobreak \allowbreak \filbreak \goodbreak \eject \supereject \dosupereject \removelastskip \smallbreak \medbreak \bigbreak ; + \_doc ----------------------------- + Boxes. + \`\line`, \`\leftline`, \`\rightline`, \`\centerline`, \`\rlap`, \`\llap`, + \`\underbar`. + \_cod ----------------------------- + \_def \_line {\_hbox to\_hsize} \_def \_leftline #1{\_line{#1\_hss}} \_def \_rightline #1{\_line{\_hss#1}} \_def \_centerline #1{\_line{\_hss#1\_hss}} \_def \_rlap #1{\_hbox to0pt{#1\_hss}} \_def \_llap #1{\_hbox to0pt{\_hss#1}} -\_public - \line \leftline \rightline \centerline \rlap \llap ; - \_def\_underbar #1{$\_setbox0=\_hbox{#1}\dp0=0pt \_math \_underline{\_box0}$} -\_public - \underbar ; + +\_public \line \leftline \rightline \centerline \rlap \llap \underbar ; + + \_doc ----------------------------- + The \`\strutbox` is declared as 10pt size dependent (like in plain \TeX), but + the macro `\_setbaselineskip` (from `fonts-opmac.opm`) redefines it. + \_cod ----------------------------- \_newbox\_strutbox \_setbox\_strutbox=\_hbox{\_vrule height8.5pt depth3.5pt width0pt} \_def \_strut {\_relax\_ifmmode\_copy\_strutbox\_else\_unhcopy\_strutbox\_fi} -\_public - \strutbox \strut ; + +\_public \strutbox \strut ; + + \_doc ----------------------------- + Alignment. \`\hidewidth` \`\ialign` \`\multispan`. + \_cod ----------------------------- \_def \_hidewidth {\_hskip\_hideskip} % for alignment entries that can stick out \_def \_ialign{\_everycr={}\_tabskip=\_zoskip \_halign} % initialized \halign @@ -119,10 +157,15 @@ \_def \_multispan #1{\_omit \_mscount=#1\_relax \_loop \_ifnum\_mscount>1 \_spanA \_repeat} \_def \_spanA {\_span\_omit \_advance\_mscount by-1 } -\_public - \hidewidth \ialign \multispan ; -% tabbing macros ommited +\_public \hidewidth \ialign \multispan ; + + \_doc ----------------------------- + Tabbing macros are omitted because they are obsolete. + \nl + Indentation and others. \`\textindent`, \`\item`, \`\itemitem`, + \`\narrower`, \`\raggedright`, \`\ttraggedright`, \`\leavevmode`. + \_cod ----------------------------- \_def \_hang {\_hangindent\_parindent} \_def \_textindent #1{\_indent\_llap{#1\_enspace}\_ignorespaces} @@ -133,8 +176,18 @@ \_def \_raggedright {\_rightskip=0pt plus2em \_spaceskip=.3333em \_xspaceskip=.5em\_relax} \_def \_ttraggedright {\_tt \_rightskip=0pt plus2em\_relax} % for use with \tt only -\_public - \hang \textindent \item \itemitem \narrower \raggedright \ttraggedright ; +\_def \_leavevmode {\_unhbox\_voidbox} % begins a paragraph, if necessary + +\_public \hang \textindent \item \itemitem \narrower \raggedright \ttraggedright \leavevmode ; + + \_doc ----------------------------- + Few character codes are set for backward compatibility. But old obscurities + (from plain TeX) based on \`\mathhexbox` + are not supported -- an error message and recommendation + to directly using of the desired character is implemented by the + \`\_usedirectly` macro). + The user can re-define these control sequences of course. + \_cod ----------------------------- %\chardef\%=`\% \_let\% = \_pcent % more natural, can be used in lua codes. @@ -158,15 +211,19 @@ \_def\dag{\_errmessage{\_usedirectly †}} \_def\ddag{\_errmessage{\_usedirectly ‡}} %\_def\copyright{\_errmessage{\_usedirectly ©}} -\_def\copyright{©} +\_def\copyright{©} % << example, what to do %\_def\Orb{\_mathhexbox20D} % obsolete (part of Copyright) %\_def\P{\_mathhexbox27B} % obsolete \_def \_usedirectly #1{Load Unicoded font by \string\fontfam\space and use directly #1} -\_def \_leavevmode {\_unhbox\_voidbox} % begins a paragraph, if necessary \_def \_mathhexbox #1#2#3{\_leavevmode \_hbox{$\_math \_mathchar"#1#2#3$}} -\_public - \leavevmode \mathhexbox ; +\_public \mathhexbox ; + + \_doc ----------------------------- + Accents. + The macros \`\ooalign`, \`\d`, \`\b`, \`\c`, \`\dots`, + are defined for backward compatibility. + \_cod ----------------------------- \_def \_oalign #1{\_leavevmode\_vtop{\_baselineskip=0pt \_lineskip=.25ex \_ialign{##\_crcr#1\_crcr}}} @@ -180,8 +237,15 @@ \_def \_c #1{{\_setbox0=\_hbox{#1}\_ifdim\_ht0=1ex\_accent\_cedilla #1% \_else\_ooalign{\_unhbox0\_crcr\_hidewidth\_cedilla\_hidewidth}\_fi}} \_def\_dots{\_relax\_ifmmode\_ldots\_else$\_math\_ldots\_thinsk$\_fi} -\_public - \oalign \ooalign \d \b \c \dots ; +\_public \oalign \ooalign \d \b \c \dots ; + + \_doc ----------------------------- + The accents commands like `\v`, `\.`, `\H`, etc. are not defined. Use the + accented characters directly -- it is best solution. But you can use the + macro \`\oldaccents` which defines accented macros. + \nl + Much more usable is to define these control sequences to other purposes. + \_cod ----------------------------- \def \_oldaccents {% \_def\`##1{{\_accent\_tgrave ##1}}% @@ -196,8 +260,7 @@ \_def\"##1{{\_accent\_dieresis ##1}}% \_def\r##1{{\_accent\_ring ##1}}% } -\_public - \oldaccents ; +\_public \oldaccents ; % ec-lmr encoding (will be changed after \fontfam macro): \_chardef\_tgrave=0 @@ -230,6 +293,14 @@ \_let \_uniaccents=\_relax } + \_doc ----------------------------- + The last part of plain \TeX/ macros. + \`\hrulefill`, \`\dotfill`, \`\rightarrowfill`, \`\leftarrowfill`, + \`\magnification`, \`\bye`. + Math macros are defined in the `math-macros.opm` file. + \_cod ----------------------------- + + \_def \_hrulefill {\_leaders\_hrule\_hfill} \_def \_dotfill {\_cleaders\_hbox{$\_math \_mkern1.5mu.\_mkern1.5mu$}\_hfill} \_def \_rightarrowfill {$\_math\_smash-\_mkern-7mu% @@ -238,8 +309,8 @@ \_def \_leftarrowfill {$\_math\_mathord\_leftarrow\_mkern-7mu% \_cleaders\_hbox{$\_mkern-2mu\_smash-\_mkern-2mu$}\_hfill \_mkern-7mu\_smash-$} -\_public - \hrulefill \dotfill \rightarrowfill \leftarrowfill ; + +\_public \hrulefill \dotfill \rightarrowfill \leftarrowfill ; % \_downbracefil \_upbracefil will be re-defined when Unicode-math is used \_mathchardef \_braceld="37A \_mathchardef \_bracerd="37B @@ -256,8 +327,7 @@ \_dimen\_footins=8truein } % only for backward compatibility, but \margins macro is preferred. -\_public - \magnification ; +\_public \magnification ; \_def \_showhyphens #1{\_setbox0=\_vbox{\_parfillskip=0pt \_hsize=\_maxdimen \_tenrm \_pretolerance=-1 \tolerance=-1 \hbadness=0 \showboxdepth=0 \ #1}} @@ -265,33 +335,5 @@ \_def \_bye {\_par \_vfill \_supereject \_end} \_public \bye ; - \_endcode % ------------------------------------- -All macros from plain TeX are rewritten here. Differences are mentioned in -the documentation below. - -The `\dospecials` works like in plin TeX but does nothing with `_`. -If you need to do the same with this character, you can re-define: - -\begtt - \addto \dospecials{\do\_} -\endtt - -The shortcuts like `\chardef\@one` is not defined in \OpTeX/. Use normal -numbers instead of such obscurities. - -The `\magstep` is defined with \space, no with \relax, in order to be -expandable. - -The `\strutbox` is declared as 10pt size dependent (like in plainTeX), but -the macro `\setbaselineskip` (from OPmac) redefines it. - -Few character codes are set for backward compatibility. But old obscurities -(from plain TeX) are not supported -- an error message about directly using -of the desired character is prepared instead). User can re-define the control -sequences `\l`, `\L`, `\aa`, `\copyright` etc. of course. - -The accents commands like `\v`, `\.`, `\H`, etc. are not defined. Use the -accented characters directly -- it is best solution. But you can use the -macro `\oldaccents` which defines accented macros. diff --git a/Master/texmf-dist/tex/luatex/optex/prefixed.opm b/Master/texmf-dist/tex/luatex/optex/prefixed.opm index e6015bc7cb5..7778bc03744 100644 --- a/Master/texmf-dist/tex/luatex/optex/prefixed.opm +++ b/Master/texmf-dist/tex/luatex/optex/prefixed.opm @@ -3,7 +3,7 @@ \_codedecl \public {Prefixing and code syntax <2020-02-14>} % preloaded in format \_doc --------- - All TeX82 primitives have alternative control sequence \_hbox \_string, ... + All \TeX/ primitives have alternative control sequence `\_hbox` `\_string`, ... \_cod --------- \let\_directlua = \directlua @@ -17,34 +17,42 @@ } \_doc ------------------ - `\public <sequence> <sequence> ... ;` does + \`\ea` is useful shortcut for `\expandafter`. We recommend to use always the + private form of \`\_ea` + because there is high probability that `\ea` will be redefined by the user. + \nl + \`\public` `<sequence> <sequence> ... ;` does `\let \<sequence> = \_<sequence>` for all sequences. - - `\private <sequence> <sequence> ...;` does + \nl + \`\private` `<sequence> <sequence> ...;` does `\let \_<sequence> = \<sequence>` for all sequences. - - The auxiliary macro `\xargs <what> <sequece> <sequence> ... ;` + \nl + \`\xargs` `<what> <sequence> <sequence> ... ;` does `<what><sequence>` for each sequences. - - `\_ea` is useful shotcut for `\expandafter`. \_cod ----------------- \_let\_ea =\_expandafter % usefull shortcut \_long\_def \_xargs #1#2{\_ifx #2;\_else \_ea#1\_ea#2\_ea\_xargs \_ea #1\_fi} +\_def \_pkglabel{} \_def \_public {\_xargs \_publicA} -\_def \_publicA #1{\_ea\_let \_ea#1\_csname _\_csstring #1\_endcsname} +\_def \_publicA #1{\_ea\_let \_ea#1\_csname \_pkglabel _\_csstring #1\_endcsname} \_def \_private {\_xargs \_privateA} -\_def \_privateA #1{\_ea\_let \_csname _\_csstring #1\_endcsname =#1} +\_def \_privateA #1{\_ea\_let \_csname \_pkglabel _\_csstring #1\_endcsname =#1} + +\_public \public \private \xargs \ea ; \_doc ----------------------- - Each `.opm` file should begin with `\_codedecl \macro {<info>}`. - If `\macro` is defined already then the `\endpinput` protects to read - such file more than one times. Else the <info> is printed to terminal - and file is read. - \_cod \_fin ------------------ + Each macro file should begin with \`\_codedecl` `\macro {<info>}`. + If the `\macro` is defined already then the `\endpinput` protects to read + such file more than one times. Else the <info> is printed to the terminal + and the file is read.\nl + The {\`\_endcode`} is defined as `\endinput` in the `optex.ini` file. + \`\wterm` `{<text>}` prints `<text>` + to the terminal and to the `.log` file (as in plain \TeX/). + \_cod ----------------------- \_def \_codedecl #1#2{% \_ifx #1\_undefined \_wterm{#2}% @@ -52,32 +60,67 @@ } \_def \_wterm {\_immediate \_write16 } -\_public \public \private \xargs \ea \wterm ; -\_private \optexversion ; +\_public \wterm ; + + \_doc ------------------------ + The `\optexversion` and `\fmtname` are defined in the `optex.ini` file. + Maybe, somebody will need a private version of these macros. + \_cod ------------------------ + +\_private \optexversion \fmtname ; + + \_doc ----------------------------- + The `\_mathsbon` and `\_mathsboff` are defined in `math-macros.opm` file. + Now, we define the macro \`\_namespace` `{<pkg label>}` for package writers, see + section~\ref[pkg-namespace]. + \_cod ----------------------------- + +\_def\_namespace #1{% + \_ifcsname namesp:#1\_endcsname \_errmessage + {The name space "#1" is used already, it cannot be used twice}% + \_endinput + \_else + \_ea \_gdef \_csname namesp:#1\_endcsname {}% + \_gdef \_pkglabel{_#1}% + \_directlua{ + callback.register("process_input_buffer", + function (str) + return string.gsub(str, "\_nbb[.]([a-zA-Z])", "\_nbb _#1_\_pcent 1") + end ) + }% + \_gdef \_endcode {% + \_ifmathsb \_mathsbon \_else \_mthsboff \_fi + \_gdef \_pkglabel{_#1}% + \_global \_let \_endcode=\_endinput + \_endinput }% + \_fi +} + +\_endcode%---------------------------------------------------- -\_endcode %---------------------------------------------------- +\sec Concept of name spaces of control sequences -\secc Prefixing control sequences +\secc Prefixing internal control sequences All control sequences used in \OpTeX/ are used and defined with `_` prefix. -Then user can be sure that when he/she does \def\foo then internal macros of +The user can be sure that when he/she does `\def\foo` then internal macros of \OpTeX/ nor \TeX/ primitives will be not damaged. For example -`\def\ifx{something}` will not damage maros because \OpTeX/'s macros -are using `\_ifx` instead `\ifx`. +`\def\if{...}` will not damage macros because \OpTeX/'s macros +are using `\_if` instead of `\if`. -All \TeX/ primitives are initialzed with two representative control +All \TeX/ primitives are initialized with two representative control sequences: `\word` and `\_word`, for example `\hbox` and `\_hbox`. The first alternative is reserved for users or such control sequences can be re-defined by user. -Note that \OpTeX/ sets the character `_` as letter, so it can be used in +\OpTeX/ sets the character `_` as letter, so it can be used in control sequences. When a control sequence begins with this character then it means that it is a primitive or it is used in \OpTeX/ macros as -internal. User can redefine such control sequence only if he/she explicitly -know what happens. +internal. User can redefine such prefixed control sequence only +if he/she explicitly know what happens. -We newer change catcode of `_`, so internal macros can be +We never change catcode of `_`, so internal macros can be redefined by user without problems if it is desired. We need not something like `\makealetter` from \LaTeX/. @@ -85,74 +128,112 @@ something like `\makealetter` from \LaTeX/. we need to set non-prefixed version. This is done by \begtt -\_public <list of control sequences> ; +\public <list of control sequences> ; \endtt -For example `\_public \foo \bar ;` does `\let\foo=\_foo`, `\let\bar=\_bar`. +For example \^`\public`` \foo \bar ;` does `\let\foo=\_foo`, `\let\bar=\_bar`. At the end of each code segment in \OpTeX/, the `\_public` macro is used. You can see, what macros are defined for public usage in such code segment. -The macro `\_private` does reverse job to `\_public` with the same syntax. -For example `\_private \foo \bar ;` does `\let\_foo=\foo`, `\let\_bar=\bar`. -This should be used when nonprefixed variant of control sequence is declared +The macro \^`\private` does a reverse job to `\public` with the same syntax. +For example `\private \foo \bar ;` does `\let\_foo=\foo`, `\let\_bar=\bar`. +This should be used when unprefixed variant of control sequence is declared already but we need the prefixed variant too. +In this documentation: if both variants of a control sequence are declared +(prefixed and unprefixed), then the accompanying text mentions only +unprefixed variant. The code typically defines prefixed variant +and then the `\public` (or `\_public`) macro is used. \secc Name space of control sequences for users User can define or declare any control sequence with a name without any `_`. This does not make any problem. Only one exception is the reserved control -sequence `\par` which is generated and used as internal in \TeX/. +sequence `\par`. It is generated by tokenizer (at empty lines) +and used as internal in \TeX/. -User can define or declare control seqquences with `_` character, for +User can define or declare control sequences with `_` character, for example `\my_control_sequence`, but with the following exceptions: \begitems -* Control sequences which begins with one `_` and there is no second `_` in - it and all used letters are lowercase, are reserved for \TeX/ primitives and - \OpTeX/ internal macros. +* Control sequences which begin with `_` are reserved for \TeX/ primitives, + \OpTeX/ internal macros and macro package writers. * Control sequences (terminated by non-letter) in the form `\<word>_` or `\<word>_<one-letter>`, where - <word> is a sequence of letters, are unaccesible, because they + <word> is a sequence of letters, are unaccessible, because they are interpreted as `\<word>` followed by `_` or as `\<word>` followed by `_<one-letter>`. This is important for writing math, for example: -\begtt - \int_a^b ... is interpreted as \int _a^b - \max_M ... is interpreted as \max _M - \alpha_{ij} ... is interpreted as \alpha _{ij} +\begtt \adef-{_} + \int-a^b ... is interpreted as \int _a^b + \max-M ... is interpreted as \max _M + \alpha-{ij} ... is interpreted as \alpha _{ij} \endtt This feature is implemented using lua code at input processor level, see - math-macro.opm for more details. You can deactivate this feature by - `\mathsboff`. After this, you can stil write `$∫_a^b$` or `$\int _a^b$` - without problems but `\int_a^b` yields to undefined control sequence - `\int_a`. You can activate this feature again by `\mathsbon` -- the + the section~\ref[math-macros] for more details. You can deactivate this feature by + \^`\mathsboff`. After this, you can still write + `$`$\int$`_a^b$` (Unicode) or `$\int _a^b$` % $∫_a^b$ (Unicode) or $\int _a^b$ + without problems but `\int``_a^b` yields to undefined control sequence + `\int``_a`. You can activate this feature again by \^`\mathsbon`. The effect will take shape from next line read from input file. * Control sequences in the form `\_<pkg>_<word>` is intended for package - writers as internal macros for a package with `<pkg>` identifier. + writers as internal macros for a package with `<pkg>` identifier, + see section~\ref[pkg-namespace]. \enditems -All other control sequences can be used in user name space. For example `\word`, -`\word_xx`, `\Word_x`, `\word_x_y`. +The single letter control sequences like `\%`, `\$`, `\^` etc. are not used +in internal macros. User can redefine them, but (of course) some classical +features can be lost (printing percent character by `\%` for example). + +\secc[pkg-namespace] Name spaces for package writers + +Package writer should use internal names in the form `\_<pgk>_<sequence>`, +where `<pkg>` is a package label. For example: +`\_qr_newbase` from `qrcode-x.tex` package. + +The package writer needs not write repeatedly `\_pkg_foo` `\_pkg_bar` +etc.\ again and again in the macro file.\fnote +{We have not adatped the idea from expl3 language:)} +When \^`\_namespace` `{<pkg>}` +is declared at the beginning of the macro file then all occurrences of +`\.foo` will be replaced by `\_<pkg>_foo` at the input processor level. +The macro writer can write (and backward can read his code) simply with +`\.foo`, `\.bar` control sequences and `\_<pkg>_foo`, `\_<pkg>_bar` +control sequences are processed internally. +The scope of the `\_namespace` command ends at the `\_encode` command +or when another `\_namespace` is used. This command checks +if the package label is not declared by the `\_namespace` twice. + +The `\_public` macro does `\let\foo = \_<pkg>_foo` when +`\_namespace {<pkg>}` is declared. And the `\_private` macro does reverse +operation to it. + +If the package writer needs to declare a control sequence by `\newif`, then +there is an exception of the rule described above. Use +`\_newifi\_if<pkg>_bar`, for example `\_newifi\_ifqr_incorner`. +Then the control sequences `\_qr_incornertrue` and +`\_qr_incornerfalse` can be used (or the sequences `\.incornertrue` +and `\.incornerfalse` when `\_namespace{qr}` is used). \secc Macro files syntax -Each segment of \OpTeX/ marcos is stored in one file with `.opm` extension -(means OPtex Macros). Your macros should be in normal *.tex file. +Each segment of \OpTeX/ macros is stored in one file with `.opm` extension +(means OPtex Macros). Your macros should be in normal `*.tex` file. -The code in `*.opm` files starts by `\_codedecl` and ends by `\_endcode`. -The `\_endcode` is equivalent for `\endinput`, so documentation can follow. -The `\_codedecl` has syntax: +The code in macro files starts by \^`\_codedecl` and ends by \^`\_endcode`. +The \^`\_endcode` is equivalent for `\endinput`, so documentation can follow. +The \^`\_codedecl` has syntax: \begtt \_codedecl \sequence {Name <version>} \endtt -If the mentioned `\sequence` is defined, then `\_codedecl` does the same as +If the mentioned `\sequence` is defined, then \^`\_codedecl` does the same as `\endinput`: this protect from reading the file twice. We suppose, that -`\sequence` is defined. +`\sequence` is defined in the macro file. -We can read the `*.opm` file in documentation mode. Then the code and the -comments after `\_endcode` are printed. +It is possible to use the \^`\_doc` ... \^`\_cod` pair between the macro lines. +The documentation text should be here. It is ignored when macros are read +but it can be printed using `optexdoc.opm` macros like in this documentation. diff --git a/Master/texmf-dist/tex/luatex/optex/ref-file.opm b/Master/texmf-dist/tex/luatex/optex/ref-file.opm index 5f2b50f06d2..01363ef9a97 100644 --- a/Master/texmf-dist/tex/luatex/optex/ref-file.opm +++ b/Master/texmf-dist/tex/luatex/optex/ref-file.opm @@ -3,7 +3,7 @@ \_codedecl \openref {File for references <2020-02-14>} % preloaded in format \_doc -------------------------- - The `\_inputref` macro is used in `\everyjob`. It reads `\jobname.ref` file + The \`\_inputref` macro is used in `\everyjob`. It reads `\jobname.ref` file if it exists. After the file is read then it is removed and opened to write a new contents to this file. \_cod -------------------------- @@ -14,14 +14,14 @@ \_isfile{\_jobname.ref}\_iftrue \_input {\jobname.ref} \_gfnotenum=0 \_lfnotenum=0 \_mnotenum=0 - \_openrefA{\_string\inputref}% + \_openrefA{\_string\_inputref}% \_fi } \_doc -------------------------- If the file does not exists then it is not created by default. It means that if you process a document without any forward references then no `\jobname.ref` - file is created because it is unusable. The `\_wref` macro is dummy in + file is created because it is unusable. The \^`\_wref` macro is dummy in such case. \_cod -------------------------- @@ -29,9 +29,12 @@ \_let\_wref=\_wrefrelax \_doc --------------------- - If a macro needs to ceate and to use `.ref` file then such file must be created by - `\_openref`. When the file is created (using internal `\_openrefA`) then - `\_opneref` destroys itself, because we need not to open the file again. + If a macro needs to ceate and to use `.ref` file then such macro must use + \`\openref`. When the file is created (using internal \`\_openrefA`) then + the \`\_wref` `\<macro>{<data>}` is redefined in order to + save the line `\<macro><data>` to the `.ref` file using asynchronous + `\write` primitive. Finally, the `\_openref` destroys itself, because we + need not to open the file again. \_cod --------------------- \_def\_openref {% @@ -47,31 +50,40 @@ \def\openref{\_openref} \_doc ---------------------- - We are using a convention that the macros used in `.ref` file are named - `\_X<foo>`. If there is a new wersion of \OpTeX/ with different collection + We are using convention that the macros used in `.ref` file are named + `\_X<foo>`. If there is a new version of \OpTeX/ with different collection of such macros then we don't want to read the `.ref` files produced by an - old version of \OpTeX/ or by OPmac. So first line of `.ref` line is in + old version of \OpTeX/ or by OPmac. So first line of `.ref` file is in the form - \begtt + \begtt \catcode`\<=13 \Xrefversion{<version>} \endtt We can check the version compatibility by this macro. Because OPmac does not understand `\_Xrefversion` we use - `\Xrefversion` (different form OPmac) here. + \`\Xrefversion` (with different number of `<version>` form OPmac) here. + The result: OPmac skips the `.ref` files produced by \OpTeX/ and vice + versa. \_cod ---------------------- -\_def\_REFversion{3} % actual version of .ref files +\_def\_REFversion{3} % 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 \_doc ----------------------- - You cannot define your special `.ref` macos before `.ref` file is read + You cannot define your special `.ref` macros before `.ref` file is read because it is read in `\everyjob`. But you can define such macros using - `\refdecl{<definitions of your ref macros>}`. - This command sends to `.ref` file your <definitions of your ref macros> - immediately. Next lines in `.ref` file should include our macros. - - We must read <definition of your ref macros> when catcode of `#` is 12 + \`\refdecl``{<definitions of your ref macros>}`. + This command sends to `.ref` file your `<definitions of your ref macros>` + immediately. Next lines in `.ref` file should include our macros. Example + from CTUstyle2: + \begtt + \refdecl{% + \def\totlist{} \def\toflist{}^^J + \def\Xtab#1#2#3{\addto\totlist{\totline{#1}{#2}{#3}}}^^J + \def\Xfig#1#2#3{\addto\toflist{\tofline{#1}{#2}{#3}}} + } + \endtt + We must read `<definition of your ref macros>` when catcode of `#` is 12 because we needn't to duplicate each `#` in the `.ref` file. \_cod \_fin ----------------- @@ -85,9 +97,14 @@ \_endcode % ================================================ -The REF file looks like: +The `.ref` file has the name `\jobname.ref` and +it saves information about references, TOC lines, etc. +All data needed in next \TeX/ run are saved here. +\OpTeX/ reads this file at the beginning of the document +(using `\everyjob`) if such file exists. +The `.ref` file looks like: -\begtt +\begtt \catcode`\<=13 \Xrefversion{<ref-version>} \_Xpage{<gpageno>}{<pageno>} \_Xtoc{<level>}{<type>}{<text>}{<title>} @@ -98,19 +115,23 @@ The REF file looks like: \_Xlabel{<label>}{<text>} ... \endtt - -where <gpageno> is internal page number numbered from one and <pageno> is -a page number used in pagination. Each page begins with `\_Xpage`. -The <label> is <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 tile 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 +% +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`. +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 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. The `.ref` file is read when the processing of the document starts using -`\everyjob`. It is removed and opened to writting immediately when it is read. -But the `.ref` file should be missing. If none references are needed in the -document then `.ref` file is not created. +`\everyjob`. It is read, removed and opened to writing immediately. +But the `.ref` file should be missing. If none forward references are needed +in the document then `.ref` file is not created. For example, you only want +to test a simple plain \TeX/ macro, you create `test.tex` file, you do +`optex test` and you don't need to see empty `test.ref` file in your directory. + diff --git a/Master/texmf-dist/tex/luatex/optex/references.opm b/Master/texmf-dist/tex/luatex/optex/references.opm index 3cd27c043e7..ccd1157a2a7 100644 --- a/Master/texmf-dist/tex/luatex/optex/references.opm +++ b/Master/texmf-dist/tex/luatex/optex/references.opm @@ -3,23 +3,24 @@ \_codedecl \ref {References <2020-03-03>} % preloaded in format \_doc ---------------------------- - `\_Xpage {<gpageno>}{<pageno>}` saves the patameter pair into `\_currpage`. - Resets `\_lfnotenum`, it is used if footnotes are numbered from one at each page. + \`\_Xpage` `{<gpageno>}{<pageno>}` saves the parameter pair into \`\_currpage`. + Resets `\_lfnotenum`; it is used if footnotes are numbered from one at each page. \_cod ---------------------------- \_def\_Xpage#1#2{\_def\_currpage{{#1}{#2}}\_lfnotenum=0 } \_doc ---------------------------- - `\_Xlabel {<label>}{<text>}` saves <text> to `\_lab:<label>` and saves - `[<gpageno>]{<pageno>}` to `\_pgref:<label>`. + \`\_Xlabel` `{<label>}{<text>}` saves the <text> to `\_lab:<label>` and saves + `[pg:<gpageno>]{<pageno>}` to `\_pgref:<label>`. \_cod ---------------------------- \_def\_Xlabel#1#2{\_sdef{_lab:#1}{#2}\_sxdef{_pgref:#1}{\_ea\_bracketspg\_currpage}} \_def\_bracketspg#1#2{[pg:#1]{#2}} \_doc ---------------------------- - `\label[<label>]` saves decalred labet to `\_lastlabel` and `\wlabel{<text>}` - uses `\lastlabel` and activates `\wref\_Xlabel{<label>}{<text>}`. + \`\label``[<label>]` saves the decalred label to `\_lastlabel` and + \`\wlabel``{<text>}` uses the `\_lastlabel` and activates + `\wref\_Xlabel{<label>}{<text>}`. \_cod ---------------------------- \_def\_label[#1]{\_isempty{#1}\_iftrue \_global\_let \_lastlabel=\_undefined @@ -37,16 +38,17 @@ \_global\_let\_lastlabel=\_undefined \_fi } +\_public \label \wlabel ; \_doc ---------------------------- - `\ref[<label>]` uses saved `\_lab:<label>` and prints (linked) <text>. + \`\ref``[<label>]` uses saved `\_lab:<label>` and prints (linked) `<text>`. If the reference is backwarded then we know `\lab:<label>` without any need to read REF file. On the other hand, if the reference is forwarded, then we doesn't know `\_lab:<label>` in first run of \TeX/ and we print warning and do `\_openref`. - - `\pgref[<label>]` uses `{<gpageno>}{<pageno>}` from `\_pgref:<label>` and - prints (linked) <pageno> using `\_ilink` macro. + \nl + \`\pgref``[<label>]` uses `{<gpageno>}{<pageno>}` from `\_pgref:<label>` and + prints (linked) `<pageno>` using `\_ilink` macro. \_cod ---------------------------- \_def\_ref[#1]{\_isdefined{_lab:#1}% @@ -59,12 +61,11 @@ \_else ??\_opwarning{pg-label [#1] unknown. Try to TeX me again}\_openref \_fi } -\_public - \label \wlabel \ref \pgref ; +\_public \ref \pgref ; \_doc ----------------------------- - Default `\_printlabel` is empty (labes are not printed). - The `\showlabels` redefines it as box with zero dimensions and + Default \`\_printlabel` is empty macro (labels are not printed). + The \`\showlabels` redefines it as box with zero dimensions and with left lapped `[<label>]` in blue 10pt `\tt` font shifted up by 1.7ex. \_cod ----------------------------- @@ -79,7 +80,7 @@ If the references are \"forward" (i.~e. the `\ref` is used first, the destination -is created later), or if the reference text is page number, we must read +is created later) or if the reference text is page number then we must read `.ref` file first in order to get appropriate information. See section \ref[ref-file] for more information about `.ref` file concept. diff --git a/Master/texmf-dist/tex/luatex/optex/sections.opm b/Master/texmf-dist/tex/luatex/optex/sections.opm index 2a7629560c3..bbe599c5339 100644 --- a/Master/texmf-dist/tex/luatex/optex/sections.opm +++ b/Master/texmf-dist/tex/luatex/optex/sections.opm @@ -3,7 +3,9 @@ \_codedecl \chap {Titles, chapters, sections, subsections <2020-03-14>} % preloaded in format \_doc --------------------------- - We are using scaled fonts for titles. They are scaled from main fonts size + We are using scaled fonts for titles + \`\_titfont`, \`\_chapfont`, \`\_secfont` and \`\_seccfont`. + They are scaled from main fonts size of the document, which is declared by first `\typosize[<fo-size>/<b-size>]` command. \_cod --------------------------- @@ -14,7 +16,7 @@ \_def \_seccfont {\_scalemain\_boldify\_typoscale[\_magstep1/\_magstep1]} \_doc --------------------------- - The `\tit` macro is defined by `\eoldef`, it means that the parameter is + 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. \_cod --------------------------- @@ -27,38 +29,40 @@ \_public \tit ; \_doc --------------------------- - You can re-define `\_printchap`, `\_printsec` or `\_printsecc` macros if - another design of section titles is needed. These macros gets the <title> - text in its parameter. The common recommendations for these macros are: + You can re-define \`\_printchap`, \`\_printsec` or \`\_printsecc` macros if + another design of section titles is needed. These macros gets the + `<title>` text in its parameter. The common recommendations for these macros are: \begitems - * Use `\_abovetitle{<penaltyA>}{<skipA>}` and `\_belowtitle{<skipB>} + * Use \^`\_abovetitle``{<penaltyA>}{<skipA>}` and \^`\_belowtitle``{<skipB>}` for inserting vertical material above and below the section title. - The arguments of these macros are normally used, i.e. \_abovetitle` - inserts <penaltyA><skipA> and `\_belowtitle` inserts <skipB>. + The arguments of these macros are normally used, i.\,e.\ \^`\_abovetitle` + inserts `<penaltyA><skipA>` and \^`\_belowtitle` inserts `<skipB>`. But there is an - exception: if `\_belowtitle{<skip>}` is immediately followed by next - `\_abovetitle{<penalty>}` (for example section title is immediately followed by - subsection title), then only <skipA> is generated, i.e. - <skipB><penaltyA><skipA> is reduced only to <skipA> + exception: if \^`\_belowtitle``{<skipB>}` is immediately followed by + \^`\_abovetitle``{<penaltyA>}{<skipA>}` (for example section title is + immediately followed by subsection title), then only `<skipA>` is generated, + i.\,e.\ `<skipB><penaltyA><skipA>` is reduced only to `<skipA>`. The reason of such behavior: we don't want to duplicate vertical skip and we don't want to use negative penalty in such cases. - Moreower, `\_abovetitle{<penaltyA>}{<skipA>}` takes previous whatever + Moreover, \^`\_abovetitle``{<penaltyA>}{<skipA>}` takes previous whatever vertical skip (other than from `\_belowtitle`) and generates only - greater from this pair of skips. I.e. <whatever-skip><penaltyA><skipA> - is reduced to $<penaltyA>\max(<whatever-skip><skipA>)$. + greater from this pair of skips. It means that `<whatever-skip><penaltyA><skipA>` + is transformed to `<penaltyA>`max(`<whatever-skip><skipA>`). The reason of such behavior: we don't want to duplicate vertical skips (from `\_belowlistskip`, for example) above the title. - * Use `\_printrefnum[<pre>@<post>]` in horizontal mode. It prints - <pre><ref-num><post>. The <ref-num> is `\thechapnum` or `\thesecnum` - or `\theseccnum` depending on what type o title is processed. - If `\nonum` prefix is used then `\_printrefnum` prints nothing. - The macro `\_printrefnum` does more work: it creates destination of hyperlinks - (if `\hyperlinks{}{}` is used) and saves references from label (if - `\label[<label>]` precedes) and saves references for table of contents - (if `\maketoc` is used). - * Use `\nbpar` for closing the paragraph for printing title. This + * Use \^`\_printrefnum``[<pre>@<post>]` in horizontal mode. It prints + `<pre><ref-num><post>`. The `<ref-num>` is \^`\_thechapnum` or \^`\_thesecnum` + or \^`\_theseccnum` depending on what type o title is processed. + If \^`\nonum` prefix is used then \^`\_printrefnum` prints nothing. + The macro \^`\_printrefnum` does more work: it creates destination of hyperlinks + (if \^`\hyperlinks``{}{}` is used) and saves references from label (if + \^`\label``[<label>]` precedes) and saves references for table of contents + (if \^`\maketoc` is used). + * Use \^`\nbpar` for closing the paragraph for printing title. This command inserts `\_nobreak` between each line of such paragraph, so the title cannot be broken to more pages. + * You can use \^`\_firstnoindent` in order to the first paragraph after + the title is not indented. \enditems \_cod --------------------------- @@ -66,7 +70,7 @@ {\_chapfont \_noindent \_mtext{chap} \_printrefnum[@]\_par \_nobreak\_smallskip \_noindent \_raggedright #1\_nbpar}\_mark{}% - \_nobreak \_belowtitle{\_medskip}% + \_nobreak \_belowtitle{\_bigskip}% \_firstnoindent } \_def\_printsec#1{\_par @@ -83,7 +87,7 @@ } \_doc -------------------------- - The `\_sectionlevel` is the level of the printed section: + The \`\_sectionlevel` is the level of the printed section: \begitems * `\_sectionlevel=0` -- reserved for parts of the book (unused by default) * `\_sectionlevel=1` -- chapters (used in `\chap`) @@ -99,26 +103,30 @@ } \_doc -------------------------- - The `\_chapx` initializes counters used in chapters, - the `\_secx` initializes counters in sections - and `\_seccx` initializes counters in subsections. - If you have another concept of numbering objects used in your + The \`\_chapx` initializes counters used in chapters, + the \`\_secx` initializes counters in sections + and \`\_seccx` initializes counters in subsections. + If you have more types of numbered objects in your document then you can + declare appropriate counters and do `\addto\_chapx{\yourcounter=0 }` + for example. If you have another concept of numbering objects used in your document, you can re-define these macros. All settings here are global because it is used by `{\_globaldefs=1 \_chapx}`. Default concept: Tables, figuers and display maths are numbered from one in each section -- subsetions doesn't reset these counters. + Footnotes declared by \^`\fnotenumchapters` are numbered in each chapter + from one. - The `\_the*` macros includes the format of numbers used when the object + The `\_the*` macros + \`\_thechapnum`, \`\_thesecnum`, \`\_theseccnum`, + \`\_thetnum`, \`\_thefnum` and \`\_thednum` + include the format of numbers used when the object is printing. If chapter is never used in the document then `\_chapnum=0` - and `\_othe\_chapnum.` expands to empty. Sections have numbers <num> and + and \`\_othe``\_chapnum.` expands to empty. Sections have numbers <num> and subsections <num>.<num>. On the other hand, if chapter is used in the - document then `\_chapnum>0` and sections have numbers <num>.<num> - and subsections have numbers <num>.<num>.<num>. + document then `\_chapnum>0` and sections have numbers` <num>.<num>` + and subsections have numbers `<num>.<num>.<num>`. - If you have more types of numbered objects in your document then you can - declare appropriate counters and do `\addto\_chapx{\yourcounter=0 }` - for example. \_cod -------------------------- \_newcount \_chapnum % chapters @@ -128,12 +136,9 @@ \_newcount \_fnum % figure numbers \_newcount \_dnum % numbered display maths -\_def \_chapx {\_incr\_chapnum \_secnum=0 \_seccnum=0 \_resetcountchap \_lfnotenum=0 } -\_def \_secx {\_incr\_secnum \_seccnum=0 \_resetcountsec } -\_def \_seccx {\_incr\_seccnum } - -\_def \_resetcountchap {\_tnum=0 \_fnum=0 \_dnum=0 } -\_def \_resetcountsec {\_tnum=0 \_fnum=0 } +\_def \_chapx {\_secx \_secnum=0 \_lfnotenum=0 } +\_def \_secx {\_seccx \_seccnum=0 \_tnum=0 \_fnum=0 \_dnum=0 \_resetABCDE } +\_def \_seccx {} \_def \_thechapnum {\_the\_chapnum} \_def \_thesecnum {\_othe\_chapnum.\_the\_secnum} @@ -146,8 +151,9 @@ \_def\_incr #1{\_global\_advance#1by1 } \_doc ---------------------------- - The `\notoc` and `\nonum` prefixes are implemented by - internal `\_ifnotoc` and `\_ifnonum`. + The \`\notoc` and \`\nonum` prefixes are implemented by + internal `\_ifnotoc` and `\_ifnonum`. They are reset + after each chapter/section/subsection by the \`\_resetnonumnotoc` macro. \_cod ---------------------------- \_newifi \_ifnotoc \_notocfalse \_def\_notoc {\_global\_notoctrue} @@ -156,8 +162,8 @@ \_public \notoc \nonum ; \_doc ---------------------------- - The `\chap`, `\sec` and `\secc` macros are implemnted here. - The `\_inchap`, `\_insec` and `\_insecc` macros does the real work, + 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. \_cod ---------------------------- @@ -168,21 +174,21 @@ \_eoldef\_inchap #1{\_par \_sectionlevel=1 \_def \_savedtitle {#1}% saved to .ref file - \_ifnonum \_else {\_globaldefs=1 \_chapx}\_fi + \_ifnonum \_else {\_globaldefs=1 \_incr\_chapnum \_chapx}\_fi \_edef \_therefnum {\_ifnonum \_space \_else \_thechapnum \_fi}% \_printchap{#1}% \_resetnonumnotoc } \_eoldef\_insec #1{\_par \_sectionlevel=2 \_def \_savedtitle {#1}% saved to .ref file - \_ifnonum \_else {\_globaldefs=1 \_secx}\_fi + \_ifnonum \_else {\_globaldefs=1 \_incr\_secnum \_secx}\_fi \_edef \_therefnum {\_ifnonum \_space \_else \_thesecnum \_fi}% \_printsec{#1}% \_resetnonumnotoc } \_eoldef\_insecc #1{\_par \_sectionlevel=3 \_def \_savedtitle {#1}% saved to .ref file - \_ifnonum \_else {\_globaldefs=1 \_seccx}\_fi + \_ifnonum \_else {\_globaldefs=1 \_incr\_seccnum \_seccx}\_fi \_edef \_therefnum {\_ifnonum \_space \_else \_theseccnum \_fi}% \_printsecc{#1}% \_resetnonumnotoc @@ -190,12 +196,13 @@ \_public \chap \sec \secc ; \_doc ---------------------------- - The `\_printrefnum[<pre>@<post>]` macro is used in `\_print*` macros. - The `\_wtotoc {<level>}{<info>}{<ref-num>}{<title-text>}` - macro expands its parameters and does `\_wref`. + The \`\_printrefnum``[<pre>@<post>]` macro is used in `\_print*` macros. + \nl + The \`\_wtotoc` `{<level>}{<info>}{<ref-num>}{<title-text>}` + macro expands its parameters and does \^`\_wref`. - Note that the <tite-text> is `\detokenize`d before `\wref`, so the - problem of \"fragile macros" from old \LaTeX/ never occurrs. + Note that the `<tite-text>` is `\detokenize`d before `\_wref`, so the + problem of \"fragile macros" from old \LaTeX/ never occurs. \_cod ---------------------------- \_def \_printrefnum [#1@#2]{\_leavevmode % we must be in horizontal mode @@ -211,17 +218,17 @@ \_def \_wtotocA #1#2#3#4{\_wref\_Xtoc{{#1}{#2}{#3}{#4}}} \_doc ----------------------------- - The `\_abovetitle{<penaltyA>}{<skipA>}` and `\_belowtitle{<skipB>}` pair + The \`\_abovetitle``{<penaltyA>}{<skipA>}` and \`\_belowtitle``{<skipB>}` pair communicates using a special penalty 11333 in vertical mode. The `\_belowtitle` puts the vertical skip (its value is saved in `\_savedtitleskip`) followed by this special penalty. The `\_abovetitle` reads `\lastpenalty` and if it has this special value - then it removes the skip used before and dont use the parameter. - The `\abovetitle` creates <skipA> only if whatever previous skip is less - or equal than <skipA>. We must save <whatever-skip>, remove it, - create <penaltyA> (if belowtitle does not preceded) and create - <whatever-skip> or <skipA> depending on what is greater. - The amount of <skipA> is measured using `\setbox0=\vbox`. + then it removes the skip used before and don't use the parameter. + The `\abovetitle` creates `<skipA>` only if whatever previous skip is less + or equal than `<skipA>`. We must save `<whatever-skip>`, remove it, + create `<penaltyA>` (if `\_belowtitle` does not preceded) and create + <whatever-skip> or `<skipA>` depending on what is greater. + The amount of `<skipA>` is measured using `\setbox0=\vbox`. \_cod ----------------------------- \_newskip \_savedtitleskip @@ -236,8 +243,8 @@ \_def\_belowtitle #1{#1\_global\_savedtitleskip=\_lastskip \_penalty11333 } \_doc ----------------------------- - `\nbpar` sets `\interlinepenaty` value. - `\nl` is \"new line" in text (or titles), but space in toc or healdlines or outlines. + \`\nbpar` sets `\interlinepenaty` value. + \`\nl` is \"new line" in text (or titles), but space in toc or headlines or outlines. \_cod ----------------------------- \_def\_nbpar{{\_interlinepenalty=10000\_endgraf}} @@ -249,24 +256,23 @@ \_public \nbpar \nl ; \_doc ----------------------------- - `\_firstnoindent` puts a material to `\everypar` in order to next + \`\_firstnoindent` puts a material to `\everypar` in order to next paragraph will be without indentation. It is useful after titles. If you dislike this feature then you can say `\let\_firtnoindent=\relax`. - The `\_wipeepar` removes the material from `\everypar`. + The \`\_wipeepar` removes the material from `\everypar`. \_cod ----------------------------- -\_def \_afternoindent {\_global\_everypar={\_wipeepar \_setbox7=\_lastbox}} +\_def \_firstnoindent {\_global\_everypar={\_wipeepar \_setbox7=\_lastbox}} \_def \_wipeepar {\_global\_everypar={}} -\_let \_firstnoindent=\_afternoindent \_doc ----------------------------- The `\mark` (for running heads) is used in `\_printsection` only. We suppose that chapters will be printed after `\vfil\break`, so user can implement chapter titles for running headers directly by macros, no - `\mark` machanism is needed. But sections need `\mark`s. And they can be + `\mark` mechanism is needed. But sections need `\mark`s. And they can be mixed with chapter's running heads, of course. - The `\_insermark{<title text>}` saves `\mark` in the format + The \`\_insermark``{<title text>}` saves `\mark` in the format `{<title-num>} {<title-text>}`, so it can be printed \"as is" in `\headline` (see the space between them), or you can define a formating macro with two parameters for processing these data, if you need it. @@ -275,10 +281,10 @@ \_def\_insertmark#1{\_mark{{\_ifnonum\_else\_therefnum\_fi} {\_unexpanded{#1}}}} \_doc ----------------------------- - \OpTeX/ sets `\headline={}` by default, so no running heads are printed. - You can activate the running heads by following code, for example: + \OpTeX/ sets `\headline={}` by default, so no running headings are printed. + You can activate the running headings by following code, for example: \begtt - \addto \_chapx {\_edef\_runningchap {\_thechapnum: \_unexpanded\_ea{\_savedtitle}}} + \addto\_chapx {\_edef\_runningchap {\_thechapnum: \_unexpanded\_ea{\_savedtitle}}} \def \formathead #1#2{\isempty{#1}\iffalse #1: #2\fi} \headline = {% \ifodd \pageno @@ -288,12 +294,13 @@ \fi } \endtt - - The `\caption/<letter>` uses `\_<letter>num` counter. - The group opened by `\caption` is finalized by first \par from + The \`\caption``/<letter>` uses `\_<letter>num` counter. + The group opened by `\caption` is finalized by first `\par` from empty line or from `\vskip` or from `\endinsert`. The `\_printcaption<letter>` is called, it starts with - printing of the caption. + printing of the caption.\nl + The \`\cskip` macro inserts nobreakable vertical space between caption and + the object. \_cod ----------------------------- \_def\_caption/#1{\_def\_tmpa{#1}\_nospaceafter \_capA} @@ -308,15 +315,18 @@ \_def\_par{\_nbpar\_egroup}\_let\par=\_par \_cs{_printcaption\_tmpa}% } +\_def \_cskip {\_par\_nobreak\_medskip} % space between caption and the object + +\_public \caption \cskip ; \_doc ----------------------------- - The `\_printcaption<letter>` macro starts in vertical mode. It must - switch to horizontal mode, it must use `\_wlabel\_thecapnum` (in order to - make reference and hyperlink destination) a it can use: + The \`\_printcaptiont` and \`\_printcaptionf` macros start in vertical mode. + They switch to horizontal mode and use `\_wlabel\_thecapnum` (in order to + make reference and hyperlink destination) a they can use: \begitems * `\_thecaptitle` ... expands to the word Table or Figure (depending on the current language). - * `\_thecapnum` ... expands to `\the<letter>num` (caption number). + * `\_thecapnum` ... expands to `\the<letter>num` (caption number). \enditems \_cod ----------------------------- @@ -325,14 +335,11 @@ \_narrowlastlinecentered\_iindent } \_let \_printcaptionf = \_printcaptiont % caption of figures = caption of tables -\_def \_cskip {\_par\_nobreak\_medskip} % space between caption and the object - -\_public \caption \cskip ; \_doc ----------------------------- The default format of `\caption` text is paragraph in block narrower by `\_iindent` and with the last line is centered. This setting is done by - `\_narrowlastlinecentered` macro. + the \`\_narrowlastlinecentered` macro. \_cod ----------------------------- \_def\_narrowlastlinecentered#1{% @@ -342,7 +349,7 @@ } \_doc ----------------------------- - `\eqmark` is processed in display mode (we add `\eqno` primitive) + \`\eqmark` is processed in display mode (we add `\eqno` primitive) or in internal mode when `\eqaligno` is used (we don't add `\eqno`). \_cod ----------------------------- @@ -354,20 +361,13 @@ \_public \eqmark ; \_doc ----------------------------- - The `\numberedpar <letter>{<name>}` is implemented here. - You can say `\let\resetcountsec=\relax` if you don't want to reset - counters A, B, C, D, E nor `\fnum` nor `\tnum` in sections, but only in - chapters. Or you can define you own concept of `\_chapx` and `\_secx` - macros (see above). Then you will want to re-define `\_theAnum`, `\_thefnum` - etc. macros. + The \`\numberedpar` `<letter>{<name>}` is implemented here. \_cod ----------------------------- \_newcount\_counterA \_newcount\_counterB \_newcount\_counterC \_newcount\_counterD \_newcount\_counterE -\_def\_resetcounters{\_counterA=0 \_counterB=0 \_counterC=0 \_counterD=0 \_counterE=0 } -\_addto \_resetcountchap {\_resetcounters} -\_addto \_resetcountsec {\_resetcounters} +\_def\_resetABCDE {\_counterA=0 \_counterB=0 \_counterC=0 \_counterD=0 \_counterE=0 } \_def \_theAnum {\_othe\_chapnum.\_othe\_secnum.\_the\_counterA} \_def \_theBnum {\_othe\_chapnum.\_othe\_secnum.\_the\_counterB} @@ -380,19 +380,22 @@ \_optdef\_numberedparparam[]{% \_ea \_printnumberedpar \_csname _the\_tmpa num\_ea\_endcsname\_ea{\_tmpb}} +\_public \numberedpar ; + \_doc ----------------------------- - The `\_printnumberedpar \theXnum {<name>}` opens numbered paragraph and + The \`\_printnumberedpar` `\theXnum {<name>}` opens numbered paragraph and prints it. The optional parameter is in `\_the\_opt`. You can re-define it if you need another design. - `\_printnumberedpar` need not to be re-define if you only need to print + `\_printnumberedpar` needs not to be re-defined if you only want to print Theorems in italic and to insert vertical skips (for example). You can do this - by the following: - \_begtt + by the following code: + \begtt \def\theorem {\medskip\bgroup\it \numberedpar A{Theorem}} \def\endtheorem {\par\egroup\medskip} - \_endtt + \theorem Let $M$ be... \endtheorem + \endtt \_cod ----------------------------- \_def \_printnumberedpar #1#2{\_par @@ -400,8 +403,8 @@ {\bf #2 #1\_istoksempty\_opt\_iffalse \_space \_the\_opt \_fi.}\_space \_ignorespaces } -\_public \numberedpar ; - \_endcode % ------------------------------------- +2020-04-22 \_chapx, \_secx, \_seccx rewritten +2020-03-14 introduced diff --git a/Master/texmf-dist/tex/luatex/optex/slides.opm b/Master/texmf-dist/tex/luatex/optex/slides.opm index 135a2bdce40..4729f0e512f 100644 --- a/Master/texmf-dist/tex/luatex/optex/slides.opm +++ b/Master/texmf-dist/tex/luatex/optex/slides.opm @@ -4,7 +4,7 @@ \_doc ----------------------------- Default margins and design is declared here. - Note that `\_ttfont` is scaled by `mag1.15` in order to balance the + The `\_ttfont` is scaled by `mag1.15` in order to balance the ex height of Helvetica (Heros) and LM fonts Typewriter. The `\begtt`...`\endtt` verbatim is printed by smaller text. \_cod ----------------------------- @@ -32,7 +32,7 @@ \_doc ----------------------------- The bottom margin is set to 3\,mm. If we use 1\,mm, then baseline of `\footline` is 2\,mm from the bottom page. This is depth of the `\Grey` - rectange used for page numbers. It is rlapped to `\hoffset` because left + rectangle used for page numbers. It is r-lapped to `\hoffset` width because left margin = `\hoffset` = right margin. It is 14\,mm for narrow pages or 16\,mm for wide pages. \_cod ----------------------------- @@ -43,15 +43,15 @@ \_hbox to\_hoffset{\White\_hss\_folio\_kern3mm}}} \_doc ----------------------------- - The `\subtit` is defined analogicaly like `\tit`. + The \`\subtit` is defined analogically like `\tit`. \_cod ----------------------------- \_eoldef\_subtit#1{\_vskip20pt {\_leftskip=0pt plus1fill \_rightskip=\_leftskip \_subtitfont #1\_nbpar}} \_doc ----------------------------- - The `\pshow<num>` is implemented by printing the text in invisible - (transparent) font when `\layernum<<num>`. + The \`\pshow``<num>` prints the text in invisible + (transparent) font when \^`\layernum`\code{<}`<num>`. The color font feature is used for this transparency. \_cod ----------------------------- @@ -60,10 +60,10 @@ \_def\_pshow#1{\_use{=#1}\Red \_use{<#1}\Transparent \_ignorespaces} \_doc ----------------------------- - The main level list is activated here. The `\_item:X` and + The main level list of items is activated here. The `\_item:X` and `\_item:x` are used and are re-defined here. If we are in nested level of items and `\pg+` is used then - `\egroups` macro xepands to the right number of `\egroup`s + `\egroups` macro expands to the right number of `\egroup`s in order to close page correctly. The level of nested item lists is saved to the `\_ilevel` register and used when we start again the next text after `\pg+`. @@ -80,7 +80,7 @@ \_addto\_egroups{\_egroup}} \_doc ----------------------------- - The default values of `\pg;`, `\pg+` and `\pg.` are very simple. + The default values of \`\pg`, i.\,e.\ `\pg;`, `\pg+` and `\pg.` are very simple. They are used when `\showslides` is not specified. \_cod ----------------------------- @@ -91,7 +91,7 @@ \_doc ----------------------------- We need no numbers and no table of contents when using slides. - The `\_printsec` macro is redefined in order the title is centered + The \^`\_printsec` macro is redefined in order the title is centered and typeset in `\Blue`. \_cod ----------------------------- @@ -108,18 +108,19 @@ } \_doc ----------------------------- - When `\slideshow` is active then each page is opened (roughly speaking) - by `\setbox\_slidepage=\vbox\bgroup` and closed by `\egroup`. The material is + When \`\slideshow` is active then each page is opened + by `\setbox\_slidepage=\vbox\bgroup` (roughly speaking) + and closed by `\egroup`. The material is `\unvbox`ed and saved for the usage in the next usage if `\pg+` is in process. - The `\_slidelayer` is inceremnted instead `\pageno` if `\pg+`. + The \`\_slidelayer` is incremented instead `\pageno` if `\pg+`. This counter is equal to `\count1`, so it is printed to the terminal and log file next to `\pageno`. - The code is somewhat more complicated when `\layers` is used. Then - <layered-text> is saved to the `\_layertext` macro, the material before - it is in `\_sidepage` box and the material after it is in `\_slidepageB` - box. The pages are completrd in the `\loop` which increments the - `\layernum` register. + The code is somewhat more complicated when \^`\layers` is used. Then + `<layered-text>` is saved to the \`\_layertext` macro, the material before + it is in \`\_slidepage` box and the material after it is in `\_slidepageB` + box. The pages are completed in the `\loop` which increments the + \`\layernum` register. \_cod ----------------------------- \_newbox\_slidepage \_newbox\_slidepageB @@ -179,10 +180,11 @@ \_global\_maxlayers=#1 \_setbox\_slidepageB=\_vbox\_bgroup } +\_public \subtit \slideshow \pg \wideformat \use \pshow ; \_doc ----------------------------- - Default `\layers <num>` macro (when `\slideshow` is not activated) is simple. - It prints the <layered-text> with `\layernum=<num>+1` because we need the + Default \`\layers` `<num>` macro (when \^`\slideshow` is not activated) is simple. + It prints the `<layered-text>` with `\layernum=<num>+1` because we need the result after last layer is processed. \_cod ----------------------------- @@ -190,10 +192,9 @@ \_let\endlayers=\_relax \_def\layers{\_layers} -\_public \subtit \slideshow \pg \wideformat \use \pshow ; \_doc ----------------------------- - We must to redefine `\fnotenumpages` because the data from `.ref` file + We must to redefine \`\fnotenumpages` because the data from `.ref` file are less usable for implementing such feature: the footnote should be in more layers repeatedly. But we can suppose that each page starts by `\pg;` macro, so we can reset the footnote counter by diff --git a/Master/texmf-dist/tex/luatex/optex/styles.opm b/Master/texmf-dist/tex/luatex/optex/styles.opm index d2ef38a0136..a51f4e998d3 100644 --- a/Master/texmf-dist/tex/luatex/optex/styles.opm +++ b/Master/texmf-dist/tex/luatex/optex/styles.opm @@ -3,12 +3,14 @@ \_codedecl \report {Basic styles of OpTeX <2020-03-28>} % preloaded in format \_doc ----------------------------- - The `{\boxlines <line-1><eol><line-2><eol>...<line-n><eol>}` - returns to the outer vertical mode a box with <line-1>, next box with - <line-2> etc. Each box has its natural width. This is reaon why we cannot + We define auxiliary macro first (used by the \^`\address` macro) + \nl + The `{`\`\boxlines` `<line-1><eol><line-2><eol>...<line-n><eol>}` + returns to the outer vertical mode a box with `<line-1>`, next box with + `<line-2>` etc. Each box has its natural width. This is reason why we cannot use paragraph mode where each resulting box has the width `\hsize`. - The <eol> is set active and `\everypar` starts `\hbox{` and acive <eol> - closes this `\hbox` by `}`. + The `<eol>` is set active and `\everypar` starts `\hbox{` and acive <eol> + closes this `\hbox` by `}`. \_cod ----------------------------- \_def\_boxlines{% @@ -21,9 +23,12 @@ \_def\_boxlinesC{\_futurelet\_next\_boxlinesD} \_def\_boxlinesD{\_ifx\_next\_empty\_else\_ea\_egroup\_fi} +\_public \boxlines ; + \_doc ----------------------------- - The `\report` and `\letter` style initialization macos are defined here. - Their behavior is documented in user part of the manual in the section \ref[styles]. + The \`\report` and \`\letter` style initialization macros are defined here. + \nl + The `\letter` defines \`\address` and \`\subject` macros. \_cod ----------------------------- \_def\_report{ @@ -48,12 +53,17 @@ \_parskip=\_medskipamount \_nopagenumbers } +\_public \letter \report ; + + \_doc ----------------------------- + The \`\slides` macro reads macro file `slides.opm`, see the section~\ref[slides]. + \_cod ----------------------------- \_def\_slides{\_par \_input slides.opm } +\_public \slides ; -\_public \boxlines \letter \report \slides ; \_endcode % ------------------------------------- diff --git a/Master/texmf-dist/tex/luatex/optex/table.opm b/Master/texmf-dist/tex/luatex/optex/table.opm index c210c75b34c..cf907988bcf 100644 --- a/Master/texmf-dist/tex/luatex/optex/table.opm +++ b/Master/texmf-dist/tex/luatex/optex/table.opm @@ -1,16 +1,17 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \table {Basic macros for OpTeX <2020-03-13>} % preloaded in format +\_codedecl \table {Basic macros for OpTeX <2020-04-10>} % preloaded in format \_doc ----------------------------- - The result of `\table` is inserted into `\_tablebox`. You can change - default value if you want `\let\_tablebox=\vtop` or `\let\_tablebox=\relax`. + The result of the \`\table``{<declaration>}{<data>}` macro is inserted into + `\_tablebox`. You can change default value if you want by + `\let\_tablebox=\vtop` or `\let\_tablebox=\relax`. \_cod ----------------------------- \_let\_tablebox=\_vbox \_doc ----------------------------- - Categories )for example of `|` character) have to be normal when reading + Categories (for example of `|` character) have to be normal when reading `\table` parameters. \_cod ----------------------------- @@ -18,10 +19,10 @@ \_public \table ; \_doc ----------------------------- - The `\_tablinspace` is implemented by enlarging given `\tabstrut` + The \^`\tablinespace` is implemented by enlarging given \^`\tabstrut` by desired dimension (height and depth too) and by setting - `\_lineskip=-2\_tablinspace`. So, normal table rows where no `\hrule` is - between them have normal baseline distance. + `\_lineskip=-2\_tablinespace`. Normal table rows (where no `\hrule` is + between them) have normal baseline distance. \_cod ----------------------------- \_def\_tableA#1{% @@ -43,18 +44,21 @@ \_newcount\_colnum % number of columns \_doc ----------------------------- - The `\_scantabdata` converts `\table` <declaration> to `\halign` <declaration>. - The result is stored into `\_tbdata` tokens list. For example, the `\_scandata` creates - following result when <declaration>=`|cr||cl|`. + The \`\_scantabdata` converts `\table`'s `<declaration>` to + `\halign` `<declaration>`. + The result is stored into \`\_tabdata` tokens list. + For example, the + following result is generated when `<declaration>=|cr||cl|`. \begtt tabdata: \_vrule\_the\_tabiteml\_hfil#\_unsskip\_hfil\_the\_tabitemr\_tabstrutA - &\_the\_tabiteml\_hfil#\_unsskip\_the\_tabitemr \_vrule\_kern\_vvkern\_vrule\_tabstrutA + &\_the\_tabiteml\_hfil#\_unsskip\_the\_tabitemr + \_vrule\_kern\_vvkern\_vrule\_tabstrutA &\_the\_tabiteml\_hfil#\_unsskip\_hfil\_the\_tabitemr\_tabstrutA &\_the\_tabiteml#\_unsskip\_hfil\_the\_tabitemr\_vrule\_tabstrutA ddlinedata: &\_dditem &\_dditem\_vvitem &\_dditem &\_dditem \endtt - The second result in `\_ddlinedata` macro is a teplate of one row of the table - used by `\crli` macro. + The second result in the \`\_ddlinedata` macro is a teplate of one row of the table + used by \^`\crli` macro. \_cod ----------------------------- \_def\_scantabdata#1{\_let\_next=\_scantabdata @@ -79,7 +83,7 @@ \_def\_addtabitem{\_ifnum\_colnum>0 \_addtabdata{&}\_addto\_ddlinedata{&\_dditem}\_fi \_advance\_colnum by1 \_let\_tmpa=\_relax} -\_def\_addtabdata#1{\_toksapp\_tabdata{#1}} +\_def\_addtabdata#1{\_tabdata\_ea{\_the\_tabdata#1}} \_def\_addtabvrule{% \_ifx\_tmpa\_vrule \_addtabdata{\_kern\_vvkern}% \_ifnum\_colnum=0 \_addto\_vvleft{\_vvitem}\_else\_addto\_ddlinedata{\_vvitem}\_fi @@ -91,24 +95,27 @@ \_def\_ddlinedata{} \_doc ----------------------------- - The default \"declaration letters" `c`, `l`, `r` and `p` are defined here. - You can define more such leeters by `\def\_tabdeclare<letter>{...}` for a non-parametric + The default \"declaration letters" `c`, `l`, `r` and `p` are declared. + by `\def\_tabdeclare<letter>{...}` for a non-parametric letter and by `\def\_paramtabdeclare<letter>{...}` for a letter with a parameter. The double hash `##` must be in the definition, it is replaced by a real table item data. + All items are put in group because of `\aftergroup` can be used (from + `\localcolors` for example). + You can declare more such \"declaration letters" if you want. \_cod ----------------------------- -\_def\_tabdeclarec{\_the\_tabiteml\_hfil##\_unsskip\_hfil\_the\_tabitemr} -\_def\_tabdeclarel{\_the\_tabiteml##\_unsskip\_hfil\_the\_tabitemr} -\_def\_tabdeclarer{\_the\_tabiteml\_hfil##\_unsskip\_the\_tabitemr} -\_def\_paramtabdeclarep#1{\_the\_tabiteml +\_def\_tabdeclarec{{\_the\_tabiteml\_hfil##\_unsskip\_hfil\_the\_tabitemr}} +\_def\_tabdeclarel{{\_the\_tabiteml\_relax##\_unsskip\_hfil\_the\_tabitemr}} +\_def\_tabdeclarer{{\_the\_tabiteml\_hfil##\_unsskip\_the\_tabitemr}} +\_def\_paramtabdeclarep#1{{\_the\_tabiteml \_vtop{\_hsize=#1\_relax \_baselineskip=\_normalbaselineskip - \_lineskiplimit=0pt \_noindent##\_unsskip \_lower\_dp\_tstrutbox\hbox{}}\_the\_tabitemr} + \_lineskiplimit=0pt \_noindent##\_unsskip\_lower\_dp\_tstrutbox\hbox{}}\_the\_tabitemr}} \_doc ----------------------------- - User puts optional spaces around the table item typically, i.e. he/she writes + User puts optional spaces around the table item typically, i.\,e.\ he/she writes `& text &` instead `&text&`. The left space is ignored by internal \TeX/ algorithm but the right space must be removed by macros. This is a reason why we reccomend to - use `\_unsskip` after each `##` in your definition of \"declaration letters". + use \`\_unsskip` after each `##` in your definition of \"declaration letters". This macro isn't only the primitive `\unskip` because we allow usage of plain \TeX/ `\hideskip` macro: `&\hideskip text\hideskip&`. \_cod ----------------------------- @@ -116,9 +123,11 @@ \_def\_unsskip{\_ifdim\_lastskip>0pt \_unskip\_fi} \_doc ----------------------------- - The family of `\_cr*` macros and `\tskip <dimen>` is implemented here. - The `\_zerotabrule` is used in order to suppress the negative `\lineskip` - declared by `\tablinespace`. + The family of `\_cr*` macros + \`\crl`, \`\crll`, \`\crli`, \`\crlli`, \`\crlp` and + \`\tskip` `<dimen>` is implemented here. + The \`\_zerotabrule` is used in order to suppress the negative `\lineskip` + declared by \^`\tablinespace`. \_cod ----------------------------- \_def\_crl{\_crcr\_noalign{\_hrule}} @@ -152,15 +161,15 @@ \_public \crl \crll \crli \crlli \crlp \tskip ; \_doc ----------------------------- - The `\mspan[<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. + The \`\mspan``[<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 ----------------------------- \_def\_mspan{\_omit \_tabdata={\_tabstrutA}\_let\_tmpa=\_relax \_afterassignment\_mspanA \_mscount=} \_def\_mspanA[#1]#2{\_loop \_ifnum\_mscount>1 \_cs{_span}\_omit \_advance\_mscount-1 \_repeat \_colnum=0 \_def\_tmpa{}\_tabdata={}\_scantabdata#1\_relax - \_setbox0=\_vbox{\_halign\_expandafter{\_the\_tabdata\_cr#2\_crcr}\_global\_setbox8=\_lastbox}% + \_setbox0=\_vbox{\_halign\_expandafter{\_the\_tabdata\_cr#2\_cr}\_global\_setbox8=\_lastbox}% \_setbox0=\_hbox{\_unhbox8 \_unskip \_global\_setbox8=\_lastbox}% \_unhbox8 \_ignorespaces} \_public \mspan ; @@ -170,7 +179,8 @@ If we re-define `\hrule` to `\_orihrule height1pt` then each usage of redefined `\hrule` uses `1pt` height if this parameter isn't overwriten by another following `height` parameter. This principle is used for - settings another default rule thickness than 0.4pt. + settings another default rule thickness than 0.4\,pt by the macro + \`\rulewidth`. \_cod ----------------------------- \_newdimen\_drulewidth \_drulewidth=0.4pt @@ -183,7 +193,7 @@ \_public \rulewidth ; \_doc ----------------------------- - The `\frame` uses \"`\vbox` in `\vtop`" trick in order to keep the + The \`\frame``{<text>}` uses \"\code{\\vbox} in \code{\\vtop}" trick in order to keep the baseline of the internal text at the same level as outer baseline. User can write `\frame{abcxyz}` in normal paragraph line, for example and gets the expected result: \frame{abcxyz}. @@ -198,4 +208,4 @@ \_endcode % ------------------------------------- - +2020-04-10 second group for items in order to \localcolors diff --git a/Master/texmf-dist/tex/luatex/optex/uni-lcuc.opm b/Master/texmf-dist/tex/luatex/optex/uni-lcuc.opm index 92ed39d24c8..fd5291a0733 100644 --- a/Master/texmf-dist/tex/luatex/optex/uni-lcuc.opm +++ b/Master/texmf-dist/tex/luatex/optex/uni-lcuc.opm @@ -15926,3 +15926,19 @@ E01EF . \_tmp 1E9B 1E60 \_tmp 1FBE 0399 % end of file +\_endcode + +All codes in unicode table keep information about pairs lowecase-uppercase +letters or single letter. We need to read such information and set +appropriate `\lccode` and `\uccode`. The `\catcode` above the code 127 +is not set, i.\,e.\ the `\catocde`=12 for all codes above 127. + +The file `uni-lcuc.opm` does this work. It is not much intereting file, only +first few lines from 15928 lines in total is shown here. + +{\everytt={\typosize[8/10]\_let\_printverbline=\_printcodeline \medskip}\ttline=-1 +\def\docfile{uni-lcuc.opm} +\verbinput (3-30) uni-lcuc.opm +\vskip-\medskipamount +\noindent\typosize[8/]\dots etc. (see {\tt\Brown\docfile}) +} diff --git a/Master/texmf-dist/tex/luatex/optex/unimath-codes.opm b/Master/texmf-dist/tex/luatex/optex/unimath-codes.opm index 83d59835b5f..f1d0b01b0f7 100644 --- a/Master/texmf-dist/tex/luatex/optex/unimath-codes.opm +++ b/Master/texmf-dist/tex/luatex/optex/unimath-codes.opm @@ -2,6 +2,13 @@ \_codedecl \_ncharrmA {Uni math codes <2020-03-14>} % preloaded on demand by \loadmath + \_doc ----------------------------- + The control sequences for `\alpha`, `\beta` etc are redefined here. + The `\alpha` expands to the charcter with unicode `"03B1`, this is normal + character $α$. You can type in directly in your editor, if you know how + to do this. + \_cod ----------------------------- + \_umathnumB="0391 \_greekdef \Alpha \Beta \Gamma \Delta \Epsilon \Zeta \Eta \Theta \Iota \Kappa \Lambda \Mu \Nu \Xi \Omicron \Pi \Rho \varTheta \Sigma \Tau \Upsilon \Phi @@ -12,6 +19,10 @@ \lambda \mu \nu \xi \omicron \pi \rho \varsigma \sigma \tau \upsilon \varphi \chi \psi \omega \varbeta \vartheta \phi \varpi \_relax + \_doc ----------------------------- + The math alphabets are declared here using the \^`\_umathrange` macro. + \_cod ----------------------------- + \_chardef\_ncharrmA=`A \_chardef\_ncharrma=`a \_chardef\_ncharbfA="1D400 \_chardef\_ncharbfa="1D41A \_chardef\_ncharitA="1D434 \_chardef\_ncharita="1D44E @@ -78,6 +89,14 @@ \_protected\_def\_bsansdigits {\_umathrange{0-9}\_digitbsO} \_protected\_def\_ttdigits {\_umathrange{0-9}\_digitttO} + \_doc ----------------------------- + The `\rm`, `\it`, `\cal` etc. are redefined here.\nl + You can redefine them if you need different behavior (for example + you don't want to use sans serif bold in math). + When you do this then you must repeat `\_public \bf ;`\nl + \`\_inmath` `{<cmds>}` applies `<cmds>` only in math mode. + \_cod ----------------------------- + \_protected\_def\_inmath#1{\_relax \_ifmmode#1\_fi} % to keep off \loop processing in text mode % You can redefine these macros to follow your wishes. @@ -96,10 +115,15 @@ \_protected\_def\_mbisans {\_bisansvariables \_isansgreek \_bsansdigits} \_protected\_def\_script {\_rmvariables \_fam4 } -\_public - \rm \it \bf \bi \tt \bbchar \cal \frak \misans \mbisans \script ; +\_public \rm \it \bf \bi \tt \bbchar \cal \frak \misans \mbisans \script ; -% Math codes: + \_doc ----------------------------- + Each Unicode slot carries information about math type. This is saved in + the file `mathclass.txt` which is copied to `mathclass.opm` The file + has the following format: + {\vitt{mathclass.opm}\verbinput (70-85) mathclass.opm } + We have to read this information and convert it to the `\Umathcode`s. + \_cod ----------------------------- \_begingroup % \input mathclass.opm (which is a copy of MathClass.txt): \_def\_p#1;#2{\_edef\_tmp{\_pB#2}\_ifx\_tmp\_empty \_else\_pA#1....\_end#2\_fi} @@ -124,6 +148,13 @@ \_input mathclass.opm \_endgroup + \_doc ----------------------------- + Each math symbol has its declaration in the file `unicode-math-table.tex` + which is copied to `unimath-table.opm`. The file has following format: + {\vitt{unimath-table.opm}\verbinput (70-85) unimath-table.opm } + We have to read this information and convert it to the Unicode math codes. + \_cod ----------------------------- + \_begingroup % \input unimath-table.opm (it is a copy of unicode-math-table.tex): \_def\UnicodeMathSymbol #1#2#3#4{% \_global\_Umathcharnumdef#2=\_Umathcodenum#1\_relax @@ -134,6 +165,13 @@ \_input unimath-table.opm \_endgroup + \_doc ----------------------------- + Many special characters must be declared with care... + \_cod ----------------------------- + +\_global\_Udelcode`<=1 "027E8 % these characters have different meaning +\_global\_Udelcode`>=1 "027E9 % as normal and as delimeter + \_nitgreek \_nitvariables \_rmdigits % default setting \_Umathcode `- = 2 1 "2212 @@ -179,10 +217,14 @@ \_protected\def \overrightarrow {\Umathaccent 7 1 "020D7 } \_protected\def \overleftrightarrow {\Umathaccent 7 1 "020E1 } -% corrections: - \_mathchardef\ldotp="612E \_let\|=\Vert +\_mathcode`\_="8000 + + \_doc ----------------------------- + Aliases are declared here. They are names not menitioned in the `unimath-table.opm` file + but commonly used in \TeX. + \_cod ----------------------------- \_let \setminus=\smallsetminus \_let \diamond=\smwhtdiamond @@ -242,6 +284,10 @@ \_let \upphi=\mupphi \_let \upvarpi=\mupvarpi + \_doc ----------------------------- + The \^`\not` macro is redefined here. + \_cod ----------------------------- + \_protected\_def\_not#1{% \_ifcsname _not!\_csstring#1\_endcsname \_csname _not!\_csstring#1\_endcsname \_else \_mathrel{\_mathord{\_rlap{\_kern1pt/}}\_mathord{#1}}% @@ -262,36 +308,34 @@ \_public \not ; -% we need no more 8bit math fonts - -\mathcode`\_="8000 + \_doc ----------------------------- + Newly declared public control sequences are used in internal macros by + \OpTeX/. We need to get new meanings of these control sequences in + private name space. + \_cod ----------------------------- -\_private +\_private \ldotp \cdotp \bullet \triangleleft \trianglerigt \mapstochar \rightarrow \prime \lhook \rightarrow \leftarrow \rhook \triangleright \triangleleft \Relbar \Rightarrow \relbar \rightarrow \Leftarrow \mapstochar \longrightarrow \Longleftrightarrow \vdots \ddots ; - \_endcode --------------------------------------------- +\secc A few observations -You can combine more fonts, if you register them to another -math families (5, 6, 7, etc.) in \normalmath macro. +You can combine more fonts in math, if you register them to another +math families (5, 6, 7, etc.) in the \^`\normalmath` macro. -The default value of \normalmath shows a combination of base Unicode Math -font with 8bit Math font at family 4. See definition of \script macro where -\fam4 is used. Of course, we need to set \rmvariables too, because 8bit font +The default value of \^`\normalmath` shows a combination of base Unicode Math +font with 8bit Math font at family 4. See definition of the `\script` macro where +`\fam4` is used. Of course, we need to set `\rmvariables` too, because 8bit font accepts only codes less than 255. -See http://tex.stackexchange.com/questions/308749/ for more technical details. - ------ - XITSmath-bold needs correction: the norm symbol ||x|| is missing here. So, you can define: +\begtt \def\_boldmath{% \loadumathfamily 1 {[xitsmath-bold]}{} % Base font \loadmathfamily 4 rsfs % script @@ -299,3 +343,10 @@ can define: \def\|{\Udelimiter 0 5 "02016 }% % norm delimiter from family 5 \setmathdimens } +\endtt + +\_endinput + +History: +2020-04-09 Bug fix: \Udelcode`<, \Udelcode`> added +
\ No newline at end of file diff --git a/Master/texmf-dist/tex/luatex/optex/usebib.opm b/Master/texmf-dist/tex/luatex/optex/usebib.opm index de6a0bf40d2..149c5f5d87a 100644 --- a/Master/texmf-dist/tex/luatex/optex/usebib.opm +++ b/Master/texmf-dist/tex/luatex/optex/usebib.opm @@ -2,10 +2,13 @@ \_codedecl \MakeReference {Reading bib databases <2020-03-13>} % loaded on demand by \usebib -% we needn't \errmessage when bad TeX engnine is detected during \input librarian: + \_doc ----------------------------- + Loading the `librarian.tex` macro package. See `texdoc librarian` + for more information about it. + \_cod ----------------------------- \_def\_tmp{} -\_let\_errmessageori=\_errmessage +\_let\_errmessageori=\_errmessage % we needn't \errmessage during \input librarian \_def\_errmessage#1{\_def\_tmp{error}} \_let\_newwriteori=\_newwrite % we need not to create \jobname.lbr: \_def\_newwrite#1{\_csname lb@restoreat\_endcsname \_endinput} @@ -22,7 +25,9 @@ \_private \BibFile \ReadList \SortList \SortingOrder \NameCount \AbbreviateFirstname \CreateField \RetrieveFieldInFor \RetrieveFieldIn ; -% The \usebib command: + \_doc ----------------------------- + The `\usebib` command. + \_cod ----------------------------- \_def\_usebib/#1 (#2) #3 {% \_ifx\_citelist\_empty @@ -55,7 +60,9 @@ \_def\_readbibentryA#1{\_readbibentryB#1,,\_relax!.} \_def\_readbibentryB#1#2,#3\_relax!.{\_addto\_citelist{\_citeI[#1#2]}} -% Corrections in librarian macros: + \_doc ----------------------------- + Corrections in librarian macros. + \_cod ----------------------------- \_tmpnum=\_catcode`\@ \_catcode`\@=11 \_def\lb@checkmissingentries#1,{% we needn't \errmessage here, only \opmacwarning @@ -104,7 +111,9 @@ \_def\WriteImmediateInfo#1{} % the existence of .lbr file bocks new reading of .bib \_catcode`\@=\_tmpnum -% Main action per every entry: + \_doc ----------------------------- + Main action per every entry. + \_cod ----------------------------- \_def\MakeReference{\_par \_bibskip \_advance\_bibnum by1 @@ -126,11 +135,15 @@ \_csname _print:misc\_endcsname \_fi\_fi \_csname _print:END\_endcsname - \_ifx\_wref\_wrefrelax\_else \_immediate\_wref\_Xbib{{\EntryKey}{\_the\_bibnum}{\_the\_bibmark}}\_fi + \_ifx\_wref\_wrefrelax\_else + \_immediate\_wref\_Xbib{{\EntryKey}{\_the\_bibnum}{\_the\_bibmark}}\_fi }\_par } -% The \bprinta, \bprintb, \bprintc, \bprintv commands used in the style files: + \_doc ----------------------------- + The \`\bprinta`, \`\bprintb`, \`\bprintc`, \`\bprintv` + commands used in the style files: + \_cod ----------------------------- \_def\_bprinta {\_bprintb*} \_def\_bprintb #1[#2#3]{% @@ -175,7 +188,9 @@ \_let\_Von=\Von \_let\_Junior=\Junior } -% Various macros + multilinguas: + \_doc ----------------------------- + Various macros + multilinguas. + \_cod ----------------------------- \_def\_bibwarning{\_opwarning{Missing field "\_bibfieldname" in [\EntryKey]}} @@ -189,77 +204,71 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -The following command is implemented here: - - \usebib/<sorttype> (<style>) <bibfiles> - -where <sorttype> is one letter 'c' (references ordered by citation order in -the text) or 's' (references ordered by key in the style file), -<style> is the part of the name `bib-<style>.opm` of the style file -and <bibfiles> are one or more `.bib` file names without suffix separated by +The file `usebib.opm` implements the command +`\usebib/<sorttype> (<style>) <bibfiles>` +where `<sorttype>` is one letter `c` (references ordered by citation order in +the text) or `s` (references ordered by key in the style file), +`<style>` is the part of the name `bib-<style>.opm` of the style file +and `<bibfiles>` are one or more `.bib` file names without suffix separated by comma without space. Example: - \usebib/s (simple) mybase,yourbase +\begtt +\usebib/s (simple) mybase,yourbase +\endtt -This command reads the <bibfiles> directly and creates the list of -bibliographics references (only those declared by by \cite[] or \nocite[] -in the text). The formatting of such references is defined in the style +This command reads the `<bibfiles>` directly and creates the list of +bibliographics references (only those declared by by `\cite[]` or +`\nocite[]` in the text). The formatting of such references is defined in the style file. The usage is mentioned in user documentation too. -The principle "first entry wins" is used. Suppose - - \usebib/s (simple) local,global - +The principle \"first entry wins" is used. Suppose `\usebib/s (simple) local,global`. If an entry with the same label is declared in `local.bib` and in `global.bib` too then the first wins. So, you can set an exceptions in your -local.bib file for your document, for example. - +`local.bib` file for your document. -Notes for style writers: ------------------------- +\seccc Notes for style writers The `bib-<style>.opm` file must define the commands: -`\_authorname` ... formatting of one name in the authors list. The macro can +\begitems +* `\_authorname` ... formatting of one name in the authors list. The macro can use the following data: `\_NameCount` (the number of the currently processed author name in the list), `0\_namecount` (the total number of the authors in the list), `\_Lastname`, `\_Firstname`, `\_Von`, `\_Junior` (the parts of the name). See the documentation of the librarian package for more info. - -`\_editorname` ... the same as `\_authorname`, but for editors list. - -`_print:<entrytype>` (defined by `\_sdef`) for formatting the entry of <entrytype>. - The <entrytype> have to be lowercase. This command can use the command: - -`\_bprinta [<fieldname>] {<if defined>} {<if not defined>}`. The part <if defined> +* `\_editorname` ... the same as `\_authorname`, but for editors list. +* `_print:<entrytype>` (defined by `\_sdef`) for formatting the entry of `<entrytype>`. + The `<entrytype>` have to be lowercase. This command can use the command: +* `\_bprinta [<fieldname>] {<if defined>} {<if not defined>}`. The part <if defined> is executed if <fieldname> is declared in .bib file for the entry which is currently processed. Else the part <if not defined> is processed. The part <if defined> can include the `*` parameter which is replaced by the value of the <fieldname>. The part <if not defined> can include the `\_bibwarning` command if the <fieldname> is mandatory. -`\_bprintb [<fieldname>] {<if defined>} {<if not defined>}`. The same as - \_bprinta, but the `##1` parameter is used instead `*`. Differences: `##1` +* `\_bprintb [<fieldname>] {<if defined>} {<if not defined>}`. The same as + `\_bprinta`, but the `##1` parameter is used instead `*`. Differences: `##1` parameter can be used more than once and can be enclosed in nested braces. The * parameter can be used at most once and cannot be enclosed in braces. Warning: if the `\_bprintb` commands are nested (`\_bprintb` in `\_bprintb`), then you need to write `####1` parameter for internal `\_bprintb`. - But if `\_bprinta` commands are nested then the * parameter is not dubbled. -`\_pbprintc \macro {<if non-empty>}`. The <if non-empty> part is executed if + But if `\_bprinta` commands are nested then the parameter is not duplicated. +* `\_pbprintc \macro {<if non-empty>}`. The <if non-empty> part is executed if `\macro` is non-empty. The * parameter can be used, it is replaced by the `\macro`. -`\_bprintv [<field1>,<field2>,...] {<if defined>} {<if not defined>}`. +* `\_bprintv [<field1>,<field2>,...] {<if defined>} {<if not defined>}`. The part <if defined> is executed if <field1> or <filed2> or ... is defined, else the second part <if not defined> is executed. There is one filed name or the list field names separated by commas. The parts cannot include any parameter. - +\enditems +% There are two special fieldnames: `!author` and `!editor`. The processed list of authors or editors (by repeatedly calling `\_authorname` or `\_editorname`) are used here insted of raw data. You can define `_print:BEGIN` and/or `_print:END` which is executed at the begin or -end of each <entrytype>. The formatting does not solve the numbering and +end of each `<entrytype>`. The formatting does not solve the numbering and paragraph indentation of the entry. This is processed by `\_printbib` macro used in \OpTeX/ (and may be redefined by the author or document designer). @@ -274,14 +283,14 @@ here. If you are using non-standard fieldnames in .bib database and bib. style, you has to declare them by `\_CreateField {<fieldname>}`. -You can declare \_SortingOrder in the manner documented by librarian package. +You can declare `\_SortingOrder` in the manner documented by librarian package. If your style adds some words or abbreviations you can make them multilingual by saying `\_mtext{<label>}` instead such word and `\_mtdef{<label>} {<English>} {<Czech>} {<Slovak>}` declaration. The right part is printed by current value of the `\language` regiter. You can add more languages by re-defining the `\_mtdef` command. -See the section \ref[languages] for more information. +See the section \ref[langphrases] for more information. If you are using `\nonumcitations`, then the `\_bibmark` tokens register have to be prepared in the style file (in `_print:BEGIN`, `_print:END`, in @@ -290,29 +299,26 @@ in the document. The example of the style file is in `bib-simple.opm`. -User or author of the bib. style can create the hidden field which has a +User or author of the `bib.` style can create the hidden field which has a precedence while sorting names. Example: \begtt - \CreateField {sortedby} - \SpecialSort {sortedby} +\CreateField {sortedby} +\SpecialSort {sortedby} \endtt - Suppose that the .bib file includes: - \begtt - ... - author = "Jan Chadima", - sortedby = "Hzzadima Jan", - ... +... +author = "Jan Chadima", +sortedby = "Hzzadima Jan", +... \endtt - Now, this author is sorted between H and I, because the Ch digraph in this name has to be sorted by this rule. If you need (for example) to place the autocitations before other citations, then you can mark your entries in `.bib` file by `sortedby = "@"`, because this -character is sorted before A. +character is sorted before `A`. \_endinput diff --git a/Master/texmf-dist/tex/luatex/optex/verbatim.opm b/Master/texmf-dist/tex/luatex/optex/verbatim.opm index cfd9ed43548..92a7abac553 100644 --- a/Master/texmf-dist/tex/luatex/optex/verbatim.opm +++ b/Master/texmf-dist/tex/luatex/optex/verbatim.opm @@ -1,33 +1,35 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \begtt {Verbatim <2020-03-21>} % preloaded in format +\_codedecl \begtt {Verbatim <2020-04-22>} % preloaded in format \_doc ---------------------------- - The internal parameters for verbatim macros are set. + The internal parameters + \`\_ttskip`, \`\_ttpenalty`, \`\_viline`, \`\_vifile` and \`\_ttfont` + for verbatim macros are set. \_cod ---------------------------- \_def\_ttskip{\_medskip} % space above and below \begtt, \verbinput \_mathchardef\_ttpenalty=100 % penalty between lines in \begtt, \verbinput \_newcount\_viline % last line number in \verbinput -\_newread\_vifile % file fgiven by \verinput +\_newread\_vifile % file given by \verinput \_def\_ttfont{\_tt} % default tt font \_doc ---------------------------- - `\code{<text>}` expands to `\detokenize{<text>}` when `\escapechar=-1`. In + \`\code``{<text>}` expands to `\detokenize{<text>}` when `\escapechar=-1`. In order to do it more robust when it is used in `\write` then it expands as noexpanded `\code<space>` (followed by space in its csname). This macro does the real work. - The `\_printinverbatim{<text>}` macro is used for `\code{<text>}` printing and for - \code{`}<text>\code{`} printing. It is defined as `\_hbox`, so the in-verbatim <text> + The \`\_printinverbatim``{<text>}` macro is used for `\code{<text>}` printing and for + \code{`}<text>\code{`} printing. It is defined as `\hbox`, so the in-verbatim <text> will be never broken. But you can re-define this macro. When `\code` occurs in PDF outlines then it does the same as `\detokenize`. The macro for preparing outlines sets `\escapechar` to $-1$ and uses - `\_regoul` token list before `\edef`. + \^`\_regoul` token list before `\edef`. - The `\code` is not `\_proteced` because we want that it expands to - `\_unexpanded{\code<space>{<text>}}` in `\write` parameters. This protect the + The `\code` is not `\proteced` because we want it expands to + `\unexpanded{\code<space>{<text>}}` in `\write` parameters. This protect the expansions of the `\code` parameter (like `\\`, `\^` etc.). \_cod ---------------------------- @@ -37,13 +39,12 @@ \_def\_printinverbatim#1{\_leavevmode\_hbox{#1}} \_regmacro {}{}{\_let\code=\_detokenize \_let\_code=\_detokenize} - \_public \code ; \_doc ---------------------------- - The `\_setverb` macro sets all catcodes to \"verbatim mode". It should be used only + The \`\_setverb` macro sets all catcodes to \"verbatim mode". It should be used only in a group, so we prepare a new catcode table with \"verbatim" catcodes and we define - it as `\_catcodetable\_verbatimcatcodes`. After the group is finished then + it as\nl `\_catcodetable`\`\_verbatimcatcodes`. After the group is finished then original catcode table is restored. \_cod ---------------------------- @@ -58,19 +59,19 @@ \_def\_setverb{\_catcodetable\_verbatimcatcodes }% \_doc ---------------------------- - `\activettchar<char>` saves original catcode of previously declared <char> (if - such character was declared) from `\_savedttchar` and `\_savedttcharc` + \`\activettchar``<char>` saves original catcode of previously declared `<char>` (if + such character was declared) using \`\_savedttchar` and \`\_savedttcharc` values. Then new such values are stored. The declared charater is activated by `\_adef` as a macro (active character) which opens a group, does `\_setverb` and other settings and reads its parameter until second the same - character. This is done by `\_readverb` macro. Finally it prints scanned - <text> by `\_printinverbatim` and closes group. Suppose that `\activettchar"` is + character. This is done by the \`\_readverb` macro. Finally it prints scanned + `<text>` by \^`\_printinverbatim` and closes group. Suppose that `\activettchar"` is used. Then the following work is schematically done: \begtt \_def "{\_begingroup \_setverb ... \_readverb} \_def \_readverb #1"{\_printinverbatim{#1}\_endgroup} \endtt - Note that the second occurence of `"` is not active because `\_setverb` + Note that the second occurrence of `"` is not active because `\_setverb` deactivates it. \_cod ---------------------------- @@ -84,49 +85,48 @@ \_public \activettchar ; \_doc ---------------------------- - `\begtt` id defined only as public. We don't need private `\_begtt` variant. - This macro os defined by `\eoldef`, so user can put an parameter at the + \`\begtt` is defined only as public. We don't need private `\_begtt` variant. + This macro is defined by `\eoldef`, so user can put a parameter at the same line where `\begtt` is. This `#1` parameter is used after `\_everytt` - parameters settings, so user can change it locally. + parameters settings, so user can change them locally. - The `\begtt` macro opens group, does `\_setverb` and another preprocessing, sets + The `\begtt` macro opens group, does \^`\_setverb` and another preprocessing, sets `\endlinechar` to `^^J` and reads the following text in verbatim mode - until `\endtt` occurs. This scanning is done by `\_startverb` macro which is + until \`\endtt` occurs. This scanning is done by \`\_startverb` macro which is defined as: - \begtt - \_def\_startverb #1\endtt #2^^J{...} + \begtt \adef/{\bslash} + \_def\_startverb #1/endtt #2^^J{...} \endtt We must to ensure that the backslash in `\endtt` has category 12 (this is a reason of the `\ea` chain in real code). - The `#2` is something between `\endtt` and end of line and it is simply + The `#2` is something between `\endtt` and end of the same line and it is simply ignored. - The `\startverb` puts the scanned data to `\_prepareverbdata`. It sets the data + The `\_startverb` puts the scanned data to \`\_prepareverbdata`. It sets the data to `\_tmpb` without changes by default, but you should re-define it in order - to does s special changes (for example colorization of the code), if you - want. The scanned data have `^^J` at each end of line and all spaces are - active characters. Other characters have nomal category 11 or 12. - - When `\prepareverbdata` finishes then `\startverb` runs `\_printverb` loop - over aech line of the data and does a final work: last skip plus `\noindent` - without first indentation box. This trick keeps horizontal mode without - indentation when the empty line after `\endtt` does not exists. But it stops - horizontal mode without any new box in outer vertical mode if `\par` is - processed immediately after `\endtt`. - - The `\_printverb` macro calls `\_printverbline{<line>}` to each scanned line of - verbatim text. This macro expect that it strarts in vertical mode ant it must - do `\par` in order to return the vertical mode. The `\_printverblinenum` - is used here: it does nothing when `\_ttline<0` else it prints the line + to do special changes, if you want. (For example, \^`\hisyntax` redefines + this macro.) The scanned data have `^^J` at each end of line and all spaces are + active characters (defined as {\visiblesp`\ `}). + Other characters have normal category 11 or 12. + + When `\_prepareverbdata` finishes then `\_startverb` runs \`\_printverb` loop + over each line of the data and does a final work: last skip plus `\noindent` + in the next paragraph. + + The `\_printverb` macro calls \`\_printverbline``{<line>}` to each scanned line of + verbatim text. This macro expect that it strarts in vertical mode and it must + do `\par` in order to return the vertical mode. The \`\_printverblinenum` + is used here: it does nothing when `\_ttline`\code{<0} else it prints the line number using `\_llap`. \_cod ---------------------------- \_eoldef \begtt#1{\_par \_wipeepar - \_begingroup \_vskip\_parskip \_ttskip + \_begingroup \_setverb \_ifnum\_ttline<0 \_let\_printverblinenum=\_relax \_else \_initverblinenum \_fi - \_adef{ }{\ }\_parindent=\_ttindent \_parskip=0pt + \_adef{ }{\ }\_adef\^^I{\t}\_parindent=\_ttindent \_parskip=0pt + \_def\t{\_hskip \_dimexpr\_tabspaces em/2\_relax}% \_the\_everytt \_relax #1\_relax \_ttfont \_endlinechar=`^^J \_startverb @@ -134,46 +134,49 @@ \_ea\_def\_ea\_startverb \_ea#\ea1\_csstring\\endtt#2^^J{% \_prepareverbdata\_tmpb{#1^^J}% \_ea\_printverb \_tmpb\_end - \_par\_ttskip - \_endgroup + \_par + \_endgroup \_ttskip \_isnextchar\_par{}{\_noindent}% } \_def\_printverb #1^^J#2{\_ifx\_end#2 - \_bgroup \_adef{ }{}\_if\_relax#1\_relax\_egroup \_else\_egroup \_printverbline{#1}\_fi + \_bgroup \_adef{ }{}\_def\t{}% + \_ifcat&\_egroup \_else\_egroup \_printverbline{#1}\_fi \_else \_printverbline{#1}% \_ea \_printverb \_ea #2% \_fi } \_def\_prepareverbdata#1#2{\_def#1{#2}} -\_def\_printverbline#1{\_penalty \_ttpenalty \_indent \_printverblinenum #1\par} +\_def\_printverbline#1{\_penalty \_ttpenalty + \_indent \_printverblinenum \_kern\_ttshift #1\par} \_def\_initverblinenum{\_tenrm \_thefontscale[700]\_ea\_let\_ea\_sevenrm\_the\_font} \_def\_printverblinenum{\_global\_advance\_ttline by1 \_llap{\_sevenrm \_the\_ttline\_kern.9em}} \_doc ---------------------------- - Macro `\verbinput` uses a file read perviously or opens the given file. Then - it runss the parameter scanning by `\_viscanparameter` and `\_viscanminus`. - Finally the `\_doverbinput` is run. At begining of `\_doverbinput` we have + Macro \`\verbinput` uses a file read previously or opens the given file. Then + it runs the parameter scanning by \`\_viscanparameter` and \`\_viscanminus`. + Finally the \`\_doverbinput` is run. At begining of `\_doverbinput`, we have `\_viline`= number of lines already read using previous `\verbinput`, `\_vinolines`= the number of lines we need to skip and `\_vidolnes`= the number of lines we need to print. - After group is opened then similar preparation is done as in `\begtt`. Then - we skip `\_nolines` lines in a loop a and we read `\_dolines` lines. The + Similar preparation is done as in `\begtt` after the group is opened. Then + we skip \`\_vinolines` lines in a loop a and we read \`\_vidolines` lines. The read data is accumulated into `\_tmpb` macro. The next steps are equal to - the steps done in `\_startverb` macro: data are processed via - `\_prepareverbdata` and printed via `\_printverb` loop. + the steps done in \^`\_startverb` macro: data are processed via + \^`\_prepareverbdata` and printed via \^`\_printverb` loop. \_cod \_fin ---------------------- -\_def\_verbinput (#1) #2 {\_par \_def\_tmpa{#2}% +\_def\_verbinput #1(#2) #3 {\_par \_def\_tmpa{#3}% + \_def\_tmpb{#1}% cmds used in local group \_ifx\_vifilename\_tmpa \_else - \_openin\_vifile=#2 + \_openin\_vifile={#3}% \_global\_viline=0 \_global\_let\_vifilename=\_tmpa \_ifeof\_vifile - \_opwarning{\_noexpand\verbinput - file "#2" is unable to reading} + \_opwarning{\_noexpand\verbinput - file "#3" is unable to reading} \_ea\_ea\_ea\_skiptorelax \_fi \_fi - \_viscanparameter #1+\_relax + \_viscanparameter #2+\_relax } \_def\_skiptorelax#1\_relax{} @@ -213,8 +216,9 @@ \_vskip\_parskip \_ttskip \_wipeepar \_begingroup \_ifnum\_ttline<-1 \_let\_printverblinenum=\_relax \_else \_initverblinenum \_fi - \_setverb \_adef{ }{\ }\_parindent=\_ttindent \_parskip=0pt - \_the\_everytt\_relax \_ttfont + \_setverb \_adef{ }{\ }\_adef\^^I{\t}\_parindent=\_ttindent \_parskip=0pt + \_def\t{\_hskip \_dimexpr\_tabspaces em/2\_relax}% + \_the\_everytt\_relax \_tmpb\_relax \_ttfont \_endlinechar=`^^J \_tmpnum=0 \_loop \_ifeof\_vifile \_tmpnum=\_vinolines\_space \_fi \_ifnum\_tmpnum<\_vinolines\_space @@ -232,15 +236,32 @@ \_ea\_prepareverbdata \_ea \_tmpb\_ea{\_tmpb^^J}% \_ea\_printverb \_tmpb\_end \_global\_ttlinesave - \_par\_ttskip + \_par \_endgroup - \_noindent \_setbox0=\_lastbox + \_ttskip + \_isnextchar\_par{}{\_noindent}% } \_def\_vireadline{\_read\_vifile to \_tmp \_global\_advance\_viline by1 } \_def\_visaveline{\_ea\_addto\_ea\_tmpb\_ea{\_tmp}} -\_public - \verbinput ; +\_public \verbinput ; + + \_doc ----------------------------- + The \`\visiblesp` sets spaces as visible characters \char9251. + It redefines {\visiblesp`\ `} primitive, so it is useful for verbatim modes only. + \_cod ----------------------------- + +\_def \_visiblesp{\_ifx\_initunifonts\_relax \_def\ {\_char9251 }% + \_else \_def\ {\_char32 }\_fi} + +\_public \visiblesp ; \_endcode +\_endinput + +History: +2020-04-22 ... \ttshift introduced +2020-04-06 ... \visiblesp added +2020-04-04 ... ^^I activated as \t for multiline verbatim + \verbinput <cmds> (...) <filename>, <cmds> added. |