summaryrefslogtreecommitdiff
path: root/macros/generic/hyacc-cm/hyacc-cm.tex
blob: 794c603d7ace2d1277d4b66051f7210f7ec97dde (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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%% HyAcc-CM.tex is a system for European language hyphenation
 %%% using the original CM fonts.  It is based on an earlier
 %%% system given by Jacques D\'esarm\'enien

 %%% for French in his fePlain format of the mid 1980's.
 %%%
 %%% AIM:
 %%% Permit automatic TeX hyphenation, under the
 %%% original Computer Modern font norm, in words containing
 %%% composite accented characters;
 %%% more precisely, allow those hyphenations
 %%% that occur far from the accents.  Without
 %%% HyAcc-CM.tex, hyphenation is blocked near and after the
 %%% first accented character.
 %%%
 %%% SETUP:
 %%% \input at some point after Plain has been
 %%% compiled with appropriate hyphenation patterns for the
 %%% languages to be used.  See HyMaster.tex for a typical
 %%% example.
 %%%
 %%% COMMANDS:
 %%%  --- \JDaccents a modified international version of
 %%% J. Desarmenien's e-accute accent in his "fePlain" format;
 %%% hyphenation except near accents.  This is default.
 %%%  --- \GFaccents similar to \JDaccents, but slightly
 %%% fragile (for LaTeX); it avoids a dot matrix (low
 %%% resolution) printer bug afflicting \JDaccents.  From
 %%% German.sty corrected for French and international use.
 %%%  --- \DKaccents gives Knuth's regime under which no
 %%% hyphenation is allowed beyond first accent in word with
 %%% accent.
 %%%
 %%% PECULIARITY:
 %%% By default, non-zero lc and uc codes for the
 %%% sporadic characters \ae, \AE, \oe, \OE,
 %%% \o, \O, \i, \j following an oecumenical policy
 %%% of M. Ferguson and D. Taupin.
 %%%  --- \noMLcodes makes them zero
 %%%  (Knuth's Plain setting) and
 %%%  --- \MLcodes returns to our default.
 %%%
 %%% RESTRICTIONS:
 %%% For fonts of the original Computer Modern
 %%% norm and NOT not the Cork norm.
 %%% Do not use prose accents in math mode.
 %%%
 %%% VIRTUES:
 %%% decent hyphenation without special European fonts;
 %%% compatibility with Knuth's documentation.%%XX
 %%% Temporary 100% return to Knuth's regime is possible
 %%% via \DKaccents\noMLcodes
 %%%
 %%% HISTORY AND PROGRAMMER DOCUMENTATION see HyAcc-CM.doc.
 %%%
 %%% POSTING: by  Daniel Flipo <flipo@frcitl81.bitnet> and
 %%% Laurent Siebenmannn <siebenmann@LALCLS.IN2P3.FR> ftp
 %%% rsovax.ups.circe.fr [130.84.128.100] logon: anonymous,
 %%% password: your name.
 %%%
 %%% VERSION : August, 1992
 %%% Modifications: Polish \ogonek added,
 %%%                \box0 replaced by \box\hy@accbox

 \def\Msg{\immediate\write16}
 %% Prevent this file from being loaded twice!
  \let\this\relax
  \ifx\JDaccents\undefined\relax
  \else\Msg{}%
      \Msg{ *** \string\JDaccents\space
                    already defined.}%
      \let\this\endinput
  \fi
  \this

 %% If \allowhyphens is already defined
 %% (by German.tex for instance), just complain.
 \ifx\undefined\allowhyphens
   \let\this\relax
 \else
   \Msg{}%
   \message{ *** \string\allowhyphens\space
                 (from German.tex) already defined.}%
   \let\this\endinput
 \fi
 \this
 %%XX
 \def\W@{\immediate\write16}%
  \W@{ *************************************************** }
  \W@{ HyAcc-CM INTERNATIONAL ACCENTUATION MECHANISM FOR CM FONTS}
  \W@{ permitting decent hyphenation of words with accents.}
  \W@{ Version of Aug 1992.}
  \W@{ Updates: ftp rsovax.ups.circe.fr [130.84.128.100].}
  \W@{ *************************************************** }

 \chardef\JDCatAt=\the\catcode`\@
 \catcode`\@=11
  \catcode`\~=12 %% was 13

  \newbox\hy@accbox

  \def\hyaccent#1#2{{\accent#1 #2}\@Allowhyphens{#2}}%

  %% for \JDaccents
  \def\@@allowhyphens{\penalty\@M\hskip\z@skip}%% for sporadics
  \def\@@Allowhyphens#1{\setbox\hy@accbox\hbox{#1}%% \hyaccent
    \penalty\@M\hskip-\wd\hy@accbox #1}%

  %% for \GFaccents
  \def\preLetterSkip@{\ifcat
    a\next\relax\penalty\@M\hskip\z@\fi} %XXspacing

 \def\@@@Allowhyphens#1{\noexpand
  \futurelet\next\preLetterSkip@}

 \let\next\relax %% avoids some mysterious errormessages
        %% in case you uncautiously use %%XX
        %% accents in messages, %%XX
        %% \GFaccents\message{Imb\'ecile!}

 %%% Composite accents for CM fonts
 %% TeXbook p.  52

 \def\DoCMAccents{%% cf \dospecials  of Plain
  \do`"12..%% grave
  \do'"13..%% accute
  \do^"5E..%% hat
  \do""7F..%% umlaut
  \do~"7E..%% tilde
  \do="16..%% macron (bar over)
  \do."5F..%% dot over
  \do u"15..%% breve
  \do v"14..%% check
  \do H"7D..%% long umlaut
   %%\t tie absent see below
  }

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

 \def\DoAccent#1#2.#3{\CheckPeriod{#3}%
    \expandafter
    \def\csname #1\endcsname##1{%
        \relax\hyaccent{#2}{##1}}%
    }

  \let\do\DoAccent
  \DoCMAccents %% Sets up principal new accent macros

 %%% Residual accents : \c,\aa,\AA,\l,\L

 \def\oldCedilla#1{\setbox\hy@accbox\hbox{#1}%
  \ifdim\ht\hy@accbox=1ex\accent24 #1%
  \else{\ooalign{\unhbox\hy@accbox\crcr\hidewidth\char24\hidewidth}}%
  \fi}

 \def\c#1{{\oldCedilla#1}\@Allowhyphens{#1}}

 \def\L{\char32 L}
 \def\l{\char32 l}

 \def\AA{\leavevmode\setbox\hy@accbox\hbox{h}%
    \dimen@\ht\hy@accbox\advance\dimen@-1ex%
    \rlap{\raise.67\dimen@\hbox{\char'27}}\@allowhyphens A}

 \def\aa{\hyaccent{"17}{a}}

 \def\oldUnderBar#1{\oalign{#1\crcr\hidewidth
    \vbox to.2ex{\hbox{\char22}\vss}\hidewidth}}

 \def\b#1{\oldUnderBar#1\@Allowhyphens{#1}}% underbar

 \def\d#1{\oalign{#1\crcr
       \hidewidth.\hidewidth}\@Allowhyphens{#1}}%underdot

 \def\t#1{{\edef\next{\the\font}\the\textfont1\accent
         "7F\next#1}\@Allowhyphens{#1}}
    %% tie; \textfont1 is cmmi

 \def\oldOgonek#1{\setbox\hy@accbox=\hbox{`}\ooalign{\hidewidth
                  \lower\ht\hy@accbox\copy\hy@accbox%%\hidewidth
                  \crcr#1\crcr}}
 \def\ogonek#1{{\oldOgonek#1}\@Allowhyphens{#1}}% ogonek


 %%% Sporadic characters in cm
 %%% Plain assigns codes 0; Ferguson and Taupin as follows
 %%% see article of Taupin (to appear)
 %%% For better or worse, this permits hyphenation of
 %%% words containing these characters.
 %%% More importantly it is a policy that
 %%% is language-independant.
 %%% But catcodes are left 12 and not 11, to prevent use
 %%% in macro names when directly typed.

 \def\SetULCodes#1#2{%
  \uccode#1=#1\lccode#1=#2
  \uccode#2=#1\lccode#2=#2
  }

 \def\KillULCodes#1#2{%
  \uccode#1=0\lccode#1=0
  \uccode#2=0\lccode#2=0
  }

 \def\MLcodes{%
  \SetULCodes{"19}{"19} %% \ss (degenerate case)
  \SetULCodes{"1D}{"1A} %% \AE,\ae
  \SetULCodes{"1E}{"1B} %% \OE,\oe
  \SetULCodes{"1F}{"1C} %% \O, \o
  \lccode"10="10 %% \i
  }

 \def\noMLcodes{%
  \KillULCodes{"19}{"19} %% \ss (degenerate case)
  \KillULCodes{"1D}{"1A} %% \AE,\ae
  \KillULCodes{"1E}{"1B} %% \OE,\oe
  \KillULCodes{"1F}{"1C} %% \O, \o
  \lccode"10=0 %% \i
  }

 %%% For LaTeX 2.xx necessary change for \parbox macro
 \ifx\documentstyle\undefined
 \else   %% if LaTeX IS loaded, save our new definitions of
        %% \' \` and \= for \parbox macro (LaTeX 2.xx)
  \let\@acci=\'
  \let\@accii=\`
  \let\@acciii=\=
 \fi

 %% JD for Jacques Desarmenien
 \def\JDaccents{\let\@Allowhyphens\@@Allowhyphens
                \let\@allowhyphens\@@allowhyphens}

 %% GF for German French
 \def\GFaccents{\let\@Allowhyphens\@@@Allowhyphens
                \let\@allowhyphens\@@allowhyphens}

 %% DK for Don Knuth
 \def\DKaccents{\def\@Allowhyphens##1{\relax}%
                \let\@allowhyphens\relax}

 %% Back to normal catcodes
 \catcode`\~=13
 \catcode`\@=\JDCatAt

 \MLcodes\JDaccents  %% defaults

 \endinput