summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/xetex/unimath-plain-xetex/unimath-plain-xetex-doc.tex
blob: b75d69c651f45c7bac6548d0ff4809471578b694 (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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
%% The document of unimath-plain-xetex
%% ******************************************************
%% * This work may be distributed and/or modified under *
%% * the conditions of the LaTeX Project Public License *
%% *     http://www.latex-project.org/lppl.txt          *
%% * either version 1.3c of this license or any later   *
%% * version.                                           *
%% ******************************************************
\def\mainfontname{erewhon}
\def\sansfontname{Fira Sans Book}
\def\monofontname{Source Code Pro}
\def\mathfontname{Erewhon Math}
\input unimath-plain-xetex
\unicodeprimesoff
\betweenprimeskip=-1mu\relax

\def\xetex{X\kern-.125em\lower.5ex\hbox{\char"018E}\kern-.1667em%
  T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX}
\let\XeTeX\xetex
\let\tex\TeX
\def\latex{L\kern-.24em{\setbox0=\hbox{T}\vbox to \ht0{\hbox{\sevenrm A}\vss}}%
  \kern-.12em\TeX}
\def\umpx{unimath-plain-\xetex}
\def\biggskip{\vskip24pt plus 8pt minus 4pt}
\def\pkg#1{{\tensf #1}}
\font\hugesans="\sansfontname" at 35pt
\font\sevenlmmath="Latin Modern Math:script=math,+ssty=0" at 7pt
\makefontcmdcompatible{ten}

\def\ttverbatim{\begingroup
  \catcode`\\=12 \catcode`\{=12 \catcode`\}=12 \catcode`\$=12
  \catcode`\&=12 \catcode`\#=12 \catcode`\%=12 \catcode`\~=12
  \catcode`\_=12 \catcode`\^=12 \obeyspaces \obeylines \tt}
\outer\def\begintt{$$\let\par=\endgraf \ttverbatim \parskip=0pt
  \catcode`\|=0 \rightskip-2pc \ttfinish}
{\catcode`\|=0 |catcode`|\=12 % | is temporary escape character
  |obeylines % end of line is active
  |gdef|ttfinish#1^^M#2\endtt{#1|vbox{#2}|endgroup$$}}
\def\charhex{\char"}
\catcode`\"=\active
{\obeylines \gdef"{\ttverbatim \spaceskip.5em \let^^M=\  \let"=\endgroup}}
\def\<#1>{$\langle${\it#1\/}$\rangle$}

\long\def\scalehbox#1#2#3{%
  \leavevmode
  \setbox0\hbox{{#3}}%
  \setbox1\hbox{%
    \special{pdf:btrans}%
    \special{x:scale #1 #2}%
    \hbox to 0pt{\copy0\hss}%
    \special{pdf:etrans}%
  }%
  \ht1#2\ht0
  \dp1#2\dp0
  \hbox to#1\wd0{\box1\kern#1\wd0\hss}%
}

\newdimen\paperwd
\newdimen\paperht
\newdimen\hmarginwd
\newdimen\vmarginht
\hsize=12cm
\vsize=16cm
\hmarginwd=3cm
\vmarginht=3cm
\hoffset=\dimexpr\hmarginwd-1in\relax
\voffset=\dimexpr\vmarginht-1in\relax
\paperwd=\dimexpr2\hmarginwd+\hsize\relax
\paperht=\dimexpr2\vmarginht+\vsize\relax
\special{papersize=\the\paperwd,\the\paperht}
\long\def\protectedwrite#1#2{\edef\wrt{\write#1{#2}}\wrt}

\newcount\secno
\secno=0
\newwrite\tocout
\edef\tocname{\jobname.toc}
\openout\tocout=\tocname
\newread\tocin
\openin\tocin=\tocname
\long\outer\def\section#1{\par\bigskip\penalty-1000%
  \noindent \advance\secno by 1\relax
  {\twelvebf\hbox to 0pt{\hss\twentybf\the\secno\kern12pt}#1}%
  \protectedwrite\tocout{\the\secno\quad 
    #1\hskip.5em\leaders\hbox to 1.2em{.\hss}\hfill}%
  \write\tocout{\hbox to .5em{\hss\the\pageno}\par}%
  \par\medskip\penalty1000\relax}
\parindent2pc

% title
\centerline{\twentyrm The 
  \scalehbox{0.5}{0.5}{%
  \special{pdf:code q 1 Tr}%
  {\hugesans\umpx}%
  \special{pdf:code Q}}
  package}
\biggskip

\centerline{Zhang Tingxuan}
\medskip

\centerline{2022/11/26\quad Version 0.1}
\biggskip

\centerline{\bf Abstract}
\medskip
{\leftskip=4pc\rightskip=4pc\parindent=1.5pc
{\sf\umpx} package provides OpenType math font support in {\it plain \tex\/} 
format. The {\sf\umpx} package needs \xetex.\par}

% TOC
\bigskip
\centerline{\bf Contents}
\medskip
\begingroup\leftskip=4pc\rightskip=4pc\parindent=0pc
\ifeof\tocin\else\closein\tocin\input\tocname\fi
\endgroup\bigskip

\section{How to use this package?}
Please notice again that you're using {\it plain\/} format but not 
\latex\ format. If you are using \latex\ format, please use 
\pkg{unicode-math} package instead.

In your document, write
\begintt
\input unimath-plain-xetex
\endtt
Then compile your document with "xetex", you can get OpenType math support 
in your document. The package will set the math font ``Latin Modern Math'' 
with ``Latin Modern'' text fonts in default. To change the font, you can 
define some names before loading the package. For example,
\begintt
\def\mainfontname{TeX Gyre Termes}
\def\sansfontname{TeX Gyre Heros}
\def\monofontname{TeX Gyre Cursors}
\def\mathfontname{TeX Gyre Termes Math}
\input unimath-plain-xetex
\endtt
Your text fonts will be set in the first 3 lines and your math font will 
be set in the fourth line.

Currently, the package supports only font family names to use, if 
you want to use the file names, you can revise the code in 
"unimath-plain-xetex.tex".



\section{Text font commands}
The package provides text font commands in the format of 
$$\hbox{"\"\<pt-size>\<family>\<series>\<shape>}$$
such as "\tensfbfit", "\twelvebf", etc. The packages provides 
font commands in size of 5\,pt, 7\,pt, 9\,pt, 10\,pt, 12\,pt and 20\,pt, 
such as "\fiverm", "\sevensf", "\twelvett", etc.

Take ten point as an example,
$$\vbox{\openup10pt%
  \halign{ \hfil#\hfil \cr
  {\twelverm Serif} \cr 
    \vbox{\openup-8pt\halign{#&\quad#&\quad#\cr 
                    & Upright  & {\tenit Italic} \cr
      Medium        & "\tenrm" & "\tenit"        \cr
      {\tenbf Bold} & "\tenbf" & "\tenbfit"      \cr}} \cr
  {\twelvesf Sans} \cr 
    \vbox{\openup-8pt\halign{#&\quad#&\quad#\cr 
                      & {\tensf Upright}  & {\tensfit Italic} \cr
      {\tensf Medium} & "\tensf"   & "\tensfit"        \cr
      {\tensfbf Bold} & "\tensfbf" & "\tensfbfit"      \cr}} \cr
  {\twelvett Typewritter} \cr
    \vbox{\openup-8pt\halign{#&\quad#&\quad#\cr 
                      & {\tentt Upright}  & {\tenttit Italic} \cr
      {\tentt Medium} & "\tentt"   & "\tenttit"        \cr
      {\tenttbf Bold} & "\tenttbf" & "\tenttbfit"      \cr}} \cr}}$$
The font commands can be used as those provided in "plain.tex", for example,
"{\tenbfit ABC}" yields {\tenbfit ABC}.

But if you would't like to remember that many commands, you can write
$$\hbox{\tentt"\makefontcmdcompatible"\{\<pt-size>\}}$$
after loading the package. For example, if you write
\begintt
\makefontcmdcompatible{ten}
\endtt
the \<family>-\<series>-\<shape> order of "\ten"\<some> commands 
can be write randomly: writing "\tenbfsfit" is the same as "\tensfbfit".

You can also get more text font commands through the "\genfontcmd" command:
$$\hbox{\tentt"\genfontcmd"\{\<pt-size>\}\{\<dimension>\}}$$
For example, 
\begintt
\genfontcmd{fortyfour}{44pt}
\genfontcmd{verytiny}{2bp}
\endtt
will make commands like "\fortyfourrm" and "\verytinysfbfit" available.



\section{Math font commands}
%Traditional plain \tex\ uses "\fam" mechanism to change the font of letters 
%and numbers in math mode. But using the "\fam" mechanism to change the face 
%of a math symbol in an OpenType math font is almost impossible. For example, 
%the roman ``${\rm A}$'' is encoded U+0041, but the italic math ``$A$'' is 
%encoded U+1D434.But this problem can be solved through redefining the math 
%character.
You can input math formulae just like using traditional plain \tex. But 
OpenType math font is loaded. For example, "$a{\bf0}={\bf0}$" yields 
$a{\bf0}={\bf0}$. Available math font commands are listed below:
\begintt
\rm, \bf, \it, \bfit,\sf, \sfbf, \sfit, \sfbfit,
\tt, \cal, \calbf, \bb, \bbit, \frak, \frakbf
\endtt
The \<family>-\<series>-\<shape> order of these commands allows being random; 
"cal" can be replaced by "scr".

This package uses "unicode-math-symbols.tex" to generate math symbol commands, 
the source file can be found in \pkg{unicode-math} package. To find all of 
the math symbol commands, you can execute
\begintt
texdoc unimath-symbols
\endtt
in Terminal.

You can also input Unicode math characters in your document's source file. 
For example, "$∫_a^b y\,dx$" yields $∫_a^b y\,dx$ and "$$∫_a^b y\,dx.$$" yields 
$$∫_a^b y\,dx.$$



\section{Primes ($'$)}
The package changed ``"'"'' command in math mode, which yields prime(s) 
in superscript. After loading this package, the primes produced by ``"'"'' 
will be turned into Unicode primes:
$$\vbox{\openup2pt\halign{#\hfil\quad&\quad#\hfil\quad&\quad#\hfil\cr
{\it Input} & {yields} & {\it Unicode slot}\cr
"$'$"     & $^{\hbox{\sevenlmmath\charhex2032}}$ & U+2032 \cr
"$''$"    & $^{\hbox{\sevenlmmath\charhex2033}}$ & U+2033 \cr
"$'''$"   & $^{\hbox{\sevenlmmath\charhex2034}}$ & U+2034 \cr
"$''''$"  & $^{\hbox{\sevenlmmath\charhex2057}}$ & U+2057 \cr
"$'''''$" & $^{\hbox{\sevenlmmath\charhex2032
  \hskip-.15em\charhex2032
  \hskip-.15em\charhex2032
  \hskip-.15em\charhex2032
  \hskip-.15em\charhex2032}}$
  & $(\hbox{U+2032})\times5$\cr
$\vdots$ & $\vdots$ & $\vdots$ \cr
$(\hbox{"'"})\times N$ & $(^{\hbox{\sevenlmmath\charhex2032}})\times N$ &
$(\hbox{U+2032})\times N$\hbox to 20pt{\quad$(N>4)$\hss} \cr
}}$$
However, some OpenType math fonts don't contain some of the characters above. 
For example, there is no U+2032, U+2033 or U+2034 in Erewhon Math. 
When using such fonts, you can ``turn off'' the Unicode primes easily 
by inputing the following line {\it after} loading the package:
\begintt
\unicodeprimesoff
\endtt
Then when you input ``"'"'' $n$ times you will get $n$ primes, 
and each prime's Unicode character slot is U+2032, even when $n\leq 4$.

If the primes contain more than one single prime encoded U+2032, 
a negative math skip will inserted between every two single primes. 
This math skip is defined as "\betweenprimeskip" and its default value 
is "-2.7mu", which is proper for Latin Modern Math. To change the value 
of "\betweenprimeskip" is just like change any math skip, for example,
\begintt
\betweenprimeskip=-1mu
\endtt
This line should also be written {\it after} loading the package.

\section{Using multiple math fonts}
You can use more than one OpenType math fonts in math mode. 
This is the method to set multiple math fonts:
$$\vbox{%
  \hbox{"\def\mathalphafontname{"\<font family name>"}"}%
  \hbox{"\def\mathdelimiterfontname{"\<font family name>"}"}%
  \hbox{"\def\mathordfontname{"\<font family name>"}"}%
  \hbox{"\def\mathopfontname{"\<font family name>"}"}%
  \hbox{"\def\mathbinfontname{"\<font family name>"}"}%
  \hbox{"\def\mathaccentfontname{"\<font family name>"}"}%
}$$
Such definitions should be written {\tenit before} "\input"ing the package. 
For example, 
\begintt
\def\mathfontname{XITS Math}
\def\mathalphafontname{TeX Gyre Pagella Math}
\input unimath-plain-xetex
\endtt
Then your math font will be set as XITS Math and the font of variable family 
(numbers, Latin and Greek letters) will be set as \TeX\ Gyre Pagella Math.

"\mathalphafontname" will influence the font of numbers ("0"--"9"), Latin 
letters ("A"--"Z", "a"--"z") and Greek letters ("\alpha" and so on). 

"\mathdelimiterfontname" will influence the font of math delimiters, 
including some open symbols, close symbols and some ordinary symbols 
which can be used as delimiters like "\{", "\}", "\vert" and so on. 
Horizontal delimiters (or very long accents) are also influenced by 
"\mathdelimiterfontname".

"\mathordfontname" will influence the font of non-delimiter ordinary 
symbols, punctuations and ``"!"''. For example, ``","'', ``":"'' and 
"\colon"'s font will be influenced by it.

"\mathopfontname" will influence the font of large operators like "\sum".

"\mathbinfontname" will influence the font of binary operators and relations 
like ``"+"'' and ``"="''.

"\mathaccentfontname" will influence the font of math accents like "\dot".

\closeout\tocout
\bye