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
|
% \iffalse meta-comment
% copyright (C) 2016 Robert Alessi
%
% Please send error reports and suggestions for improvements to
% Robert Alessi <alessi@robertalessi.net>
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
% 02111-1307, USA.
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{arabluatex.dtx}
%</driver>
%<package-info>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package-info>\ProvidesPackage{arabluatex}
%<*package-info>
[2016/01/26 v1.0 This is ArabTeX for LuaLaTeX]
%</package-info>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage[english]{babel}
\usepackage{fontspec,luatextra,realscripts}
\defaultfontfeatures{RawFeature={+liga}}
\setmainfont{Libertinus Serif}
\setsansfont{Libertinus Sans}
\setmonofont[Scale=.9]{Libertinus Mono}
\usepackage{arabluatex}[2016/01/26]
\usepackage{hypdoc}
\hypersetup{colorlinks, allcolors=blue}
\usepackage{multicol}
\newcommand{\package}[1]{\textsf{#1}}
\usepackage{paralist}
\setdefaultitem{\textendash}{\textendash}{\textendash}{\textendash}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage[skins]{tcolorbox}
\usepackage{csquotes}
\usepackage[style=authoryear, natbib]{biblatex}
\addbibresource{arabluatex.bib}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{arabluatex.dtx}
\PrintChanges
\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
%
% \changes{1.0}{2016/01/26}{Converted to DTX file}
%
% \DoNotIndex{\newcommand,\newenvironment,\renewcommand}
%
% \providecommand*{\url}{\texttt}
% \GetFileInfo{arabluatex.dtx}
%
% \title{\tcbox[enhanced, tikznode, drop lifted shadow, colback=white,
% boxrule=.25mm]%
% {The \textsf{arabluatex} package\\
% \fileversion~from \filedate}}
%
% \newcommand*{\NEWfeature}[1]{%
% \hskip 1sp \marginpar{\small\sffamily\raggedright
% New feature\\#1}}
%
% \author{Robert Alessi \\
% \href{mailto:alessi@robertalessi.net?Subject=arabluatex}%
% {\texttt{alessi@robertalessi.net}}}
% \date{}
%
% \maketitle
% \begin{multicols}{2}[\section*{\large Contents}]\footnotesize
% \makeatletter
% \@starttoc{toc}
% \makeatother
% \end{multicols}
% \begin{multicols}{2}[\section*{\large List of tables}]
% \footnotesize
% \makeatletter
% \@starttoc{lot}
% \makeatother
% \end{multicols}
%
% \begin{abstract}
% This package provides for \LuaLaTeX\ an Arab{\TeX}-like interface
% to generate Arabic writing from an \textsc{ascii}
% transliteration. It is particularly well-suited for complex
% documents such as technical documents or critical editions where a
% lot of left-to-right commands intertwine with Arabic
% writing. \package{arabluatex} is able to process any Arab\TeX\
% input notation. Its output can be set in the same modes of
% vocalization as Arab\TeX\ ones, or in different roman
% transliterations. It further allows some typographical
% refinements.
% \end{abstract}
%
% \section*{License and disclamer}
% \addcontentsline{toc}{section}{License and disclamer} Please send
% error reports and suggestions for improvements to Robert Alessi
% <\href{mailto:alessi@robertalessi.net?Subject=arabluatex}%
% {\texttt{alessi@{\allowbreak}robertalessi.net}}>
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
% 02111-1307, USA.
%
% \section{Introduction}
% In comparison to Prof. Lagally's outstanding Arab\TeX,\footnote{See
% \url{http://ctan.org/pkg/arabtex}} Arab\LuaTeX\ is at present
% nothing more than a modest piece of software. Hopefully---if I may
% say so---it will eventually provide all of its valuable qualities to
% the \LuaLaTeX\ users.
%
% \package{arabtex} dates back to 1992. As far as I know, it was then
% the first and only way to typeset Arabic texts with \TeX\ and
% \LaTeX. To achieve this, \package{arabtex} provided---and still
% does---an Arabic font in \emph{Nasḫī} style and a macro package that
% defined its own input notation which was, as the author stated,
% \enquote{both machine, and human, readable, and suited for
% electronic transmission and e-mail
% communication}.\footnote{\textcite[2]{Lagally2004}.} Even if the
% same can be said about Unicode, Arab\TeX\ \textsc{ASCII} input
% notation still surpasses Unicode input, in my opinion, when it comes
% to typesetting complex documents, such as scientific documents or
% critical editions where footnotes and other kind of annotations can
% be particulary abundant. It must also be said that most text editors
% have trouble in displaying Arabic script connected with preceding or
% following \LaTeX\ commands: it often happens that commands seem
% misplaced, not to mention punctuation marks, or opening or closing
% braces, brackets or parentheses that are unexpectedly displayed in
% the wrong direction. Of course, some text editors provide ways to
% get around such difficulties by inserting invisible Unicode
% characters, such as LEFT-TO-RIGHT or RIGHT-TO-LEFT MARKS
% (\texttt{U+200E}, \texttt{U+200F}), RTL/LTR \enquote{embed}
% characters (\texttt{U+202B}, \texttt{U+202A}) and RLO/LRO
% \enquote{bidi-override} characters (\texttt{U+202E},
% \texttt{U+202D}).\footnote{Gáspár Sinai's Yudit probably has the
% best Unicode support. See \url{www.yudit.org}.} Nonetheless, it
% remains that inserting all the time these invisible characters in
% complex documents rapidly becomes confusing and cumbersome.
%
% The great advantage of Arab\TeX\ notation is that it is immune from
% all these difficulties, let alone its being clear and
% straightforward. One also must remember that computers are designed
% to process code. Arab\TeX\ notation is a way of encoding Arabic
% language, just as \TeX\ \enquote{mathematics mode} is a way of
% processing code to display mathematics. As such, not only does it
% allow greater control over typographical features, but it also can
% be processed in several different ways: so without going into
% details, depending on one's wishes, Arab\TeX\ input can be full
% vocalized Arabic (\emph{scriptio plena}), vocalized Arabic or
% non-vocalized Arabic (\emph{scriptio defectiva}); it further can be
% transliterated into whichever romanization standard the user may
% choose.
%
% But there may be more to be said on this point, as encoding Arabic
% also naturally encourages the coder to vocalize the texts---without
% compelling him to do so, of course. Accurate coding may even have
% other virtuous effects. For instance, hyphens may be used for tying
% particles or prefixes to words, or to mark inflectional endings, and
% so forth. In other words, accurate coding produces accurate texts
% that can stand to close grammatical scrutiny and to complex textual
% searches as well.
%
% Having that in mind, I started \package{arabluatex}. With the help
% of Lua, it will eventually interact with some other packages yet to
% come to produce from \verb|.tex| source files, in addition to
% printed books, \texttt{TEI xml} compliant critical editions and/or
% lexicons that can be searched, analyzed and correlated in various
% ways.
%
%
%
%\subsection{\package{arabluatex} is for \LuaLaTeX}
% It goes without saying that \package{arabluatex} requires
% \LuaLaTeX. \TeX\ and \LaTeX\ have \package{arabtex}, and \XeLaTeX\
% has \package{arabxetex}. Both of them are much more advanced than
% \package{arabluatex}, as they can process a number of different
% languages,\footnote{To date, both packages support Arabic, Maghribi,
% Urdu, Pashto, Sindhi, Kashmiri, Uighuric and Old Malay; in addition
% to these, \package{arabtex} also has a Hebrew mode, including
% Judeo-Arabic and Yiddish.} whereas \package{arabluatex} can process
% only Arabic for the time being. More languages will be included in
% future releases of \package{arabluatex}.
%
% In comparison to \package{arabxetex}, \package{arabluatex} works in
% a very different way. The former relies on the
% \href{http://scripts.sil.org/TECkitIntro}{\texttt{TECkit}} engine
% which converts Arab\TeX\ input on the fly into Unicode Arabic
% script, whereas the latter passes Arab\TeX\ input on to a set of Lua
% functions. At first, \LaTeX\ commands are taken care of in different
% ways: some, as \cs{emph}, \cs{textbf} and the like are expected to
% have Arabic text as arguments, while others, as \cs{LR}, for
% \enquote{left-to-right text}, are not. Then, once what is Arabic is
% carefully separated form what is not, it is processed by other Lua
% functions which rely on different sets of correpondence tables to do
% the actual conversion in accordance with one's wishes. Finally, Lua
% returns to \TeX\ the converted strings---which may in turn contain
% some other Arab\TeX\ input yet to be processed---for further
% processing.
%
% \section{Usage}
% \newcommand{\dmg}[1]{%
% \SetTranslitConvention{dmg}%
% \arb[trans]{#1}}
% \newcommand{\loc}[1]{%
% \SetTranslitConvention{loc}%
% \arb[trans]{#1}\SetTranslitConvention{dmg}}
% \begin{longtable}{llll}
% \toprule
% Letter & \multicolumn{2}{l}{Transliteration\footnotemark}
% & Arab\TeX\ notation \\
% & \texttt{dmg} & \texttt{loc} & \\ \midrule
% \endhead \footnotetext{See below **}
% \arb[novoc]{a} & \dmg{A} & \loc{A} & \verb|A| \\
% \arb[novoc]{b} & \dmg{b} & \loc{b} & \verb|b| \\
% \arb[novoc]{t} & \dmg{t} & \loc{t} & \verb|t| \\
% \arb[novoc]{_t} & \dmg{_t} & \loc{_t} & \verb|_t| \\
% \arb[novoc]{j} & \dmg{j} & \loc{j} & \verb|^g| or \verb|j| \\
% \arb[novoc]{.h} & \dmg{.h} & \loc{.h} & \verb|.h| \\
% \arb[novoc]{x} & \dmg{x} & \loc{x} & \verb|_h| or \verb|x|\\
% \arb[novoc]{d} & \dmg{d} & \loc{d} & \verb|d| \\
% \arb[novoc]{_d} & \dmg{_d} & \loc{_d} & \verb|_d| \\
% \arb[novoc]{r} & \dmg{r} & \loc{r} & \verb|r| \\
% \bottomrule
% \caption{Standard notation for Arabic}
% \end{longtable}
% Usage goes here. \cs{hop}\oarg{ah}\marg{ouh}
%
% \StopEventually{}
%
% \section{Implementation}
%
% \iffalse
%<*package>
% \fi
%
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{arabluatex}%
[2016/01/26 v1.0 ArabTeX-like interface for LuaLaTeX]
\RequirePackage{ifluatex}
% \end{macrocode}
% \package{arabluatex} requires \LuaLaTeX\ of course.
% \begin{macrocode}
\ifluatex\else
\PackageError{arabluatex}{lualatex needed}{%
Package `arabluatex' needs LuaTeX.\MessageBreak
So you should use `lualatex' to process your document!\MessageBreak
See documentation of `arabluatex' for further information.}%
\expandafter\expandafter\expandafter\csname endinput\endcsname
\fi
% \end{macrocode}
% \begin{macrocode}
\DeclareOption{voc}{\def\al@mode{voc}}
\DeclareOption{fullvoc}{\def\al@mode{fullvoc}}
\DeclareOption{novoc}{\def\al@mode{novoc}}
\DeclareOption{trans}{\def\al@mode{trans}}
\ExecuteOptions{voc}
\ProcessOptions\relax
\def\al@mode@voc{voc}
\def\al@mode@fullvoc{fullvoc}
\def\al@mode@novoc{novoc}
\def\al@mode@trans{trans}
% \newif\ifal@mode@defined
\RequirePackage{amsmath}
\RequirePackage{etoolbox}
\RequirePackage{luacode}
\RequirePackage{xparse}
\RequirePackage{environ}
\luadirect{dofile(kpse.find_file("arabluatex.lua"))}
% \end{macrocode}
% This is needed by the current versions of \package{polyglossia} and
% \package{luabidi}. \package{luabidi} provides a \cs{Footnote}
% command. Use it as well if it is loaded.
% \begin{macrocode}
\luadirect{tex.enableprimitives("luatex",tex.extraprimitives("omega"))}
% \end{macrocode}
% \begin{macrocode}
\AtBeginDocument{\ifdefined\arabicfont\relax\else
\PackageWarning{arabluatex}{\string\arabicfont\ is not defined!^^JI
will try to load Amiri}%
\newfontfamily\arabicfont[Script=Arabic]{Amiri}\fi}%
\AtBeginDocument{\def\setRL{\pardir TRT\textdir TRT}}
\AtBeginDocument{\def\setLR{\pardir TLT\textdir TLT}}
\AtBeginDocument{\ifdef{\LR}%
{\RenewDocumentCommand{\LR}{m}{\bgroup\textdir TLT\rmfamily#1\egroup}}
{\NewDocumentCommand{\LR}{m}{\bgroup\textdir TLT\rmfamily#1\egroup}}}
\AtBeginDocument{\ifdef{\RL}%
{\RenewDocumentCommand{\RL}{m}{\bgroup\textdir TRT\rmfamily#1\egroup}}
{\NewDocumentCommand{\RL}{m}{\bgroup\textdir TRT#1\rmfamily\egroup}}}
\AtBeginDocument{\ifdef{\aemph}%
{\RenewDocumentCommand{\aemph}{m}{$\overline{\text{#1}}$}}
{\NewDocumentCommand{\aemph}{m}{$\overline{\text{#1}}$}}}
\def\al@trans@style{\itshape}%
\NewDocumentCommand{\SetTranslitStyle}{m}{\def\al@trans@style{#1}}
\def\al@trans@convention{dmg}
\NewDocumentCommand{\SetTranslitConvention}{m}{\def\al@trans@convention{#1}}
\DeclareDocumentCommand{\cap}{m}%
{\luadirect{tex.sprint(cap(\luastringN{#1}))}}
\DeclareDocumentCommand{\txarb}{+m}{\bgroup\textdir
TRT\arabicfont#1\egroup}
\DeclareDocumentCommand{\txtrans}{+m}{\bgroup\textdir
TLT\rmfamily#1\egroup}
\DeclareDocumentCommand{\arb}{O{\al@mode} +m}%
{\edef\@tempa{#1}%
\ifx\@tempa\al@mode@voc%
\bgroup\textdir TRT\arabicfont%
\luadirect{tex.sprint(processvoc(\luastringN{#2}))}\egroup%
\else%
\ifx\@tempa\al@mode@fullvoc%
\bgroup\textdir TRT\arabicfont%
\luadirect{tex.sprint(processfullvoc(\luastringN{#2}))}\egroup%
\else%
\ifx\@tempa\al@mode@novoc%
\bgroup\textdir TRT\arabicfont%
\luadirect{tex.sprint(processnovoc(\luastringN{#2}))}\egroup%
\else%
\ifx\@tempa\al@mode@trans%
\bgroup\textdir TLT\al@trans@style%
\luadirect{tex.sprint(processtrans(\luastringN{#2},
\luastringO{\al@trans@convention}))}\egroup%
\else%
\fi\fi\fi\fi}
\NewEnviron{arab}[1][\al@mode]%
{\par\edef\@tempa{#1}%
\ifx\@tempa\al@mode@voc%
\bgroup\pardir TRT\textdir TRT\arabicfont%
\luadirect{tex.sprint(processvoc(\luastringO{\BODY}))}\egroup%
\else%
\ifx\@tempa\al@mode@fullvoc%
\bgroup\pardir TRT\textdir TRT\arabicfont%
\luadirect{tex.sprint(processfullvoc(\luastringO{\BODY}))}\egroup%
\else%
\ifx\@tempa\al@mode@novoc%
\bgroup\pardir TRT\textdir TRT\arabicfont%
\luadirect{tex.sprint(processnovoc(\luastringO{\BODY}))}\egroup%
\else
\ifx\@tempa\al@mode@trans%
\bgroup\pardir TLT\textdir TLT\al@trans@style%
\luadirect{tex.sprint(processtrans(\luastringO{\BODY},
\luastringO{\al@trans@convention}))}\egroup%
\else
\fi\fi\fi\fi}[\par]
\DeclareDocumentCommand{\Marginpar}{m}{\marginpar{\textdir TLT #1}}
\RenewDocumentCommand{\thefootnote}{}{\bgroup\textdir
TLT\arabic{footnote}\egroup}
\DeclareDocumentCommand{\LRfootnote}{m}{\bgroup\pardir
TLT\LR{\footnote{#1}}\egroup}
\endinput
% \end{macrocode}
%
% \printbibliography
%
% \iffalse
%</package>
% \fi
%
% \Finale
\endinput
|