Debian Codegraph @

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

raw
1 \def\fileversion{1.1} % ^^A -*-latex-*-
2 \def\filedate{1996/07/02}
3 %\iffalse meta-comment
4 %\altfont: A \LaTeXe\ package for using alternative fonts
5 %
6 %Copyright \copyright\ 1996 Sebastian Marius Kirsch\texttt{%
7 % $\langle$sebastian\[email protected]$\rangle$}
8 %
9 %This program is free software; you can redistribute it and/or modify
10 %it under the terms of the GNU General Public License as published by
11 %the Free Software Foundation; either version 2 of the License, or
12 %(at your option) any later version.
13 %
14 %This program is distributed in the hope that it will be useful,
15 %but WITHOUT ANY WARRANTY; without even the implied warranty of
16 %MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 %GNU General Public License for more details.
18 %
19 %You should have received a copy of the GNU General Public License
20 %along with this program; if not, write to the Free Software
21 %Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 %\fi
23 %
24 %\changes{0.9}{1996/06/29}{Based on \texttt{psfont} v1.0d. Not restricted to
25 %PostScript fonts.}
26 %\changes{0.9a}{1996/06/30}{Updating documentation. Throwing out most \PS\
27 %specific parts.}
28 %\changes{1.0}{1996/06/30}{1st public release}
29 %\changes{1.0a}{1996/07/01}{\texttt{\textbackslash AvailableFont} can have
30 %empty arguments}
31 %\changes{1.0a}{1996/07/01}{Adding new documentation.}
32 %\changes{1.1}{1996/07/02}{2nd public release }
33 %
34 % \CheckSum{236}
35 %% \CharacterTable
36 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
37 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
38 %% Digits \0\1\2\3\4\5\6\7\8\9
39 %% Exclamation \! Double quote \" Hash (number) \#
40 %% Dollar \$ Percent \% Ampersand \&
41 %% Acute accent \' Left paren \( Right paren \)
42 %% Asterisk \* Plus \+ Comma \,
43 %% Minus \- Point \. Solidus \/
44 %% Colon \: Semicolon \; Less than \<
45 %% Equals \= Greater than \> Question mark \?
46 %% Commercial at \@ Left bracket \[ Backslash \\
47 %% Right bracket \] Circumflex \^ Underscore \_
48 %% Grave accent \` Left brace \{ Vertical bar \|
49 %% Right brace \} Tilde \~}
50 %%
51 %
52 %\title{\altfont: Using alternative fonts\thanks{This file has version number
53 %\fileversion, last revised \filedate.}}
54 %
55 %\author{Sebastian Marius Kirsch\\
56 % \texttt{sebastian\[email protected]}}
57 %
58 %\date{\filedate}
59 %
60 %\maketitle
61 %
62 %\begin{abstract}
63 %With this package, you can use many alternative fonts with one single
64 %package. \psNFSS\ and \mfNFSS\ use one file for every font, while I prefer
65 %having everything in one package. Besides, of you load two of the font
66 %changing packages, the latter one overwrites the changes of the first
67 %one. Having all in one package avoids this.
68 %\end{abstract}
69 %
70 %\section{Introduction}
71 %
72 %This package is intended as a replacement for some parts of both \psNFSS\ and
73 %\mfNFSS. It is a replacement for the parts that actually change the default
74 %fonts. It was originally written as a replacement for \textsf{psfonts} of
75 %\psNFSS, but I realized that it was not very reasonable to restrict it to
76 %PostScript fonts. So it is now not focused on any particular PostScript font,
77 %but can be used for any font, \MF\ or PostScript. I'll discuss this in detail
78 %in section \ref{sec:psmfnfss}.
79 %
80 %\section{Installation}
81 %
82 %The actual package is produced by running \TeX\ on |altfont.ins|. This
83 %produces |altfont.sty|, the style file, and |altfont.cfg|, the configuration
84 %file. Both files must be moved where \TeX\ can find them.
85 %
86 %\subsection{The configuration file}
87 %
88 %\DescribeMacro{\AvailableRMFont}
89 %\DescribeMacro{\AvailableRMFont}
90 %\DescribeMacro{\AvailableRMFont}
91 %\DescribeMacro{\AvailableFont}
92 %All available fonts must declared in the configuration file. This is done
93 %using the macros |\AvailableRMFont|, |\AvailableSFFont|, |\AvailableTTFont|,
94 %and |\AvailableFont|. They have the following syntax:
95 %
96 %\begin{quote}
97 % \cmd{\AvailableRMFont}\oarg{additional code}\marg{long name}\marg{\NFSS\
98 % family name}\\
99 % \cmd{\AvailableSFFont}\oarg{additional code}\marg{long name}\marg{\NFSS\
100 % family name}\\
101 % \cmd{\AvailableTTFont}\oarg{additional code}\marg{long name}\marg{\NFSS\
102 % family name}\\
103 % \cmd{\AvailableFont}\oarg{additional code}\marg{symbolic name}%
104 % \marg{roman font}\texttt{\%}\\\marg{sans serif font}\marg{typewriter font}
105 %\end{quote}
106 %
107 %The first argument contains a symbolic name for the font, while the second
108 %argument contains the internal name for the family. The symbolic name is to
109 %be used as an option to the package. (It is easier to remember Times as
110 %\texttt{times} than as \texttt{ptm}.)
111 %
112 %The optional argument contains code that is executed after the font is
113 %loaded. It can be used to e.~g.\ change the font encoding or to redefine some
114 %other defaults such as |\bfdefault|.
115 %
116 %The macro |\AvailableFont| does the same, but for three font families at
117 %once. This can be used for font families that have the varinats sans serif
118 %and typewriter, e.~g.\ the Computer Modern fonts, as well as for managing a
119 %combination of three fonts under one short name. The arguments can also be
120 %empty.
121 %
122 %Typical commands looks like this:
123 %
124 %\begin{verbatim}
125 %\AvailableRMFont{times}{ptm}
126 %\AvailableSFFont{helv}{phv}
127 %\AvailableTTFont{Courier}{pcr}
128 %\AvailableFont[\altfontenc{T1}]{dco}{cmor}{cmoss}{cmott}
129 %\end{verbatim}
130 %
131 %\DescribeMacro{\DefaultRMFont}
132 %\DescribeMacro{\DefaultSFFont}
133 %\DescribeMacro{\DefaultTTFont}
134 %You can also tell \altfont\ about default \PS\ fonts. If the user calls the
135 %option |onlyps|, the default fonts are substituted for the fonts he has not
136 %defined. This is useful when you do not want to supply every font to be used
137 %in the document, but want your document to contain only \PS\ fonts. The
138 %syntax of these commands looks like this:
139 %
140 %\begin{quote}
141 % \cmd{\DefaultRMFont}\marg{\NFSS\ family name}\\
142 % \cmd{\DefaultSFFont}\marg{\NFSS\ family name}\\
143 % \cmd{\DefaultTTFont}\marg{\NFSS\ family name}
144 %\end{quote}
145 %
146 %\DescribeMacro{\altfontenc}
147 %If you want to change the font encoding in the \meta{additional code} section
148 %of any of the |\Available|\ldots|Font| macros, you have to use |\altfontenc|
149 %instead of a plain |\RequirePackage[|\ldots|]{fontenc}|. The reason for this
150 %is discussed later. This is the syntax of |\altfontenc|:
151 %
152 %\begin{quote}
153 % \cmd{\altfontenc}\marg{encoding}
154 %\end{quote}
155 %
156 %Generally, you can neither use commands that have
157 %optional arguments nor load classes or packages in the \meta{additional code}
158 %section.
159 %
160 %\section{Syntax}
161 %
162 %You load the package with |\usepackage[|\ldots|]{altfont}|, as usual, with
163 %the fonts you want to use in square brackets. Typical commands look like
164 %this:
165 %
166 %\begin{verbatim}
167 %\usepackage[palatino,gill,courier]{altfont}
168 %\usepackage[newcent,onlyps]{altfont}
169 %\usepackage[dco]{altfont}
170 %\usepackage[pandora,courier]{altfont}
171 %\end{verbatim}
172 %
173 %\section{\psNFSS\ vs. \mfNFSS}
174 %\label{sec:psmfnfss}
175 %
176 %There are two other popular packages for using alternative fonts with \LaTeX:
177 %\psNFSS\ by Sebastian Rahtz, which is responsible for \PS\ fonts, and
178 %\mfNFSS\ by Frank Mittelbach and Rainer Sch\"opf, which focuses on
179 %\MF\ fonts.
180 %
181 %In my opinion, it was not very reasonable to divide the font changing between
182 %two packages. The fonts look to \LaTeX\ all the same, so why make a
183 %difference in the packages?
184 %
185 %For fonts which are to be used as |\{rm,sf,tt}default| fonts, both packages
186 %have little style files which change these defaults. But if you load two of
187 %those packages, the latter overwrites the changes of the first one. These
188 %packages all do the same, so why not include them into one style file?
189 %
190 %Well, I did this, and the result is easier to use and safer than the
191 %packages from \psNFSS\ and \mfNFSS. Because of these improvements, I would
192 %like my package to get included into these packages. (I know, I'm
193 %unselfish. ;-)
194 %
195 %Since \psNFSS\ and \mfNFSS\ focuse on particular fonts, while my package can
196 %be used with any font, it is not very likely to be included in either
197 %package, though both could make use of it.
198 %
199 %\section{Legal rubbish}
200 %\altfont: A \LaTeXe\ package for using alternative fonts
201 %
202 %Copyright \copyright\ 1996 Sebastian Marius Kirsch\texttt{%
203 % $\langle$sebastian\[email protected]$\rangle$}
204 %
205 %This program is free software; you can redistribute it and/or modify
206 %it under the terms of the GNU General Public License as published by
207 %the Free Software Foundation; either version 2 of the License, or
208 %(at your option) any later version.
209 %
210 %This program is distributed in the hope that it will be useful,
211 %but WITHOUT ANY WARRANTY; without even the implied warranty of
212 %MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
213 %GNU General Public License for more details.
214 %
215 %You should have received a copy of the GNU General Public License
216 %along with this program; if not, write to the Free Software
217 %Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
218 %
219 %\StopEventually
220 %
221 %\section{The \texttt{docstrip} modules}
222 %
223 %This file contains three modules to direct \texttt{docstrip} in generating the
224 %external files:
225 %
226 %\begin{tabular}[t]{ll}
227 %driver & A short driver for producing the documentation\\
228 %package & The package itself\\
229 %config & The local configuration file\\
230 %\end{tabular}
231 %
232 %\section{Producing the documentation}
233 %
234 %This short driver can be extracted by \texttt{docstrip} to produce the
235 %documentation.
236 %
237 % \begin{macrocode}
238 %<*driver>
239 \documentclass{ltxdoc}
240
241 \usepackage{mflogo}
242 \providecommand{\MF}{\textsf{METAFONT}} % for those without mflogo.sty
243
244 \newcommand*{\NFSS}{\mbox{\textsf{NFSS}}}
245 \newcommand*{\psNFSS}{\mbox{\textsf{psNFSS}}}
246 \newcommand*{\mfNFSS}{\mbox{\textsf{mfNFSS}}}
247 \newcommand*{\altfont}{\textsf{alt\-font}}
248 \newcommand*{\PS}{Post\-Script}
249
250 \begin{document}
251
252 \DocInput{altfont.dtx}
253
254 \end{document}
255 %</driver>
256 % \end{macrocode}
257 %
258 %\section{The Code}
259 %
260 %\subsection{Introduction}
261 %
262 %First we have to introduce ourselves.
263 %
264 % \begin{macrocode}
265 %<*package>
266 \NeedsTeXFormat{LaTeX2e}
267 \ProvidesPackage{altfont}%
268 [\filedate\space v\fileversion\space loading alternative fonts]
269 % \end{macrocode}
270 %
271 %\subsection{Switches}
272 %
273 %Next, we define some switches. They are used to determine whether some fonts
274 %have already been loaded, so we can warn the user when he tries to load two
275 %colliding fonts.
276 %
277 % \begin{macrocode}
278 \newif\ifrm@set\rm@setfalse
279 \newif\ifsf@set\sf@setfalse
280 \newif\iftt@set\tt@setfalse
281 % \end{macrocode}
282 %
283 %\subsection{Default \PS\ fonts}
284 %
285 %\begin{macro}{\DefaultRMFont}
286 %\begin{macro}{\DefaultSFFont}
287 %\begin{macro}{\DefaultTTFont}
288 %These are some commands for changing the default \PS\ fonts.
289 %
290 % \begin{macrocode}
291 \newcommand{\DefaultRMFont}[1]{\renewcommand{\def@rmfont}{#1}}
292 \newcommand{\DefaultSFFont}[1]{\renewcommand{\def@sffont}{#1}}
293 \newcommand{\DefaultTTFont}[1]{\renewcommand{\def@ttfont}{#1}}
294 \newcommand{\def@rmfont}{}
295 \newcommand{\def@sffont}{}
296 \newcommand{\def@ttfont}{}
297 % \end{macrocode}
298 %\end{macro}\end{macro}\end{macro}
299 %
300 %\subsection{Declaring the options}
301 %
302 %\begin{macro}{\AvailableRMFont}
303 %\begin{macro}{\AvailableSFFont}
304 %\begin{macro}{\AvailableTTFont}
305 %These commands are needed later in the configuration
306 %file. There is one command for each font family, ie.\ roman, sans serif or
307 %typewriter.
308 %
309 %They declare their first argument as an option.
310 %
311 %If the option is called, and the font family has already been defined, a
312 %\cmd{\PackageError} is reported. If not, the second argument is defined as
313 %the approriate family default.
314 %
315 %When the family default has successfully been set, the corresponding switch
316 %is turned, so it is not redefined anywhere else in this file.
317 %
318 %The optional argument contains some code that is to be executed when the
319 %defaults have been set. This is a very useful hook, e.~g.\ when a certain
320 %font family is only available in OT1 or Cork encoding, we can execute a
321 %|\altfontenc{OT1}| after the font is loaded. This command is a little hack to
322 %get around some limitations of |\newcommand| and |\DeclareOption| and is
323 %described in section \ref{sec:altfontenc}. A plain |\usepackage| will not
324 %work!
325 %
326 % \begin{macrocode}
327 \newcommand{\AvailableRMFont}[3][]{%
328 \DeclareOption{#2}{%
329 \ifrm@set\PackageError{altfont}{%
330 \protect\rmfamily\space already defined as \rmdefault
331 }{%
332 You tried to load two roman families at the same time,\MessageBreak
333 e.g. times and palatino}
334 \else\renewcommand{\rmdefault}{#3}\rm@settrue
335 #1
336 \fi}
337 }
338 \newcommand{\AvailableSFFont}[3][]{%
339 \DeclareOption{#2}{%
340 \ifsf@set\PackageError{altfont}{%
341 \protect\sffamily\space already defined as \sfdefault
342 }{%
343 You tried to load two sans serif families at the same time,\MessageBreak
344 e.g. gill and helvetica}
345 \else\renewcommand{\sfdefault}{#3}\sf@settrue
346 #1
347 \fi}
348 }
349 \newcommand{\AvailableTTFont}[3][]{%
350 \DeclareOption{#2}{%
351 \iftt@set\PackageError{altfont}{%
352 \protect\ttfamily\space already defined as \ttdefault
353 }{%
354 You tried to load two typewriter families at the same time,\MessageBreak
355 e.g. courier and typewriter}
356 \else\renewcommand{\ttdefault}{#3}\tt@settrue
357 #1
358 \fi}
359 }
360 % \end{macrocode}
361 %\end{macro}\end{macro}\end{macro}
362 %
363 %\subsection{One command fits all}
364 %
365 %\begin{macro}{\AvailableFont}
366 %With the macro |\AvailableFont|, all three defaults are set with one
367 %option. This is useful for managing combinations of three fonts under one
368 %name, as well as for fonts that have the variants sans serif and
369 %typewriter. (The Computer Modern fonts are one of those, and Lucida, I
370 %think.)
371 %
372 %|\AvailableFont| may also have empty arguments.
373 %
374 % \begin{macrocode}
375 \newcommand*{\AvailableFont}[5][]{%
376 \DeclareOption{#2}{%
377 \def\@temprm{#3}\def\@tempsf{#4}\def\@temptt{#5}
378 \ifx\empty\@temprm\else
379 \ifrm@set\PackageError{altfont}{%
380 \protect\rmfamily\space already defined as \rmdefault
381 }{%
382 You tried to load two roman families at the same time,
383 \MessageBreak e.g. times and palatino}
384 \else\renewcommand{\rmdefault}{#3}\rm@settrue
385 \fi
386 \fi
387 \ifx\empty\@tempsf\else
388 \ifsf@set\PackageError{altfont}{%
389 \protect\sffamily\space already defined as \sfdefault
390 }{%
391 You tried to load two sans serif families at the same time,
392 \MessageBreak e.g. gill and helvetica}
393 \else\renewcommand{\sfdefault}{#4}\sf@settrue
394 \fi
395 \fi
396 \ifx\empty\@temptt\else
397 \iftt@set\PackageError{altfont}{%
398 \protect\ttfamily\space already defined as \ttdefault
399 }{%
400 You tried to load two typewriter families at the same time,
401 \MessageBreak e.g. courier and typewriter}
402 \else\renewcommand{\ttdefault}{#5}\tt@settrue
403 \fi
404 \fi
405 #1
406 }
407 }
408 % \end{macrocode}
409 %\end{macro}
410 %
411 %\subsection{Loading font encodings in \texttt{\textbackslash Available\ldots
412 %Font}}
413 %\label{sec:altfontenc}
414 %
415 %\begin{macro}{\altfontenc}
416 %Working on this package, I discovered two limitations of |\newcommand| and
417 %|\DeclareOption|.
418 %
419 %\begin{itemize}
420 %\item You cannot use a command with an optional argument in the argument of
421 % another command.
422 %\item You cannot load a package with |\RequirePackage| or |\usepackage| in the
423 % \meta{code} section of a |\DeclareOption| command.
424 %\end{itemize}
425 %
426 %I wanted to be able to load different font encodings in the optional argument
427 %of the |\Available|\ldots|Font| command, so I had to work around these
428 %limitations. The result is this command:
429 %
430 % \begin{macrocode}
431 \newcommand*{\altfontenc}[1]{\PassOptionsToPackage{#1}{fontenc}%
432 \AtEndOfPackage{\RequirePackage{fontenc}}}
433 % \end{macrocode}
434 %\end{macro}
435 %
436 %By passing the option to \texttt{fontenc} with |\PassOptionsToPackage|, I
437 %avoid having an optional argument to |\RequirePackage|. By delaying the
438 %|\RequirePackage|, I avoid loading a package in an option. Ugly but useful.
439 %
440 %\subsection{Loading the configuration file}
441 %
442 %Next, the configuration file is loaded. If it is not found, an error is
443 %issued, because the package is quite useless without it.
444 %
445 % \begin{macrocode}
446 \InputIfFileExists{altfont.cfg}{}{%
447 \PackageError{altfont}{%
448 No local configuration file found
449 }{%
450 The altfont package was loaded without a local\MessageBreak
451 configuration file, so it doesn't know which fonts\MessageBreak
452 are available.}
453 }
454 %</package>
455 % \end{macrocode}
456 %
457 %\subsection{The configuration file}
458 %
459 %The configuration file looks like this:
460 %
461 %\subsubsection{Introduction}
462 %
463 %As usual\ldots
464 %
465 % \begin{macrocode}
466 %<*config>
467 \NeedsTeXFormat{LaTeX2e}
468 \ProvidesFile{altfont.cfg}%
469 [\filedate\space v\fileversion\space Local configuration for altfont.sty]
470 % \end{macrocode}
471 %
472 %\subsubsection{Declaring default PostScript fonts}
473 %
474 %Here, the default PostScript fonts are defined. They are needed later, if the
475 %author does not define all fonts he wants to use, but wants his document to
476 %contain only \PS\ fonts. Strictly spoken, this does not belong to a package
477 %for \PS\ and \MF\ fonts, but I think it is nonetheless very useful.
478 %
479 % \begin{macrocode}
480 \DefaultRMFont{ptm}
481 \DefaultSFFont{phv}
482 \DefaultTTFont{pcr}
483 % \end{macrocode}
484 %
485 %\subsubsection{Available fonts}
486 %
487 %Now the available fonts are defined. They are divided into three
488 %categories---roman fonts, sans serif fonts and typewriter fonts, as it is
489 %done in \LaTeXe\ itself.
490 %
491 %They are defined using the |\Available|\ldots|Font| macros. These macros
492 %define a symbolic name to be used as an option to the package, and take the
493 %name of the \NFSS\ font family as a second argument.
494 %
495 % \begin{macrocode}
496 \AvailableRMFont{times}{ptm}
497 \AvailableRMFont{palatino}{ppl}
498 \AvailableRMFont{newcent}{pnc}
499
500 \AvailableSFFont{helv}{phv}
501 \AvailableSFFont{gill}{pgs}
502
503 \AvailableTTFont{courier}{pcr}
504
505 \AvailableFont[\altfontenc{T1}]{dco}{cmor}{cmoss}{cmott}
506 \AvailableFont[\altfontenc{OT1}%
507 \DeclareFontSubstitution{OT1}{pnr}{m}{n}%
508 \renewcommand{\bfdefault}{b}%
509 \renewcommand{\itdefault}{sl}]{pandora}{pnr}{pnss}{pntt}
510 %</config>
511 % \end{macrocode}
512 %
513 %In case you wonder, the dco fonts are another package I wrote. They consist
514 %of the regular dc fonts with oldstyle digits. I didn't release it yet,
515 %contact me if you are interested.
516 %
517 %And that's the configuration. Of course one could do much more with this
518 %configuration file, declaring new options and all. It's probably the biggest
519 %hook a package could have. :-)
520 %
521 %\subsection{\texttt{onlyps}: Using only \PS\ fonts}
522 %
523 %\begin{macro}{onlyps}
524 %This option redefines all other family defaults that have not yet been
525 %\cmd{\renewcommand}ed to \PS\ fonts. It uses the default fonts as defined in
526 %the configuration file. If no default fonts have been defined, an error is
527 %reported.
528 %
529 % \begin{macrocode}
530 %<*package>
531 \DeclareOption{onlyps}{
532 \ifrm@set\else
533 \ifx\empty\def@rmfont
534 \PackageWarning{altfont}{No default roman font defined!}
535 \else\renewcommand{\rmdefault}{\def@rmfont}\fi
536 \fi
537 \ifsf@set\else
538 \ifx\empty\def@sffont
539 \PackageWarning{altfont}{No default sans serif font defined!}
540 \else\renewcommand{\sfdefault}{\def@sffont}\fi
541 \fi
542 \iftt@set\else
543 \ifx\empty\def@ttfont
544 \PackageWarning{altfont}{No default typewriter font defined!}
545 \else\renewcommand{\ttdefault}{\def@ttfont}\fi
546 \fi
547 }
548 % \end{macrocode}
549 %\end{macro}
550 %
551 %\subsection{The end}
552 %
553 %At last, the options are processed.
554 %
555 % \begin{macrocode}
556 \ProcessOptions
557 %</package>
558 % \end{macrocode}
559 %
560 %\Finale
561 \endinput