summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ledmac/ledpatch.sty
blob: d80586e7505f9d195c6969709a88a03ff40ef3f7 (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
% ledpatch.sty
% Copyright Peter Wilson 2004, 2005
% herries dot press at earthlink dot net
%
% Patch(es) for ledmac
%
%
%%%%\ProvidesFile{ledpatch}[2004/12/18 v0.1 patches for ledmac v0.6]
%\ProvidesFile{ledpatch}[2005/01/11 v0.2 patches for ledmac v0.6]
%\ProvidesFile{ledpatch}[2005/03/24 v0.3 patches for ledmac v0.7]
%\ProvidesFile{ledpatch}[2005/04/15 v0.3a patches for ledmac v0.7]
%\ProvidesFile{ledpatch}[2005/06/02 v0.4 patches for ledmac v0.7]
\ProvidesFile{ledpatch}[2005/08/22 v0.5 patches for ledmac v0.7]


%%%%%%%%%%%%%%%%%%%%%%%%%%%% v0.5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% There was a missing \else in \l@dcheckcols just before the
%%% error message. The symptom was reported by Tobias Verbeke.

\renewcommand*{\l@dcheckcols}{%
  \ifnum\l@dcolcount=1\relax
  \else
    \ifnum\l@dampcount=1\relax
    \else
      \ifnum\l@dcolcount=\l@dampcount\relax
      \else
        \l@d@err@UnequalColumns
      \fi
    \fi
    \l@dampcount=\l@dcolcount
  \fi}

%%% \startlock and \endlock did not work properly in the middle
%%% of a line. Problem reported by Stefano Cracolic
%%% Letting S stand for \startlock and E for \endlock and t for regular
%%% text, numbering is per the following examples:
%%%
%%%  1 Sttttt     1 Sttttt     1 Sttttt     1 Sttttt    
%%%    tttttt       tttttt       tttttt       tttttt    
%%%  2 ttEStt     2 ttttES       tttttE       tttttt    
%%%    tttttt       tttttt     2 Sttttt     2 EStttt    
%%%    tttttt       tttttt       tttttt       tttttt    
%%%    ttEttt       ttEttt       ttEttt       ttEttt    
%%%  3 tttttt     3 tttttt     3 tttttt     3 tttttt    
%%%  4 tttStt     4 tttttS     4 tttStt     4 ttSEtt    
%%%    tttttt       tttttt       tttttt     5 tttttt    
%%%    tttttt       tttttt       tttttt     6 tttttt    
%%%    ttEttt       Ettttt       tttttE     7 tttttt    
%%%  5 tttttt     5 tttttt     5 tttttt     8 tttttt    

\renewcommand*{\do@lockon}{%
  \ifx\next\lock@off
    \global\let\lock@off=\skip@lockoff
  \else
    \do@lockonL
  \fi}

\newcommand*{\do@lockonL}{%
  \xright@appenditem{\the\absline@num}\to\actionlines@list
  \ifsublines@
    \xright@appenditem{-1005}\to\actions@list
%%    \ifcase\sub@lock
%%      \sub@lock \@ne
%%    \else
%%      \sub@lock \z@
%%    \fi
    \ifnum\sub@lock=\z@
      \sub@lock \@ne
    \else
      \ifnum\sub@lock=\thr@@
        \sub@lock \@ne
      \fi
    \fi
  \else
    \xright@appenditem{-1003}\to\actions@list
%%      \ifcase\@lock
%%        \@lock \@ne
%%      \else
%%        \@lock \z@
%%      \fi
    \ifnum\@lock=\z@
      \@lock \@ne
    \else
      \ifnum\@lock=\thr@@
        \@lock \@ne
      \fi
    \fi
  \fi}

\newcommand*{\do@lockoffL}{%
  \xright@appenditem{\the\absline@num}\to\actionlines@list
  \ifsublines@
    \xright@appenditem{-1006}\to\actions@list
    \ifnum\sub@lock=\tw@
      \sub@lock \thr@@
    \else
      \sub@lock \z@
    \fi
  \else
    \xright@appenditem{-1004}\to\actions@list
    \ifnum\@lock=\tw@
      \@lock \thr@@
    \else
      \@lock \z@
    \fi
  \fi}
\renewcommand*{\do@lockoff}{\do@lockoffL}
\global\let\lock@off=\do@lockoff

\renewcommand*{\do@actions@fixedcode}{%
  \ifcase\@l@dtempcnta
  \or%                     % 1001
    \global\sublines@true
  \or%                     % 1002
    \global\sublines@false
  \or%                     % 1003
%%    \ifcase\@lock
%%      \global\@lock=\@ne
%%    \else
%%      \global\@lock=\z@
%%    \fi
      \global\@lock=\@ne
  \or%                     % 1004
    \ifnum\@lock=\tw@
      \global\@lock=\thr@@
    \else
      \global\@lock=\z@
    \fi
  \or%                     % 1005
5%    \ifcase\sub@lock
%%      \global\sub@lock=\@ne
%%    \else
%%      \global\sub@lock=\z@
%%    \fi
     \global\sub@lock=\@ne
  \or%                     % 1006
    \ifnum\sub@lock=\tw@
      \global\sub@lock=\thr@@
    \else
      \global\sub@lock=\z@
    \fi
  \or%                     % 1007
    \l@dskipnumbertrue
  \else
    \led@warn@BadAction
  \fi}



%%% Reworked the sidenotes code.
%%% Sidenotes are normally aligned on their bottom lines,
%%% i.e, multiline notes extend upwards. To align notes on
%%% their top lines (multiline notes extend downwards):
%%% \rightnoteupfalse and/or \leftnoteupfalse. The default
%%% is, of course, \rightnoteuptrue and \leftnoteuptrue.

\newif\ifrightnoteup
  \rightnoteuptrue

\renewcommand*{\l@drsnote}[1]{%
  \ifnumberedpar@
    \xright@appenditem{\noexpand\vl@drsnote{#1}}%
                       \to\inserts@list
    \global\advance\insert@count \@ne
  \fi\ignorespaces}

\renewcommand*{\vl@drsnote}[1]{\setl@drp@rbox{#1}}

\renewcommand*{\setl@drp@rbox}[1]{%
  {\parindent\z@\hsize=\ledrsnotewidth\ledrsnotefontsetup
   \global\setbox\l@drp@rbox
   \ifrightnoteup
     =\vbox to\z@{\vss#1}%
   \else
     =\vbox to0.7\baselineskip{\strut#1\vss}%
   \fi}}

\newif\ifleftnoteup
  \leftnoteuptrue

\renewcommand*{\l@dlsnote}[1]{%
  \ifnumberedpar@
    \xright@appenditem{\noexpand\vl@dlsnote{#1}}%
                       \to\inserts@list
    \global\advance\insert@count \@ne
  \fi\ignorespaces}

\renewcommand*{\vl@dlsnote}[1]{\setl@dlp@rbox{#1}}

\renewcommand*{\setl@dlp@rbox}[1]{%
  {\parindent\z@\hsize=\ledlsnotewidth\ledlsnotefontsetup
   \global\setbox\l@dlp@rbox
   \ifleftnoteup
     =\vbox to\z@{\vss #1}%
   \else
     =\vbox to 0.70\baselineskip{\strut#1\vss}%
   \fi}}

\renewcommand*{\l@dcsnote}[1]{%
  \ifnumberedpar@
    \xright@appenditem{\noexpand\vl@dcsnote{#1}}%
                       \to\inserts@list
    \global\advance\insert@count \@ne
  \fi\ignorespaces}

\renewcommand*{\vl@dcsnote}[1]{\gdef\l@dcsnotetext{#1}}
 
\renewcommand*{\affixside@note}{%
  \gdef\@templ@d{}%
  \ifx\@templ@d\l@dcsnotetext \else
    \if@twocolumn
      \if@firstcolumn
        \setl@dlp@rbox{\l@dcsnotetext}%
      \else
        \setl@drp@rbox{\l@dcsnotetext}%
      \fi
    \else
      \@l@dtempcntb=\sidenote@margin
      \ifnum\@l@dtempcntb>\@ne
        \advance\@l@dtempcntb by\page@num
      \fi
      \ifodd\@l@dtempcntb
        \setl@drp@rbox{\l@dcsnotetext}%
      \else
        \setl@dlp@rbox{\l@dcsnotetext}%
      \fi
    \fi
  \fi}




%%%%%%%%%%%%%%%%%%%%%%%%%%%% v0.4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% The instructions on page 26 in the manual regarding creating
%%% a new familiar footnote series are incorrect. Instead follow
%%% how the provided series are defined, that is, for example:
%%% \makeatletter
%%% \newcommand{\footnoteD}[1]{%
%%%   \stepcounter{footnoteD}%
%%%   \protected@xdef\@thefnmarkD{\thefootnoteD}%
%%%   \@footnotemarkD
%%%   \vfootnoteD{D}{#1}\m@mmf@prepare}
%%% 
%%% \newcounter{footnoteD} 
%%%   \renewcommand{\thefootnoteD}{\arabic{footnoteD}}
%%% \newinsert\footinsD
%%% 
%%% \newcommand{\mpfootnoteD}[1]{%
%%%   \stepcounter{footnoteD}%
%%%   \protected@xdef\@thefnmarkD{\thefootnoteD}%
%%%   \@footnotemarkD 
%%%   \mpvfootnoteD{D}{#1}\m@mmf@prepare}
%%% \newinsert\mpfootinsD
%%% 
%%% \footnormalX{D}
%%% \addfootinsX{D}
%%% \makeatother
%%% 

%%% Change \addfootinsX to correct screwups in defining new familar 
%%% series footnotes. Problem initially noted by Dirk Schlimm 
%%% (dschlimm@gmail.com) in private email, 2005/05/31

\renewcommand*{\addfootinsX}[1]{%
  \footnormalX{#1}%
  \g@addto@macro{\doxtrafeeti}{%
    \setbox\@outputbox \vbox{%
      \unvbox\@outputbox
      \ifvoid\@nameuse{footins#1}\else
        \@nameuse{footstart#1}{#1}\@nameuse{footgroup#1}{#1}\fi}}%
  \g@addto@macro{\doreinxtrafeeti}{%
    \ifvoid\@nameuse{footins#1}\else
      \insert\@nameuse{footins#1}{\unvbox\@nameuse{footins#1}}\fi}%
%%%  \g@addto@macro{\l@dfambeginmini}{%
%%%    \expandafter\let\csname footnote#1\endcsname=\@nameuse{mpfootnote#1}}%
  \g@addto@macro{\l@dfambeginmini}{%
    \expandafter\expandafter\expandafter\let\expandafter\expandafter
      \csname footnote#1\endcsname \csname mpfootnote#1\endcsname}%
%%%  \g@addto@macro{\l@dfamendmini}{%
%%%    \ifvoid\@nameuse{mpfootins#1}\else\@nameuse{mpfootgroup#1{#1}}}%
  \g@addto@macro{\l@dfamendmini}{%
    \ifvoid\@nameuse{mpfootins#1}\else\@nameuse{mpfootgroup#1}{#1}\fi}%
}




%%%%%%%%%%%%%%%%%%%%%%%%%%%% v0.3a %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Slight efficiency improvement (particularly for ledpar)

\newcommand*{\l@dunhbox@line}[1]{\unhbox #1}

\renewcommand*{\do@line}{%
  {\vbadness=10000
   \splittopskip=\z@
   \do@linehook
\l@demptyd@ta
   \global\setbox\one@line=\vsplit\raw@text to\baselineskip}%
  \unvbox\one@line \global\setbox\one@line=\lastbox
  \getline@num
  \affixline@num
  \hb@xt@ \linewidth{\l@dld@ta\add@inserts\affixside@note
    \l@dlsn@te
%%%%    {\ledllfill\hb@xt@ \wd\one@line{\new@line\unhbox\one@line}\ledrlfill\l@drd@ta%
    {\ledllfill\hb@xt@ \wd\one@line{\new@line\l@dunhbox@line{\one@line}}\ledrlfill\l@drd@ta%
    \l@drsn@te
  }}
  \add@penalties}


\endinput

%%%%%%%%%%% earlier patches now in ledmac.sty itself