summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/optex/base/others.opm
blob: 0c9f4cae6a0358b88eae67dbfa2a9b6bd42a38dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
%% This is part of the OpTeX project, see http://petr.olsak.net/optex

\_codedecl \uv {Miscenaleous <2020-08-02>} % preloaded in format

    \_doc ----------------------------
    \`\useOpTeX` and \`\useoptex` are declared as `\relax`.
    \_cod ----------------------------

\_let \useOpTeX = \_relax   \_let \useoptex = \_relax

    \_doc ----------------------------
    The \`\lastpage` and \`\totalpages` get the information from the
    \^`\_currpage`. The \^`\_Xpage` from `.ref` file sets the \^`\_currpage`.
    \_cod ----------------------------

\_def\_totalpages {\_openref\_ea\_ignoresecond\_currpage}
\_def\_lastpage   {\_openref\_ea\_usesecond\_currpage}
\_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
\_chardef\flqq=171   \_chardef\frqq=187
\_chardef\promile=8240

\_def\uv#1{\clqq#1\crqq}

\_let\uslang=\enlang  \_let\ehyph=\enlang
\_let\chyph=\cslang   \_let\shyph=\sklang
\_let\csUnicode=\csPatt \_let\czUnicode=\csPatt \_let\skUnicode=\skPatt

    \_doc ----------------------------
    The \`\letfont` was used in \csplain/ instead of `\fontlet`.
    \_cod ----------------------------

\_let \letfont = \_fontlet

    \_doc ----------------------------
    Non-breaking space in Unicode.
    \_cod ----------------------------

\let ^^a0=~

    \_doc ----------------------------
    TikZ needs these funny control sequences.
    \_cod ----------------------------

\_ea\_toksdef \_csname toks@\_endcsname=0
\_ea\_let     \_csname voidb@x\_endcsname=\_voidbox

    \_doc ----------------------------
    We don't want to read `opmac.tex` unless `\input opmac` is specified.
    \_cod ----------------------------

\_def\OPmacversion{OpTeX}

    \_doc ----------------------------
    We allow empty lines in math formulae. It is more comfortable.
    \_cod ----------------------------

\_suppressmathparerror = 1

    \_doc ----------------------------
    Lorem ipsum can be printed by \`\lipsum``[<range>]` or \`\lorem``[<range>]`,
    for example `\lipsum[3]` or `\lipsum[112-121]`, max=150.

    First usage of `\lipsum` reads the \LaTeX/ file `lipsum.ltd.tex`
    by \`\_lipsumload`
    and prints the selected paragraph(s). Next usages of `\lipsum`
    prints the selected paragraph(s) from memory. This second and more
    usages of `\lipsum` are fully expandable. If you want to have all
    printings of `\lipsum` expandable, use dummy `\lipsum[0]` first.

    `\lipsum` adds `\_par` after each printed paragraph. If you don't need
    such `\_par` here, use \`\lipsumtext``[<number>]`.
    This macro prints only one selected paragraph <number> and does not add `\_par`.
    \_cod ----------------------------

\_def\_lipsumtext[#1]{\_lipsumload\_cs{_lip:#1}}
\_def\_lipsum[#1]{\_lipsumA #1\_empty-\_empty\_end}
\_def\_lipsumA #1-#2\_empty#3\_end{%
   \_fornum #1..\_ifx^#2^#1\_else#2\_fi \_do {\_lipsumtext[##1]\_par}}
\_def\_lipsumload{{%
   \_setbox0=\_vbox{\_tmpnum=0 % vertical mode during \input lipsum.ltd.tex
      \_def\ProvidesFile##1[##2]{}%
      \_def\SetLipsumLanguage##1{}%
      \_def\NewLipsumPar{\_incr\_tmpnum \_sxdef{_lip:\_the\_tmpnum}}%
      \_opinput {lipsum.ltd.tex}%
      \_global\_let\_lipsumload=\_empty
   }}}
\_public \lipsum \lipsumtext ;
\_let \lorem=\lipsum

   \_doc -----------------------------
   Lua\TeX/ version 1.14 and newer provides `\partokenname` which allows to
   specify something different than `\par` at empty lines. We set `\_par`
   (see bellow) in \OpTeX/ version 1.04+ and newer. Some macros were rewritten
   due to this change. And we copy old versions of these changed macros here
   in order to allow to use older Lua\TeX/ versions where `\partokenname` is
   not provided.\nl
   Note that your macros where a parameter is separated by the empty line
   must be changed too. Use `\def\macro #1\_par{...}` instead
   `\def\macro #1\par{...}`.
   \_cod -----------------------------

\_ifx\_partokenname\_undefined % LuaTeX 1.13 or older:

   \_def\_begmulti #1 {\_par\_bgroup\_wipeepar\_multiskip\_penalty0 \_def\_Ncols{#1}
      \_setbox6=\_vbox\_bgroup\_bgroup \_let\_setxhsize=\_relax \_penalty-99
      \_advance\_hsize by\_colsep
      \_divide\_hsize by\_Ncols  \_advance\_hsize by-\_colsep
      \_mullines=0
      \_def\par{\_ifhmode\_endgraf\_global\_advance\_mullines by\_prevgraf\_fi}%
   }
   \_def\_incaption {\_bgroup
      \_ifcsname _\_tmpa num\_endcsname \_ea\_incr \_csname _\_tmpa num\_endcsname
      \_else \_opwarning{Unknown caption /\_tmpa}\_fi
      \_edef\_thecapnum {\_csname _the\_tmpa num\_endcsname}%
      \_edef\_thecaptitle{\_mtext{\_tmpa}}%
      \_ea\_the \_csname _everycaption\_tmpa\_endcsname
      \_def\_par{\_nbpar\_egroup}\_let\par=\_par
      \_cs{_printcaption\_tmpa}%
   }
   \_def\_boxlines{%
      \_def\_boxlinesE{\_ifhmode\_egroup\_empty\_fi}%
      \_def\_nl{\_boxlinesE}%
      \_bgroup \_lccode`\~=`\^^M\_lowercase{\_egroup\_let~}\_boxlinesE
      \_everypar{\_setbox0=\_lastbox\_endgraf
         \_hbox\_bgroup \_catcode`\^^M=13 \_let\par=\_nl \_aftergroup\_boxlinesC}%
   }
   \_def\_letter{
      \_def\_address{\_vtop\_bgroup\_boxlines \_parskip=0pt \_let\par=\_egroup}
      \_def\_subject{{\_bf \_mtext{subj}: }}
      \_public \address \subject ;
      \_typosize[11/14]
      \_vsize=\_dimexpr \_topskip + 49\_baselineskip \_relax % added 2020-03-28
      \_parindent=0pt
      \_parskip=\_medskipamount
      \_nopagenumbers
   }
   \_def\_printverbline#1{\_putttpenalty \_indent \_printverblinenum \_kern\_ttshift #1\par}
   \_public \begmulti \boxlines \letter ;

\_else % LuaTeX 1.14 or newer:

   \_doc -----------------------------
   We set `\partokenneame` to `\_par` in order to keep the name `\par` in
   user name space. I.e. a user can say `\def\par{paragraph}` for example
   without crash of processing the document. Se section~\ref[prefixed] for
   more details about the name space concept.\nl
   Moreover, we set `\partokencontext` to one in order to the `\_par` token
   is inserted not only at empty lines, but also at the end of `\vbox`, `\vtop` and
   `\vcenter` if horizontal mode is opened here. This differs from default
   \TeX/ behavior where horizontal mode is closed in these cases without
   inserting par token.\nl
   We set \`\_partokenset` to defined value 1 in order to the macro programmer can
   easily check these settings in \OpTeX/ format by
   `\ifx\_partokenset\undefined ... \else ...\fi`.
   \_cod -----------------------------

   \_partokenname\_par
   \_partokencontext=1
   \_let\_partokenset=1
\_fi

\_endcode

2021-08-02 \SetLipsumLanguage added, fix for new lipusm version
2021-01-04 \lipsumtext introduced
2020-05-22 \lipsum uses \fornum (expandable after first usage)
2020-04-02 released