aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2016-04-27 08:00:52 +0200
committerRobert Alessi <alessi@robertalessi.net>2016-04-27 08:00:52 +0200
commit4119ec9eb6c00ef899a41d8f9ae3abca577b3e9f (patch)
treeec3c091ed8a08636b1109073bc64af931e73ef64
parentecbddd777ca0a96ce9c455c7c5e7e3689f3ca119 (diff)
downloadarabluatex-4119ec9eb6c00ef899a41d8f9ae3abca577b3e9f.tar.gz
updated documentation on the new \abjad command
-rw-r--r--arabluatex.dtx100
-rw-r--r--arabluatex.lua15
2 files changed, 60 insertions, 55 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx
index 62adc75..27e970e 100644
--- a/arabluatex.dtx
+++ b/arabluatex.dtx
@@ -27,7 +27,7 @@
27%<package-info>\NeedsTeXFormat{LaTeX2e}[1999/12/01] 27%<package-info>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
28%<package-info>\ProvidesPackage{arabluatex} 28%<package-info>\ProvidesPackage{arabluatex}
29%<*package-info> 29%<*package-info>
30 [2016/03/31 v1.0.1 This is ArabTeX for LuaLaTeX] 30 [2016/04/26 v1.1 This is ArabTeX for LuaLaTeX]
31%</package-info> 31%</package-info>
32% 32%
33%<*driver> 33%<*driver>
@@ -130,12 +130,13 @@
130\usepackage[english]{babel} 130\usepackage[english]{babel}
131\usepackage{dox} 131\usepackage{dox}
132\doxitem{Option}{option}{options} 132\doxitem{Option}{option}{options}
133\def\actualchar{ =}
133\usepackage{fontspec,luatextra,realscripts} 134\usepackage{fontspec,luatextra,realscripts}
134\defaultfontfeatures{RawFeature={+liga;+onum;+hlig}} 135\defaultfontfeatures{RawFeature={+liga;+onum;+hlig}}
135\setmainfont{Libertinus Serif} 136\setmainfont{Libertinus Serif}
136\setsansfont{Libertinus Sans} 137\setsansfont{Libertinus Sans}
137\setmonofont[Scale=.9]{Libertinus Mono} 138\setmonofont[Scale=.9]{Libertinus Mono}
138\usepackage{arabluatex}[2016/03/31] 139\usepackage{arabluatex}[2016/04/26]
139\usepackage{varioref} 140\usepackage{varioref}
140\usepackage{hypdoc} 141\usepackage{hypdoc}
141\hypersetup{unicode=true, colorlinks, allcolors=blue, 142\hypersetup{unicode=true, colorlinks, allcolors=blue,
@@ -176,8 +177,8 @@
176\DeclareIndexFieldFormat{indextitle}{\index{#1=\emph{#1}}} 177\DeclareIndexFieldFormat{indextitle}{\index{#1=\emph{#1}}}
177\addbibresource{arabluatex.bib} 178\addbibresource{arabluatex.bib}
178\EnableCrossrefs 179\EnableCrossrefs
179\CodelineIndex
180\RecordChanges 180\RecordChanges
181\CodelineIndex
181\begin{document} 182\begin{document}
182 \DocInput{arabluatex.dtx} 183 \DocInput{arabluatex.dtx}
183 \addcontentsline{toc}{section}{Change History} 184 \addcontentsline{toc}{section}{Change History}
@@ -207,8 +208,8 @@
207% Right brace \} Tilde \~} 208% Right brace \} Tilde \~}
208% 209%
209% 210%
210% \changes{1.0}{2016/03/29}{Initial release} 211% \changes{v1.0}{2016/03/29}{Initial release}
211% \changes{1.0.1}{2016/03/31}{Minor update of the documentation} 212% \changes{v1.0.1}{2016/03/31}{Minor update of the documentation}
212% 213%
213% \DoNotIndex{\newcommand,\newenvironment,\renewcommand} 214% \DoNotIndex{\newcommand,\newenvironment,\renewcommand}
214% \DoNotIndex{\~,\AtBeginDocument,\bgroup,\csname} 215% \DoNotIndex{\~,\AtBeginDocument,\bgroup,\csname}
@@ -216,7 +217,7 @@
216% \DoNotIndex{\else,\endcsname,\endinput,\expandafter,\fi} 217% \DoNotIndex{\else,\endcsname,\endinput,\expandafter,\fi}
217% \DoNotIndex{\ifdef,\ifdefined,\ifx,\MessageBreak,\NeedsTeXFormat} 218% \DoNotIndex{\ifdef,\ifdefined,\ifx,\MessageBreak,\NeedsTeXFormat}
218% \DoNotIndex{\NewDocumentCommand,\newif,\PackageError,\PackageWarning} 219% \DoNotIndex{\NewDocumentCommand,\newif,\PackageError,\PackageWarning}
219% \DoNotIndex{\relax,\RenewDocumentCommand,\string} 220% \DoNotIndex{\relax,\RenewDocumentCommand,\string,\verb}
220% 221%
221% \providecommand*{\url}{\texttt} 222% \providecommand*{\url}{\texttt}
222% \GetFileInfo{arabluatex.dtx} 223% \GetFileInfo{arabluatex.dtx}
@@ -404,8 +405,7 @@
404% complain if you try to compile your document with another 405% complain if you try to compile your document with another
405% engine. That aside, \package{arabluatex} does not load packages such 406% engine. That aside, \package{arabluatex} does not load packages such
406% as \package{polyglossia} or \package{luabidi}. It can work with 407% as \package{polyglossia} or \package{luabidi}. It can work with
407% \package{polyglossia} though, but does not require it.\footnote{With 408% \package{polyglossia} though, but does not require it.
408% one exception: see \vref{sec:abjad}.}
409% 409%
410% \paragraph{Font setup} 410% \paragraph{Font setup}
411% If you wish to use your own Arabic font, you can define it before 411% If you wish to use your own Arabic font, you can define it before
@@ -1502,42 +1502,37 @@ consonants, though three of them are also used as vowels
1502% \arb[trans]{'abjad} numbers are usually distinguished from the 1502% \arb[trans]{'abjad} numbers are usually distinguished from the
1503% surrounding words by a stroke placed over them. 1503% surrounding words by a stroke placed over them.
1504% 1504%
1505% For the time being, \package{arabluatex} inserts those numbers with the 1505% \DescribeMacro{\abjad} \NEWfeature{v.1.1} \arb[trans]{'abjad}
1506% help of \package{polyglossia}. If one wishes to use the 1506% numbers are inserted with the command \cs{abjad}\marg{number} in any
1507% \arb[trans]{abjad} system, he may put in his preamble:--- 1507% of the |voc|, |fullvoc| and |novoc| modes, where \meta{number} may
1508% \iffalse 1508% be any number between 1 and 1999, like so:---
1509%<*example>
1510% \fi
1511\begin{arabluaverbatim}
1512\usepackage{polyglossia}
1513\setdefaultlanguage{english} % please adapt
1514\setotherlanguage{arabic} % to enable the 'abjad' numbers
1515\end{arabluaverbatim}
1516% \iffalse
1517%</example>
1518% \fi %
1519% \DescribeMacro{\abjad} Then one may use the command
1520% \cs{abjad}\marg{number} in any of the |voc|, |fullvoc| and |novoc|
1521% modes, where \meta{number} may be any number between 1 and 1999,
1522% like so:---
1523% \begin{quote} 1509% \begin{quote}
1524% |\abjad{45}| |kitAbu-hu| |fI| |'l-`AdAti| \arb[voc]{\abjad{45} 1510% |\abjad{45}| |kitAbu-hu| |fI| |'l-`AdAti| \arb[voc]{\abjad{45}
1525% kitAbu-hu fI 'l-`AdAti} \arb[trans]{\abjad{45} kitAbu-hu fI 1511% kitAbu-hu fI 'l-`AdAti} \arb[trans]{\abjad{45} kitAbu-hu fI
1526% 'l-`AdAti}. 1512% 'l-`AdAti}.
1527% \end{quote} 1513% \end{quote}
1514% \begin{quoting}
1515% \textsc{Rem.}~\emph{a.} As can be seen in the above given example,
1516% \package{arabluatex} expresses the \arb[trans]{'abjad} numbers in
1517% Roman numerals if it finds the command \cs{abjad} in any of the
1518% transliteration modes.
1519%
1520% \textsc{Rem.}~\emph{b.} \cs{abjad} may also be found outside
1521% Arabic environments. In that case, \package{arabluatex} does not
1522% print the stroke as a distinctive mark over the number for it is
1523% not surrounded by other Arabic words. In case one nonetheless
1524% wishes to print the stroke, he can use the \cs{aemph} command that
1525% is described below in \vref{sec:emphasis}:---
1526% \begin{quote}
1527% |The| |\arb[trans]{'abjad}| |number| |for| |1874| |is|
1528% |\abjad{1874}| The \arb[trans]{'abjad} number for 1874 is
1529% \abjad{1874}.
1528% 1530%
1529% \iffalse 1531% |The| |\arb[trans]{'abjad}| |number| |for| |1874| |is|
1530%<*example> 1532% |\aemph{\abjad{1874}}| The \arb[trans]{'abjad} number for 1874
1531% \fi 1533% is \aemph{\abjad{1874}}.
1532\begin{arabluacode}[text only] 1534% \end{quote}
1533 Apart from this case, \package{arabluatex} makes no use of 1535% \end{quoting}
1534 \package{polyglossia}. The support for the \arb[trans]{'abjad}
1535 numbering system is planned for inclusion in a future version of
1536 \package{arabluatex}.
1537\end{arabluacode}
1538% \iffalse
1539%</example>
1540% \fi
1541% 1536%
1542% \subsection{Additional characters} 1537% \subsection{Additional characters}
1543% \label{sec:additional-characters} 1538% \label{sec:additional-characters}
@@ -1596,7 +1591,7 @@ consonants, though three of them are also used as vowels
1596% \begin{quote} 1591% \begin{quote}
1597% |\abjad{45}:| |kitAbu-hu| |\aemph{fI| |'l-`AdAti}| 1592% |\abjad{45}:| |kitAbu-hu| |\aemph{fI| |'l-`AdAti}|
1598% \arb[voc]{\abjad{45}: kitAbu-hu \aemph{fI 'l-`AdAti}} 1593% \arb[voc]{\abjad{45}: kitAbu-hu \aemph{fI 'l-`AdAti}}
1599% \arb[trans]{45: kitAbu-hu fI 'l-\cap{`AdAti}}. 1594% \arb[trans]{\abjad{45}: kitAbu-hu fI 'l-\cap{`AdAti}}.
1600% \end{quote} 1595% \end{quote}
1601% 1596%
1602% \section{Special applications} 1597% \section{Special applications}
@@ -1741,17 +1736,18 @@ consonants, though three of them are also used as vowels
1741% \section{\LaTeX\ Commands in Arabic environments} 1736% \section{\LaTeX\ Commands in Arabic environments}
1742% \label{sec:commands-in-arb} 1737% \label{sec:commands-in-arb}
1743% \paragraph{General principle} \label{ref:cmd-inside-arabic}\LaTeX\ 1738% \paragraph{General principle} \label{ref:cmd-inside-arabic}\LaTeX\
1744% commands are accepted in 1739% commands are accepted in Arabic environments. The general principle
1745% Arabic environments. The general principle which applies is that 1740% which applies is that single-argument commands
1746% single-argument commands (\cs{command}\marg{arg}) such as 1741% (\cs{command}\marg{arg}) such as \cs{emph}\marg{text},
1747% \cs{emph}\marg{text}, \cs{textbf}\marg{text} and the like, are 1742% \cs{textbf}\marg{text} and the like, are assumed to have Arabic text
1748% assumed to have Arabic text as their arguments:--- 1743% as their arguments:---
1749% \begin{quote} 1744% \begin{quote}
1750% |\abjad{45}| |kitAbu-hu| |\emph{fI| |'l-\cap{`AdAti}}| 1745% |\abjad{45}| |kitAbu-hu| |\emph{fI| |'l-\cap{`AdAti}}|
1751% \arb[voc]{\abjad{45} kitAbu-hu \emph{fI l-\cap{`AdAti}}} 1746% \arb[voc]{\abjad{45} kitAbu-hu \emph{fI l-\cap{`AdAti}}}
1752% \arb[trans]{45 kitAbu-hu \emph{fI 'l-\cap{`AdAti}}}.\footnote{This 1747% \arb[trans]{\abjad{45} kitAbu-hu \emph{fI
1753% is odd in Arabic script, but using such features as \cs{emph} or 1748% 'l-\cap{`AdAti}}}.\footnote{This is odd in Arabic script, but
1754% \cs{textbf} is a matter of personal taste.} 1749% using such features as \cs{emph} or \cs{textbf} is a matter of
1750% personal taste.}
1755% \end{quote} 1751% \end{quote}
1756% 1752%
1757% The same applies to footnotes:--- 1753% The same applies to footnotes:---
@@ -1970,7 +1966,7 @@ wa-ya.sIru ta.hta 'l-jildi
1970% \begin{macrocode} 1966% \begin{macrocode}
1971\NeedsTeXFormat{LaTeX2e} 1967\NeedsTeXFormat{LaTeX2e}
1972\ProvidesPackage{arabluatex}% 1968\ProvidesPackage{arabluatex}%
1973[2016/03/31 v1.0.1 ArabTeX-like interface for LuaLaTeX] 1969[2016/04/26 v1.1 ArabTeX-like interface for LuaLaTeX]
1974\RequirePackage{ifluatex} 1970\RequirePackage{ifluatex}
1975% \end{macrocode} 1971% \end{macrocode}
1976% \package{arabluatex} requires \LuaLaTeX\ of course. Issue a warning 1972% \package{arabluatex} requires \LuaLaTeX\ of course. Issue a warning
@@ -2156,7 +2152,13 @@ wa-ya.sIru ta.hta 'l-jildi
2156 \else \fi\fi\fi\fi}[\par] 2152 \else \fi\fi\fi\fi}[\par]
2157% \end{macrocode} 2153% \end{macrocode}
2158% \end{environment} 2154% \end{environment}
2159% \begin{macro}{\abjad} \cs{abjad} 2155% \begin{macro}{\abjad} \cs{abjad}\marg{number} expresses its argument
2156% in Arabic letters in accordance with the \arb[trans]{'abjad}
2157% arrangement of the alphabet. \meta{number} must be between 1 and
2158% 1999. It is now coded in Lua so that \package{polyglossia} is no
2159% longer needed. See |arabluatex.lua| for more information.
2160% \changes{v1.1}{2016/04/26}{New and more flexible \protect\cs{abjad}
2161% command.}
2160% \begin{macrocode} 2162% \begin{macrocode}
2161\NewDocumentCommand{\abjad}{m}% 2163\NewDocumentCommand{\abjad}{m}%
2162 {\luadirect{tex.sprint(abjadify(#1))}} 2164 {\luadirect{tex.sprint(abjadify(#1))}}
diff --git a/arabluatex.lua b/arabluatex.lua
index 102974a..0f3984b 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -388,24 +388,27 @@ local abjad = {
388{".g"} 388{".g"}
389} 389}
390 390
391-- this function is adapted from an 'obsolete project' of Khaled
392-- Hosny's that dates back to 2010. Thanks to him.
393-- See https://github.com/khaledhosny/lualatex-arabic
391function abjadify(n) 394function abjadify(n)
392 local result = "" 395 local abjadnum = ""
393 if n >= 1000 then 396 if n >= 1000 then
394 for i=1,math.floor(n/1000) do 397 for i=1,math.floor(n/1000) do
395 result = result .. abjad[4][1] 398 abjadnum = abjadnum .. abjad[4][1]
396 end 399 end
397 n = math.fmod(n,1000) 400 n = math.fmod(n,1000)
398 end 401 end
399 if n >= 100 then 402 if n >= 100 then
400 result = result .. abjad[3][math.floor(n/100)] 403 abjadnum = abjadnum .. abjad[3][math.floor(n/100)]
401 n = math.fmod(n, 100) 404 n = math.fmod(n, 100)
402 end 405 end
403 if n >= 10 then 406 if n >= 10 then
404 result = result .. abjad[2][math.floor(n/10)] 407 abjadnum = abjadnum .. abjad[2][math.floor(n/10)]
405 n = math.fmod(n, 10) 408 n = math.fmod(n, 10)
406 end 409 end
407 if n >= 1 then 410 if n >= 1 then
408 result = result .. abjad[1][math.floor(n/1)] 411 abjadnum = abjadnum .. abjad[1][math.floor(n/1)]
409 end 412 end
410 return "\\arb{"..result.."}" 413 return "\\arb{"..abjadnum.."}"
411end 414end