Debian Codegraph @

texmf-dist/tex/optex/base/plain-macros.opm

raw
1 %% This is part of the OpTeX project, see http://petr.olsak.net/optex
2
3 \_codedecl \magstep {Macros from plain TeX <2022-10-11>} % preloaded in format
4
5 \_doc -----------------------------
6 The \`\dospecials` works like in plain TeX but does nothing with `_`.
7 If you need to do the same with this character, you can re-define:
8 \begtt
9 \addto \dospecials{\do\_}
10 \endtt
11 \`\active` is character constant 13, we can use it in the context
12 \code{\\catcode`}<character>\code{=\\active}.
13 \_cod -----------------------------
14
15 \_def\_dospecials {\do\ \do\\\do\{\do\}\do\$\do\&%
16 \do\#\do\^\do\^^K\do\^^A\do\%\do\~}
17 \_chardef\_active = 13
18
19 \_public \dospecials \active ;
20
21 \_doc -----------------------------
22 The shortcuts `\chardef\@one` is not defined in \OpTeX/. Use normal
23 numbers instead of such obscurities.
24 \nl
25 The \`\magstep` and \`\magstephalf` are
26 defined with `\space`, (no `\relax`), in order to be expandable.
27 \_cod -----------------------------
28
29 \_def \_magstephalf{1095 }
30 \_def \_magstep#1{\_ifcase#1 1000\_or 1200\_or 1440\_or 1728\_or 2074\_or 2488\_fi\_space}
31 \_public \magstephalf \magstep ;
32
33 \_doc -----------------------------
34 Plain \TeX/ basic macros and control sequences.
35 \`\endgraf`, \`\endline`.
36 The `^^L` is not defined in \OpTeX/ because it is obsolete.
37 \_cod -----------------------------
38
39 \_def\^^M{\ } % control <return> = control <space>
40 \_def\^^I{\ } % same for <tab>
41
42 \_def\lq{`} \def\rq{'}
43 \_def\lbrack{[} \_def\rbrack{]} % They are only public versions.
44 % \catcode`\^^L=\active \outer\def^^L{\par} % ascii form-feed is "\outer\par" % obsolete
45
46 \_let\_endgraf=\_par \_let\_endline=\_cr
47 \_public \endgraf \endline ;
48
49 \_doc -----------------------------
50 Plain \TeX/ classical \`\obeylines` and \`\obeyspaces`.
51 \_cod -----------------------------
52
53 % In \obeylines, we say `\let^^M=\_par' instead of `\def^^M{\_par}'
54 % since this allows, for example, `\let\_par=\cr \obeylines \halign{...'
55 {\_catcode`\^^M=13 % these lines must end with %
56 \_gdef\_obeylines{\_catcode`\^^M=13\_let^^M\_par}%
57 \_glet^^M=\_par} % this is in case ^^M appears in a \write
58 \_def\_obeyspaces{\_catcode`\ =13 }
59 {\_obeyspaces\_glet =\_space}
60 \_public \obeylines \obeyspaces ;
61
62 \_doc -----------------------------
63 Spaces.
64 \`\thinspace`, \`\negthinspace`, \`\enspace`, \`\enskip`,
65 \`\quad`, \`\qquad`, \`\smallskip`,
66 \`\medskip`, \`\bigskip`, \`\nointerlineskip`, \`\offinterlineskip`,
67 \`\topglue`, \`\vglue`, \`\hglue`, \`\slash`.
68 \_cod -----------------------------
69
70 \_protected\_def\_thinspace {\_kern .16667em }
71 \_protected\_def\_negthinspace {\_kern-.16667em }
72 \_protected\_def\_enspace {\_kern.5em }
73 \_protected\_def\_enskip {\_hskip.5em\_relax}
74 \_protected\_def\_quad {\_hskip1em\_relax}
75 \_protected\_def\_qquad {\_hskip2em\_relax}
76 \_protected\_def\_smallskip {\_vskip\_smallskipamount}
77 \_protected\_def\_medskip {\_vskip\_medskipamount}
78 \_protected\_def\_bigskip {\_vskip\_bigskipamount}
79 \_def\_nointerlineskip {\_prevdepth=-1000pt }
80 \_def\_offinterlineskip {\_baselineskip=-1000pt \_lineskip=0pt \_lineskiplimit=\_maxdimen}
81
82 \_public \thinspace \negthinspace \enspace \enskip \quad \qquad \smallskip
83 \medskip \bigskip \nointerlineskip \offinterlineskip ;
84
85 \_def\_topglue {\_nointerlineskip\_vglue-\_topskip\_vglue} % for top of page
86 \_def\_vglue {\_afterassignment\_vglA \_skip0=}
87 \_def\_vglA {\_par \_dimen0=\_prevdepth \_hrule height0pt
88 \_nobreak\_vskip\_skip0 \_prevdepth=\_dimen0 }
89 \_def\_hglue {\_afterassignment\_hglA \_skip0=}
90 \_def\_hglA {\_leavevmode \_count255=\_spacefactor \_vrule width0pt
91 \_nobreak\_hskip\_skip0 \_spacefactor=\_count255 }
92 \_protected\_def~{\_penalty10000 \ } % tie
93 \_protected\_def\_slash {/\_penalty\_exhyphenpenalty} % a `/' that acts like a `-'
94
95 \_public \topglue \vglue \hglue \slash ;
96
97 \_doc -----------------------------
98 Penalties macros:
99 \`\break`, \`\nobreak`, \`\allowbreak`, \`\filbreak`, \`\goodbreak`,
100 \`\eject`, \`\supereject`, \`\dosupereject`,
101 \`\removelastskip`, \`\smallbreak`, \`\medbreak`, \`\bigbreak`.
102 \_cod -----------------------------
103
104 \_protected\_def \_break {\_penalty-10000 }
105 \_protected\_def \_nobreak {\_penalty10000 }
106 \_protected\_def \_allowbreak {\_penalty0 }
107 \_protected\_def \_filbreak {\_par\_vfil\_penalty-200\_vfilneg}
108 \_protected\_def \_goodbreak {\_par\_penalty-500 }
109 \_protected\_def \_eject {\_par\_break}
110 \_protected\_def \_supereject {\_par\_penalty-20000 }
111 \_protected\_def \_dosupereject {\_ifnum \_insertpenalties>0 % something is being held over
112 \_line{}\_kern-\_topskip \_nobreak \_vfill \_supereject \_fi}
113 \_def \_removelastskip {\_ifdim\_lastskip=\_zo \_else \_vskip-\_lastskip \_fi}
114 \_def \_smallbreak {\_par\_ifdim\_lastskip<\_smallskipamount
115 \_removelastskip \_penalty-50 \_smallskip \_fi}
116 \_def \_medbreak {\_par\_ifdim\_lastskip<\_medskipamount
117 \_removelastskip \_penalty-100 \_medskip \_fi}
118 \_def \_bigbreak {\_par\_ifdim\_lastskip<\_bigskipamount
119 \_removelastskip \_penalty-200 \_bigskip \_fi}
120
121 \_public \break \nobreak \allowbreak \filbreak \goodbreak \eject \supereject \dosupereject
122 \removelastskip \smallbreak \medbreak \bigbreak ;
123
124 \_doc -----------------------------
125 Boxes.
126 \`\line`, \`\leftline`, \`\rightline`, \`\centerline`, \`\rlap`, \`\llap`,
127 \`\underbar`.
128 \_cod -----------------------------
129
130 \_def \_line {\_hbox to\_hsize}
131 \_def \_leftline #1{\_line{#1\_hss}}
132 \_def \_rightline #1{\_line{\_hss#1}}
133 \_def \_centerline #1{\_line{\_hss#1\_hss}}
134 \_def \_rlap #1{\_hbox to\_zo{#1\_hss}}
135 \_def \_llap #1{\_hbox to\_zo{\_hss#1}}
136 \_def\_underbar #1{$\_setbox0=\_dirhbox{#1}\_dp0=\_zo \_math \_underline{\_box0}$}
137
138 \_public \line \leftline \rightline \centerline \rlap \llap \underbar ;
139
140 \_doc -----------------------------
141 The \`\strutbox` is declared as 10pt size dependent (like in plain \TeX), but
142 the macro `\_setbaselineskip` (from `fonts-opmac.opm`) redefines it.
143 The `\strut` macro puts the \^`\strutbox`.
144 \_cod -----------------------------
145
146 \_newbox\_strutbox
147 \_setbox\_strutbox=\_hbox{\_vrule height8.5pt depth3.5pt width0pt}
148 \_def \_strut {\_relax\_ifmmode\_copy\_strutbox\_else\_unhcopy\_strutbox\_fi}
149
150 \_public \strutbox \strut ;
151
152 \_doc -----------------------------
153 Alignment. \`\hidewidth` \`\ialign` \`\multispan`.
154 \_cod -----------------------------
155
156 \_def \_hidewidth {\_hskip\_hideskip} % for alignment entries that can stick out
157 \_def \_ialign{\_everycr={}\_tabskip=\_zoskip \_halign} % initialized \halign
158 \_newcount\_mscount
159 \_def \_multispan #1{\_omit \_mscount=#1\_relax
160 \_loop \_ifnum\_mscount>1 \_spanA \_repeat}
161 \_def \_spanA {\_span\_omit \_advance\_mscount by-1 }
162
163 \_public \hidewidth \ialign \multispan ;
164
165 \_doc -----------------------------
166 Tabbing macros are omitted because they are obsolete.
167 \nl
168 Indentation and similar macros are defined here: \`\hang`, \`\textindent`,
169 \`\item`, \`\itemitem`, \`\narrower`, \`\raggedright`, \`\ttraggedright`, \`\leavevmode`.
170 \_cod -----------------------------
171
172 \_def \_hang {\_hangindent\_parindent}
173 \_def \_textindent #1{\_indent\_llap{#1\_enspace}\_ignorespaces}
174 \_def \_item {\_par\_hang\_textindent}
175 \_def \_itemitem {\_par\_indent \_hangindent2\_parindent \_textindent}
176 \_def \_narrower {\_advance\_leftskip\_parindent
177 \_advance\_rightskip\_parindent}
178 \_def \_raggedright {\_rightskip=0pt plus2em
179 \_spaceskip=.3333em \_xspaceskip=.5em\_relax}
180 \_def \_ttraggedright {\_tt \_rightskip=0pt plus2em\_relax} % for use with \tt only
181 \_def \_leavevmode {\_unhbox\_voidbox} % begins a paragraph, if necessary
182
183 \_public \hang \textindent \item \itemitem \narrower \raggedright \ttraggedright \leavevmode ;
184
185 \_doc -----------------------------
186 Few character codes are set for backward compatibility. But old obscurities
187 (from plain \TeX) based on \`\mathhexbox`
188 are not supported -- an error message and recommendation
189 to directly using the desired character is implemented by the
190 \`\_usedirectly` macro).
191 The user can re-define these control sequences of course.
192 \_cod -----------------------------
193
194 %\chardef\%=`\%
195 \_let\% = \_pcent % more natural, can be used in lua codes.
196 \_chardef\&=`\&
197 \_chardef\#=`\#
198 \_chardef\$=`\$
199 \_chardef\ss="FF
200 \_chardef\ae="E6
201 \_chardef\oe="F7
202 \_chardef\o="F8
203 \_chardef\AE="C6
204 \_chardef\OE="D7
205 \_chardef\O="D8
206 \_chardef\i="19 \chardef\j="1A % dotless letters
207 \_chardef\aa="E5
208 \_chardef\AA="C5
209 \_chardef\S="9F
210 \_def\l{\_errmessage{\_usedirectly ł}}
211 \_def\L{\_errmessage{\_usedirectly Ł}}
212 %\def\_{\_ifmmode \kern.06em \vbox{\hrule width.3em}\else _\fi} % obsolete
213 \_protected\_def\_{\_relax \_ifmmode \_hbox{_}\_else _\_fi}
214 \_def\dag{\_errmessage{\_usedirectly †}}
215 \_def\ddag{\_errmessage{\_usedirectly ‡}}
216 \_def\copyright{\_errmessage{\_usedirectly ©}}
217 %\_def\Orb{\_mathhexbox20D} % obsolete (part of Copyright)
218 %\_def\P{\_mathhexbox27B} % obsolete
219
220 \_def \_usedirectly #1{Load Unicoded font by \string\fontfam\space and use directly #1}
221 \_def \_mathhexbox #1#2#3{\_leavevmode \_hbox{$\_math \_mathchar"#1#2#3$}}
222 \_public \mathhexbox ;
223
224 \_doc -----------------------------
225 The \`\_unichars` macro is run when Unicode font family is loaded,
226 Unicodes are used instead old plain \TeX/ settings.
227 \_cod -----------------------------
228
229 \def\_unichars{% Plain TeX character sequences with different codes in Unicode:
230 \_chardef\ss=`ß
231 \_chardef\ae=`æ \_chardef\AE=`Æ
232 \_chardef\oe=`œ \_chardef\OE=`Œ
233 \_chardef\o=`ø \_chardef\O=`Ø
234 \_chardef\aa=`å \_chardef\AA=`Å
235 \_chardef\l=`ł \_chardef\L=`Ł
236 \_chardef\i=`ı \_chardef\j=`ȷ
237 \_chardef\S=`§ \_chardef\P=`¶
238 \_chardef\dag`†
239 \_chardef\ddag`‡
240 \_chardef\copyright`©
241 }
242
243 \_doc -----------------------------
244 Accents.
245 The macros \`\ooalign`, \`\d`, \`\b`, \`\c`, \`\dots`,
246 are defined for backward compatibility.
247 \_cod -----------------------------
248
249 \_def \_oalign #1{\_leavevmode\_vtop{\_baselineskip=\_zo \_lineskip=.25ex
250 \_ialign{##\_crcr#1\_crcr}}}
251 \_def \_oalignA {\_lineskiplimit=\_zo \_oalign}
252 \_def \_ooalign {\_lineskiplimit=-\_maxdimen \_oalign} % chars over each other
253 \_def \_shiftx #1{\_dimen0=#1\_kern\_ea\_ignorept \_the\_fontdimen1\_font
254 \_dimen0 } % kern by #1 times the current slant
255 \_def \_d #1{{\_oalignA{\_relax#1\_crcr\_hidewidth\_shiftx{-1ex}.\_hidewidth}}}
256 \_def \_b #1{{\_oalignA{\_relax#1\_crcr\_hidewidth\_shiftx{-3ex}%
257 \_vbox to.2ex{\_hbox{\_char\_macron}\_vss}\_hidewidth}}}
258 \_def \_c #1{{\_setbox0=\_hbox{#1}\_ifdim\_ht0=1ex\_accent\_cedilla #1%
259 \_else\_ooalign{\_unhbox0\_crcr\_hidewidth\_cedilla\_hidewidth}\_fi}}
260 \_def\_dots{\_relax\_ifmmode\_ldots\_else$\_math\_ldots\_thinsk$\_fi}
261 \_public \oalign \ooalign \d \b \c \dots ;
262
263 \_doc -----------------------------
264 The accent commands like `\v`, `\.`, `\H`, etc. are not defined. Use the
265 accented characters directly -- it is the best solution. But you can use the
266 macro \`\oldaccents` which defines accented macros.
267 \nl
268 Much more usable is to define these control sequences for other purposes.
269 \nl
270 The \`\_uniaccents` macro redeclares codes for accents and it is run when
271 Unicode font family is loaded.
272 \_cod -----------------------------
273
274 \_def \_oldaccents {%
275 \_def\`##1{{\_accent\_tgrave ##1}}%
276 \_def\'##1{{\_accent\_tacute ##1}}%
277 \_def\v##1{{\_accent\_caron ##1}}%
278 \_def\u##1{{\_accent\_tbreve ##1}}%
279 \_def\=##1{{\_accent\_macron ##1}}%
280 \_def\^##1{{\_accent\_circumflex ##1}}%
281 \_def\.##1{{\_accent\_dotaccent ##1}}%
282 \_def\H##1{{\_accent\_hungarumlaut ##1}}%
283 \_def\~##1{{\_accent\_ttilde ##1}}%
284 \_def\"##1{{\_accent\_dieresis ##1}}%
285 \_def\r##1{{\_accent\_ring ##1}}%
286 }
287 \_public \oldaccents ;
288
289 % ec-lmr encoding (will be changed after \fontfam macro):
290 \_chardef\_tgrave=0
291 \_chardef\_tacute=1
292 \_chardef\_circumflex=2
293 \_chardef\_ttilde=3
294 \_chardef\_dieresis=4
295 \_chardef\_hungarumlaut=5
296 \_chardef\_ring=6
297 \_chardef\_caron=7
298 \_chardef\_tbreve=8
299 \_chardef\_macron=9
300 \_chardef\_dotaccent=10
301 \_chardef\_cedilla=11
302
303 \_def \_uniaccents {% accents with Unicode
304 \_chardef\_tgrave="0060
305 \_chardef\_tacute="00B4
306 \_chardef\_circumflex="005E
307 \_chardef\_ttilde="02DC
308 \_chardef\_dieresis="00A8
309 \_chardef\_hungarumlaut="02DD
310 \_chardef\_ring="02DA
311 \_chardef\_caron="02C7
312 \_chardef\_tbreve="02D8
313 \_chardef\_macron="00AF
314 \_chardef\_dotaccent="02D9
315 \_chardef\_cedilla="00B8
316 \_chardef\_ogonek="02DB
317 \_let \_uniaccents=\_relax
318 }
319
320 \_doc -----------------------------
321 The plain \TeX/ macros
322 \`\hrulefill`, \`\dotfill`, \`\rightarrowfill`, \`\leftarrowfill`,
323 \`\downbracefill`, \`\upbracefill`.
324 The last four are used in non-Unicode variants of `\overrightarrow`,
325 `\overleftarrow`, `\overbrace` and `\underbrace` macros, see
326 section~\ref[math-macros].
327 \_cod -----------------------------
328
329 \_def \_hrulefill {\_leaders\_hrule\_hfill}
330 \_def \_dotfill {\_cleaders\_hbox{$\_math \_mkern1.5mu.\_mkern1.5mu$}\_hfill}
331 \_def \_rightarrowfill {$\_math\_smash-\_mkern-7mu%
332 \_cleaders\_hbox{$\_mkern-2mu\_smash-\_mkern-2mu$}\_hfill
333 \_mkern-7mu\_mathord\_rightarrow$}
334 \_def \_leftarrowfill {$\_math\_mathord\_leftarrow\_mkern-7mu%
335 \_cleaders\_hbox{$\_mkern-2mu\_smash-\_mkern-2mu$}\_hfill
336 \_mkern-7mu\_smash-$}
337
338 \_mathchardef \_braceld="37A \_mathchardef \_bracerd="37B
339 \_mathchardef \_bracelu="37C \_mathchardef \_braceru="37D
340 \_def \_downbracefill {$\_math \_setbox0=\_hbox{$\_braceld$}%
341 \_braceld \_leaders\_vrule height\_ht0 depth\_zo \_hfill \_braceru
342 \_bracelu \_leaders\_vrule height\_ht0 depth\_zo \_hfill \_bracerd$}
343 \_def \_upbracefill {$\_math \_setbox0=\_hbox{$\_braceld$}%
344 \_bracelu \_leaders\_vrule height\_ht0 depth\_zo \_hfill \_bracerd
345 \_braceld \_leaders\_vrule height\_ht0 depth\_zo \_hfill \_braceru$}
346
347 \_public \hrulefill \dotfill
348 \rightarrowfill \leftarrowfill \downbracefill \upbracefill ;
349
350 \_doc -----------------------------
351 The last part of plain \TeX/ macros: \`\magnification`, \`\showhyphens`, \`\bye`.
352 Note that math macros are defined in the `math-macros.opm` file
353 (section~\ref[math-macros]).
354 \_cod -----------------------------
355
356 \_def \_magnification {\_afterassignment \_magA \_count255 }
357 \_def \_magA {\_mag=\_count255 \_truedimen\_hsize \_truedimen\_vsize
358 \_dimen\_footins=8truein
359 }
360 % only for backward compatibility, but \margins macro is preferred.
361 \_public \magnification ;
362
363 \_def \_showhyphens #1{\_setbox0=\_vbox{\_parfillskip=0pt \_hsize=\_maxdimen \_tenrm
364 \_pretolerance=-1 \tolerance=-1 \hbadness=0 \showboxdepth=0 \ #1}}
365
366 \_def \_bye {\_par \_vfill \_supereject \_byehook \_end}
367 \_public \showhyphens \bye ;
368
369 \_doc -----------------------------
370 Plain \TeX/ reads `hyphen.tex` with patterns when \^`\language``=0`. We do the same.
371 \_cod -----------------------------
372
373 \_lefthyphenmin=2 \_righthyphenmin=3 % disallow x- or -xx breaks
374 \_input hyphen % en(USenglish) patterns from TeX82
375
376 \_endcode % -------------------------------------
377
378 2024-04-28 ... \_ corrected
379 2022-10-11 ... \_unichars extended
380 2022-02-19 ... \input hyphen.tex moved here (format file is 80k smaller)
381 2021-09-24 ... \_unichars introduced
382 2021-04-09 ... \_public\showhyphens, bug fixed
383 2020-02-14 ... released