%%%%% 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{} give rather than , but \uppercase{} gives . 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 , 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 , 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.