summaryrefslogtreecommitdiff
path: root/language/typingtex/Active8MacProse.dir/Active8MacCM.tex
blob: 0fda92a4c88410e11c568300c8c8e2e67d755927 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
 %%%%% Active8MacCM.tex
   %%% November 1992, Mar 1994

 %%%% NB: 7bit ascii file

 %%% Author:
   %% Laurent Siebenmann, Orsay, France
   %% lcs@matups.matups.fr <= bug reports here please!

 %%% Master Posting:
   %% ftp matups.matups.fr in directory TypingTeX.dir

 %%% AIM:
   %% Exploit TeX's active character mechanism
   %% in conjunction with CaesarCM
   %% to allow direct typing of prose for TeX
   %% using all accented characters of Times or other
   %% Macintosh fonts (Helvetica, Palatino etc.)
   %% A fortiori, one can use the less rich but more readable
   %% bitmapped fonts Monaco, Geneva etc.

 %%% INSTRUCTIONS:
  %% You have merely  to \input
  %% this file on top of any format in which the
  %%  7-bit typing system for accented characters
  %% CaesarCM has been incorporated.
  %% format-dumper-CM  is a tool to create such
  %% formats.  Then direct typing
  %% of accented characters is acceptable to TeX.
  %% TeX will use a ready-made accented character
  %% if these are available in the current font
  %% and create a composite character otherwise.
  %% LaTeX users must \input the file
  %%   --- AFTER LaTeX.tex and
  %%   --- BEFORE   \documentstyle

  %%%  CASE CHANGE RESTORED!
  %% Such macros as these necessarily fail to
  %% extend the action  of the primitives
  %% \uppercase and \lowercase
  %% to directly typed accented characters.
  %% To replace (or indeed redefine) these, consider
  %% using \Uppercase and \Lowercase
  %% Or \eUppercase and \eLowercase from caesarcm.tex.
  %% See documentation following  \endinput

 %%%% \Uppercase and \Lowercase to extend action of
  %%% \uppercase and \lowercase to 128-255.  Robust.
  %%% Misbehave on \ss, \ae, \oe, \o and caps (leave them fixed)
  %%% \eUppercase and \eLowercase of caesarcm.tex
  %%% have perfect behavior --- but are fragile.

 \begingroup
  \catcode`\@=11
  \catcode`\/=13

 \global\let\primuppercase\uppercase
 \global\let\primlowercase\lowercase

 %%\count@ is Plain scratch counter \count255
 %%% These counts exist globally global despite appearances
 \ifx\undefined\Ct@\csname newcount\endcsname\Ct@\fi
 \ifx\undefined\Ct@@\csname newcount\endcsname\Ct@@\fi
 \ifx\undefined\Ct@@@\csname newcount\endcsname\Ct@@@\fi

   \count@=12\Ct@=128\Ct@@=255
   \loop
     \catcode\Ct@=\count@
   \ifnum\Ct@<\Ct@@\relax
     \advance\Ct@ by \@ne
   \repeat

 %%%%% Casing alphabetic Mac Characters
   %%
 \def\Alphaholder@{%
   /^^e7^^87./^^83^^8e./^^ea^^92./^^ee^^97./^^f2^^9c.%
   /^^cb^^88./^^e9^^8f./^^ed^^93./^^f1^^98./^^f4^^9d.%
   /^^e5^^89./^^e6^^90./^^eb^^94./^^ef^^99./^^f3^^9e.%
   /^^80^^8a./^^e8^^91./^^ec^^95./^^85^^9a./^^86^^9f.%
   /^^d9^^d8./^^cc^^8b./^^84^^96./^^cd^^9b./^^81^^8c.%
   /^^82^^8d./^^ae^^be./^^ce^^cf./^^af^^bf.%
   }
  %\def\CheckPeriod#1{\if#1.\else %
  %  \errmessage{ !!! Error in character data}\fi}
 \def\space{ }
 
\def/#1#2.{\lccode\number`#1=\number`#2\lccode\number`#2=\number`#2}
  
   \xdef\LAlphaPrep@{\Alphaholder@}%
     %\show\LAlphaPrep@

 
\def/#1#2.{\uccode\number`#1=\number`#1\uccode\number`#2=\number`#1}
   \xdef\UAlphaPrep@{\Alphaholder@}%
   %\show\UAlphaPrep@

 %%%%% Casing nonalphabetic Mac Characters
 \def\Otherholder@{%
  /^^a0./^^a1./^^a2./^^a3./^^a4./^^a5./^^a6./^^a7.%
  /^^a8./^^a9./^^aa./^^ab./^^ac./^^ad.%
  /^^b0./^^b1./^^b2./^^b3./^^b4./^^b5./^^b6./^^b7.%
  /^^b8./^^b9./^^ba./^^bb./^^bc./^^bd.%
  /^^c0./^^c1./^^c2./^^c3./^^c4./^^c5./^^c6./^^c7.%
  /^^c8./^^c9./^^ca./^^d0./^^d1./^^d2./^^d3./^^d4.%
  /^^d5./^^d6./^^d7./^^da./^^db./^^dc./^^dd./^^de.%
  /^^df./^^e0./^^e1./^^e2./^^e3./^^e4./^^f0./^^f5.%
  /^^f6./^^f7./^^f8./^^f9./^^fa./^^fb./^^fc./^^fd.%
  /^^fe./^^ff.}

 \def/#1.{\uccode\number`#1\z@}
 \xdef\UOtherPrep@{\Otherholder@}
 %\show\UOtherPrep@

 \def/#1.{\lccode\number`#1\z@}
 \xdef\LOtherPrep@{\Otherholder@}
 %\show\LOtherPrep@

 \gdef\SetCorkULCodeSeg{%
  \loop
   \Ct@=\count@\advance\Ct@ by 32
   \uccode\count@=\count@
   \lccode\count@=\Ct@
   \uccode\Ct@=\count@
   \lccode\Ct@=\Ct@
  \ifnum\count@<\Ct@@
   \relax\advance\count@ by 1
  \repeat
  }

 \gdef\SetCorkULCodes{%
  %%% Impose Cork lc uc and sf codes
  \count@=128 \Ct@@=158 \SetCorkULCodeSeg %% segment "80 to "BF
  %%%  Cork "9F is \S and "BF  is pound sign lc/uc codes 0
  \count@=192 \Ct@@=223 \SetCorkULCodeSeg %% segment "C0 to "FF
  }

 \gdef\Uppercase#1{\UAlphaPrep@\UOtherPrep@
      \primuppercase{#1}%
      \SetCorkULCodes
      }

 \gdef\Lowercase#1{\LAlphaPrep@\LOtherPrep@
      \primlowercase{#1}%
      \SetCorkULCodes
      }

 \endgroup

  \begingroup
  \catcode`\@=11
  \global\let\EX@\expandafter

   %\show\CaesarCMLoaded
   {\catcode`!=12
    \ifx\CaesarCMLoaded\undefined
      \immediate\write16{}%
      \immediate\write16{ !!! CaesarCM not loaded}
      \gdef\temp{}\else  \gdef\temp{}
      \fi}
    \temp %\endgroup\end

  { \catcode`!=11
    \ifx\ActiveEight\undefined
      \gdef\temp{}
    \else
      \W@{}%
      \W@{ !!! Stop! An Active8MacCM typing setup has already been
loaded.
      \gdef\temp{\endgroup\end}\else  \gdef\temp{}
      \global\let\ActiveEight\relax
    \fi}
    \temp

   %%% Globally set high ASCII to 13
    %%
   \count@="80\Ct@@="FF
   \loop
     \global\catcode\count@=\active
   \ifnum\count@<\Ct@@\relax
     \advance\count@ by \@ne
   \repeat

 \def\CheckPeriod#1{\if#1.\else
        \errmessage{ !!! Error in character data}\fi}

  %%% \lcucActAccDef ^^83^^8eEe\'. %%is example!
   %% Presumably uc and lc codes already set
\def\lcucActAccDef#1#2#3#4#5#6{%
   \CheckPeriod{#6}%
   \global\catcode`#1=\active
   \global\catcode`#2=\active
     \gdef#1{#5#3}%% #3 and #4 ascii catcode 11; #5 is \' say
     \gdef#2{#5#4}%
   }

  %%% \CharAct@ ^^d4^^60. %% is example!
     %% leaves uc lc unresolved
 \def\CharAct@#1#2#3{%
  \global\catcode`#1=\active
  \CheckPeriod{#3}%
   \global\let#1#2%
   }

  %%% \QuoteAct@ ^^d4^^60. %% is example!
     %%
 \def\QuoteAct@#1.#2#3{%
  \CheckPeriod{#3}%
   \global\catcode`#1=\active
   \xdef#1{\string#2}%
   \global\uccode`#2=0\global\lccode`#2=0
   }

  %%% \Forbid@
     %%
 \def\Forbid@ #1{%
    \global\catcode`#1=15 }

  \catcode`/=13
  \let/\lcucActAccDef

  \catcode`\*=13
  \let*=\QuoteAct@

  \catcode`\|=13
  \let|=\CharAct@

 %%% / is \lcucActAccDef
  /^^e7^^87Aa\'.
  /^^83^^8eEe\'.
  /^^ea^^92Ii\'.
  /^^ee^^97Oo\'.
  /^^f2^^9cUu\'.
  /^^cb^^88Aa\`.
  /^^e9^^8fEe\`.
  /^^ed^^93Ii\`.
  /^^f1^^98Oo\`.
  /^^f4^^9dUu\`.
  /^^e5^^89Aa\^.
  /^^e6^^90Ee\^.
  /^^eb^^94Ii\^.
  /^^ef^^99Oo\^.
  /^^f3^^9eUu\^.
  /^^80^^8aAa\".
  /^^e8^^91Ee\".
  /^^ec^^95Ii\".
  /^^85^^9aOo\".
  /^^86^^9fUu\".
  /^^d9^^d8Yy\".
  /^^cc^^8bAa\~.
  /^^84^^96Nn\~.
  /^^cd^^9bOo\~.
  /^^81^^8cAa\*.%\show^^81
  /^^82^^8dCc\c.

  %%% | is \CharAct@
  |^^ae\AE.
  |^^be\ae.
  |^^ce\OE.
  |^^cf\oe.
  |^^af\O.
  |^^bf\o.
  |^^a7\ss.

  %%% * is \QuoteAct@
    {\catcode"5C=12 *^^d2.^^5c.}%% backslash code!!
    *^^d3.^^22.%%  ''
    *^^d4.^^60.%%  `
    *^^d5.^^27.%%  '

  \gdef\Symb@@#1{%
    \EX@ \ifx \csname #1@\endcsname\relax
             ^^58%% Print X if nothing better
       \else
             \csname #1@\endcsname
       \fi}

  \xdef\questiondown@{\string^^3e}%
  \xdef\exclamdown@{\string^^3c}%
  %\def\guillemotleft@{\DLG}%% in gllmts.tex
  %\def\guillemotright@{\DRG}%% in gllmts.tex
  \def\dagger@{$\m@th\dag$}%
  \gdef\daggerdbl@{$\m@th\ddag$}%
  \gdef\section@{$\m@th\S$}
  \gdef\paragraph@{$\m@th\P$}
  \gdef\pound@{{\ifdim\fontdimen\@ne\font >\z@
      \it\else \font\ft=cmu10\ft\fi\char`\$}}%% cheat
  %\gdef\paragraph@{X}%% unavailable

     \gdef^^c0{\questiondown}
     \gdef^^c1{\exclamdown}
     \gdef^^c7{\guillemotleft}
     \gdef^^c8{\guillemotright}
     \gdef^^a4{\section}
     \gdef^^a3{\pound}
     \gdef^^a0{\dagger}
     \gdef^^e0{\daggerdbl}
     \gdef^^a6{\paragraph}
     \gdef^^e4{\perthousand}

  %%% If Caesar not present \Symb@@=\Symb@
     \gdef\questiondown{\Symb@@{questiondown}}
     \gdef\exclamdown{\Symb@@{exclamdown}}
     \gdef\guillemotleft{\Symb@@{guillemotleft}}
     \gdef\guillemotright{\Symb@@{guillemotright}}
     \gdef\section{\Symb@@{section}}
     \gdef\pound{\Symb@@{pound}}
     \gdef\dagger{\Symb@@{dagger}}
     \gdef\daggerdbl{\Symb@@{daggerdbl}}
     \gdef\paragraph{\Symb@@{paragraph}}
     \gdef\perthousand{\Symb@@{perthousand}}

  \ifx\CaesarCMLoaded\relax
     \global\let\Symb@@=\Symb@ %% of Caesar
  \fi

   \endgroup

 %%%%%% LaTeX material

  { \catcode`!=11 \catcode`\@=11
   \ifx\undefined\@@line %% \@@line unique to LPlain
     \gdef\temp{\endinput}
   \else
     \gdef\temp{}
   \fi}
    \temp  %% \endinput unless LaTeX

  { \catcode`!=11\catcode`\@=11
      \ifx\@@end\undefined %% \@@end  unique to LaTeX
        \W@{}%
        \W@{ !!! LaTeX must be fully loaded }%
        \W@{ !!! before Active8MacCM.tex}%
        \gdef\temp{\end}%
      \else
       \gdef\temp{}
      \fi}
    \temp

  { \catcode`!=11\catcode`\@=11
      \ifx\subsubsection\undefined %% yes before \documentstyle
        \gdef\temp{}
      \else
        \W@{}%
        \W@{ !!! Active8MacCM.tex must be input}%
        \W@{ !!! before \noexpand\documentstyle occurs.}%
        \gdef\temp{\end{document}}%
      \fi}
    \temp

 %%%%%% end of LaTeX material

 \endinput

 %%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%
 Active8MacCM.doc


        Documentation for Active8MacCM.tex

                   Alpha version, November 1992
                   Beta version, Mar 1994

 ********************************************************
 NOTA BENE In this documentation please read CM for CX and cm for
cx. (The following serves also for the CK (Cork) font encoding
--- reading CK for CX etc.)
 ********************************************************

    Although Active8MacCX.tex can be used with most TeX formats,
it complements the accent administration package caesarcx.tex in a
well-planned way.  When the two are to be used together, be sure
to obtain versions of Active8MacCX.tex and caesarcx.tex that are
in step. The master postings are currently on ftp
matups.matups.fr. Then on typing a given eight bit Macintosh
character, you will get the best rendition of that character that
is available in the current font.

    There is alarming misbehavior of

  ---  \uppercase, \lowercase

for characters in the range 128-255. Not only does
\uppercase{<eacute>} give <eacute> rather than <Eacute>, but
\uppercase{<Ugrave>} gives <Udieresis>.  Good hyphenation with all
languages served by the Cork norm more or less dictates Cork
standard uc and lc code assignments.  And the misbehavior just
noted is consequence of using them. The one reasonable way to
systematically eliminate the misbehavior is to use "I/O filters"
for TeX to align the code of characters typed to the Cork code.
But few TeX implementations have this desirable flexibility; on
the Macintosh only Direct TeX has it.

    A rather straightforeward remedy is provided by the substitute
macros \Uppercase and \Lowercase defined here. They coincide with
\uppercase and \lowercase  on 7-bit (ascii) TeX input, but are
designed to behave correctly on directly typed Macintosh
characters in the range: 128-255.

    \Uppercase and \Lowercase are robust in the sense that they
are unlikely to cause their argument to blow up no matter how
complex it may be. In particular no \edef-type expansion is used.
Additionally they themselves can hopefully be subjected to
\edef-type expansion. These macros work by temporarily adjusting
many catcodes for the application of \uppercase and \lowercase.
Hence, like, \verbtim macros, they are somewhat slow. Further in
spite of their robustness, these macros may misbehave where
\edef-type expansion is used indescriminately (notably in LaTeX)
the reason is that after expansion the Cork uc and lc codes are
more appropriate, whereas these macros insist on using Macintosh
uc and lc codes.
    
    A second solution and more ambitions solution is provided
by macros

          \eUppercase, \eLowercase

defined already in the accent administration package caesarcx.tex;
the performance edge is double:

 (i)  these macros deal correctly with \ae,\oe,\o,\ss,\i and
capitalized versions, whereas all competeting macros leave them
invariant.
 (ii) inlike \Uppercase, \Lowercase often give correct results
when applied to characters in the 128-255 range that have been
subjected to \edef-type expansion.

These macros work by expanding (via the \edef mechanism) until
\uppercase and \lowercase produce the right effect; hence they are
fragile. The "e" in \eUppercase should recall "expansion" or
"\edef". No massive use uc and lc code changes is involved; these
macros are fairly fast.

     \eUppercase, \eLowercase should not be applied to any
material that is not known to be *safe* under \edef-type
expansion; all category 11 and 12 characters are safe; beginners
should regard *all* other material with suspicion, notably font
changes.

     It is tempting to hide the misbehavior of \lowercase and
\uppercase from the  eye of the user by \let'ing the primitive
commands \lowercase and \uppercase equal to \relax.   But this is
in fact dangerous, especially if macros are loaded thereafter,
because programmers use \lowercase and  \uppercase as low level
tools for macro loading.  THOU SHALT NOT GLOBALLY REDEFINE TEX
PRIMITIVES is a commandment deserving respect.

       It is tempting and often very effective to sort out all
case change problems at a blow by redefining via

     \let \uppercase\Uppercase \let \lowercase\Lowercase

or

     \let \uppercase\eUppercase \let \lowercase\eLowercase

although (as explained above) this is antisocial. Use it privately
so long as it gives good results, but  never pass on such a
dangerous system to an unsuspecting third party. Everything within
a TeX group of moderate size can legitimately be considered
private! So this efficient device has  reasonable scope in
practice.  Incidentally, caesarcx.tex Active8MacCX.tex and
preserve intact versions \primuppercase, \primlowercase for
convenience and security.


 ***** Occasional problems and their current remedies *****

     If TeX issues mysterious complaints in response to the
(local!) redefinition above, try to pacify it by using standard
7-bit  ascii typing there.  Consider also using \ufcr
(=\UpdateFontClassRegister) command of Caesar before the
troublesome part, and selectively replacing the complex \uppercase
by the simple \primuppercase. As a last resort use \noCaesar to
locally to revert to composite characters.

            -----------------------------

     Some special problems occur for LaTeX.  By default a command

    \CaesarProtectLaTeX

is in effect to avoid them.  This makes Caesar use composite
accented characters in its headings. It does so by (re)defining
parameters \LHdShield,  \RHdShield. Other remedies for other
problems are included.

     To undo this at a later point (to perfect the LaTeX
typography) use

    \CaesarDeprotectLaTeX

Then LaTeX may get stuck or lose accented characters in headings
--- especially those involving special font changes and accented
characters. In this case try 7-bit ascii typing for the
troublesome headings.  If that does not work or is too much
bother, revert locally to \CaesarProtectLaTeX.

   Beware that \uppercase is used by LaTeX behind the user's back
and mixed with \edef type expansions.

NB. These difficulties with LaTeX are due to  unnecessary use by
LaTeX of expansion of the sort done by \edef, (and \write, \mark,
etc.).  Hopefully they will all dissappear without trace in
version 3 of LaTeX.  Present versions af LaTeX are fragile, hence
provisional.


 ***** Related tools *****

 (A) Bernd Raichle <raichle@azu.informatik.uni-stuttgart.de>, has
a patch for the TeX program offering improved versions of
\uppercase, \lowercase that do not incur any problems, since they
operate after macro expansion, at the horizontal list level.  It
is not yet available.  Raichle's patch and Active8MacCX.tex both
solve case change problems by *delaying* the case changes, but of
course to different degrees and in different ways.

 (B) I/O filters available in DirectTeX of W. Ricken let one adopt
the easy solution that uses the Cork code only within TeX. To
enjoy the flexibility of Caesar (use of ready-made accented
characters if they happen to be present), input characters do have
to be active.

 (C) The same is accomplished for any TeX on the Macintosh through
use of Cork-encoded screen fonts allied with a special Macintosh
KCHR resource. These have been provided by N. Jungers and are
available on ftp matups.matups.fr.


  ***** Thanks and programmer notes *****

        Comments of Daniel Taupin  and Bernd Raichle in the GUT
TeX forum October 1992 brought into focus the multiple case change
problems stirred up by use of active characters. Taupin noticed
that automatically capitalised headlines in the LaTeX book style
caused difficulties for all then existing 8-bit typing systems
which used active characters to align input to norms for output
(see my Prague proceedings article 1992, where the case change
problem is mentioned). This stirred me to introduce the two
replacement pairs \Uppercase,\Lowercase and \eUppercase,
\eLowercase for \uppercase, \lowercase.  From the programmer's
viewpoint these replacements are the net contribution of these
macros.

        The author's sincere thanks go to them.


 ***** References *****

 ---   L. Siebenmann,   *La mise en application d\'efinitive de
la norme de Cork*,   pages 107 to 118 in EuroTeX92, Proceedings of
the 7th European TeX Conference, Prague, Sept 1992, Ed. J. Zlatu\v
ska <zlatuska@cspuni12.bitnet>, ISBN 80-210-0480-0, Published in
book form, by Czechoslovak TeX Users Group,  Matematick\'y \'ustav
UK, Sokolovsk\'a 83, CS 18600, Praha, Mailorders: 30 DM hardcover
and 25 DM soft cover, preprint possibly also posted on ftp
matups.matups.fr.

 ---  B. Jackowski and M. Ry\'cko, *Polishing \TeX*, ibid. pages
119-134.