Debian Codegraph @

texmf-dist/tex/optex/base/others.opm

raw
1 %% This is part of the OpTeX project, see http://petr.olsak.net/optex
2
3 \_codedecl \uv {Miscenaleous <2026-05-17>} % preloaded in format
4
5 \_doc ----------------------------
6 \`\useOpTeX` and \`\useoptex` are declared as `\relax`.
7 \_cod ----------------------------
8
9 \_let \useOpTeX = \_relax \_let \useoptex = \_relax
10
11 \_doc ----------------------------
12 The \`\lastpage` and \`\totalpages` get the information from the
13 \^`\_currpage`. The \^`\_Xpage` from `.ref` file sets the \^`\_currpage`.
14 \_cod ----------------------------
15
16 \_def\_totalpages {\_openref\_ea\_ignoresecond\_currpage}
17 \_def\_lastpage {\_openref\_ea\_usesecond\_currpage}
18 \_def\_currpage {{0}{?}}
19 \_public \lastpage \totalpages ;
20
21 \_doc ----------------------------
22 We need \`\uv`, \`\clqq`, \`\crqq`, \`\clq`, \`\crq`,
23 \`\flqq`, \`\frqq`, \`\flq`, \`\frq`, \`\uslang`, \`\ehyph`
24 \`\chyph`, \`\shyph`, for backward compatibility with \csplain.
25 Codes are set according to Unicode because we are using Czech only in Unicode
26 when \LuaTeX/ is used.
27 \_cod ----------------------------
28
29
30 % \uv, \promile, \clqq, \crqq for compatibility with csplain:
31
32 \_chardef\clqq=8222 \_chardef\crqq=8220 \_chardef\clq=8218 \_chardef\crq=8216
33 \_def\flqq{«\_kern.3em } \_def\frqq{\_kern.3em»} % including traditional nobreak space, see
34 \_def\flq{“\_kern.15em } \_def\frq{\_kern.15em”} % Lexique des Règles typographiques, page 149
35 \_chardef\promile=8240
36 \_private \flqq \frqq \flq \frq ; % used in \frquotes
37
38 \_def\uv#1{„#1“}
39
40 \_let\uslang=\enlang \_let\ehyph=\enlang
41 \_let\chyph=\cslang \_let\shyph=\sklang
42 \_let\csUnicode=\csPatt \_let\czUnicode=\csPatt \_let\skUnicode=\skPatt
43
44 \_doc ----------------------------
45 The \`\letfont` was used in \csplain/ instead of `\fontlet`.
46 \_cod ----------------------------
47
48 \_let \letfont = \_fontlet
49
50 \_doc ----------------------------
51 Non-breaking space in Unicode.
52 \_cod ----------------------------
53
54 \let ^^a0=~
55
56 \_doc ----------------------------
57 Old macro packages need these funny control sequences.
58 We don't use them in new macros.
59 \_cod ----------------------------
60
61 \_catcode`\@=11
62 \_let\z@=\_zo \_let\z@skip=\_zoskip
63 \_newdimen\p@ \p@=1pt
64 \_toksdef\toks@=0
65 \_let\voidb@x=\_voidbox
66 \_chardef\@ne=1 \_chardef\tw@=2 \_chardef\thr@@=3 \_chardef\sixt@@n=16
67 \_mathchardef\@m=1000 \_mathchardef\@M=10000 \_mathchardef\@MM=20000
68 \_countdef\m@ne=22 \m@ne=-1
69 \_chardef\@cclv=255 \_mathchardef\@cclvi=256
70 \_skipdef\skip@=0
71 \_dimendef\dimen@=0 \_dimendef\dimen@i=1
72 \_dimendef\dimen@ii=2
73 \_countdef\count@=255
74 \_def\m@th{\_mathsurround\z@}
75 \_def\o@lign{\_lineskiplimit\z@ \_oalign}
76 \_def\n@space{\_nulldelimiterspace\z@ \m@th}
77 \_newdimen\p@renwd \p@renwd=8.75pt
78 \_def\alloc@#1#2#3#4#5{\_allocator#5{\_csstring#2}#3}
79 \_catcode`\@=12
80
81 \_doc ----------------------------
82 We don't want to read `opmac.tex` unless `\input opmac` is specified.
83 \_cod ----------------------------
84
85 \_def\OPmacversion{OpTeX}
86
87 \_doc ----------------------------
88 We allow empty lines in math formulae. It is more comfortable.
89 \_cod ----------------------------
90
91 \_suppressmathparerror = 1
92
93 \_doc ----------------------------
94 Lorem ipsum can be printed by \`\lipsum``[<range>]` or \`\lorem``[<range>]`,
95 for example `\lipsum[3]` or `\lipsum[112-121]`, max=150.
96
97 First usage of `\lipsum` reads the \LaTeX/ file `lipsum.ltd.tex`
98 by \`\_lipsumload`
99 and prints the selected paragraph(s). Next usages of `\lipsum`
100 prints the selected paragraph(s) from memory.
101 `\lipsum` is fully expandable.
102
103 `\lipsum` adds `\_par` after each printed paragraph. If you don't need
104 such `\_par` here, use \`\lipsumtext``[<number>]` or `\lipsum[<number>.]`
105 (i.e.\ dot after the parameter). The first case prints the paragraph
106 <number> without the final `\_par` and the second case prints only
107 first sentence from the paragraph <number> using \`\_lipsumdot`.
108 \_cod ----------------------------
109
110 \_newbox\_nonebox
111 \_def\_lipsumtext[#1]{\_lipsumload\_cs{_lip:#1}}
112 \_def\_lipsum[#1]{\_lipsumA #1.]{#1}}
113 \_def\_lipsumA #1.#2]#3{\_ifx^#2^\_lipsumB #1\_empty-\_empty\_fin \_else \_lipsumdot[#1].\_fi}
114 \_def\_lipsumB #1-#2\_empty#3\_fin{%
115 \_fornum #1..\_ifx^#2^#1\_else#2\_fi \_do {\_lipsumtext[##1]\_par}}
116 \_def\_lipsumfile{lipsum.ltd.tex}
117 \_def\_lipsumload{\_beglocalcontrol
118 {\_setbox\_nonebox=\_vpack{\_tmpnum=0 % vertical mode during \input lipsum.ltd.tex
119 \_def\ProvidesFile##1[##2]{}%
120 \_def\SetLipsumLanguage##1{}%
121 \_def\NewLipsumPar{\_incr\_tmpnum \_sxdef{_lip:\_the\_tmpnum}}%
122 \_opinput\_lipsumfile
123 \_glet\_lipsumload=\_empty
124 }}%
125 \_endlocalcontrol}
126 \_def\_lipsumdot[#1]{\_lipsumload \_ea\_ea\_ea \_lipsumdotA \_csname _lip:#1\_endcsname.\_fin}
127 \_def\_lipsumdotA #1.#2\_fin {#1}
128
129 \_public \lipsum \lipsumtext ;
130 \_let \lorem=\lipsum
131
132 \_doc -----------------------------
133 Selected macros from \ulink[https://petr.olsak.net/optex/optex-tricks.html]{\OpTeX/ tricks}
134 are registered using \`\_regtrick``<cs-name>`. The <cs-name> is defined
135 as \^`\loadtrick` `<cs-name> <cs-name>`. When a user runs such a registered
136 <cs-name> then \`\loadtrick` `<cs-name>` reads the appropriate code from the
137 file `optex-tricks.opm` and the <cs-name> is redefined. Finally, <cs-name> is run again.\nl
138 The `optex-tricks.opm` file includes blocks started by \^`\_trick` followed
139 by the declared <cs-names> followed by semicolon followed by the code
140 with declarations of <cs-names> itself. The next \`\_trick` does
141 `\endpinput` of the file. The file is read inside temporary `\vbox` with `\globaldefs=1`
142 because it can be read inside horizontal mode and/or inside a group.
143 The `optextrick` name space is used during reading the code from
144 the file. Only registered control sequences are re-defined directly
145 in user name space.\nl
146 You can load a code chunk by \^`\loadtrick` `<cs-name>`. This
147 command doesn't run the `<cs-name>`, only loads the appropriate code. It
148 should be usable if you want to load the code before the first usage of
149 the `<cs-name>`.
150 \_cod -----------------------------
151
152 \_def\_regtrick#1{\_ifx#1\_undefined\_def#1{\_loadtrickD#1}\_else\_badtrick\_fi}
153 \_def\_loadtrickD#1{\_loadtrick#1#1}
154 \_def\_loadtrick#1{\_beglocalcontrol
155 \_resetnamespace{optextrick}\_setctable\_optexcatcodes
156 \_savecatcodetable\_tmpcatcodes \_catcodetable\_tmpcatcodes
157 \_long\_def\_loadtrickA ##1\_trick##2#1##3;{##1}%
158 \_wlog{Loading trick macros for \_string#1}%
159 \_setbox\_nonebox=\_vpack{\_let\:=\_trickprefix \_def\_trickseq{#1}%
160 \_globaldefs=1 \_ea\_loadtrickA \_input {optex-tricks.opm}}%
161 \_restorectable \_endnamespace
162 \_endlocalcontrol
163 }
164 \_def\_trick #1;{\_endinput}
165 \_public \loadtrick ;
166
167 \_xargs \_regtrick \begfile \createfile \beglua \begLUA \logginglua
168 \sethours \setminutes \setseconds \setweekday \Othe \ordnum \showpglists \shownodes \runsystem
169 \directoutput \algol \algolkw \algolcap \algolnum \makeLOA \setaca \scaleto \scaletof
170 \ttlineref \lref \easylist \keepstyle \fcread \shadedframe \roundframe \cancel \ignoreinspic
171 \keystroke \colortab \crx \crtop \crbot \crmid \longtable \vcent \vbot \tnote
172 \tabnodes \tablebefore \framedblocks \twoblocks \pstart \settabs \import \incrpp \ispageodd
173 \iniseccc \seccc \makeLOF \makeLOT \captionF \captionT \correctvsize \pgforeground
174 \onlyifnew \thedimen \rebox \leftfill \rightfill \lrfill \directchar \ereplstring
175 \xreplstring \replmacro \tdnum \clipbox \ismatch \isinmacro \mathinexpr \xparshape
176 \csvread \csvdecl \dbcreate \inode \enode \execedges \showtree \jsonread \jsoncnv
177 \treedata \tracingtreedata \treenodes \ul \inspicto \inspictoh
178 \verbhyphens \verbhyphenpenalty ;
179 \_sdef{_item:m}{\_loadtrick{\style m}\_cs{_item:m}}
180
181 \_doc
182 The `\:` is used as a prefix before `\def` etc. in the file `optex-tricks.opm`
183 if the declared control sequence is from user namespace. It checks if a user
184 have defined it before the trick is loaded and prints warning in this case.
185 The `\:` is set to \`\_trickprefix` in the group before trick loading.
186 If a trick includes only one autoloaded control sequence then it
187 needs not to be prefixed by `\:` because if a user redefines it then
188 the usage of it doesn't run autoloading.
189 \_cod
190
191 \_def\_trickprefix #1#2{\_ifx#2\_undefined \_else \_def\_tmp{\_loadtrickD#2}\_ifx\_tmp#2\_else
192 \_opwarning{trick by \_ea\_string\_trickseq\_space loaded: \_string#2 redefined}\_fi\_fi #1#2}
193
194 \_doc -----------------------------
195 Lua\TeX/ version 1.14 and newer provides `\partokenname` which allows to
196 specify something different than `\par` at empty lines. We set `\_par`
197 (see below) in \OpTeX/ version 1.04+ and newer. Some macros were rewritten
198 due to this change. And we copy old versions of these changed macros here
199 in order to allow to use older Lua\TeX/ versions where `\partokenname` is
200 not provided.\nl
201 Note that your macros where a parameter is separated by the empty line
202 must be changed too. Use `\def\macro #1\_par{...}` instead
203 `\def\macro #1\par{...}`.
204 \_cod -----------------------------
205
206 \_ifx\_partokenname\_undefined % LuaTeX 1.13 or older:
207
208 \_def\_incaption {\_bgroup
209 \_ifcsname _\_tmpa num\_endcsname \_ea\_incr \_csname _\_tmpa num\_endcsname
210 \_else \_opwarning{Unknown caption /\_tmpa}\_fi
211 \_edef\_thecapnum {\_csname _the\_tmpa num\_endcsname}%
212 \_edef\_thecaptitle{\_mtext{\_tmpa}}%
213 \_ea\_the \_csname _everycaption\_tmpa\_endcsname
214 \_def\_par{\_nbpar\_egroup}\_let\par=\_par
215 \_cs{_printcaption\_tmpa}%
216 }
217 \_def\_boxlines{%
218 \_def\_boxlinesE{\_ifhmode\_egroup\_empty\_fi}%
219 \_def\_nl{\_boxlinesE}%
220 \_bgroup \_lccode`\~=`\^^M\_lowercase{\_egroup\_let~}\_boxlinesE
221 \_everypar{\_setbox0=\_lastbox\_endgraf
222 \_hbox\_bgroup \_catcode`\^^M=13 \_let\par=\_nl \_aftergroup\_boxlinesC}%
223 }
224 \_def\_letter{
225 \_def\_address{\_vtop\_bgroup\_boxlines \_parskip=0pt \_let\par=\_egroup}
226 \_def\_subject{{\_bf \_mtext{subj}: }}
227 \_public \address \subject ;
228 \_typosize[11/14]
229 \_vsize=\_dimexpr \_topskip + 49\_baselineskip \_relax % added 2020-03-28
230 \_parindent=0pt
231 \_parskip=\_medskipamount
232 \_nopagenumbers
233 }
234 \_def\_printverbline#1{\_putttpenalty \_indent \_printverblinenum \_kern\_ttshift #1\par}
235 \_public \boxlines \letter ;
236
237 \_else % LuaTeX 1.14 or newer:
238
239 \_doc -----------------------------
240 We set `\partokenneame` to `\_par` in order to keep the name `\par` in the
241 public namespace for end users. I.e.\ a user can say `\def\par{paragraph}` for example
242 without crash of processing the document. Se section~\ref[namespaces] for
243 more details about the name space concept.\nl
244 Moreover, we set `\partokencontext` to one in order to the `\_par` token
245 is inserted not only at empty lines, but also at the end of `\vbox`, `\vtop` and
246 `\vcenter` if horizontal mode is opened here. This differs from default
247 \TeX/ behavior where horizontal mode is closed in these cases without
248 inserting par token.\nl
249 We set \`\_partokenset` to defined value 1 in order to the macro programmer can
250 easily check these settings in \OpTeX/ format by
251 `\ifx\_partokenset\undefined ... \else ...\fi`.
252 \_cod -----------------------------
253
254 \_partokenname\_par
255 \_partokencontext=1
256 \_let\_partokenset=1
257 \_fi
258
259 \_endcode
260
261 2026-05-17 \frqq, \flqq redefined
262 2024-11-21 \_trickprefix introduced
263 2024-09-09 for old LuaTeX 1.13: \_def\_bemulti removed
264 2024-06-27 \_loadtrickD introduced in order to save format size.
265 2024-03-11 \_lipsumload+\_loadtrick: \vpack used instead \vbox.
266 2024-03-04 \_beglocalcontrol used in \_lipsumload.
267 2024-02-18 \_beglocalcontrol used in \_loadtrik.
268 2023-12-23 \_nonebox instead box 0 introduced.
269 2023-10-17 \_loadtrick introduced.
270 2022-05-04 \lipsum[<num>]. changed to \lipsum[<num>.] to keep macro expandable.
271 2022-04-21 syntax \lipsum[<num>]. introduced.
272 2022-02-16 declaration of @-names moved here from plain-at.opm.
273 2021-08-02 \SetLipsumLanguage added, fix for new lipusm version
274 2021-01-04 \lipsumtext introduced
275 2020-05-22 \lipsum uses \fornum (expandable after first usage)
276 2020-04-02 released