Debian Codegraph @

texmf-dist/doc/xelatex/mathspec/mathspec.tex

raw
1 \documentclass{ltxdockit}
2
3 \usepackage{amsmath}
4 \usepackage{mathspec}
5 \usepackage{xltxtra,eukdate}
6
7 \renewcommand\contentsname{table of contents}
8 \addtokomafont{sectionentry}{\rmfamily\mdseries\scshape\lowercase}
9 \addtokomafont{section}{\rmfamily\mdseries\scshape\color{spot}\lowercase}
10 \addtokomafont{subsection}{\rmfamily\mdseries\itshape\color{spot}}
11 \makeatletter
12 \def\@seccntformat#1{\protect\makebox[0pt][r]{\csname the#1\endcsname\hspace{\marglistsep}}}
13 \makeatother
14 \hypersetup{linkcolor=black,urlcolor=black}
15
16 \definecolor{spot}{rgb}{0.6,0,0}
17 \definecolor{boxframe}{rgb}{0.6,0,0}
18 \definecolor{boxfill}{rgb}{1,.95,.95}
19
20 \lstnewenvironment{example}[1][]
21 {\lstset{%
22 aboveskip=1.5\lstenvsep,
23 xleftmargin=3pt,
24 xrightmargin=3pt,
25 frame=single,
26 backgroundcolor=\color{boxfill},
27 rulecolor=\color{boxframe},
28 framesep=2.5pt,
29 framerule=0.5pt,
30 style=latex,#1}}
31 {}
32
33 \linespread{1.05}
34 \setmainfont[
35 Extension = .otf,
36 UprightFont = *-regular,
37 ItalicFont = *-italic,
38 BoldFont = *-bold,
39 BoldItalicFont = *-bolditalic,
40 Numbers=OldStyle,
41 Scale=MatchLowercase,
42 ]{texgyrepagella}
43 \setallsansfonts[
44 Extension = .otf,
45 UprightFont = *-Regular,
46 ItalicFont = *-Italic,
47 BoldFont = *-Bold,
48 BoldItalicFont = *-BoldItalic,
49 Numbers={OldStyle,Proportional},
50 Scale=MatchLowercase
51 ]{UniversalisADFStd}
52 \setallmonofonts[
53 Scale=MatchLowercase,
54 BoldFont=Inconsolatazi4-Bold.otf,
55 AutoFakeSlant]{Inconsolatazi4-Regular.otf}
56 \setmathsfont(Digits,Latin)[
57 Scale = 0.85,
58 Extension = .otf ,
59 UprightFont = *-Regular,
60 ItalicFont = *-Italic,
61 BoldFont = *-Bold,
62 BoldItalicFont = *-BoldItalic,
63 ]{LibreBaskerville}
64 \setmathsfont(Greek)[
65 Extension = .otf ,
66 UprightFont = *-Regular,
67 ItalicFont = *-Italic,
68 BoldFont = *-Bold,
69 BoldItalicFont = *-BoldItalic,
70 Scale=MatchLowercase,
71 ]{STIX}
72 \setmathrm[Scale=MatchLowercase]{LibreBaskerville-Regular.otf}
73
74 \exchangeforms{phi}
75 \setminwhitespace[750]
76
77 \newfontfamily\MathematicalPi{STIXMath-Regular.otf}
78 \newcommand\MP[1]{{\MathematicalPi #1}}
79
80 \makeatletter
81 \setlogokern{eT}{-0.074em}
82 \setlogokern{Xe}{-0.063em}
83 \setlogokern{eL}{-0.068em}
84 \setlogokern{La}{-0.305em}
85 \setlogokern{aT}{-0.07313em}
86 \setlogokern{X2}{0.101em}
87 \setlogodrop{0.131em}
88 \setLaTeXa{%
89 \ifdim\fontdimen\@ne\font=\z@\else
90 \addfontfeature{FakeSlant=\the\fontdimen\@ne\font}%
91 \fi
92 \if b\expandafter\@car\f@series\@nil
93 \check@mathfonts\fontsize\sf@size\z@
94 \math@fontsfalse\selectfont A%
95 \else
96 \scshape a%
97 \fi}
98 \setLaTeXee{\mbox{$\epsilon$}}
99 \seteverylogo{%
100 \if b\expandafter\@car\f@series\@nil%
101 \setlogokern{Te}{-0.075em}%
102 \setlogokern{eX}{-0.068em}%
103 \else
104 \setlogokern{Te}{-0.084em}%
105 \setlogokern{eX}{-0.063em}%
106 \fi}
107 \newcommand\tablerowa[3]{$\csname #1#3\endcsname$ & \cmd{#1#3} & $\csname #2#3\endcsname$ & \MakeLowercase{\cmd{#2#3}}}
108 \newcommand\tablerowb[1]{$\csname #1\endcsname$ & $\csname var#1\endcsname$ & \cmd{var#1}}
109 \def\topbottomrule{\noalign{\ifnum0=`}\fi
110 \@aboverulesep=\aboverulesep
111 \global\@belowrulesep=\belowrulesep
112 \global\@thisruleclass=\@ne
113 \@ifnextchar[{\@BTrule}{\@BTrule[\heavyrulewidth]}}
114 \renewcommand{\topfraction}{.75}
115 \renewcommand{\bottomfraction}{.75}
116 \renewcommand{\textfraction}{.25}
117 \renewcommand{\floatpagefraction}{.75}
118 \setcounter{topnumber}{9}
119 \setcounter{bottomnumber}{9}
120 \setcounter{totalnumber}{20}
121 \setcounter{dbltopnumber}{9}
122 \def\fps@figure{htb!}
123 \g@addto@macro\table{\collecttable}
124 \newlength\captionwidth
125 \newlength\mincaptionwidth
126 \setlength\mincaptionwidth{50mm}
127 \long\def\collecttable#1\caption#2{%
128 \toks@{#1}%
129 \sbox\z@{\ignorespaces\the\toks@\unskip}%
130 \setlength\captionwidth{\wd\z@}%
131 \ifdim\captionwidth <\mincaptionwidth
132 \captionwidth\mincaptionwidth
133 \fi
134 \caption{#2}%
135 \centerline{\box\z@}}
136 \def\formatcaption#1:#2\@nil{{\spotcolor\scshape\MakeLowercase{#1}}\hspace{1em}#2}
137 \long\def\@makecaption#1#2{%
138 \vskip\abovecaptionskip
139 \sbox\@tempboxa{\formatcaption#1:#2\@nil}%
140 \ifdim\wd\@tempboxa >\captionwidth
141 \centerline{\parbox[t]{\captionwidth}{\formatcaption#1:#2\@nil}}%
142 \else
143 \global\@minipagefalse
144 \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
145 \fi
146 \vskip\belowcaptionskip}
147 \newenvironment{advanced}
148 {\begin{minipage}[t]{\textwidth}\begin{description}\item[\rmfamily\mdseries\scshape\footnotesize\spotcolor advanced]\itshape\footnotesize}
149 {\end{description}\end{minipage}}
150 \makeatother
151
152 \usepackage{eukdate}
153 \usepackage{booktabs}
154 \usepackage{multirow}
155 \usepackage{shortvrb}
156 \MakeShortVerb{|}
157
158 \newcommand\permitbreak{\linebreak[0]}
159 \newrobustcmd*{\sprm}[1]{%
160 \mbox{%
161 {\verbatimfont(}%
162 \prm{#1}%
163 {\verbatimfont)}}}
164
165 \hypersetup{
166 pdftitle={The mathspec package},
167 pdfsubject={Font selection for mathematics with XeLaTeX},
168 pdfauthor={Andrew Gilbert Moschou}}
169
170 \title{The \textsf{\spotcolor mathspec} package\\[0.25em]\mdseries\itshape\normalsize Font selection for mathematics with \XeLaTeX\\[1ex]\mdseries\upshape version 0.2b}
171 \author{Andrew Gilbert Moschou\thanks{v0.2b update by Will Robertson (\texttt{[email protected]}).}\\\texttt{[email protected]}
172 }
173 \makeatletter\let\@today\today\def\today{\scshape\MakeLowercase{\@today}}\makeatother
174
175 \hyphenation{in-com-pa-ti-ble Hoef-ler ma-the-ma-tics des-pite}
176
177 \frenchspacing
178 \begin{document}
179 \maketitle
180
181 \tableofcontents
182
183 \section{Preamble}
184
185 This document describes the \sty{mathspec} package, a package that provides an interface to select ordinary text fonts for typesetting mathematics with \XeLaTeX. It relies on \sty{fontspec} to work and familiarity with \sty{fontspec} is advised. I thank Will Robertson for his useful advice and suggestions!
186
187 The package is developmental and later versions might to be incompatible with this version. This version is incompatible with earlier versions. The package requires at least version 0.9995 of \XeTeX.
188
189 Should you be using this package? If you are using another \LaTeX\ package for some mathematics font, then you should not (unless you know what you are doing). If you want to use Asana Math or Cambria Math (or the final release version of the \acr{STIX} fonts) then you should be using |unicode-math|.
190
191 Some paragraphs in this document are marked \textsc{\spotcolor advanced}. Such paragraphs may be safely ignored by basic users.
192
193 \section{Introduction}
194
195 Since Jonathan Kew released \XeTeX, an extension to \TeX\ that permits the inclusion of system wide Unicode fonts and modern font technologies in \TeX\ documents, users have been able to easily typeset documents using readily available fonts such as Hoefler Text and Times New Roman (This document is typeset using Sabon \acr{LT} Std). Will Robertson’s \XeLaTeX\ package \sty{fontspec} provides an automatic font selection process for such fonts. Still, mathematics typesetting has not benefited from this development to the same extent as text typesetting, which is not surprising given the font requirements that are demanded.
196
197 Will Robertson has in development a package \sty{unicode-math} that is used to typeset mathematics using some font that has an OpenType mathematics table. Currently, the only two that are available are Cambria Math, a new design, by Microsoft and Asana Math, ultimately based on Hermann Zapf’s Palatino, by Apostolos Syropoulos. It is expected that the \acr{STIX} fonts, based on Times, may also be used.
198
199 Thus, it is evident that a book designer is confronted with such narrow variety in mathematics typefaces, even considering already established \LaTeX\ fonts such as \acr{AMS} Euler (and Computer Modern, of course!) that are dedicated to providing mathematics typefaces; and the book designer is challenged to find a suitable pair of matching typefaces for mathematics and body text.
200
201 This package provides mathematics alphabets in any of the same typefaces that are available to \XeTeX, using \sty{fontspec} as a back end. Other mathematics symbols such as arrows and operators, whose designs are largely independent of an alphabetic typeface, can be taken from collections like MnSymbol or Computer Modern and are not covered by the scope of this package.
202
203 \section{Implementation}
204
205 \begin{ltxsyntax}
206
207 \cmditem{usepackage}\oprm{\sty{mathspec} and \sty{fontspec} options}|{mathspec}|
208
209 \noindent To use the package, put \cmd{usepackage}|{mathspec}| in the preamble of the document. It is not necessary to put \cmd{usepackage}|{fontspec}| because \sty{mathspec} will ensure that \sty{fontspec} is loaded anyway. To load \sty{fontspec} with some options, parse them through \sty{mathspec}, for example, \cmd{usepackage}|[quiet]|\permitbreak|{mathspec}| is equivalent to:
210 \begin{verbatim}
211 \usepackage[quiet]{fontspec}
212 \usepackage{mathspec}
213 \end{verbatim}
214
215 Actually, \sty{mathspec} ordinarily loads \sty{fontspec} with the \opt{no-math} option. To cancel this, explicitly use the \opt{math} option: e.g.\ \cmd{usepackage}|[math]{mathspec}|.
216
217 \end{ltxsyntax}
218
219 \section{Setting fonts}
220
221 \subsection{Letters and Digits}
222
223 \begin{ltxsyntax}
224
225 \cmditem{setmathsfont}(sets)[shapes, font features]{font name}
226 \cmditem{setmathfont}(sets)[shapes, font features]{font name}
227
228 This single command is used to entirely describe the desired font for some use. For each character set (Digits, Latin, Greek), there is a (possibly shared) \cmd{setmathsfont} command. The command can be used only in the preamble. Then, there can be only one typeface for each character set in a single document.
229
230 For basic use, \sprm{sets} is mandatory. \oprm{shapes, font features} is optional and may be omitted.
231
232 \begin{marglist}
233
234 \item[\prm{sets}]
235 A comma separated value list of any of the following: \opt{Digits}, \opt{Latin}, \opt{Greek}.
236
237 \begin{advanced}
238 \prm{sets} may also take the value \opt{Special}. \sprm{sets} is actually optional and if it is omitted, then |(Special)| is asumed. For basic use, it is safe to ignore \opt{Special}, so \sprm{sets} would effectively be a mandatory argument.
239
240 If the value of \prm{sets} is \opt{Special}, then {\spotcolor\cmd{eu@ScopeSet@Special}\oprm{font features}\mprm{font name}} is executed, but this command is provided by \sty{mathspec} to gobble its arguments (that is, it does nothing). The command {\spotcolor\cmd{eu@ScopeSet@Special}} maybe predefined before \sty{mathspec} is loaded (or redefined after \sty{mathspec} is loaded) to cause the command to do something else. This effectively means that
241 {\spotcolor\cmd{setmathsfont}\sprm{sets}\oprm{font features}\mprm{font name}}
242 is a \sty{mathspec} command, but
243 {\spotcolor\cmd{setmathsfont}\oprm{font features}\mprm{font name}}
244 is an external command which another package might use.
245 \end{advanced}
246
247 \item[\prm{shapes}]
248 A comma separated value list of keys and their values. The permitted keys and their values are:
249
250 \begin{optionlist}
251
252 \optitem[]{Uppercase}{\opt{Regular}, \opt{Italic}, \opt{Plain}}
253
254 \optitem[]{Lowercase}{\opt{Regular}, \opt{Italic}, \opt{Plain}}
255
256 \optitem[]{Arabic}{\opt{Regular}, \opt{Italic}, \opt{Plain}}
257
258 \end{optionlist}
259 To set the symbols in an upright font, choose \opt{Regular}. To set the symbols in an italic font, choose \opt{Italic}. Choose \opt{Plain} to indicate that no font is assignment is to be performed by \sty{mathspec}, so that the symbols will remain with their default font (usually Computer Modern). If a value’s key is omitted, its default value, which depends on the \prm{set}, as shown in table~\ref{tab:defaultshapes} is chosen.
260
261 The default values are very good and you would be wise not to change the shapes for the \opt{Latin} and \opt{Digit} sets. The \opt{Greek} shapes may be changed, if needed, to adhere to some particular style, for example all \opt{Italic} or all \opt{Regular}.
262
263 \begin{table}\centering
264 \begin{tabular}{@{}ccc@{}}\topbottomrule
265 Set & Key & Default value \\\midrule
266 \opt{Digits} & \opt{Arabic} & \opt{Regular}\\
267 \opt{Latin} & \opt{Uppercase} & \opt{Italic}\\
268 \opt{Latin} & \opt{Lowercase} & \opt{Italic}\\
269 \opt{Greek} & \opt{Uppercase} & \opt{Regular}\\
270 \opt{Greek} & \opt{Lowercase} & \opt{Italic}\\\bottomrule
271 \end{tabular}
272 \caption{The default shapes for the symbol sets.}\label{tab:defaultshapes}
273 \end{table}
274
275 \item[\smash{\begin{tabular}[t]{@{}r@{}}\prm{font features}\\\prm{font name}\end{tabular}}]
276 \prm{font features} and \prm{font name} follow directly from \sty{fontspec} to select the font and its features. See \sty{fontspec}’s documentation for details.
277
278 \end{marglist}
279
280 Note that if \prm{sets} contains multiple sets, the command is iterated over each set. Each of these iterations share the same \prm{shapes and font features} and \prm{font name}. If you require that the different sets have individual options and font names, they must be specified in separate commands. However, if a value’s key is omitted, the individual default values are still applied.
281
282 These same command options follow through to the other commands of this package.
283
284 \end{ltxsyntax}
285
286 \subsection{Symbols}
287
288 There is currently no way to set the font for general mathematical symbols such as:
289 \begin{center}
290 \MP =, \MP ×, \MP ↦, \MP ∂, \MP ∅, \MP ∈, \MP ∫, \MP ⊂
291 \end{center}
292 You can try the package \sty{MnSymbol}, which has greater (and more uniform) coverage, with the package option \opt{MnSymbol}, e.g.\ \cmd{usepackage}|[MnSymbol]|\permitbreak|{mathspec}|. Note that \sty{MnSymbol} is a third party package by Achim Blumensath, which can only be used if additionally installed.
293
294 \subsection{Examples}
295
296 The following command:
297 \begin{example}
298 \setmathsfont(Digits,Latin,Greek)
299 [Numbers={Lining,Proportional}]{Minion Pro}
300 \end{example}
301 is equivalent to:
302 \begin{example}
303 \setmathsfont(Digits)[Numbers={Lining,Proportional}]{Minion Pro}
304 \setmathsfont(Latin)[Numbers={Lining,Proportional}]{Minion Pro}
305 \setmathsfont(Greek)[Numbers={Lining,Proportional}]{Minion Pro}
306 \end{example}
307 and indicates that all digits, Latin and Greek characters are to be set in Minion Pro with lining, proportional digits, with digits and uppercase Greek in regular and Latin and lowercase Greek in italic, which are the default shapes.
308
309 The following command:
310 \begin{example}
311 \setmathsfont(Digits,Greek)
312 [Uppercase=Plain,Lowercase=Regular,Scale=MatchLowercase]
313 {GFS Porson}
314 \end{example}
315 is equivalent to:
316 \begin{example}
317 \setmathsfont(Digits)
318 [Uppercase=Plain,Lowercase=Regular,Scale=MatchLowercase]{GFS Porson}
319 \setmathsfont(Greek)
320 [Uppercase=Plain,Lowercase=Regular,Scale=MatchLowercase]{GFS Porson}
321 \end{example}
322 and indicates that all digits and lowercase Greek charaters are to be set in GFS Porson, scaled so that its x-height matches the main font’s, in regular. Uppercase Greek characters remain unchanged (probably from Computer Modern).
323
324 \subsection{Declaring alphabets}
325
326 The mathematics alphabets like \cmd{mathrm} and \cmd{mathcal} can be set using these commands.
327
328 \begin{ltxsyntax}
329
330 \cmditem{setmathrm}[font features]{font name}
331
332 This command defines \cmd{mathrm}, \cmd{mathit}, \cmd{mathbf} and the font for operators like $\sin$ and $\log$.
333
334 \cmditem{setmathsf}[font features]{font name}
335
336 This command defines \cmd{mathsf}.
337
338 \cmditem{setmathtt}[font features]{font name}
339
340 This command defines \cmd{mathtt}.
341
342 \cmditem{setmathcal}[font features]{font name}
343
344 This command defines \cmd{mathcal}.
345
346 \cmditem{setmathbb}[font features]{font name}
347
348 This command defines \cmd{mathbb}.
349
350 \cmditem{setmathfrak}[font features]{font name}
351
352 This command defines \cmd{mathfrak}.
353
354 \end{ltxsyntax}
355
356 \subsection{Shorthands}
357
358 These commands are useful to save typing the same information multiple times, if the same font is used for different purposes.
359
360 \begin{ltxsyntax}
361
362 \cmditem{setallmainfonts}(sets)[shapes, font features]{font name}
363
364 This command is equivalent to:
365
366 \cmd{setmainfont}\oprm{font features}\mprm{font name}\\
367 \cmd{setmathsfont}\sprm{sets}\oprm{shapes, font features}\mprm{font name}\\
368 \cmd{setmathrm}\oprm{font features}\mprm{font name}
369
370 If \sprm{sets} is omitted, then |(Digits,Latin,Greek)| is assumed.
371
372 \cmditem{setprimaryfont}[shapes, font features]{font name}
373
374 This command is equivalent to:
375
376 \cmd{setallmainfonts}|(Digits,Latin)|\oprm{shapes, font features}\mprm{font name}
377
378 \cmditem{setallsansfonts}[font features]{font name}
379
380 This command is equivalent to:
381
382 \cmd{setsansfont}\oprm{font features}\mprm{font name}\\
383 \cmd{setmathsf}\oprm{font features}\mprm{font name}
384
385 \cmditem{setallmonofonts}[font features]{font name}
386
387 This command is equivalent to:
388
389 \cmd{setmonofont}\oprm{font features}\mprm{font name}\\
390 \cmd{setmathtt}\oprm{font features}\mprm{font name}
391
392 \end{ltxsyntax}
393
394 \subsection{A further example}
395
396 This document used to be typeset with the following:
397
398 \begin{example}
399 \setmainfont[Numbers=OldStyle]{Sabon LT Std}
400 \setallsansfonts[Numbers={OldStyle,Proportional},Scale=MatchLowercase]{Candara}
401 \setallmonofonts[Numbers=OldStyle,Scale=MatchLowercase]{Consolas}
402 \setmathsfont(Digits,Latin)[Scale=MatchLowercase]{Bembo MT}
403 \setmathsfont(Greek)[Scale=MatchLowercase]{STIXGeneral}
404 \setmathrm{Sabon LT Std}
405 \exchangeforms{phi}
406 \setminwhitespace[750]
407 \end{example}
408
409 The main text font is Sabon \acr{LT} Std with old style figures. The sans serif font is Candara with old style, proportional figures and the monospaced font is Consolas with old style figures, both scaled to match Sabon \acr{LT} Std in x-height.
410
411 The mathematics font for digits and Latin symbols is Bembo \acr{MT} and for Greek symbols STIXGeneral, both scaled to match Sabon \acr{LT} Std in x-height.
412
413 The |\mathrm|, |\mathit| and |\mathbf| alphabets are set in Sabon \acr{LT} Std.
414
415 Finally, the normal and variant forms of Greek lowercase phi are exchanged, see section~\ref{sec:greek} Greek symbols, and the minimum white space on each side of a spaced character is $750\,\mathrm{mmu}$, see section~\ref{sec:glyphbounds} Glyph bounds.
416
417 \section{Greek symbols}\label{sec:greek}
418
419 For reference, the Greek alphabet and variant letter forms are given in table~\ref{tab:greek}. Despite its name, \cmd{varsigma}~$\varsigma$ is not a variant form of \cmd{sigma}~$\sigma$, it is the final form. Digamma~$\Digamma\digamma$ is an obsolete letter of the alphabet, originally placed between epsilon~$\Epsilon\epsilon$ and zeta~$\Zeta\zeta$.
420
421 \begin{table}
422 \begin{tabular}{@{}c@{}}\topbottomrule
423 \begin{tabular}{@{}clcl@{}}
424 \multicolumn{2}{@{}c}{Uppercase} & \multicolumn{2}{c@{}}{Lowercase}\\\midrule
425 \tablerowa Aa{lpha}\\\tablerowa Bb{eta}\\\tablerowa Gg{amma}\\\tablerowa Dd{elta}\\
426 \tablerowa Ee{psilon}\\\tablerowa Zz{eta}\\\tablerowa Ee{ta}\\\tablerowa Tt{heta}\\
427 \tablerowa Ii{ota}\\\tablerowa Kk{appa}\\\tablerowa Ll{ambda}\\\tablerowa Mm{u}\\
428 \tablerowa Nn{u}
429 \end{tabular}
430 \hspace{1em}
431 \begin{tabular}{@{}rlrl@{}}
432 \multicolumn{2}{@{}c}{Uppercase} & \multicolumn{2}{c@{}}{Lowercase}\\\midrule
433 \tablerowa Xx{i}\\\tablerowa Oo{micron}\\\tablerowa Pp{i}\\\tablerowa Rr{ho}\\
434 \multirow{2}*{$\Sigma$} & \multirow{2}*{\cmd{Sigma}} & $\varsigma$ & \cmd{varsigma}\\
435 && $\sigma$ & \cmd{sigma}\\\tablerowa Tt{au}\\\tablerowa Uu{psilon}\\\tablerowa Pp{hi}\\
436 \tablerowa Cc{hi}\\\tablerowa Pp{si}\\\tablerowa Oo{mega}\\\tablerowa Dd{igamma}
437 \end{tabular}\\\topbottomrule
438 \begin{tabular}{@{}ccl@{}}
439 Normal form & \multicolumn{2}{c@{}}{Variant form}\\\midrule
440 \tablerowb{beta}\\\tablerowb{epsilon}\\\tablerowb{theta}\\\tablerowb{kappa}
441 \end{tabular}
442 \hspace{1em}
443 \begin{tabular}{@{}ccl@{}}
444 Normal form & \multicolumn{2}{c@{}}{Variant form} \\\midrule
445 \tablerowb{pi}\\\tablerowb{rho}\\\tablerowb{phi}\\\tablerowb{Theta}
446 \end{tabular}\\\bottomrule
447 \end{tabular}
448 \caption{The Greek alphabet and variant letter forms with control sequences.\label{tab:greek}}
449 \end{table}
450
451 \begin{ltxsyntax}
452
453 \item
454 \begin{marglist}\item
455 \begin{advanced}
456 Initially, \sty{mathspec} defines control sequences for the Greek characters that are absent in Computer Modern, because they are similar in form to Latin characters, from {\addfontfeature{FakeSlant=\the\fontdimen1\font}\scshape ascii}, thus control sequences like {\spotcolor\cmd{Alpha}} and {\spotcolor\cmd{omicron}} are defined. Any variant forms that are absent become equivalent to the normal forms. The meanings of these control sequences are preserved by other control sequences of the same names prefixed with |eu@cm@| (e.g.\ {\spotcolor\cmd{eu@cm@alpha}}), which may be recalled after the Greek mathematics font is changed.
457 \end{advanced}
458 \end{marglist}
459
460 %{\itshape\footnotesize\csitem{\smash{\begin{tabular}[t]{@{}r@{}}|eu@cm@alpha|\\\cmd{eu@cm@beta}\\\color{black}\rmfamily etc.\end{tabular}}}
461 %\acr{\spotcolor ADVANCED}\quad Initially, \sty{mathspec} defines control sequences for the Greek characters that are absent in Computer Modern, because they are similar in form to Latin characters, from {\addfontfeature{FakeSlant=\the\fontdimen1\font}\scshape ascii}, thus control sequences like \cmd{Alpha} and \cmd{omicron} are defined. Any variant forms that are absent become equivalent to the normal forms. The meanings of these control sequences are preserved by other control sequences of the same names prefixed with |eu@cm@| (e.g.\ \cmd{eu@cm@alpha}), which may be recalled after the Greek mathematics font is changed.}
462
463 \cmditem{exchangeforms}{list}
464
465 \begin{marglist}
466
467 \item[\prm{list}] A comma separated value list of any of the names for the Greek symbols which have variant forms: |beta|, |epsilon|, |theta|, |kappa|, |pi|, |rho|, |phi|, |Theta|.
468
469 \end{marglist}
470
471 Some authors might prefer the normal and variant forms of a symbol to be exchanged. For example, I prefer \cmd{phi} to print the orthotic phi ‘$\phi$’ and \cmd{varphi} the cursive phi ‘$\varphi$’, contrary to many text fonts. To exchange the forms of any symbol, include its name in the list.
472
473 \cmditem{normalisevarforms}[list]
474 \cmditem{normalizevarforms}[list]
475
476 \begin{marglist}
477
478 \item[\prm{list}] As above, a comma separated value list of any of the names for the Greek symbols which have variant forms: |beta|, |epsilon|, |theta|, |kappa|, |pi|, |rho|, |phi|, |Theta|.
479
480 If \oprm{list} is omitted, then |[beta,epsilon,theta,kappa,pi,rho,phi,Theta]|, that is every such symbol, is assumed.
481
482 \end{marglist}
483
484 Since not all fonts contain all variant forms, there might be the odd variant letter that remains in Computer Modern while other Greek letters have changed font. For these characters, the command \cmd{normalisevarforms} (or \cmd{normalizevarforms}) will cause the listed symbols that are absent from the font to be equivalent to their corresponding normal forms. If a symbol is listed which is included in the font, then it is ignored.
485
486 Note that this command only adjusts the characters that are absent in the font. Of course, this might mean that, for example, |\vartheta| and |\theta| would print the same glyph, which would be dubious if they are to be used in the same document, with different meanings.
487
488 \end{ltxsyntax}
489
490 \makeatletter
491 It should be noted that \cmd{epsilon} prints the lunate epsilon~‘$\eu@cm@epsilon$’ and \cmd{varpepsilon} prints the usual (double loop) epsilon~‘$\eu@cm@varepsilon$’ in Plain \TeX\ and \LaTeX. This is in contrast to Unicode text fonts, which contain the lunate style epsilon separately from the Greek alphabet among variant letter forms and symbols (where Unicode assigns ‘Greek Lunate Epsilon Symbol’). The definition of \cmd{LaTeXe}, which prints ‘\LaTeXe’ uses \cmd{varepsilon} and care should be taken to ensure that \cmd{LaTeXe} still uses the usual epsilon either by using one of the methods that were presented in this section or by redefining \cmd{LaTeXe} (possibly using my \sty{metalogo} package), because {\setLaTeXee{\mbox{$\varepsilon$}}‘\LaTeXe’} is not as good as {\setLaTeXee{\mbox{$\epsilon$}}‘\LaTeXe’}.
492 \makeatother
493
494 \section{Glyph bounds}\label{sec:glyphbounds}
495
496 In using this package to set text fonts for mathematics, there are issues with glyph bounds (similar to italic correction), as illustrated in the equations:
497 \begin{example}
498 \begin{align}
499 f(x) &= \sum_{n = -\infty}^\infty c_{n}e^{jnx} \\
500 c_{n} &= \frac{1}{2π}\int_{-π}^{π}f(x)e^{-jnx}\,\mathrm dx
501 \end{align}
502 \end{example}
503 \begin{align}
504 f(x) &= \sum_{n = -\infty}^\infty c_{n}e^{jnx}\label{eq:1}\\
505 c_{n} &= \frac 1{2π}\int_{-π}^{π}f(x)e^{-jnx}\,\mathrm dx\label{eq:2}
506 \end{align}
507 where the function $f$ is to close the the parenthesis $($ and the exponent $jnx$ is too close to its base $e$ that there is in fact a collision. The reason is that the font has metrics that are suitable for use in text, but not for mathematics.
508
509 Comparing the alphabets typeset in Computer Modern italic, in table~\ref{tab:cm}, it is shown that many characters have greater space around them in the mathematics version, which does not exist in the text version.
510
511 \begin{table}
512 \begin{tabular}{@{}rl@{}}\topbottomrule
513 Text & \usefont{OT1}{cmr}{m}{it}abcdefghijklmnopqrstuvwxyz\\
514 Mathematics & $\mathnormal{abcdefghijklmnopqrstuvwxyz}$\\\bottomrule
515 \end{tabular}
516 \caption{Computer Modern Italic in text and mathematics.\label{tab:cm}}
517 \end{table}
518
519 \begin{ltxsyntax}
520
521 \item["]\prm{character}
522
523 It is necessary to indicate exactly where additional space needs to be inserted. By putting |"| before a character, the character will be typeset with additional space inserted on both sides of it.
524
525 \cmditem{"}\prm{string}{\spotcolor|"|}
526
527 For multiple adjacent characters, each need not have a |"| in front of it, but it the characters may be surrounded by \cmd{"} before and |"| after. That is, for example |\"abcde"| is equivalent to |"a"b"c"d"e|.
528
529 Note that \prm{character} must be one of the symbols that are listed in table~\ref{tab:symbols}. \prm{string} must one or more such characters adjacent to each other. So |\"xyz"| and |\sin"x| is okay, but |\"\sin x"| is not because \cmd{sin} is not a valid character. Also note that with Greek symbols, they can only be used if typed literally, not via control sequences, so |\cos"θ| is okay but |\cos"\theta| is not. Use of control sequences for Greek symbols is still perfectly acceptable because the spacings are built into the defintions of each (for example \cmd{alpha} is defined to expand to |{"α}| automatically).
530
531 \begin{table}
532 \begin{tabular}{@{}c@{}}\topbottomrule
533 $\"0123456789"$\\
534 $\"ABCDEFGHIJKLMNOPQRSTUVWXYZ"$\\
535 $\"abcdefghijklmnopqrstuvwxyz"$\\
536 $\"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩϜ"$\\
537 $\"αβγδεζηθικλμνξοπρςστυφχψωϝ"$\\
538 $\"ϐϑϕϖϰϱϵϴ"$\\\bottomrule
539 \end{tabular}
540 \caption{All valid characters for use with \texttt" and \texttt{\textbackslash"}…\texttt".\label{tab:symbols}}
541 \end{table}
542 Use of |"| and |\"| in mathematics mode does not interfere with their use in text mode for quotation marks and umlauts or diæreses: ‘"’ co\"operates, even with {\addfontfeature{Mapping=tex-text}``|Mapping=tex-text|"}.
543
544 \cmditem{setminwhitespace}\oprm{number}
545
546 Use this command to change the minimum allowed white space around such a spaced character. The unit of \prm{number} is millimu ($\mathrm{mmu}$), that is $\frac 1{1000}\,\mathrm{mu}$. Recall $18\,\mathrm{mu} = 1\,\mathrm{em}$.
547
548 The default \prm{number} is |500| which corresponds to $500\,\mathrm{mmu} = \frac{500}{1000}\,\mathrm{mu} = 0.5\,\mathrm{mu} = \frac 1{36}\,\mathrm{em}$.
549
550 Note that this value corresponds to the inserted spaces on both sides for each spaced character. If two adjacent characters are spaced, then the total minimum white space between the two characters is twice this value. The effect is shown in table~\ref{tab:stix}.
551
552 \begin{table}
553 \begin{tabular}{@{}rl@{}}\topbottomrule
554 Text & \fontspec[ItalicFont=LibreBaskerville-Italic.otf]{LibreBaskerville-Regular.otf}\itshape abcdefghijklmnopqrstuvwxyz\\
555 Mathematics & $\"abcdefghijklmnopqrstuvwxyz"$\\\bottomrule
556 \end{tabular}
557 \caption{Libre Baskerville in text and spaced mathematics.\label{tab:stix}}
558 \end{table}
559
560 \end{ltxsyntax}
561
562 Now, the spacing in equations~(\ref{eq:1}, \ref{eq:2}) are improved by:
563 \begin{example}
564 \begin{align}
565 "f\left("x\right) &= \sum_{"n = -\infty}^\infty"c_{"n}"e^{\"jnx"} \\
566 "c_{"n} &= \frac{1}{2"π}\int_{-"π}^"π"f\bigl("x\bigr)"e^{-\"jnx"}\,\mathrm d"x
567 \end{align}
568 \end{example}
569
570 \begin{align}
571 "f\left("x\right) &= \sum_{"n = -\infty}^\infty "c_{"n}"e^{\"jnx"}\\
572 "c_{"n} &= \frac 1{2"π}\int_{-"π}^{"π}"f\bigl("x\bigr)"e^{-\"jnx"}\,\mathrm d"x
573 \end{align}
574
575 Also note that the spacing is improved by replacing |(x)| with |\bigl(x\bigr)| (which you should be doing anyway). %% changed from \left..\right to \bigl..\bigr (WSPR)
576
577 \section{Compatability}
578
579 If \sty{amsmath} is required, it must be loaded earlier than \sty{mathspec}.
580
581 \pagebreak
582 \section{The package}
583
584 The package style file is printed in this section.
585
586 \begingroup
587 \footnotesize\ttfamily
588 \setbox0\hbox{0}
589 \global\dimen0\wd0
590 \endgroup
591
592 \lstset{
593 language=[LaTeX]TeX,
594 basicstyle=\footnotesize\ttfamily,
595 keywordstyle={},
596 commentstyle=\spotcolor\itshape,
597 numbers=left,
598 numberstyle=\footnotesize,
599 keepspaces=true,
600 basewidth=\dimen0,
601 columns=fullflexible,}
602
603 \lstinputlisting{mathspec.sty}
604
605 \noindent Exactly 1000 lines! How about that?
606
607 \pagebreak
608
609 \section{License}
610
611 \setlength\parindent{0pt}
612 \parskip 1em plus 1pt minus 1pt
613
614 © Andrew Gilbert Moschou 2009
615
616 This work may be distributed and/or modified under the
617 conditions of the \LaTeX\ Project Public License, either version 1.3\textit c
618 of this license or (at your option) any later version.
619 The latest version of this license is in:
620 \parskip 0pt plus 1pt
621 \begin{center}\ttfamily
622 http://www.latex-project.org/lppl.txt
623 \end{center}
624 and version 1.3\textit c or later is part of all recent distributions of \LaTeX.
625
626 \parskip 1em plus 1pt minus 1pt
627
628 This work has the \acr{LPPL} maintenance status ‘maintained’.
629
630 The Current Maintainer of this work is Andrew Gilbert Moschou.
631
632 This work consists of the files \sty{mathspec.sty} and \sty{mathspec.tex}.
633
634 \end{document}
635