Debian Codegraph @

texmf-dist/source/latex/iwonamath/iwonamath.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: iwonamath.dtx
4 % Copyright 2023 by Boris Veytsman
5 %
6 % It may be distributed and/or modified under the conditions of the
7 % LaTeX Project Public License (LPPL), either version 1.3c of this
8 % license or (at your option) any later version. The latest version
9 % of this license is in the file
10 %
11 % https://www.latex-project.org/lppl.txt
12 %
13 %<*driver>
14 \documentclass{l3doc}
15 \usepackage{iwonamath}
16 \usepackage{natbib, booktabs}
17 \usepackage[tableposition=top]{caption}
18 \begin{document}
19 \DocInput{\jobname.dtx}
20 \end{document}
21 %</driver>
22 % \fi
23 %
24 % \GetFileInfo{iwonamath.sty}
25 % \title{\pkg{iwonamath}---a scaled version of Iwona math fonts}
26 % \date{\fileversion, \filedate}
27 % \author{Boris
28 % Veytsman\thanks{\href{mailto:[email protected]}{[email protected]},
29 % \href{mailto:[email protected]}{[email protected]}}}
30 % \maketitle
31 % \begin{abstract}
32 % \LaTeX\ support for scaled Iwona math fonts for mixing with sans
33 % serif text fonts.
34 % \end{abstract}
35 % \begin{documentation}
36 %
37 %\section{User manual}
38 %\label{sec:ug}
39 %
40 %
41 % Iwona is a sans serif typeface by Janusz Marian Nowacki. It has a
42 % very good math support~\citep{iwona}. Package \pkg{iwona} integrates
43 % text and math fonts. However, the math fonts may provide
44 % interesting companions for other text fonts. To enable the
45 % combination, this package separates math fonts and provides tools
46 % for the package writers to mix and match them with text.
47 %
48 % \begin{variable}{
49 % options/light,
50 % options/condensed,
51 % options/scale,
52 % options/Scale,
53 % options/delimitershack,
54 % options/standardversion}
55 % The package has the following options:
56 % \begin{description}
57 % \item[light] whether the math fonts use the light version of Iwona,
58 % either |true| or |false| (default)
59 % \item[condensed] whether the math fonts use the condensed version of
60 % Iwona, either |true| or |false| (default).
61 % \item[scale] the scale of the fonts, a number (by default 1). The
62 % title cased |Scale| is the synonym for this key.
63 % \item[delimitershack] whether to use the hack to get \cs{lVert} and
64 % \cs{rVert} delimiters, absent in the original font (see
65 % \citep[\S~12.5.5]{TLC3}), either |true| (default) or |false|.
66 % \item[standardversions] whether to define standard versions |normal|
67 % and |bold|, either |true| (default) or |false|. If |false|, then
68 % the package does not define any math fonts, and it is up to the user
69 % to deploy \cmd{\DefineIwonaMathVersion} do define them.
70 % \end{description}
71 % \end{variable}
72 %
73 %
74 % \begin{function}{\DefineIwonaMathVersion}
75 % \begin{syntax}
76 % \cs{DefineIwonaMathVersion}\Arg{key/value pairs}
77 % \end{syntax}
78 % The main function of the package,
79 % \cmd{\DefineIwonaMathVersion} defines a new
80 % math version based on Iwona fonts.
81 % \end{function}
82 % The keys are the following (the defaults, where applicable,
83 % correspond to the package options):
84 % \begin{variable}{main/name,
85 % main/light,
86 % main/condensed,
87 % main/bold}
88 % \begin{description}
89 % \item[name] the name of the version. By default, either |normal|
90 % or |bold| depending on the |bold| key described below.
91 % \item[light] whether the math fonts use the light version of
92 % Iwona, either |true| or |false|
93 % \item[condensed] whether the math fonts use the condensed version of
94 % Iwona, either |true| or |false|.
95 % \item[bold] whether we define a bold version, either |true| or
96 % |false| (default)
97 % \end{description}
98 % \end{variable}
99 %
100 % For the boolean keys the setting |=true| can be omitted, so
101 % |\DefineIwonaMathVersion{light=true}| and
102 % |\DefineIwonaMathVersion{light}| are equivalent
103 %
104 % Note that in the current implementation the parameters |scale| and
105 % |delimitershack| are the same for all versions defined.
106 %
107 % For example, the following invocation defines four math versions,
108 % |normal|, |bold|, |condensed| and |boldcondensed|, based on Iwona
109 % light, scaled 1.2:
110 % \begin{verbatim}
111 % \usepackage[scale=1.2, light]{iwonamath}
112 % \DefineIwonaMathVersion{name=condensed,
113 % condensed=true}
114 % \DefineIwonaMathVersion{name=boldcondensed,
115 % bold=true, condensed=true}
116 % \end{verbatim}
117 %
118 %
119 % \end{documentation}
120 %
121 % \begin{implementation}
122 %
123 % \section{Implementation}
124 % \label{sec:impl}
125 %
126 %
127 %
128 %\subsection{Setting up}
129 %\label{sec:settingup}
130 %
131 %
132 %
133 % First, we declare who we are:
134 % \begin{macrocode}
135 %<@@=iwonamath>
136 %<package>\ProvidesExplPackage {iwonamath}
137 %<fd>\ProvidesExplFile
138 %<ot1m>{ot1_FAMILY_m.fd}
139 %<ot1>{ot1_FAMILY_.fd}
140 %<oml>{oml_FAMILY_.fd}
141 %<oms>{oms_FAMILY_.fd}
142 %<omx>{omx_FAMILY_.fd}
143 %<cmsy>{omsiwonamathcmsy.fd}
144 %<package|fd>{2024-07-19} {1.1}
145 %<package|fd>{Scaled Iwona math fonts}
146 %<*package>
147 % \end{macrocode}
148 %
149 %
150 %
151 %
152 %\subsection{Options}
153 %\label{sec:optionSetting}
154 %
155 %
156 %
157 % \begin{variable}{\l_@@_scale_tl,
158 % \l_@@_mainlight_bool,
159 % \l_@@_maincondensed_bool,
160 % \l_@@_delimitershack_bool,
161 % \l_@@_standardversions_bool,
162 % options/light,
163 % options/condensed,
164 % options/scale,
165 % options/Scale,
166 % options/delimitershack,
167 % options/standardversion}
168 % \begin{macrocode}
169 \keys_define:nn { iwonamath/options }
170 {
171 scale .tl_set:N = \l_@@_scale_tl,
172 Scale .tl_set:N = \l_@@_scale_tl,
173 light .bool_set:N = \l_@@_mainlight_bool,
174 light .default:n = true,
175 condensed .bool_set:N = \l_@@_maincondensed_bool,
176 condensed .default:n = true,
177 delimitershack .bool_set:N = \l_@@_delimitershack_bool,
178 delimitershack .default:n = true,
179 standardversions .bool_set:N = \l_@@_standardversions_bool,
180 standardversions .default:n = true,
181 }
182
183 \keys_set:nn {iwonamath/options }
184 {
185 scale = 1,
186 light = false,
187 condensed = false,
188 delimitershack = true,
189 standardversions = true,
190 }
191 % \end{macrocode}
192 %
193 % \end{variable}
194 %
195 %
196 % Options processing
197 % \begin{macrocode}
198 \IfFormatAtLeastTF { 2022-06-01 }
199 { \ProcessKeyOptions [ iwonamath/options ] }
200 {
201 \RequirePackage { l3keys2e }
202 \ProcessKeysOptions { iwonamath/options }
203 }
204 % \end{macrocode}%
205 %
206 % \begin{variable}{\l_@@_versionname_tl,
207 % \l_@@_light_bool,
208 % \l_@@_condensed_bool,
209 % \l_@@_bold_bool,
210 % main/name,
211 % main/light,
212 % main/condensed,
213 % main/bold}
214 % Now the options for the main command
215 % \begin{macrocode}
216 \keys_define:nn { iwonamath/main }
217 {
218 name .tl_set:N = \l_@@_versionname_tl,
219 light .bool_set:N = \l_@@_light_bool,
220 light .default:n = true,
221 condensed .bool_set:N = \l_@@_condensed_bool,
222 condensed .default:n = true,
223 bold .bool_set:N = \l_@@_bold_bool,
224 bold .default:n = true,
225 }
226 % \end{macrocode}
227 %
228 % \end{variable}
229 %
230 %
231 %\subsection{Delimiters hack}
232 %\label{sec:delimiters}
233 %
234 % We add delimiters from |cmsy|, as discussed in
235 % \citep[\S~12.5.5]{TLC3}). We predefine the symbols for the standard
236 % versions just in case. The last line is suggested by Enrico
237 % Gregorio.
238 % \begin{macrocode}
239 \bool_if:NTF \l_@@_delimitershack_bool
240 {
241 \DeclareSymbolFont{symbols2}{OMS}{iwonamathcmsy}{m}{n}
242 \SetSymbolFont{symbols2} {bold}{OMS}{cmsy}{b}{n}
243 \DeclareMathDelimiter{\lVert}{\mathopen} {symbols2}{"6B}{largesymbols}{"0D}
244 \DeclareMathDelimiter{\rVert}{\mathclose}{symbols2}{"6B}{largesymbols}{"0D}
245 \DeclareMathDelimiter{\|}{\mathclose}{symbols2}{"6B}{largesymbols}{"0D}
246 }
247 {}
248 % \end{macrocode}
249 %
250 %
251 %\subsection{The main function}
252 %\label{sec:main}
253 %
254 %
255 % \begin{macro}{\DefineIwonaMathVersion}
256 % \begin{macrocode}
257 \DeclareDocumentCommand \DefineIwonaMathVersion { m }
258 {
259 \tl_clear:N \l_@@_versionname_tl
260 \bool_set_eq:NN \l_@@_light_bool \l_@@_mainlight_bool
261 \bool_set_eq:NN \l_@@_condensed_bool \l_@@_maincondensed_bool
262 \bool_set_false:N \l_@@_bold_bool
263 \keys_set:nn { iwonamath/main }
264 {
265 #1
266 }
267
268 \tl_if_empty:NTF \l_@@_versionname_tl
269 {
270 \bool_if:NTF \l_@@_bold_bool
271 {
272 \tl_set:Nn \l_@@_versionname_tl {bold}
273 }
274 {
275 \tl_set:Nn \l_@@_versionname_tl {normal}
276 }
277 }
278 {}
279
280 \tl_set:Nn \l_tmpa_tl {iwonamath}
281
282
283 \bool_if:NTF \l_@@_light_bool
284 {
285 \tl_set:Ne \l_tmpa_tl {\l_tmpa_tl l}
286 }
287 {}
288
289 \bool_if:NTF \l_@@_condensed_bool
290 {
291 \tl_set:Ne \l_tmpa_tl {\l_tmpa_tl c}
292 }
293 {}
294
295 \DeclareMathVersion{\l_@@_versionname_tl}
296 \bool_if:NTF \l_@@_bold_bool
297 {
298 \SetSymbolFont{operators}{\l_@@_versionname_tl}{OT1}{\l_tmpa_tl m} {b}{n}
299 \SetSymbolFont{letters} {\l_@@_versionname_tl}{OML}{\l_tmpa_tl} {b}{it}
300 \SetSymbolFont{symbols} {\l_@@_versionname_tl}{OMS}{\l_tmpa_tl}{b}{n}
301 \SetSymbolFont{largesymbols}{\l_@@_versionname_tl}{OMX}{\l_tmpa_tl}{b}{n}
302 \SetMathAlphabet\mathsf{\l_@@_versionname_tl}{OT1}{\l_tmpa_tl}{bx}{n}
303 \SetMathAlphabet\mathit{\l_@@_versionname_tl}{OT1}{\l_tmpa_tl}{bx}{it}
304 \SetSymbolFont{symbols2} {\l_@@_versionname_tl}{OMS}{iwonamathcmsy}{b}{n}
305 }
306 {
307 \SetSymbolFont{operators}{\l_@@_versionname_tl}{OT1}{\l_tmpa_tl m}{m}{n}
308 \SetSymbolFont{letters}{\l_@@_versionname_tl}{OML}{\l_tmpa_tl} {m}{it}
309 \SetSymbolFont{symbols}{\l_@@_versionname_tl}{OMS}{\l_tmpa_tl}{m}{n}
310 \SetSymbolFont{largesymbols}{\l_@@_versionname_tl}{OMX}{\l_tmpa_tl}{m}{n}
311 \SetMathAlphabet{\mathbf}{\l_@@_versionname_tl}{OT1}{\l_tmpa_tl}{bx}{n}
312 \SetMathAlphabet{\mathsf}{\l_@@_versionname_tl}{OT1}{\l_tmpa_tl}{m}{n}
313 \SetMathAlphabet{\mathit}{\l_@@_versionname_tl}{OT1}{\l_tmpa_tl}{m}{it}
314 \SetMathAlphabet{\mathtt}{\l_@@_versionname_tl}{OT1}{\l_tmpa_tl}{m}{n}
315 \SetSymbolFont{symbols2} {\l_@@_versionname_tl}{OMS}{iwonamathcmsy}{m}{n}
316 }
317
318 \bool_if:NTF \l_@@_delimitershack_bool
319 {
320
321 }
322 {}
323
324 }
325 % \end{macrocode}
326 % \end{macro}
327 %
328 %
329 %
330 %\subsection{Default versions}
331 %\label{sec:defaults}
332 %
333 % If standard versions are requested, we define them
334 % \begin{macrocode}
335 \bool_if:NTF \l_@@_standardversions_bool
336 {
337 \DefineIwonaMathVersion{}
338 \DefineIwonaMathVersion{bold}
339 }
340 {}
341 % \end{macrocode}
342 %
343 % \begin{macrocode}
344 %</package>
345 % \end{macrocode}
346 %
347 %\subsection{Font definition files}
348 %\label{sec:fd}
349 %
350 %
351 %
352 % Now, the fd files. Sometimes they are defined in special |fdd|
353 % files; here we use the main |dtx| for this.
354 %
355 % First, we check if the size is defined. If not,
356 % we define it.
357 % \begin{macrocode}
358 %<*fd>
359 \tl_if_exist:NTF \l_@@_scale_tl
360 {}
361 {
362 \tl_new:N \l_@@_scale_tl
363 \tl_set:Nn \l_@@_scale_tl {1}
364 }
365 %</fd>
366 % \end{macrocode}
367 %
368 % Our version of |cmsy| just scales the font. Note that right now the
369 % scaling is exactly the same as for other iwona math
370 % characters---maybe we need to fine tune this.
371 % \begin{macrocode}
372 %<*cmsy>
373 \DeclareFontFamily{OMS}{iwonamathcmsy}{\skewchar\font48 }
374 \DeclareFontShape{OMS}{iwonamathcmsy}{m}{n}{%
375 <-> [\l_@@_scale_tl] cmsy10%
376 }{}
377 \DeclareFontShape{OMS}{iwonamathcmsy}{b}{n}{%
378 <-> [\l_@@_scale_tl] cmbsy10%
379 }{}
380 %</cmsy>
381 % \end{macrocode}
382 %
383 % \begin{table}
384 % \centering
385 % \caption{Naming scheme for iwona fonts}
386 % \label{tab:naming}
387 % \begin{tabular}{lllll}
388 % \toprule
389 % Weight/Shape & \multicolumn{4}{c}{Base}\\
390 % \cmidrule{2-5}\\
391 % & Regular & Condensed & Light & Light Condensed \\
392 % \midrule
393 % m/n & iwonar & iwonacr & iwonal & iwonacl \\
394 % m/it & iwonari & iwonacri & iwonali & iwonacli \\
395 % b/n & iwonab & iwonacb & iwonam & iwonacm \\
396 % b/it & iwonabi & iwonacb & iwonami & iwonacmi \\
397 % \bottomrule
398 % \end{tabular}
399 % \end{table}
400 %
401 % Now, we need many files in the different weights and
402 % condensed/regular status. It would be too tedious to write all
403 % them. So we create a template with the special marks and a bash
404 % script to generate all |fd| files. Of course, \TeX\ with enough
405 % trickery can be used instead of bash, but why bother: we employ
406 % Makefiles anyways\ldots
407 %
408 % The naming scheme for Iwona fonts is shown in
409 % Table~\ref{tab:naming}. From this table we see we need three marks:
410 % |_FAMILY_| for the base family, |_MEDIUM_| for medium font and
411 % |_BOLD_| for bold font.
412 %
413 % We have two |OT1| files: one for default letters, one for |\math...|
414 % commands.
415 % \begin{macrocode}
416 %<*ot1m>
417 \DeclareFontFamily{OT1}{_FAMILY_m}{}
418 \DeclareFontShape{OT1}{_FAMILY_m}{m}{n}{<-> [\l_@@_scale_tl] rm-_MEDIUM_}{}
419 \DeclareFontShape{OT1}{_FAMILY_m}{b}{n}{<-> [\l_@@_scale_tl] rm-_BOLD_}{}
420 %</ot1m>
421 %<*ot1>
422 \DeclareFontFamily{OT1}{_FAMILY_}{}
423 \DeclareFontShape{OT1}{_FAMILY_}{m}{n}{<-> [\l_@@_scale_tl] rm-_MEDIUM_}{}
424 \DeclareFontShape{OT1}{_FAMILY_}{m}{it}{<-> [\l_@@_scale_tl] rm-_MEDIUM_i}{}
425 \DeclareFontShape{OT1}{_FAMILY_}{b}{n}{<-> [\l_@@_scale_tl] rm-_BOLD_}{}
426 \DeclareFontShape{OT1}{_FAMILY_}{bx}{n}{<-> [\l_@@_scale_tl] rm-_BOLD_}{}
427 %</ot1>
428 %<*oml>
429 \DeclareFontFamily{OML}{_FAMILY_}{}
430 \DeclareFontShape{OML}{_FAMILY_}{m}{it}{<-> [\l_@@_scale_tl] mi-_MEDIUM_i}{}
431 \DeclareFontShape{OML}{_FAMILY_}{b}{it}{<-> [\l_@@_scale_tl] mi-_BOLD_i}{}
432 \DeclareFontShape{OML}{_FAMILY_}{bx}{it}{<-> [\l_@@_scale_tl] mi-_BOLD_i}{}
433 %</oml>
434 %<*oms>
435 \DeclareFontFamily{OMS}{_FAMILY_}{}
436 \DeclareFontShape{OMS}{_FAMILY_}{m}{n}{<-> [\l_@@_scale_tl] sy-_MEDIUM_z}{}
437 \DeclareFontShape{OMS}{_FAMILY_}{b}{n}{<-> [\l_@@_scale_tl] sy-_BOLD_z}{}
438 \DeclareFontShape{OMS}{_FAMILY_}{bx}{n}{<-> [\l_@@_scale_tl] sy-_BOLD_z}{}
439 %</oms>
440 %<*omx>
441 \DeclareFontFamily{OMX}{_FAMILY_}{}
442 \DeclareFontShape{OMX}{_FAMILY_}{m}{n}{<-> [\l_@@_scale_tl] ex-_MEDIUM_}{}
443 \DeclareFontShape{OMX}{_FAMILY_}{b}{n}{<-> [\l_@@_scale_tl] ex-_BOLD_}{}
444 \DeclareFontShape{OMX}{_FAMILY_}{bx}{n}{<-> [\l_@@_scale_tl] ex-_BOLD_}{}
445 %</omx>
446 % \end{macrocode}
447 %
448 % \end{implementation}
449 %
450 % \bibliography{iwonamath}
451 % \bibliographystyle{plainnat}
452 %
453 % \PrintIndex