-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathledarab.dtx
1509 lines (1433 loc) · 45.1 KB
/
ledarab.dtx
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
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
%
% ledarab.dtx
% Author: Peter Wilson (Herries Press) herries dot press at earthlink dot net
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 of this license or (at your option) any
% later version.
% The latest version of the license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of
% LaTeX version 2003/06/01 or later.
%
% This work has the LPPL maintenance status "unmaintained".
%
% This work consists of the files listed in the README file.
%
%
%<*driver>
\documentclass[twoside]{ltxdoc}
\usepackage{url}
\usepackage[draft=false,
plainpages=false,
pdfpagelabels,
bookmarksnumbered,
% hyperindex=true
hyperindex=false
]{hyperref}
\providecommand{\phantomsection}{} % just in case hyperref is not used
\usepackage{graphicx}
% a simpler version of chngpage.sty's adjustwidth environment
\newenvironment{addtomargins}[2]{%
\begin{list}{}{%
\topsep 0pt
\addtolength{\leftmargin}{#1}%
\addtolength{\rightmargin}{#2}%
\listparindent \parindent
\itemindent \parindent
\parsep \parskip
}%
\item[]}{\end{list}}
\makeatletter
\@mparswitchfalse
\makeatother
\EnableCrossrefs
\CodelineIndex
\RecordChanges
%%\OnlyDescription
\renewcommand{\MakeUppercase}[1]{#1}
\pagestyle{headings}
\setcounter{StandardModuleDepth}{1}
\setcounter{IndexColumns}{2}
\begin{document}
\raggedbottom
\DocInput{ledarab.dtx}
\end{document}
%</driver>
%
% \fi
%
% \CheckSum{829}
%
% \makeatletter
% \newcommand*{\DescribeIt}{\leavevmode\@bsphack\begingroup\MakePrivateLetters
% \Describe@It}
% \newcommand*{\Describe@It}[1]{\endgroup
% \marginpar{\raggedleft\PrintDescribeEnv{#1}}%
% \SpecialItIndex{#1}\@esphack\ignorespaces}
% \newcommand*{\SpecialItIndex}[1]{\@bsphack
% \index{#1\actualchar{\protect\ttfamily#1}\encapchar usage}\@esphack}
%
% \DoNotIndex{\@,\@@par,\@beginparpenalty,\@empty}
% \DoNotIndex{\@flushglue,\@input}
% \DoNotIndex{\@makefnmark,\@makeother,\@maketitle}
% \DoNotIndex{\@namedef,\@ne,\@spaces,\@tempa}
% \DoNotIndex{\@tempb,\@tempswafalse,\@tempswatrue}
% \DoNotIndex{\@thanks,\@thefnmark,\@topnum}
% \DoNotIndex{\@@,\@elt,\@forloop,\@fortmp,\@gtempa,\@totalleftmargin}
% \DoNotIndex{\",\/,\@ifundefined,\@nil,\@verbatim,\@vobeyspaces}
% \DoNotIndex{\|,\~,\ ,\active,\advance,\aftergroup,\begingroup,\bgroup}
% \DoNotIndex{\mathcal,\csname,\def,\documentstyle,\dospecials,\edef}
% \DoNotIndex{\egroup}
% \DoNotIndex{\else,\endcsname,\endgroup,\endinput,\endtrivlist}
% \DoNotIndex{\expandafter,\fi,\fnsymbol,\futurelet,\gdef,\global}
% \DoNotIndex{\hbox,\hss,\if,\if@inlabel,\if@tempswa,\if@twocolumn}
% \DoNotIndex{\ifcase}
% \DoNotIndex{\ifcat,\iffalse,\ifx,\ignorespaces,\index,\input,\item}
% \DoNotIndex{\jobname,\kern,\leavevmode,\leftskip,\let,\llap,\lower}
% \DoNotIndex{\m@ne,\next,\newpage,\nobreak,\noexpand,\nonfrenchspacing}
% \DoNotIndex{\obeylines,\or,\protect,\raggedleft,\rightskip,\rm,\sc}
% \DoNotIndex{\setbox,\setcounter,\small,\space,\string,\strut}
% \DoNotIndex{\strutbox}
% \DoNotIndex{\thefootnote,\thispagestyle,\topmargin,\trivlist,\tt}
% \DoNotIndex{\twocolumn,\typeout,\vss,\vtop,\xdef,\z@}
% \DoNotIndex{\,,\@bsphack,\@esphack,\@noligs,\@vobeyspaces,\@xverbatim}
% \DoNotIndex{\`,\catcode,\end,\escapechar,\frenchspacing,\glossary}
% \DoNotIndex{\hangindent,\hfil,\hfill,\hskip,\hspace,\ht,\it,\langle}
% \DoNotIndex{\leaders,\long,\makelabel,\marginpar,\markboth,\mathcode}
% \DoNotIndex{\mathsurround,\mbox,\newcount,\newdimen,\newskip}
% \DoNotIndex{\nopagebreak}
% \DoNotIndex{\parfillskip,\parindent,\parskip,\penalty,\raise,\rangle}
% \DoNotIndex{\section,\setlength,\TeX,\topsep,\underline,\unskip,\verb}
% \DoNotIndex{\vskip,\vspace,\widetilde,\\,\%,\@date,\@defpar}
% \DoNotIndex{\[,\{,\},\]}
% \DoNotIndex{\count@,\ifnum,\loop,\today,\uppercase,\uccode}
% \DoNotIndex{\baselineskip,\begin,\tw@}
% \DoNotIndex{\a,\b,\c,\d,\e,\f,\g,\h,\i,\j,\k,\l,\m,\n,\o,\p,\q}
% \DoNotIndex{\r,\s,\t,\u,\v,\w,\x,\y,\z,\A,\B,\C,\D,\E,\F,\G,\H}
% \DoNotIndex{\I,\J,\K,\L,\M,\N,\O,\P,\Q,\R,\S,\T,\U,\V,\W,\X,\Y,\Z}
% \DoNotIndex{\1,\2,\3,\4,\5,\6,\7,\8,\9,\0}
% \DoNotIndex{\!,\#,\$,\&,\',\(,\),\+,\.,\:,\;,\<,\=,\>,\?,\_}
% \DoNotIndex{\discretionary,\immediate,\makeatletter,\makeatother}
% \DoNotIndex{\meaning,\newenvironment,\par,\relax,\renewenvironment}
% \DoNotIndex{\repeat,\scriptsize,\selectfont,\the,\undefined}
% \DoNotIndex{\arabic,\do,\makeindex,\null,\number,\show,\write,\@ehc}
% \DoNotIndex{\@author,\@ehc,\@ifstar,\@sanitize,\@title,\everypar}
% \DoNotIndex{\if@minipage,\if@restonecol,\ifeof,\ifmmode}
% \DoNotIndex{\lccode,\newtoks,\onecolumn,\openin,\p@,\SelfDocumenting}
% \DoNotIndex{\settowidth,\@resetonecoltrue,\@resetonecolfalse,\bf}
% \DoNotIndex{\clearpage,\closein,\lowercase,\@inlabelfalse}
% \DoNotIndex{\selectfont,\mathcode,\newmathalphabet,\rmdefault}
% \DoNotIndex{\bfdefault}
% \DoNotIndex{\newcommand}
%
% \newcommand{\dtxfilename}{\texttt{ledarab.dtx}}
% \def\fileversion{v0.2} \def\filedate{2024/10/09}
%
% \changes{v0.1}{2005/03/24}{First public release}
% \changes{v0.1}{2011/17/06}{Ma\"ieul Rouquette new maintainer}
% \changes{v0.2}{2024/10/09}{Rename afoot package to ledafoot}
% \hyphenation{man-u-script man-u-scripts}
%
% \newcommand{\Lpack}[1]{\textsf{#1}}
% \newcommand{\Lclass}[1]{\textsf{#1}}
% \newcommand{\file}[1]{\texttt{#1}}
% \newcommand{\env}[1]{\texttt{#1}} ^^A for environment names
% \newcommand{\ledpar}{ledpar}
% \newcommand{\ledmac}{ledmac}
% \newcommand{\Ledmac}{\Lpack{\ledmac}}
% \newcommand{\Ledpar}{\Lpack{\ledpar}}
% \newcommand{\edmac}{\texttt{EDMAC}}
% \newcommand{\tabmac}{\texttt{TABMAC}}
% \newcommand{\edstanza}{\texttt{EDSTANZA}}
% \newcommand{\ArabTeX}{\texttt{ArabTeX}}
% \newcommand{\Larabtex}{\Lpack{arabtex}}
% \newcommand{\Lafoot}{\Lpack{ledafoot}}
% \newcommand{\Lledarab}{\Lpack{ledarab}}
% \newcommand{\PWcomment}[1]{}
% \newenvironment{PW}{\itshape}{}
% \renewenvironment{PW}{\sffamily}{}
% \newcommand{\texbook}{\textit{TeXbook}}
% \newcommand{\thetexbook}{\textit{The TeXbook}}
%
% ^^A PW added following as the definitions are at some unknown elsewhere
% \newcommand{\egstart}{}
% \newcommand{\egmid}{}
% \newcommand{\egend}{}
%
% \renewcommand{\egstart}{%
% \par
% \begingroup
% \centering
% \begin{minipage}{0.45\textwidth}}
% \renewcommand{\egmid}{%
% \end{minipage}\hfill\begin{minipage}{0.45\textwidth}}
% \renewcommand{\egend}{%
% \end{minipage}\par\endgroup}
%
% \title{Critical editions and arabic typesetting: \\
% the \Lpack{ledarab} and \Lpack{ledafoot} packages\thanks{This file (\dtxfilename)
% has version number \fileversion, last revised \filedate.}}
% \author{%
% Peter Wilson \\
% Herries Press\thanks{\texttt{herries dot press at earthlink dot net}}\\
% Ma\"ieul Rouquette\thanks{\texttt{maieul at maieul dot net}}%
% \thanks{\texttt{afoot} package renamed to \texttt{ledafoot} by David Carlisle}
%}
%
% \date{}
%
%
% \maketitle
%
%
% \begin{abstract}
% The \Ledmac{} package, which is based on the \PlainTeX\ set of
% \edmac\ macros, has been used for some time for typesetting critical
% editions, and the \ArabTeX{} system enables the typesetting of arabic
% texts.
%
% The \Lafoot{} package is an extension to the \Larabtex{} package
% to enable footnotes in arabic texts and the \Lledarab{} package
% provides an interface between \Larabtex{} and \Ledmac{} (also \Ledpar)
% for arabic text
% in critical editions.
%
% Please, for all bug's report, open a ticket on \url{https://github.com/maieul/ledmac/issues/}
% \end{abstract}
%
% \tableofcontents
% \listoffigures
%
%
% \section{Introduction}
%
% The \edmac{} macros \cite{EDMACTUG} for typesetting critical editions
% of texts
% have been available for use with TeX for some years, and the
% \Larabtex{} package \cite{ARABTEX} provides for arabic typesetting.
% These two
% works are interfaced by the \Lpack{aedpatch} package provided as
% part of the \ArabTeX{} distribution.
%
% Following the introduction of \edmac{}
% there had been a small but constant demand for a
% version that could be used with LaTeX. The \Ledmac{}
% package \cite{LEDMAC} was introduced in 2003 in an attempt to satisfy
% that request. This was extended in 2004 by the \Ledpar{} package
% \cite{LEDPAR} to allow the typesetting of parallel critical texts.
% The \Lledarab{} package provides an interface between the \Larabtex{}
% and the \Ledmac{} (and \Ledpar) packages.
% The package has to try and coerce \TeX{} into paths it was not designed
% for. Use of the package, therefore, may produce some surprising results.
%
% I initially used version 3.10 (2001/09/16) of the \Larabtex{} package
% but when I moved to version 3.11 (2003/08/22) I found that the code
% for footnotes (in \file{afoot.sty}) no longer worked. The \Lafoot{} package
% provided here is based on the obsolete 3.10 version, until a working
% version\footnote{I made queries about this on the \texttt{comp.text.tex}
% newsgoup on 2005/01/06 but got no responses.}
% of \file{afoot.sty} is provided in the \ArabTeX{} distribution.
%
% \section{The \Lpack{ledafoot} package}\label{howto}
%
% The \Larabtex{} package automatically calls the \Lpack{afoot} package. If you
% want to use my version of just load \Lafoot{} before loading \Larabtex{},
% and this code will be substuted.
%
% \DescribeMacro{\footnote}
% The \cs{footnote}\marg{text} produces a numbered footnote. Unlike
% the usual LaTeX \cs{footnote} macro there is no optional argument
% for specifying the number.
%
% \DescribeMacro{\LRfootnotes}
% Inside an \env{arabtext} environment the \cs{LRfootnotes} declaration
% causes following footnotes to be in normal left to right (LtoR) roman text,
% left adjusted and with the number at the left.
%
% \DescribeMacro{\RLfootnotes}
% \DescribeMacro{\arabfootnotes}
% Inside an \env{arabtext} environment the \cs{RLfootnotes} or
% \cs{arabfootnotes} declaration
% causes any following footnotes to be in right to left (RtoL) arabic script,
% right adjusted and with the number at the right.
% In normal text the footnotes are normal.
%
% To get an arabic footnote in normal text try: \\
% \verb?...roman\footnote{\RL{arabic}}...? \\
% The footnote will be left adjusted but the note's text will be arabic.
%
%
% \section{The \Lpack{ledarab} package}
%
% The \Lledarab{} package\footnote{I offered an earlier version to Prof.
% Lagally towards the end of 2003 for possible addition to his
% \Larabtex{} package but got no response to my messages.}
% is partially based on Klaus Lagally's \file{aedpatch.sty}
% and lets the \Ledmac{} package's critical apparatus be applied
% to arabic texts. The packages must be used in the following order:
% \begin{verbatim}
% \usepackage{ledmac}
% \usepackage{ledpar} % if you need parallel texts.
% \usepackage{arabtex}
% \usepackage{ledarab}
% \end{verbatim}
%
% The package is very limited --- only the basic numbering and
% critical footnotes are supported. Even then, all critical notes
% are left adjusted with the lemma and note in left to right order, although
% the lemma and/or note may be in RtoL arabic script. Items like familiar
% footnotes, endnotes, tabulars and so on are left to you the user.
%
% In normal numbered text you can use the \cs{RL} macro within the critical
% aparatus for short pieces of arabic.
% \begin{verbatim}
% \beginnumbering
% \pstart
% Normal \edtext{latin}{\Cfootnote{roman}} text.
% Normal \edtext{\RL{latin}}{\Cfootnote{\RL{roman}}} text.
% ...
% \end{verbatim}
% In the first line above the lemma and footnote will both be in latin
% script while in the second line they will both be in arabic script; in
% each case, though, the lemma is at the left and the note follows on the
% right.
%
% \begin{verbatim}
% \beginnumbering
% \pstart
% \begin{arabtext}
% Arabic \edtext{script}{\Afootnote{roman}} text.
% Arabic \edtext{script}{\Afootnote{\LR{roman}}} text.
% Arabic \edtext{script}{\Afootnote{\RL{arabic}}} text.
% Arabic \edtext{\LR{error}}{\Afootnote{roman}} text.
% \end{arabtext}
% \pend
% ...
% \end{verbatim}
% In the first and second lines above the lemma is in arabic script and
% the note in
% latin script, while in the third line both the lemma and the note
% are in arabic script. Using \cs{LR} as part of the lemma, as in the last
% line causes errors.
%
% \begin{verbatim}
% \beginnumbering
% \begin{arabtext}
% \pstart
% Arabic \edtext{script}{\Afootnote{messy}} text.
% Arabic \edtext{script}{\Afootnote{\LR{messy}}} text.
% Arabic \edtext{script}{\Afootnote{\RL{arabic}}} text.
% \pend
% \end{arabtext}
% ...
% \end{verbatim}
% In the first two lines above the lemma is in arabic and the note
% is in what looks like (to me at least) arabic, but it is all messed up.
% In the last line both the lemma and the note are
% in arabic.
%
% \DescribeMacro{\arablnumrep}
% \DescribeMacro{\restorelnumrep}
% Line numbers are normally typeset in latin script arabic numerals and LtoR.
% Following the \cs{arablnumrep} declaration they will be typeset in
% arabic script numerals and RtoL. The \cs{restorelnumrep} ensures the
% regular line numbers. Use the declarations like:
% \begin{verbatim}
% \arablnumrep
% \begin{arabtex} ... \end{arabtex}
% \restorelnumrep
% \end{verbatim}
%
% \DescribeMacro{\latinarabic}
% \DescribeMacro{\arabiclatin}
% Arabic script naturally has a greater height or leading
% (larger \cs{baselineskip})
% than latin text. Parallel normal texts and parallel arabic texts align
% naturally, as do parallel columns of latin/arabic or arabic/latin texts.
% However, left to their own devices pages of parallel arabic and
% normal text will not align.
%
% If you are setting normal text on the left pages and arabic script
% on the right using the \cs{latinarabic} declaration should align them.
% Similarly when you have arabic script on the left and latin script
% on the right use the \cs{arabiclatin} declaration.
%
% \DescribeMacro{\ledarabstrut}
% \DescribeMacro{\savestruts}
% \DescribeMacro{\restorestruts}
% The \cs{ledarabstrut} strut is the height of a line of arabic script
% and is used to increase the height of latin text lines to match
% arabic script lines. The definition is: \\
% \verb?\newcommand*{\ledarabstrut}{\rule[-1ex]{0pt}{4ex}}? \\
% If it does not quit match the arabic script in your case then change the
% \verb?4ex? appropriately.
%
% The macro \cs{savestruts} saves the current definitions of the struts
% used in the left and right texts (\cs{latinarabic} and \cs{arabiclatin}
% change these). The macro \cs{restorestruts} set the definitions of the
% left and right struts to match those stored by the last \cs{savestruts}.
% The package calls \cs{savestruts} itself to store the default struts.
%
% For example, with regular text on the left and arabic on the right
% then the general scheme is:
% \begin{verbatim}
% \savestruts
% \begin{pages}
% \begin{Leftside}
% \beginnumbering
% \pstart
% normal text
% ...
% \end{Leftside}
% \begin{Rightside}
% \begin{arabtext}
% \beginnumbering
% \pstart
% arabic text
% ...
% \end{Rightside}
% \latinarabic
% \Pages
% \restorestruts
% \end{pages}
% \end{verbatim}
%
% In the above, if it had been: \\
% \verb?\begin{arabtext}?\\
% \verb? \Pages?\\
% \verb?\end{arabtext}?\\
% Then a redefinition of \cs{ledarabstrut} as: \\
% \verb?\renewcommand*{\ledarabstrut}{\rule[-1ex]{0pt}{3.75ex}}? \\
% might provide better alignment of the latin text with the arabic.
%
% Life gets complicated regarding lemmas and notes when there are
% parallel latin and arabic texts.
% Consider that there are the following left (latin) and right (arabic) texts
% \begin{verbatim}
% \begin{Leftside}
% ...
% 1) \edtext{latin}{\Afootnote{roman}}...
% 2) \edtext{\RL{latin}}{\Afootnote{\RL{roman}}}...
% 3) \edtext{\LR{latin}}{\Afootnote{\LR{roman}}}...
% ...
% \end{Leftside}
% \begin{Rightside}
% \begin{arabtext}
% ...
% A) \edtext{script}{\Bfootnote{arabic}}...
% B) \edtext{script}{\Bfootnote{\RL{arabic}}}...
% C) \edtext{script}{\Bfootnote{\LR{arabic}}}...
% ...
% \end{Rightside}
% \end{verbatim}
% and they are to be output as matching pages. If they are output simply as: \\
% \verb?\Pages? \\
% then the lemmas and notes for the marked lines are: \\
% 1) latin lemma, latin note \\
% 2) arabic lemma, arabic note \\
% 3) latin lemma, latin note \\
% A) arabic lemma, latin note \\
% B) arabic lemma, arabic note \\
% C) arabic lemma, latin note
%
% On the otherhand, if they are output via: \\
% \verb?\begin{arabtext} \Pages \end{arabtext}? \\
% then the lemmas and notes for the marked lines are: \\
% 1) latin lemma, messed arabic note \\
% 2) arabic lemma, arabic note \\
% 3) latin lemma, messed arabic note \\
% A) arabic lemma, messed arabic note \\
% B) arabic lemma, arabic note \\
% C) arabic lemma, messed arabic note
%
%
% \StopEventually{}
%
% \section{The \Lpack{ledafoot} implementation}
% \label{afootimpl}
%
% The \Lafoot{} package is effectively an extraction from
% the \Lpack{alatex} package of \ArabTeX, v3.10, 2000/05/08.
%
% Announce the name and version of the package, which is
% targetted for LaTeX2e.
%
% Suppress \Lpack{afoot} package.
% \begin{macrocode}
%<*afoot>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{afoot}[2005/03/24 v0.1 PW's version of ArabTeX's afoot.sty]
\expandafter\let\csname [email protected]\expandafter\csname\csname [email protected]\endcsname
% \end{macrocode}
%
% The package redefines the internals of the LaTeX \cs{footnote} macro
% along the lines of the \cs{vfootnote} macro in \PlainTeX. It also
% does some things a bit differently if the \Lpack{fnpara} package
% has been used.
%
% \begin{macro}{\@makefntext}
% I don't know why this is here as it is also defined as part of the
% \cs{@footnotetext} macro below.
% \begin{macrocode}
\AtBeginDocument{
\ifx \footglue \undefined % normal case
\else % fnpara.sty is present
\long\def\@makefntext#1{{$^{\@thefnmark}$}#1\nobreak }
\fi
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@footnotetext}
% \begin{macrocode}
%%% Make the LaTeX \cs{footnote} catcode-safe, like in Plain TeX.
\def \@footnotetext {% new, do not yet read footnote text
\insert \footins \bgroup
\ifx \footglue \undefined % prepare normal footnote
\interlinepenalty \interfootnotelinepenalty \floatingpenalty \@MM
\splittopskip \footnotesep \splitmaxdepth \dp \strutbox
\else
\global\long\def \@makefntext ##1{{$^{\@thefnmark }$}##1\nobreak }%
\setbox0=\hbox \bgroup % fnpara.sty is present
\floatingpenalty=20000 \footnotesize
\fi
\edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
\a@fntext }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@mpfootnotetext}
% The version for \env{minpage}s.
% \begin{macrocode}
\def \@mpfootnotetext {%
\global \setbox \@mpfootins \vbox \bgroup
\edef \@currentlabel {\csname p@mpfootnote\endcsname \@thefnmark }%
\unvbox \@mpfootins \reset@font \a@fntext }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\a@fntext}
% A common portion of the code for the footnote text in both normal and
% \env{minipage} environments.
% \begin{macrocode}
\def \a@fntext {% common part for footnote text
\footnotesize \hsize \columnwidth \@parboxrestore \clubpenalty 5000
\@makefntext {\rule {\z@ }{\footnotesep }}\futurelet \next \fo@t }
% \end{macrocode}
% \end{macro}
%
% The next set of macros are from the \cs{vfootnote} macro
% (\textit{The TeXbook}, Appendix B)
% \begin{macro}{\fo@t}
% Copy from \textit{TeXbook}.
% \begin{macrocode}
%%%%%%%%%%%%%%%%%%%%%%%% \footnote, parts from Plain %%%%%%%%%%%%%%%%%
\def\fo@t{%
\ifcat
\bgroup \noexpand\next
\let\next\f@@t
\else
\let\next\f@t
\fi
\next }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\f@@t}
% Copy from \textit{TeXbook}.
% \begin{macrocode}
\def\f@@t{\bgroup\aftergroup\@foot\let\next}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\f@t}
% Copy from \textit{TeXbook}.
% \begin{macrocode}
\def\f@t#1{#1\@foot}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@foot}
% This has a bit more to it than the \textit{TeXbook} macro.
% \begin{macrocode}
\def\@foot{\unskip \strut \lineskiplimit -20pt \endgraf \egroup }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\a@footnote}
% \begin{macro}{\@foot}
% \begin{macro}{\@footnotemark}
% These macros are for normal footnotes from within an arabic environment.
% \begin{macrocode}
%%%%%%%%% footnote inside an Arabic environment, Roman document style
\def\a@footnote{%
\def\@foot{% ArabTeX-LaTeX version
\ifx \footglue \undefined % normal case
\unskip \strut
\else % fnpara.sty is present
\penalty-10 \hskip\footglue \egroup % box 0
\dp0=0pt \ht0=\fudgefactor\wd0 \box0
\fi
\egroup \arab@codes \set@arabfont \test@token }%
\def\@footnotemark{\af@fnmarkb@x \a@spacetrue}%
\rmfamily \parindent \a@parindent \unarab@codes \footnote }
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\af@fnmarkb@x}
% This saves some tokens as the code is used in several places.
% \begin{macrocode}
\def\af@fnmarkb@x{%
\a@spacefalse \putword@box \@makefnmark}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\a@footnotemark}
% \begin{macro}{\@footnotemark}
% These are also for normal footnotes from within an arabic environment.
% \begin{macrocode}
\def\a@footnotemark{%
\def\@footnotemark{\af@fnmarkb@x \a@spacefalse \arab@codes \test@token}%
\unarab@codes \footnotemark }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\a@@footnote}
% \begin{macro}{\@footnotemark}
% \begin{macro}{\a@fntext}
% These macros are for arabic footnotes from within an arabic environment.
% \begin{macrocode}
%%%%%%%%% footnote inside an Arabic environment, Arabic document style
\def\a@@footnote{% ArabTeX-LaTeX version
\def\@footnotemark{\af@fnmarkb@x \a@spacetrue}%
\def\a@fntext{\a@@fntext }%
\footnote }
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\a@@fntext}
% This is also for arabic footnotes, being the common portion of the code
% for footnote text in both normal and \env{minipage} texts.
% \begin{macrocode}
\def\a@@fntext#1{% some common code for footnote text
\def\end{%
\a@par \egroup \test@token }%
\hsize \columnwidth \@parboxrestore
\initlineb@x \@footnotemark \test@token #1 \end }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\a@@footnotemark}
% \begin{macro}{\@footnotemark}
% As are these.
% \begin{macrocode}
\def\a@@footnotemark{%
\def\@footnotemark{\af@fnmarkb@x \a@spacetrue \test@token}%
\footnotemark }
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\LRfootnotes}
% Inside an \env{arabtext} environment the \cs{LRfootnotes} declaration
% results in normal footnotes, left adjusted.
% \begin{macrocode}
\def \LRfootnotes {% left to right, Arabic document
\let \a@c@footnote \a@footnote
\let \a@c@footnotemark \a@footnotemark }
\all@wcmd \LRfootnotes
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\RLfootnotes}
% Inside an \env{arabtext} environment the \cs{RLfootnotes} declaration
% results in arabic footnotes, right adjusted. In normal text the footnotes
% are normal.
% \begin{macrocode}
\def \RLfootnotes {% right to left, Arabic document
\let \a@c@footnote \a@@footnote
\let \a@c@footnotemark \a@@footnotemark }
\all@wcmd \RLfootnotes
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\arabfootnotes}
% \cs{arabfootnotes} is an alias for \cs{RLfootnotes}.
% \begin{macrocode}
\let \arabfootnotes \RLfootnotes
\all@wcmd \arabfootnotes
% \end{macrocode}
% \end{macro}
%
% Make \cs{LRfootnotes} the default.
% \begin{macrocode}
\LRfootnotes
}
% \end{macrocode}
%
% The end of the package
%
% \begin{macrocode}
%</afoot>
% \end{macrocode}
%
%
% \section{The \Lpack{ledarab} implementation}
% \label{ledarabimpl}
%
% The \Lledarab{} package is based on the original \Lpack{aedpatch}
% from the \ArabTeX{} distribution.
%
% Announce the name and version of the package, which is for LaTeX2e.
%
% \begin{macrocode}
%<*ledarab>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ledarab}[2005/03/24 v0.1 Cooperation between arabtex and ledmac]
% \end{macrocode}
%
% \begin{macro}{\tr@ce@n}
% \begin{macro}{\tr@ce@ff}
% I think, but don't know, that by appropriate (re)definitions of these
% you can get \Larabtex{}
% to produce some tracing of what is going on, perhaps by setting
% \cs{tracingmacros} to 1 instead of 0.
% \begin{macrocode}
\providecommand*{\tr@ce@n}{\tracingmacros 0}
\providecommand*{\tr@ce@ff}{\edef \tr@ce@n
{\nxp\tracingmacros \the\tracingmacros }\tracingmacros 0}
\let \tr@ce@n \relax
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@l@dparpack}
% \begin{macro}{\@l@dparpacktrue}
% \begin{macro}{\@l@dparpackfalse}
% We need a flag for knowing if \Ledpar{} is being used.
% \begin{macrocode}
\newif\if@l@dparpack
\@l@dparpackfalse
\@ifpackageloaded{ledpar}{\@l@dparpacktrue}{\@l@dparpackfalse}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Adjusting the baselines}
%
% \begin{macro}{\do@linehook}
% Arabic lines are taller than roman lines, so add some height to
% numbered lines.
% \begin{macrocode}
\renewcommand*{\do@linehook}{%
\advance\baselineskip 1ex}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{arabledparfixi}
% If the \Ledpar{} package is loaded we have to change several of its
% macros. We can't do this simply within an \cs{if@l@dparpack} because
% of the internal \cs{if}s. Hence, we define a macro whose expansion
% is the necessary changes.
%
% \begin{macrocode}
%%%%%%%%%%%%%%%%%%%%% ledpar fix %%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\arabledparfixi}{%
% \end{macrocode}
% \begin{macro}{\do@lineLhook}
% \begin{macro}{\do@lineRhook}
% Increase the height of numbered lines.
% \begin{macrocode}
\renewcommand*{\do@lineLhook}{%
\advance\baselineskip 1ex}
\renewcommand*{\do@lineRhook}{%
\advance\baselineskip 1ex}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\a@l@dparparamsL}
% \begin{macro}{\a@l@dparparamsR}
% Variations on \cs{a@parparams} from \ArabTeX's \file{aoutput.sty}.
% These are required to take account of the differing widths, by setting
% \cs{a@hsize} appropriately.
% \begin{macrocode}
\newcommand*{\a@l@dparparamsL}{%
\ifnum \parshape = \z@
\a@hsize \Lcolwidth
\a@leftmargin \z@
\else
\a@hsize \Lcolwidth \a@leftmargin \@totalleftmargin
\fi
\a@leftmargin \z@
\a@prevgraf \z@ \spreadfalse }
\newcommand*{\a@l@dparparamsR}{%
\ifnum \parshape = \z@
\a@hsize \Rcolwidth
\a@leftmargin \z@
\else
\a@hsize \Rcolwidth \a@leftmargin \@totalleftmargin
\fi
\a@leftmargin \z@
\a@prevgraf \z@ \spreadfalse }
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\Leftsidehook}
% \begin{macro}{\Rightsidehook}
%
% \begin{macrocode}
\renewcommand*{\Leftsidehook}{%
\let\a@parparams\a@l@dparparamsL}
\renewcommand*{\Rightsidehook}{%
\let\a@parparams\a@l@dparparamsR}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ledarabstrut}
% \begin{macro}{\ledstrutL}
% \begin{macro}{\ledstrutR}
% \begin{macro}{\savestruts}
% \begin{macro}{\restorestruts}
% \begin{macro}{\latinarabic}
% \begin{macro}{\arabiclatin}
% In order to get parallel arabic and normal texts to line up
% a strut has to be added to each latin line to hide their different heights;
% this is \cs{ledarabstrut}. The commands \cs{savestruts} and
% \cs{restorestruts} save and restore the original left/right strut
% definitions. The declaration \cs{latinarabic} is for left and right texts
% being latin and arabic, and for left arabic and right latin use
% \cs{arabiclatin}.
% \begin{macrocode}
\newcommand*{\ledarabstrut}{%
\rule[-1ex]{0pt}{4ex}}
\newcommand*{\savestruts}{%
\let\oldl@dstr@tL\ledstrutL
\let\oldl@dstr@tR\ledstrutR}
\newcommand*{\restorestruts}{%
\let\ledstrutL\oldl@dstr@tL
\let\ledstrutR\oldl@dstr@tR}
\newcommand*{\latinarabic}{%
\def\ledstrutL{\ledarabstrut}%
\def\ledstrutR{}}
\newcommand*{\arabiclatin}{%
\def\ledstrutL{}%
\def\ledstrutR{\ledarabstrut}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% At last, the end of \cs{arabledparfixi}.
% \begin{macrocode}
}% end of \newcommand{\arabledparfixi}{...
% \end{macrocode}
% \end{macro}
%
% Perform the fix for \Ledpar{} if necessary.
% \begin{macrocode}
\if@l@dparpack
\arabledparfixi
\savestruts
\fi
%%%%%%%%%%%%%%%%%%%%% end major ledpar fix %%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \end{macrocode}
% \end{macro}
%
% \subsection{Lemmas}
%
% \begin{macro}{\a@c@edtext}
% This is the internal version of \cs{edtext}. The parameters
% have their original catcodes.
% \begin{macrocode}
\newcommand*{\a@c@edtext}{%
\tr@ce@n \leavea@vmode \unarab@codes
\begingroup
\tr@ce@ff \rmfamily \tr@ce@n \a@@edtext}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\a@@edtext}
% An auxiliary routine to kill leading blanks and remove spurious braces
% from \cs{edtext}'s second argument.
% \begin{macrocode}
\newcommand*{\a@@edtext}[1]{%
%%% \def\next@command{\a@@@edtext {\RL{#1}}}% causes errors
\def\next@command{\a@@@edtext {#1}}%
\futurelet \next@token \test@space }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\a@edget@text}
% Get flags and lemma.
% \begin{macrocode}
\def\a@edget@text #1\@@{%
\a@edappend{\flag@start}\a@@Linsert{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\a@edend@lemma}
% Another utility routine.
% \begin{macrocode}
\newcommand*{\a@edend@lemma}{%
\ifx\end@lemmas\empty \else
\gl@p\end@lemmas\to\x@lemma
\x@lemma
\global\let\x@lemma=\relax
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\a@edput@text}
% Unpack \cs{Linsertb@x}.
% \begin{macrocode}
\newcommand*{\a@edput@text}{%
\a@Lunpack \putwordb@x {\ins@skip }}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\a@edappend}
% \cs{a@edappend}\marg{arg} adds its argument to the \cs{lineb@x}.
% \begin{macrocode}
\newcommand*{\a@edappend}[1]{%
\setbox \lineb@x \hbox {\unhbox \lineb@x #1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\a@@@edtext}
% The meat of it all
% \begin{macrocode}
\newcommand{\a@@@edtext}[2]{
\no@expands
\def\next@command{\test@special}%
%%% \xdef \@tag{#1}\set@line % the original produces roman in notes
%%% \def\@@@tag{\RL{#1}} \xdef\@tag{\@@@tag}\set@line % produces errors
\xdef \@tag{{\RL{#1}}}\set@line% produces arabic in notes GOOD ONE!!
\global\insert@count=0
\aftergroup \a@edget@text
\ignorespaces #2\relax
\endgroup
%%% #1\a@edend@lemma \@@ %% gives roman in arabic text
\showlemma{#1}\a@edend@lemma \@@% GOOD ONE
\a@edput@text \a@edappend {\flag@end }%
\arab@codes
\a@spacetrue
\tr@ce@ff \test@token}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\showlemma}
% Modify \cs{showlemma}\marg{lemma} so that its argument is set RtoL in
% arabic text, otherwise as normal. The setting of the \meta{lemma} in
% the notes is controlled independently.
% \begin{macrocode}
\renewcommand{\showlemma}[1]{%
\ifin@arab\RL{#1}\else #1\fi} % arabic in text, but roman in notes
% \end{macrocode}
% \end{macro}
%
% \subsection{Line numbering}
%
% \begin{macro}{\beginnumbering}
% \begin{macro}{\endnumbering}
% Enable \cs{beginnumbering} and \cs{endnumbering} to be used directly in
% arabic text, though I don't know if this is useful.
% \begin{macrocode}
\all@wcmd{\beginnumbering}
\all@wcmd{\endnumbering}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\beginnumberingR}
% \begin{macro}{\endnumberingR}
% Similarly, if \Ledpar{} is used, for numbering in parallel Right texts.
% \begin{macrocode}
\if@l@dparpack
\all@wcmd{\beginnumberingR}
\all@wcmd{\endnumberingR}
\fi
% \end{macrocode}