MAAMAC—Malvern A Macros

Version 1.5, last changed pdc 1995–04–06

P. Damian Cugley

0. Introduction

This document describes maamac.tex, a collection of formatting macros for plain TEX documents using fonts with the Malvern A encoding. For example, it defines commands for making composite letters and special symbols.

0.1. About this document The definitions file and this printed documentation are both in maamac.dtx, a ‘documented TEX macros’ file* which, when processed by plain TEX, generates a fresh copy of maamac.tex in the current directory in addition to the dvi file. This ensures that the printed documentation and the code it describes are identical. The dtx file uses the macros

in pdccode.tex.

0.2. What is in MAAMAC? The definitions in maamac.tex fall into three sections: §1 Building composite letters like ‘é’ from marks like ‘´’ and base letters like ‘e’. This gives

new definitions for commands like \´ and \". §2 Symbols and special letters: replacements for existing commands like \P (¶) and \ae

(æ), and new commands like \registered and \pounds. §3 Switching between alphabets. The Malvern A encoding includes separate small cap-

ital and medium capital alphabets in addition to the usual capitals and lower case. This section defines commands for transliterating a list of tokens from one alphabet to another.

The first two sections make changes to commands described in TEXbook Chapter 9 (and a few maths symbols from Chapter 16) and defined in Appendix B.

0.3. File identification Nowadays, macro files start with some comments identifying the file.

  1 % maamac.tex 1.5 1995/04/06 -- Malvern A Macros

2

  3 %%%@TeX-definition-file {
  4 %%% filename       = "$texmf/tex/plain/pdcmac/maamac.tex",
  5 %%% version        = "1.5",
  6 %%% date           = "1995/04/06",
  7 %%% package        = "pdcmac 1.0",
  8 %%% author         = "P. Damian Cugley",
  9 %%% email          = "damian.cugley@comlab.ox.ac.uk",
 10 %%% address        = "Oxford University Computing Laboratory,
 11 %%%                   Parks Road, Oxford  OX1 3QD, UK",
 12 %%% codetable      = "USASCII",
 13 %%% keywords       = "TeX, plain TeX, macros",
 14 %%% supported      = "Maybe",
 15 %%% abstract       = "Macros for using the Malvern-A font coding
 16 %%%                   scheme in plain TeX documents.
 17 %%%                   This file was generated by running
 18 %%%                   plain TeX on maamac.dtx",
 19 %%% copyright      = "Copyright (c) 1991-1995 P. Damian Cugley",
 20 %%% copying        = "DO NOT DISTRIBUTE THIS FILE.

* The LaTEX 2e distribution uses files with the ‘dtx’ suffix for similar purposes.

21–52 MAAMAC—Malvern A Macros 1.5 1995–04–06

21 %%%                   Distribute maamac.dtx only as part of the
22 %%%                   package it came in.",
23 %%% dependencies   = "",
24 %%% }

25

26 \message{1.5 <pdc 1995/04/06>}

27

1. Building composite letters

THis section redefines commands listed at the start of Chapter 9 of the TEXbook: \´ , \", etc. The main difference is that these now use ‘medium capitals’ and differently-drawn marks to make composite capital letters.

I also define ⟨chardef tokens⟩ called \acuteglyph, \twodotsglyph which may be used to print these marks in a document: ‘the acute mark “´’’… ’ might be typeset with ‘the acute mark ` ` \acuteglyph´ ´ … ’. Also, if you don’t like the way my macros look, you can say ‘\accent\acuteglyph E’ rather than having to look up its glyph number.

1.1. Utility macros First some nicknames for scratch registers.

28 \dimendef\dimena0  \dimendef\dimenb2
29 \toksdef\toksa0
30 \countdef\counta255
31 \ifx\countb\UNDEFINED \csname newcount\endcsname\countb \fi
32 \ifx\countc\UNDEFINED \csname newcount\endcsname\countc \fi

A macro to find the code in TEX’s internal encoding for a character. The character might be represented by (1) a character with category code 11 or 12, (2) a token defined with \chardef, or (3) the token \char followed by a ⟨number⟩.

33 \def\code#1{%
34  \ifcat#1a%
35  ` #1
36  \else\ifcat#1+%
37  ` #1
38  \else\ifx\char#1

% If the first token is \char the rest is the ⟨number⟩ we want.

39  \else
40  #1%
41  \fi\fi\fi

42 }

So as to make conditional macros that can be skipped over if they appear nested inside another conditional, we make include the token \then amongst the arguments, making this the ‘if-’ token to match the \else and \fi following it. This way we write, for example

\ifcap⟨character⟩ \then ⟨true text⟩ \else ⟨false text⟩ \fi

43 \let\then=\iffalse
44 \def\ifcap#1\then{\expandafter\ifcapnum\code{#1}\then}
45 \def\ifcapnum#1\then{\ifnum\lccode#1=#1}
46 \def\iflower#1\then{\expandafter\iflowernum\code{#1}\then}
47 \def\iflowernum#1\then{\ifnum\uccode#1=#1}

A macro to extract the slant-per-point parameter of a font in toe form of a TEX ⟨factor⟩.

48 \def\fontslant#1{\expandafter\stripPT\the\fontdimen1#1}
49 \begingroup \uccode` 2=` p \uccode` 3=` t \uppercase{\toksa{\endgroup
50  \def\\#123{#1}
51 }} \the\toksa
52 \let\stripPT=\\

1.2. Macros for placing marks This simple macro places the text #3 at displaced (#1, #2) from current position:

53 \def\putxy#1#2#3{\leavevmode\rlap{\hskip#1\raise#2\hbox{#3}}}

Now we have a generic mark-placement macro. It is similar to the \accent primitive, but takes two extra parameters:

                      \putmarkxy{xf }{dy}{mark}{base}

The horizontal position xf of the optical centre of the base letter (ignoring slant) is expressed as a ⟨factor⟩ (i.e., decimal fraction of the width of the base glyph). The vertical displacement dy is expressed as a fragment of TEX code that will calculate dy. The code is expanded after setting box 0 to contain the base glyph, and must put the result in \dimena. For example, we could define

    \def\fakeaccent{\putmarkxy{0.5}{\dimena\ht0 \advance\dimena-1ex }}

This produces an approximation to the primitive \accent command.

Given the x-factor xf , a base glyph with width wd, a font with slant s, the horizontal displacement dx is given by

dx = xf × wd + s × dy .

In this macro it is stored in \dimenb.

54 \def\putmarkxy#1#2#3#4{{%
55  \setbox0=\hbox{#4}#2\relax
56  \dimenb#1\wd0 \advance\dimenb\fontslant\font\dimena
57  \leavevmode
58  \putxy{\dimenb}{\dimena}{\hbox to 0pt{\hss\char#3\hss}}%
59  \box0
60 }}
61 \def\putmarky{\putmarkxy{0.5}}

1.3. Type I Marks A Type I mark is one which does not have any scope for being ‘squashed’ to go over capital letters—for example, the two-dots mark ‘¨’ and macron ‘¯ ’.

Here’s a macro for placing a Type I mark given by #1 (a ⟨number⟩) over base glyph #2 (which is anything that \code understands). The difference between this macro and simply using \accent is (1) if presented with a capital letter it will use the corresponding medium capital letter and (2) the the mark is raised by an amount intended to centre it vertically between the top of the base letter and the top of the body-height—assuming it was original centered between body-height and x-height.

If H is the body height, h the height of the base glyph,

dy = \frac{H + h}{2} − \frac{H + 1 ex}{2}
= \frac{1}{2}h − \frac{1}{2} ex

62 \def\typeImark#1#2{{%
63  \setbox2=\hbox{#2}%
64  \ifdim \ht2=1ex
65  \accent#1\relax#2%
66  \else
67  \counta\code{#2}%
68  \ifnum\counta>64 \ifnum\counta<96
69  \advance\counta 128
70  \fi \fi
71  \putmarky{\dimena0.5\ht0 \advance\dimena-0.5ex }
72  {#1}{\char\counta}%
73  \fi
74 }}

Finally we define the composite-letter-building commands.

75 \chardef\dotglyph22     \def\.{\typeImark\dotglyph}
76 \chardef\twodotsglyph23 \def\"{\typeImark\twodotsglyph}
77 \chardef\macronglyph150 \def\={\typeImark\macronglyph}
78 \chardef\longmacronglyph151
79  \def\longmacronmark{\typeImark\longmacronglyph}

1.4. Type II Marks These marks have an alternative glyph for use of capital and medium capital letters. As with \typeImark, #1 is a ⟨number⟩ and #2 is anything understood by \code.

80 \def\typeIImark#1#2{{%
81  \counta#1\relax \countb\code{#2}%
82  \ifcap{#2}\then
83  \ifnum \counta<128 \advance\counta 128 \fi
84  \ifnum \countb<128 \advance\countb 128 \fi
85  \fi
86  \accent\counta \char\countb
87 }}
88 \chardef\acuteglyph8      \def\´ {\typeIImark\acuteglyph}
89 \chardef\graveglyph9      \def\` {\typeIImark\graveglyph}
90 \chardef\circumglyph10    \def\^{\typeIImark\circumglyph}
91 \chardef\tildeglyph11     \def\~{\typeIImark\tildeglyph}
92 \chardef\ringglyph12      \def\ringmark{\typeIImark\ringglyph}
93 \chardef\caronglyph13     \def\v{\typeIImark\caronglyph}
94 \chardef\breveglyph14     \def\u{\typeIImark\breveglyph}
95 \chardef\hungarglyph15 \def\H{\typeIImark\hungarglyph}

I have abbreviated ‘circumflex’ as ‘circum’ (consistent with Adobe’s ‘asciicircum’). I have called the hook ‘ˇ ’ ‘caron’ because that is its name as used by ISO and Adobe. I have called the long Hungarian umlaut ‘˝ ’ ‘hungar’ for want of a better name (it’s short-

er than hungarumlaut)..

1.5. Cedilla and ogonek The cedilla and ogonek each have a variant intended for capital letters (in this case the variant is larger not smaller).

96 \def\cedillalike#1#2#3{{%
97  \setbox0=\hbox{#3}%
98  \ifdim\ht0>1ex
99  \ooalign{\hidewidth\char#2\relax\hidewidth\crcr\unhbox0 }%
100  \else
101  \accent#1 #3%
102  \fi

103 }}

104 \chardef\cedillaglyph6 \chardef\Cedillaglyph134
105 \def\c{\cedillalike\cedillaglyph\Cedillaglyph}
106 \chardef\ogonekglyph7 \chardef\Ogonekglyph135
107 \def\k{\cedillalike\ogonekglyph\Ogonekglyph}

2. Symbols and special letters

2.1. Special letters The letters defined here that are not included in Chapter 9 of the TEXbook are the Icelandic thorn (\TH, \th) and eth* (\DH, \dh), the Polish a and e with ogonek (\A, \a, \E, \e), and the Sami eng† (\NG, \ng).

We also give replacements for d, t and l with hook (which are usually drawn with a apostrophe-like mark), and the Esperanto letter hho (ĥ).

108 \chardef\TH"00  \chardef\th"10  \chardef\DH"04  \chardef\dh"14

* Also called ‘edh’. † Also called ‘ing’ or ‘ng’.

109 \chardef\A "01  \chardef\a "11  \chardef\E "05  \chardef\e "15
110 \chardef\NG"02  \chardef\ng"12  \chardef\L "03  \chardef\l "13
111 \chardef\AE"5E  \chardef\ae"7E  \chardef\OE"5F  \chardef\oe"7F
112 \chardef\O "5C  \chardef\o "7C
113 \chardef\vd"9C  \chardef\vt"9D  \chardef\h "9E  \chardef\vl"9F
114 \chardef\ss"18  \chardef\i "19  \chardef\j "1A
115 \def\aa{\ringmark a} \def\AA{\ringmark A}
116 \chardef\orda"98 \chardef\ordo"99 \def\No{N\ordo} \def\no{n\ordo}
117 \chardef\csuperior"98 \def\Mc{M\csuperior}

The command \Mc is used for forming names like Mc̄Donald.

2.2. Other symbols used in text

There are several new symbols here. Note that \trademark is what you will get if you use the ASCII double quote character ‘"’ in your manuscript.

118 \chardef\trademark "22
119 \chardef\copyright "FB  \chardef\registered"FD
120 \chardef\careof    "9A  \chardef\Box       "A0
121 \chardef\cents     "A2  \chardef\pounds    "A3
122 \chardef\currency  "A4  \chardef\permille  "A5
123 \chardef\yen       "A8  \chardef\florin    "A9
124 \chardef\dag       "AA  \chardef\ddag      "AB
125 \chardef\gbdecimal "AE  \chardef\minus     "AF
126 \chardef\S         "BA  \chardef\P         "BB
127 \chardef\degrees   "C0
128 \chardef\lguillemet"BC  \chardef\rguillemet"BE

The \careof sign (^{c}/_{o}) is an abbreviation for ‘care of’ in English-language addresses (actually, Australians traditionally write ‘^{c}/_{−}’). The raised dot \gbdecimal is the British decimal point (I usually do \mathcode` .=\gbdecimal and let maths mode do all the work). The \degrees sign replaces TEX’s $^\circ$.

The guillemets can also be obtained with the ligatures << and >>.

2.3. Symbols used in maths

I have stuck with the plain TEX conventions as much as possible—even though \bullet is more often used in text than maths.

129 \mathcode` \,"602C  \mathcode` \-"20AF
130 \mathcode` \."002E  \mathcode` \/"002F
131 \mathchardef\bullet   "2020  \mathchardef\times    "20A6
132 \mathchardef\backslash"005B  \mathchardef\setminus "205B
133 \mathchardef\cdot     "20AE  \mathchardef\cdotp    "60AE
134 \def\langle{\delimiter"40DB30A }  \delcode` \<"0DB30A
135 \def\rangle{\delimiter"50DD30B }  \delcode` \>"0DD30B
136 \def\lbrace{\delimiter"407B308 }  \let\{\lbrace  \mathcode` \{"407B
137 \def\rbrace{\delimiter"507D309 }  \let\}\rbrace  \mathcode` \}"407D

3. Switching between alphabets

This is one of the strange ideas that went into the design of the Malvern font—I wanted to have small capitals and medium capitals treated as separate alphabets rather than as a different style, just as I treat old-style and ranging numerals as separate symbols. These extra alphabets are present in all Malvern A encodings*

* Fonts with the Malvern A encoding but made from normal PostScript fonts will have medium capitals replaced with full capitals, and old-style numerals replaced with ranging numerals.

These extra alphabets are obtained by transliterating a sequence of letters using the \uppercase and \lowercase commands.† For example, to transliterate capitals into small capitals (the \sc command), we first make assignments so that, for example, \lccode` a is set to the code for small-capital A, then apply \lowercase to the token list.

3.1. Setting upper and lower case codes for special letters

These entries in the \uucode and \lccode tables are used by the composite-letter-building commands rather then the alphabet-switchign commands, but they are included here to be near the other code-hackery.

138 \uccode\th\TH  \lccode\TH\th  \uccode\TH\TH  \lccode\th\th
139 \uccode\a \A   \lccode\A \a   \uccode\A \A   \lccode\a \a
140 \uccode\ng\NG  \lccode\NG\ng  \uccode\NG\NG  \lccode\ng\ng
141 \uccode\l \L   \lccode\L \l   \uccode\L \L   \lccode\l \l
142 \uccode\dh\DH  \lccode\DH\dh  \uccode\DH\DH  \lccode\dh\dh
143 \uccode\e \E   \lccode\E \e   \uccode\E \E   \lccode\e \e
144 \uccode\o \O   \lccode\O \o   \uccode\O \O   \lccode\o \o
145 \uccode\ae\AE  \lccode\AE\ae  \uccode\AE\AE  \lccode\ae\ae
146 \uccode\oe\OE  \lccode\OE\oe  \uccode\OE\OE  \lccode\oe\oe
147 \uccode\i` I    \uccode\j` J \lccode\i\i \lccode\j\j
148 \uccode\csuperior` C

3.2. A macro for changing character codes

The \changecodes command is used to change those segments of character tables that are contiguous and map onto a contiguous segment in the range. It is invoked as

                         \changecodes command x y n

(where command is a token like \uccode or \mathcode and x, y, and n are ⟨number⟩s), and does the equivalent of

command i = j for all \{ \begin{matrix}x ≤ i < x + n \\ y ≤ j < y + n \end{matrix}

149 \def\changecodes#1#2#3#4{%
150  \counta#2\relax \countb#3\relax \countc#4\relax
151  \loop
152  \ifnum\countc>0
153  #1\counta\countb
154  \advance\counta 1
155  \advance\countb 1
156  \advance\countc-1
157  \repeat

158 }

We can use this immediately to arrange that lowercasing medium caps makes lower case, and uppercasing small caps makes full caps:

159 \changecodes\uccode{"E1}{` A}{26}
160 \changecodes\uccode{"C1}{"C1}{26}
161 \changecodes\lccode{"E1}{"E1}{26}
162 \changecodes\lccode{"C1}{` a}{26}

† Alas! this task would be so much easier and more efficient if it were possible to declare new alphabet-switching tables styled after the \uccode and \lccode tables which make \uppercase and \lowercase work. Then all this nonsense could happen in TEX’s mouth, which has some advantages. I can imagine commands \newchartable (used to create a token which can be used in the same way as \uccode) and \usechartable (used to defined macros that work like \uppercase). ETEX hackers take note!

We also make old-style numerals behave as lower case for ranging numerals, and also arrange that maths mode uses ranging figures.

163 \changecodes\lccode{"B0}{` 0}{10}
164 \changecodes\uccode{` 0}{"B0}{10}

In maths mode (1) we use text italic for letters, since CM MAth Italic will not match the body text and (2) we use ranging figures.

165 \changecodes\mathcode{` a}{"7461}{26}
166 \changecodes\mathcode{` A}{"7441}{26}
167 \changecodes\mathcode{` 0}{"70B0}{10}

3.3. Changing the alphabet for special letters got with commands When applying \uppercase or \lowercase to a token list, macros will be unaffected (\ae will still generate ‘ae’). To get around this we define macros that redefine these control sequences. They each take as parameters hex digits used to make character codes.

168 \def\capspecials#1#2{%
169  \chardef\TH"#10 \chardef\A "#11 \chardef\NG"#12
170  \chardef\L "#13 \chardef\DH"#14 \chardef\E "#15
171  \chardef\O "#2C \chardef\AE"#2E \chardef\OE"#2F

172 }

173 \def\lcspecials#1#2#3{%
174  \chardef\th"#10 \chardef\a "#11 \chardef\ng"#12
175  \chardef\l "#13 \chardef\dh"#14 \chardef\e "#15
176  \chardef\o "#2C \chardef\ae"#2E \chardef\oe"#2F
177  \def\ss{\char"#23 \char"#23 }\chardef\i"#39 \chardef\j"#3A

178 }

3.4. Pulling it all together Now we can define the user macros that do the work. These take one argument, a piece of text to transliterate: \sc{OX1~3QD} produces a small-capital ‘OX1 3QD’; \csc{ABCdef} produces caps and small caps ‘ABCDEF’.

179 \def\sc#1{{%
180  \changecodes\lccode{` A}{"E1}{26}\capspecials9F\lowercase{#1}%

181 }}

182 \def\mc#1{{%
183  \changecodes\lccode{` A}{"C1}{26}\capspecials8D\lowercase{#1}%

184 }}

185 \def\csc#1{{%
186  \changecodes\uccode{` a}{"E1}{26}\lcspecials9FE\uppercase{#1}%

187 }}

188 \def\allcaps#1{{%
189  \lcspecials054\uppercase{#1}%

190 }}

191 \def\alllc#1{{%
192  \capspecials17\lowercase{#1}%

193 }}