| 1 |
% \begin{meta-comment} |
| 2 |
% |
| 3 |
% $Id: cmtt.dtx,v 1.1 1996/11/19 20:47:55 mdw Exp $ |
| 4 |
% |
| 5 |
% Nicer handling of the Computer Modern Typewriter font |
| 6 |
% |
| 7 |
% (c) 1996 Mark Wooding |
| 8 |
% |
| 9 |
%----- Revision history ----------------------------------------------------- |
| 10 |
% |
| 11 |
% $Log: cmtt.dtx,v $ |
| 12 |
% Revision 1.1 1996/11/19 20:47:55 mdw |
| 13 |
% Initial revision |
| 14 |
% |
| 15 |
% |
| 16 |
% \end{meta-comment} |
| 17 |
% |
| 18 |
% \begin{meta-comment} <general public licence> |
| 19 |
%% |
| 20 |
%% mdwlist package -- various list-related things |
| 21 |
%% Copyright (c) 1996 Mark Wooding |
| 22 |
%% |
| 23 |
%% This program is free software; you can redistribute it and/or modify |
| 24 |
%% it under the terms of the GNU General Public License as published by |
| 25 |
%% the Free Software Foundation; either version 2 of the License, or |
| 26 |
%% (at your option) any later version. |
| 27 |
%% |
| 28 |
%% This program is distributed in the hope that it will be useful, |
| 29 |
%% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 30 |
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 31 |
%% GNU General Public License for more details. |
| 32 |
%% |
| 33 |
%% You should have received a copy of the GNU General Public License |
| 34 |
%% along with this program; if not, write to the Free Software |
| 35 |
%% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 36 |
%% |
| 37 |
% \end{meta-comment} |
| 38 |
% |
| 39 |
% |
| 40 |
% \begin{meta-comment} <Package preambles> |
| 41 |
%<+sty>\NeedsTeXFormat{LaTeX2e} |
| 42 |
%<+sty>\ProvidesPackage{cmtt} |
| 43 |
%<+fd>\ProvidesFile{mTTcmtt.fd} |
| 44 |
%<+def>\ProvidesFile{mTTcmtt.def} |
| 45 |
%<+sty|fd|def> [1996/05/25 1.1 Handing of the cmtt font] |
| 46 |
% \end{meta-comment} |
| 47 |
% |
| 48 |
% ^^A \CheckSum{174} |
| 49 |
%% \CharacterTable |
| 50 |
%% {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 |
| 51 |
%% 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 |
| 52 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 53 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 54 |
%% Dollar \$ Percent \% Ampersand \& |
| 55 |
%% Acute accent \' Left paren \( Right paren \) |
| 56 |
%% Asterisk \* Plus \+ Comma \, |
| 57 |
%% Minus \- Point \. Solidus \/ |
| 58 |
%% Colon \: Semicolon \; Less than \< |
| 59 |
%% Equals \= Greater than \> Question mark \? |
| 60 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 61 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 62 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 63 |
%% Right brace \} Tilde \~} |
| 64 |
%% |
| 65 |
% |
| 66 |
% \begin{meta-comment} |
| 67 |
% |
| 68 |
%<*driver> |
| 69 |
\input{mdwtools} |
| 70 |
\describespackage{cmtt} |
| 71 |
\mdwdoc |
| 72 |
%</driver> |
| 73 |
% |
| 74 |
% \end{meta-comment} |
| 75 |
% |
| 76 |
%^^A------------------------------------------------------------------------- |
| 77 |
% \section{Introductory note} |
| 78 |
% |
| 79 |
% \LaTeX\ has a rather cunning encoding handling system, which makes funny |
| 80 |
% commands like accents work properly independent of the current font's |
| 81 |
% actual layout. While this works rather well most of the time, the standard |
| 82 |
% \mtt{tt} font has been rather left out of things. \LaTeX\ assumes that |
| 83 |
% the Computer Modern Typewriter fonts have exactly the same layout as the |
| 84 |
% more normal Computer Modern Roman family (i.e., that both conform to the |
| 85 |
% \mtt{OT1} encoding). This plainly isn't true, since the Typewriter font |
| 86 |
% contains a bunch of standard ASCII characters which are omitted from the |
| 87 |
% standard Computer Modern fonts, such as curly braces \mtt{\{} and \mtt{\}}, |
| 88 |
% and the backslash \mtt{\\}; these are usually dug up from the maths fonts, |
| 89 |
% which looks fine in normal text, but looks really odd in monospace text. |
| 90 |
% Compare `\texttt{\textbackslash begin\{document\}}' to |
| 91 |
% `\mtt{\\begin\{document\}}', for example. |
| 92 |
% |
| 93 |
% There are two possibilities for dealing with this problem. One is to use |
| 94 |
% the \mtt{\\verb} command, which works since all the extra characters in |
| 95 |
% the Typewriter font are in the correct places, or use the DC~fonts, which |
| 96 |
% have a proper encoding set up which contains all of these special |
| 97 |
% characters anyway. |
| 98 |
% |
| 99 |
% Neither of these solutions is perfect. Using \mtt{\\verb} causes all |
| 100 |
% manner of little niggly problems: you can't use it in footnotes or |
| 101 |
% section headings, for example. (There are of course workarounds for this |
| 102 |
% sort of thing: the author's \package{footnote} package provides a |
| 103 |
% \env{footnote} environment which will allow verbatim text, and verbatim |
| 104 |
% text in section headings can be achieved if one is sufficiently |
| 105 |
% \TeX nical.) Using the DC~fonts is fine, although you actually lose a |
| 106 |
% glyph or two. As far as the author is aware, the character \mtt{\'} (an |
| 107 |
% `unsexed' single quote) is not present in the \mtt{T1}-encoded version of |
| 108 |
% Computer Modern Typewriter, although it is hidden away in the original |
| 109 |
% version. The author has found a need for this character in computer |
| 110 |
% listings, and was horrified to discover that it was replaced by a German |
| 111 |
% single quote character (\mtt{\\quotesinglbase}). |
| 112 |
% |
| 113 |
% This package defines a special encoding for the Computer Modern Typewriter |
| 114 |
% font, so that documents can take advantage of its ASCII characters without |
| 115 |
% resorting to verbatim text. (The main advantage of the DC~fonts, that |
| 116 |
% words containing accents can be hyohenated, doesn't really apply to the |
| 117 |
% Typewriter font, since it doesn't allow hyphenation by default anyway.) |
| 118 |
% |
| 119 |
% There are several files you'll need to create: |
| 120 |
% \begin{description} \def\makelabel#1{\hskip\labelsep\mttfamily#1\hfil} |
| 121 |
% |
| 122 |
% \item [cmtt.sty] tells \LaTeX\ that there's a new encoding. It also |
| 123 |
% provides some options for customising some aspects of the |
| 124 |
% encoding, and defines some useful commands. |
| 125 |
% |
| 126 |
% \item [mTTenc.def] describes the encoding to \LaTeX: it sets up all the |
| 127 |
% appropriate text commands so that they produce beautiful results. |
| 128 |
% |
| 129 |
% \item [mTTcmtt.fd] describes the re-encoded version of the font. This |
| 130 |
% is more or less a copy of the file \mtt{OT1cmtt.fd}. |
| 131 |
% |
| 132 |
% \end{description} |
| 133 |
% |
| 134 |
% The package accepts some options which may be useful: |
| 135 |
% \begin{description} \def\makelabel#1{\hskip\labelsep\sffamily#1\hfil} |
| 136 |
% |
| 137 |
% \item [override] overrides the meaning of the \mtt{\\ttfamily} command |
| 138 |
% (and therefore also the \mtt{\\texttt} command too), making it the |
| 139 |
% same as the new \mtt{\\mttfamily} command. This isn't the default |
| 140 |
% just in case the change breaks something in an unexpected way. |
| 141 |
% |
| 142 |
% \item [t1] informs the package that you're using the \mtt{T1} encoding, |
| 143 |
% and therefore can borrow some accented characters from the DC~version |
| 144 |
% of Computer Modern Typewriter. This will probably be unnecessary, |
| 145 |
% since the package attempts to work out what to do all by itself. |
| 146 |
% |
| 147 |
% \item [ot1] forces the package \emph{not} to use the DC~version of the |
| 148 |
% Computer Modern Typewriter font for funny accents. Only use this |
| 149 |
% option if the package thinks it should use the DC~Typewriter font |
| 150 |
% when it shouldn't. |
| 151 |
% |
| 152 |
% \end{description} |
| 153 |
% |
| 154 |
% \DescribeMacro{\mttfamily} |
| 155 |
% The command \mtt{\\mttfamily} selects the properly-encoded Typewriter |
| 156 |
% font. It's a declaration which works just like the \mtt{\\ttfamily} |
| 157 |
% command, except that comamnds like \mtt{\\\}} and \mtt{\\\_} use the |
| 158 |
% characters from the font rather than choosing odd-looking versions from |
| 159 |
% the maths fonts. All of the accent commands still work properly. In fact, |
| 160 |
% some accent commands which didn't work before have been fixed. For |
| 161 |
% example, saying `\mtt{\\texttt\{P\\'al Erd\\H os\}}' would produce |
| 162 |
% something truly appalling like `\texttt{P\'al Erd\H os}', which is |
| 163 |
% obviously ghastly. The new encoding handles this properly, and produces |
| 164 |
% `\textmtt{P\'al Erd\H os}'.\footnote{ |
| 165 |
% This isn't quite perfect. The accent, which isn't actually present in |
| 166 |
% the Typewriter font, is taken from the Computer Modern bold font, but |
| 167 |
% it doesn't look too bad. However, if you pass the option \textsf{t1} |
| 168 |
% to the \package{cmtt} package when you load it, the accent will be taken |
| 169 |
% from the DC~Typewriter font, and it will look totally wonderful.} |
| 170 |
% |
| 171 |
% \DescribeMacro{\textmtt} |
| 172 |
% Font changing commands are much more convenient than th declarations, |
| 173 |
% so a command \mtt{\\textmtt} is provided: it just typesets its argument |
| 174 |
% in the re-encoded Typewriter font. |
| 175 |
% |
| 176 |
% \DescribeMacro{\mtt} |
| 177 |
% Rather more excitingly, the \mtt{\\mtt} command allows you to generate |
| 178 |
% almost-verbatim text very easily, without any of the restrictions of |
| 179 |
% the \mtt{\\verb} command. This command was inspired by something which |
| 180 |
% David Carlisle said to me in an email correspondence regarding the |
| 181 |
% overuse of verbatim commands. |
| 182 |
% |
| 183 |
% \mtt{\\mtt} redefines several `short' commands to typeset the obvious |
| 184 |
% characters. The complete list is shown below: there are some oddities, |
| 185 |
% so watch out. |
| 186 |
% |
| 187 |
% ^^A This is an evil table. See if I care. (This is based on lots of |
| 188 |
% ^^A hacking I did in glyphs.tex, but a good deal less horrible.) |
| 189 |
% |
| 190 |
% \medskip |
| 191 |
% \hbox to \hsize\bgroup |
| 192 |
% \hfil\vbox\bgroup |
| 193 |
% \def\ex#1#2{\strut |
| 194 |
% \enskip |
| 195 |
% \mtt{\\\char`#2}\quad\hfil% |
| 196 |
% \mtt{#2}\enskip} |
| 197 |
% \def\h{\noalign{\hrule}} |
| 198 |
% \def\v{height2pt&\omit&&\omit&&\omit&&\omit&&\omit&\cr} |
| 199 |
% \let~\relax |
| 200 |
% \offinterlineskip |
| 201 |
% \ialign\bgroup&\vrule#&\ex#\cr \h\v |
| 202 |
% &~\\&&~\{&&~\}&&~\_&&~\^&\cr \v\h\v |
| 203 |
% &~\$&&~\%&&~\&&&~\#&&~\~&\cr \v\h\v |
| 204 |
% &~\"&&~\'&&~\ &&~\|&&\omit\hfil&\cr \v\h |
| 205 |
% \egroup\egroup |
| 206 |
% \hfil\egroup |
| 207 |
% \medskip |
| 208 |
% |
| 209 |
% As well as redefining these commands, \mtt{\\mtt} will endeavour to make |
| 210 |
% single special characters display themselves in a verbatim-like way. This |
| 211 |
% only works on `active' characters (like \mtt{~}), and \mtt{\\mtt} makes |
| 212 |
% no attempt to change the category codes of any characters. |
| 213 |
% |
| 214 |
% Among other things, you'll probably noticed that several accent-making |
| 215 |
% commands have been redefined. You can still use these accents through |
| 216 |
% the \mtt{\\a} command, by saying \mtt{\\a'}, \mtt{\\a\^} and so on, |
| 217 |
% as in the \env{tabbing} environment. |
| 218 |
% |
| 219 |
% There are also some oddities in the table: \mtt{\|} and \mtt{\"} can be |
| 220 |
% accessed easily without playing with silly commands. Well, that's almost |
| 221 |
% the case: these two characters are both often used as `short' verbatim |
| 222 |
% commands, so they are forced back to their normal meanings so you can |
| 223 |
% type them. |
| 224 |
% |
| 225 |
% Finally, a word on spacing. The \mtt{\\\ } command has been hijacked |
| 226 |
% to produce a funny `visible space' character. You can still produce |
| 227 |
% multiple spaces by saying something like `\mtt{\ \{\}\ \{\}}\dots\mtt{\ }', |
| 228 |
% which is a bit contrived, but that's tough. Also, \mtt{~} has been stolen |
| 229 |
% so that you can type \mtt{~} characters (e.g., in URLs), so the only |
| 230 |
% way you can tpye a nonbreaking space is by using the \mtt{\\nobreakspace} |
| 231 |
% command, which is a bit of a mouthful. There's an abbreviation, though: |
| 232 |
% \mtt{\\nbsp} now means exactly the same thing. |
| 233 |
% |
| 234 |
% Was that not all supremely useful? Oh, just a note: this document doesn't |
| 235 |
% use a single verbatim command or environment (except in the listings, |
| 236 |
% where it's unavoidable) -- it's all done with \mtt{\\mtt}. |
| 237 |
% |
| 238 |
% \implementation |
| 239 |
% |
| 240 |
% \section{Implementation} |
| 241 |
% |
| 242 |
% \subsection{The package} |
| 243 |
% |
| 244 |
% \begin{macrocode} |
| 245 |
%<*sty> |
| 246 |
% \end{macrocode} |
| 247 |
% |
| 248 |
% I'll start with some options handling. |
| 249 |
% |
| 250 |
% \begin{macrocode} |
| 251 |
\newif\ifcmtt@override |
| 252 |
\newif\ifcmtt@dcfonts |
| 253 |
\def\@tempa{T1}\ifx\encodingdefault\@tempa |
| 254 |
\cmtt@dcfontstrue |
| 255 |
\fi |
| 256 |
\DeclareOption{override}{\cmtt@overridetrue} |
| 257 |
\DeclareOption{t1}{\cmtt@dcfontstrue} |
| 258 |
\DeclareOption{ot1}{\cmtt@dcfontsfalse} |
| 259 |
\ProcessOptions |
| 260 |
% \end{macrocode} |
| 261 |
% |
| 262 |
% This bit is really trivial. I'll just declare the font encoding. Oh, that |
| 263 |
% was easy. |
| 264 |
% |
| 265 |
% \begin{macrocode} |
| 266 |
\DeclareFontEncoding{mTT}{}{} |
| 267 |
% \end{macrocode} |
| 268 |
% |
| 269 |
% Wait: there's a problem. \LaTeX\ will now complain bitterly that it can't |
| 270 |
% find the font \mtt{mTT/cmr/m/n}, which is readonable, since I haven't |
| 271 |
% declared any such font. The following line should sort this out, |
| 272 |
% |
| 273 |
% \begin{macrocode} |
| 274 |
\DeclareFontSubstitution{mTT}{cmtt}{m}{n} |
| 275 |
% \end{macrocode} |
| 276 |
% |
| 277 |
% Now I'd better load all the text commands I'll need when in this funny |
| 278 |
% font variant. |
| 279 |
% |
| 280 |
% \begin{macrocode} |
| 281 |
\input{mTTenc.def} |
| 282 |
% \end{macrocode} |
| 283 |
% |
| 284 |
% \begin{macro}{\mttfamily} |
| 285 |
% \begin{macro}{\textmtt} |
| 286 |
% |
| 287 |
% Finally, I'll need to define a command which switches to this funny font, |
| 288 |
% and a \mtt{\\text}\dots\ command for it. |
| 289 |
% |
| 290 |
% \begin{macrocode} |
| 291 |
\DeclareRobustCommand{\mttfamily}{% |
| 292 |
\fontencoding{mTT}\fontfamily{\ttdefault}\selectfont% |
| 293 |
} |
| 294 |
\DeclareTextFontCommand{\textmtt}{\mttfamily} |
| 295 |
% \end{macrocode} |
| 296 |
% |
| 297 |
% \end{macro} |
| 298 |
% \end{macro} |
| 299 |
% |
| 300 |
% If an override was requested, make \mtt{\\ttfamily} the same as |
| 301 |
% \mtt{\\mttfamily}. |
| 302 |
% |
| 303 |
% \begin{macrocode} |
| 304 |
\ifcmtt@override |
| 305 |
\let\ttfamily\mttfamily |
| 306 |
\fi |
| 307 |
% \end{macrocode} |
| 308 |
% |
| 309 |
% Well, that's all that's needed for the font definition. Here's a command |
| 310 |
% which will typeset its argument in the typewriter font, allowing easy |
| 311 |
% access to all the funny characters, and printing them properly in the |
| 312 |
% correct font (which \mtt{\\\{} doesn't do, for example). |
| 313 |
% |
| 314 |
% \begin{macro}{\mtt@setchar} |
| 315 |
% |
| 316 |
% This macro assigns the given meaning to the given control sequence. Also, |
| 317 |
% if the character named in the control sequence is currently set active, |
| 318 |
% it will set the active meaning of the character to the same value. |
| 319 |
% |
| 320 |
% \begin{macrocode} |
| 321 |
\def\mtt@setchar#1#2{% |
| 322 |
\ifx#1#2\chardef#1`#1\else\let#1#2\fi% |
| 323 |
\ifnum\catcode`#1=13% |
| 324 |
\begingroup% |
| 325 |
\lccode`\~=`#1% |
| 326 |
\lowercase{\endgroup\let~#1}% |
| 327 |
\fi% |
| 328 |
} |
| 329 |
% \end{macrocode} |
| 330 |
% |
| 331 |
% \end{macro} |
| 332 |
% |
| 333 |
% \begin{macro}{\mtt@chars} |
| 334 |
% |
| 335 |
% This macro lists the various control sequences which should be set up, |
| 336 |
% so that they can be easily added to. |
| 337 |
% |
| 338 |
% \begin{macrocode} |
| 339 |
\def\mtt@chars{% |
| 340 |
\do\#\#% |
| 341 |
\do\%\%% |
| 342 |
\do\&\&% |
| 343 |
\do\^\^% |
| 344 |
\do\~\~% |
| 345 |
\do\'\textquotesingl% |
| 346 |
\do\"\textquotedbl% |
| 347 |
\do\|\textbar% |
| 348 |
\do\$\textdollar% |
| 349 |
\do\_\textunderscore% |
| 350 |
\do\{\textbraceleft% |
| 351 |
\do\}\textbraceright% |
| 352 |
\do\\\textbackslash% |
| 353 |
\do\ \textvisiblespace% |
| 354 |
} |
| 355 |
% \end{macrocode} |
| 356 |
% |
| 357 |
% \end{macro} |
| 358 |
% |
| 359 |
% \begin{macro}{\mtt@do} |
| 360 |
% |
| 361 |
% This just sets up all the special characters listed above. It's a simple |
| 362 |
% abbreviation, really. |
| 363 |
% |
| 364 |
% \begin{macrocode} |
| 365 |
\def\mtt@do{\let\do\mtt@setchar\mtt@chars} |
| 366 |
% \end{macrocode} |
| 367 |
% |
| 368 |
% \end{macro} |
| 369 |
% |
| 370 |
% \begin{macro}{\mtt} |
| 371 |
% |
| 372 |
% And finally, the macro itself. Ta-da! |
| 373 |
% |
| 374 |
% \begin{macrocode} |
| 375 |
\DeclareRobustCommand\mtt[1]{\textmtt{\mtt@do#1}} |
| 376 |
% \end{macrocode} |
| 377 |
% |
| 378 |
% \end{macro} |
| 379 |
% |
| 380 |
% \begin{macro}{\@tabacckludge} |
| 381 |
% |
| 382 |
% The otherwise almost totally perfect \mtt{\\@tabacckludge} gets very |
| 383 |
% upset when its argument is an active character. (If you're wondering, |
| 384 |
% this is the command which is responsible for the behaviour of the \mtt{\\a} |
| 385 |
% command.) Adding a \mtt{\\string} makes everything work perfectly. |
| 386 |
% |
| 387 |
% \begin{macrocode} |
| 388 |
\def\@tabacckludge#1{% |
| 389 |
\expandafter\@changed@cmd\csname\string#1\endcsname\relax% |
| 390 |
} |
| 391 |
\let\a\@tabacckludge |
| 392 |
% \end{macrocode} |
| 393 |
% |
| 394 |
% \end{macro} |
| 395 |
% |
| 396 |
% \begin{macro}{\nbsp} |
| 397 |
% |
| 398 |
% Make an abbreviation for \mtt{\\nobreakspace}. |
| 399 |
% |
| 400 |
% \begin{macrocode} |
| 401 |
\let\nbsp\nobreakspace |
| 402 |
% \end{macrocode} |
| 403 |
% |
| 404 |
% \end{macro} |
| 405 |
% |
| 406 |
% I think that's all that I have to do for the package. If there's any |
| 407 |
% more to do, I'll add it later. |
| 408 |
% |
| 409 |
% \begin{macrocode} |
| 410 |
%</sty> |
| 411 |
% \end{macrocode} |
| 412 |
% |
| 413 |
% |
| 414 |
% \subsection{The font definition file} |
| 415 |
% |
| 416 |
% This is obviously copied almost verbatim from the file \mtt{OT1cmtt.fd}. |
| 417 |
% |
| 418 |
% \begin{macrocode} |
| 419 |
%<*fd> |
| 420 |
\DeclareFontFamily{mTT}{cmtt}{\hyphenchar\font\m@ne} |
| 421 |
\DeclareFontShape{mTT}{cmtt}{m}{n}{ |
| 422 |
<5> <6> <7> <8> cmtt8 |
| 423 |
<9> cmtt9 |
| 424 |
<10> <10.95> cmtt10 |
| 425 |
<12> <14.4> <17.28> <20.74> <24.88> cmtt12 |
| 426 |
}{} |
| 427 |
\DeclareFontShape{mTT}{cmtt}{m}{it}{ |
| 428 |
<5> <6> <7> <8> <9> <10> <10.95> <12> <14.4> <17.28> <20.74> <24.88> |
| 429 |
cmitt10 |
| 430 |
}{} |
| 431 |
\DeclareFontShape{mTT}{cmtt}{m}{sl}{ |
| 432 |
<5> <6> <7> <8> <9> <10> <10.95> <12> <14.4> <17.28> <20.74> <24.88> |
| 433 |
cmsltt10 |
| 434 |
}{} |
| 435 |
\DeclareFontShape{mTT}{cmtt}{m}{sc}{ |
| 436 |
<5> <6> <7> <8> <9> <10> <10.95> <12> <14.4> <17.28> <20.74> <24.88> |
| 437 |
cmtcsc10 |
| 438 |
}{} |
| 439 |
\DeclareFontShape{mTT}{cmtt}{m}{ui} {<->sub * cmtt/m/it} {} |
| 440 |
\DeclareFontShape{mTT}{cmtt}{bx}{n} {<->sub * cmtt/m/n} {} |
| 441 |
\DeclareFontShape{mTT}{cmtt}{bx}{it} {<->sub * cmtt/m/it} {} |
| 442 |
\DeclareFontShape{mTT}{cmtt}{bx}{ui} {<->sub * cmtt/m/it} {} |
| 443 |
%</fd> |
| 444 |
% \end{macrocode} |
| 445 |
% |
| 446 |
% |
| 447 |
% \subsection{The encoding definitions file} |
| 448 |
% |
| 449 |
% I've saved the trickiest bit until last. This file defines the mappings |
| 450 |
% from text commands to glyphs in the font. |
| 451 |
% |
| 452 |
% \begin{macrocode} |
| 453 |
%<*def> |
| 454 |
% \end{macrocode} |
| 455 |
% |
| 456 |
% First for some fun with accents. The |cmtt| font doesn't contain all of |
| 457 |
% the accents which the other Computer Modern fonts do, because those slots |
| 458 |
% contain the standard ASCII characters which usually have to be `borrowed' |
| 459 |
% from the maths fonts. |
| 460 |
% |
| 461 |
% Anyway, there's a load which don't need any special treatment. These are |
| 462 |
% chosen from the \mtt{OT1} encoding by default anyway, so I needn't |
| 463 |
% bother unless I'm really bothered about speed. I'm not, so I'll save |
| 464 |
% the memory. |
| 465 |
% |
| 466 |
% Following the example of the \TeX book, I'll use the bold roman font |
| 467 |
% for accents, so that they don't look really spindly. This is actually |
| 468 |
% remarkably difficult to do, because the \textsf{NFSS} keeps getting in |
| 469 |
% the way. I'll look after the old font name in a macro (it's handy that |
| 470 |
% \textsf{NFSS} maintains this for me) and change to a known font, do the |
| 471 |
% accent, change font back again, do the argument to the accent, and then |
| 472 |
% close the group I did all of this in, so that no-one else notices what a |
| 473 |
% naughty chap I am, really. This is startlingly evil. |
| 474 |
% |
| 475 |
% \begin{macrocode} |
| 476 |
\def\cmtt@accent#1#2{{% |
| 477 |
\let\@old@font\font@name% |
| 478 |
\ifcmtt@dcfonts% |
| 479 |
\fontencoding{T1}\selectfont% |
| 480 |
\else% |
| 481 |
\usefont{OT1}{cmr}{bx}{n}% |
| 482 |
\fi% |
| 483 |
#1{\@old@font#2}% |
| 484 |
}} |
| 485 |
% \end{macrocode} |
| 486 |
% |
| 487 |
% And now for the actual offending accents. |
| 488 |
% |
| 489 |
% \begin{macrocode} |
| 490 |
\DeclareTextCommand{\H}{mTT}{\cmtt@accent\H} |
| 491 |
\DeclareTextCommand{\.}{mTT}{\cmtt@accent\.} |
| 492 |
% \end{macrocode} |
| 493 |
% |
| 494 |
% The `under' accents are all OK, so I shan't bother to define them either. |
| 495 |
% Similarly, lots of the text symbol commands are fine as they are by |
| 496 |
% default and I don't need to try and define them again. |
| 497 |
% |
| 498 |
% This, then, is the remaining commands which really need sorting out. |
| 499 |
% (By the way, the only reason I've redefined \mtt{\\textellipsis} is |
| 500 |
% because otherwise it will mess up the nice monospacing.) |
| 501 |
% |
| 502 |
% \begin{macrocode} |
| 503 |
\DeclareTextSymbol{\textbackslash}{mTT}{92} |
| 504 |
\DeclareTextSymbol{\textbar}{mTT}{124} |
| 505 |
\DeclareTextSymbol{\textbraceleft}{mTT}{123} |
| 506 |
\DeclareTextSymbol{\textbraceright}{mTT}{125} |
| 507 |
\DeclareTextSymbol{\textless}{mTT}{60} |
| 508 |
\DeclareTextSymbol{\textgreater}{mTT}{62} |
| 509 |
\DeclareTextSymbol{\textunderscore}{mTT}{95} |
| 510 |
\DeclareTextSymbol{\textvisiblespace}{mTT}{32} |
| 511 |
\DeclareTextCommand{\textellipsis}{mTT}{...} |
| 512 |
\DeclareTextSymbol{\textquotedbl}{mTT}{34} |
| 513 |
\DeclareTextSymbol{\textquotesingl}{mTT}{13} |
| 514 |
% \end{macrocode} |
| 515 |
% |
| 516 |
% That's all there is. Please return to your homes. |
| 517 |
% |
| 518 |
% \Finale |
| 519 |
% |
| 520 |
\endinput |