aboutsummaryrefslogtreecommitdiff
path: root/arabluatex.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'arabluatex.dtx')
-rw-r--r--arabluatex.dtx231
1 files changed, 219 insertions, 12 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx
index 833b0e8..fce7f45 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/01/26 v1.0 This is ArabTeX for LuaLaTeX] 30 [2016/03/29 v1.0 This is ArabTeX for LuaLaTeX]
31%</package-info> 31%</package-info>
32% 32%
33%<*driver> 33%<*driver>
@@ -40,7 +40,7 @@
40\setmainfont{Libertinus Serif} 40\setmainfont{Libertinus Serif}
41\setsansfont{Libertinus Sans} 41\setsansfont{Libertinus Sans}
42\setmonofont[Scale=.9]{Libertinus Mono} 42\setmonofont[Scale=.9]{Libertinus Mono}
43\usepackage{arabluatex}[2016/01/26] 43\usepackage{arabluatex}[2016/03/29]
44\usepackage{polyglossia} 44\usepackage{polyglossia}
45\setdefaultlanguage{english} 45\setdefaultlanguage{english}
46\setotherlanguage{arabic} 46\setotherlanguage{arabic}
@@ -72,6 +72,7 @@
72\DeclareTotalTCBox{\arabluabox}{m}{left=0mm, right=0mm, top=0mm, 72\DeclareTotalTCBox{\arabluabox}{m}{left=0mm, right=0mm, top=0mm,
73 bottom=0mm, colback=white, boxrule=.15mm, 73 bottom=0mm, colback=white, boxrule=.15mm,
74 colframe=red!50!white}{#1} 74 colframe=red!50!white}{#1}
75\usepackage{xcolor}
75\newcommand{\package}[1]{\textsf{#1}\index{#1=#1 (package)}} 76\newcommand{\package}[1]{\textsf{#1}\index{#1=#1 (package)}}
76\usepackage{csquotes} 77\usepackage{csquotes}
77\DeclareQuoteStyle{arabic} 78\DeclareQuoteStyle{arabic}
@@ -112,7 +113,7 @@
112% Right brace \} Tilde \~} 113% Right brace \} Tilde \~}
113% 114%
114% 115%
115% \changes{1.0}{2016/01/26}{Converted to DTX file} 116% \changes{1.0}{2016/03/29}{Initial release}
116% 117%
117% \DoNotIndex{\newcommand,\newenvironment,\renewcommand} 118% \DoNotIndex{\newcommand,\newenvironment,\renewcommand}
118% 119%
@@ -122,7 +123,7 @@
122% \title{\tcbox[enhanced, tikznode, drop lifted shadow, colback=white, 123% \title{\tcbox[enhanced, tikznode, drop lifted shadow, colback=white,
123% boxrule=.25mm]% 124% boxrule=.25mm]%
124% {The \textsf{arabluatex} package\\ 125% {The \textsf{arabluatex} package\\
125% \fileversion~from \filedate}} 126% \fileversion\ -- \filedate}}
126% 127%
127% \newcommand*{\NEWfeature}[1]{% 128% \newcommand*{\NEWfeature}[1]{%
128% \hskip 1sp \marginpar{\small\sffamily\raggedright 129% \hskip 1sp \marginpar{\small\sffamily\raggedright
@@ -382,7 +383,7 @@ consonants, though three of them are also used as vowels
382% \iffalse 383% \iffalse
383%</example> 384%</example>
384% \fi 385% \fi
385% like so:--- 386% like so:---\label{ref:juha-code}
386% \setquotestyle{arabic} 387% \setquotestyle{arabic}
387% \iffalse 388% \iffalse
388%<*example> 389%<*example>
@@ -978,7 +979,7 @@ consonants, though three of them are also used as vowels
978% \arb[fullvoc]{\cap{z}ayduN ibnu \cap{`amriNU}} 979% \arb[fullvoc]{\cap{z}ayduN ibnu \cap{`amriNU}}
979% \arb[trans]{\cap{z}ayduN ibnu 980% \arb[trans]{\cap{z}ayduN ibnu
980% \cap{`amriNU}},\footnote{\enquote{Zayd is the son of ʿAmr}: the 981% \cap{`amriNU}},\footnote{\enquote{Zayd is the son of ʿAmr}: the
981% second noun is not in apposition to the first, but form part of 982% second noun is not in apposition to the first, but forms part of
982% the predicate. Hence \arb[voc]{zayduN ibnu `amriNU} and not 983% the predicate. Hence \arb[voc]{zayduN ibnu `amriNU} and not
983% \arb[voc]{zaydu bnu `amriNU}, \enquote{Zayd, son of ʿAmr}.} 984% \arb[voc]{zaydu bnu `amriNU}, \enquote{Zayd, son of ʿAmr}.}
984% |imru'u| |'l-qaysi| \arb[fullvoc]{imru'u 'l-qaysi} 985% |imru'u| |'l-qaysi| \arb[fullvoc]{imru'u 'l-qaysi}
@@ -1032,6 +1033,7 @@ consonants, though three of them are also used as vowels
1032% \arb[fullvoc]{qatalati 'l-rUmu} \arb[trans]{qatalati 1033% \arb[fullvoc]{qatalati 'l-rUmu} \arb[trans]{qatalati
1033% \cap{'l-rUmu}}. 1034% \cap{'l-rUmu}}.
1034% \end{quote} 1035% \end{quote}
1036% \label{ref:muhammaduni}
1035% However, the Arabic script does not shows the \arb[trans]{kasraT} 1037% However, the Arabic script does not shows the \arb[trans]{kasraT}
1036% which is taken by the nouns having \arb[trans]{tanwIn} although it 1038% which is taken by the nouns having \arb[trans]{tanwIn} although it
1037% is explicit in pronunciation and must appear in some transliteration 1039% is explicit in pronunciation and must appear in some transliteration
@@ -1064,7 +1066,7 @@ consonants, though three of them are also used as vowels
1064% vowel at the commencement of a word preceded by a word that ends 1066% vowel at the commencement of a word preceded by a word that ends
1065% with a vowel, either short or long, is absorbed by this vowel 1067% with a vowel, either short or long, is absorbed by this vowel
1066% viz. \arb[trans]{`al_A 'l-.tarIqi}. See \vref{sec:pipe} on the 1068% viz. \arb[trans]{`al_A 'l-.tarIqi}. See \vref{sec:pipe} on the
1067% \enquote{pipe} and **td on |dmg| mode.} 1069% \enquote{pipe} and \vref{sec:transliteration} on |dmg| mode.}
1068% |al-l_ahu| \arb[fullvoc]{yA| al-l_ahu} \arb[trans]{yA| al-l_ahu}, 1070% |al-l_ahu| \arb[fullvoc]{yA| al-l_ahu} \arb[trans]{yA| al-l_ahu},
1069% \verb+'a-fa|+\footnote{\label{fn:pipe-allah-02}See 1071% \verb+'a-fa|+\footnote{\label{fn:pipe-allah-02}See
1070% \cref{fn:pipe-allah-01}.}|-al-l_ahi| |la-ta.g`alanna| 1072% \cref{fn:pipe-allah-01}.}|-al-l_ahi| |la-ta.g`alanna|
@@ -1465,7 +1467,7 @@ consonants, though three of them are also used as vowels
1465% the \enquote{transliteration mode} may be selected globally or locally. 1467% the \enquote{transliteration mode} may be selected globally or locally.
1466% 1468%
1467% This mode transliterates the Arab\TeX\ input into one of the 1469% This mode transliterates the Arab\TeX\ input into one of the
1468% accepted standards. At said above \vpageref{ref:describe-trans}, two 1470% accepted standards. As said above \vpageref{ref:describe-trans}, two
1469% standards are supported at present: 1471% standards are supported at present:
1470% \begin{compactdesc} 1472% \begin{compactdesc}
1471% \item[dmg] \emph{Deutsche Morgenländische Gesellschaft}, which was 1473% \item[dmg] \emph{Deutsche Morgenländische Gesellschaft}, which was
@@ -1512,18 +1514,221 @@ consonants, though three of them are also used as vowels
1512% \paragraph{Proper names} \DescribeMacro{cap} Proper names or book 1514% \paragraph{Proper names} \DescribeMacro{cap} Proper names or book
1513% titles that must have their first letters uppercased may be passed 1515% titles that must have their first letters uppercased may be passed
1514% as arguments to the command \cs{cap}\marg{word}. \cs{cap} is a 1516% as arguments to the command \cs{cap}\marg{word}. \cs{cap} is a
1515% clever command, as it will give the definite article 1517% clever command, for it will give the definite article
1516% \arb[trans]{al-} in lower case in all positions. Moreover, if the 1518% \arb[trans]{al-} in lower case in all positions. Moreover, if the
1517% inital letter, apart from the article, cannot be uppercased, 1519% inital letter, apart from the article, cannot be uppercased,
1518% viz. \arb[trans]{'} or \arb[trans]{`}, the letter next to it will be 1520% viz. \arb[trans]{|"'} or \arb[trans]{`}, the letter next to it will be
1519% uppercased:--- 1521% uppercased:---
1520% \begin{quote} 1522% \begin{quote}
1521% |\cap{.hunaynu}| |bnu| |\cap{'is.h_aqa}| \arb[voc]{\cap{.hunaynu} 1523% |\cap{.hunaynu}| |bnu| |\cap{'is.h_aqa}| \arb[voc]{\cap{.hunaynu}
1522% bnu \cap{'is.h_aqa}} \arb[trans]{\cap{.hunaynu} bnu 1524% bnu \cap{'is.h_aqa}} \arb[trans]{\cap{.hunaynu} bnu
1523% \cap{'is.h_aqa}}, |\cap{`u_tm_anu}| \arb[voc]{\cap{`u_tm_anu}} 1525% \cap{'is.h_aqa}}, |\cap{`u_tm_anu}| \arb[voc]{\cap{`u_tm_anu}}
1524% \arb[trans]{\cap{`u_tm_anu}}. 1526% \arb[trans]{\cap{`u_tm_anu}}, |.daraba| |\cap{zaydu}| |bnu|
1527% |\cap{_h_alidiN}| |\cap{sa`da}| |bna| |\cap{`awfi}| |bni|
1528% |\cap{`abdi}| |\cap{'l-l_ahi}| \arb[fullvoc]{.daraba \cap{zaydu}
1529% bnu \cap{_h_alidiN} \cap{sa`da} bna \cap{`awfi} bni \cap{`abdi}
1530% \cap{'l-l_ahi}} \arb[trans]{.daraba \cap{zaydu} bnu
1531% \cap{_h_alidiN} \cap{sa`da} bna \cap{`awfi} bni \cap{`abdi}
1532% \cap{'l-l_ahi}}.
1533% \end{quote}
1534% However, \cs{cap} must be used cautiously in some very particular
1535% cases, for the closing brace of its argument may prevent a rule from
1536% being applied. To take an example, as seen above
1537% \vpageref{ref:muhammaduni}, the transliteration of
1538% \arb[fullvoc]{\cap{m}u.hammaduN 'l-nabI} must be
1539% \arb[trans]{\cap{m}u.hammaduN 'l-nabI}, as nouns having the
1540% \arb[trans]{tanwIn} take a \arb[trans]{kasraT} in pronunciation
1541% before \arb[trans]{'alifu 'l-wa.sli}. In this case, encoding
1542% \arb[fullvoc]{mu.hammaduN} like so: |\cap{mu.hammaduN}| is wrong,
1543% because the closing brace would prevent \package{arabluatex} from
1544% detecting the sequence \meta{-uN} immediately followed by
1545% \meta{'-l}. Fortunately, this can be circumvented in a
1546% straightforward way by inserting only part of the noun in the
1547% argument of \cs{cap} vz. up to the first letter that is to be
1548% uppercased, like so: |\cap{m}u.hammaduN|.
1549%
1550% \subsection{Examples}
1551% \label{sec:examples-translit}
1552% Here follows in transliteration the story of
1553% \arb[trans]{\cap{ju.hA}} and his donkey (\arb[voc]{\cap{ju.hA
1554% wa-.himAru-hu}}). See the code \vpageref{ref:juha-code}:---
1555%
1556% \SetTranslitConvention{dmg}
1557% \begin{arab}[trans]
1558% \LR{\textbf{\emph{\enquote*{dmg}} standard}:} 'at_A .sadIquN 'il_A
1559% \cap{ju.hA} ya.tlubu min-hu .himAra-hu li-yarkaba-hu fI safraTiN
1560% qa.sIraTiN. wa-qAla la-hu: \enquote{sawfa 'u`Idu-hu 'ilay-ka fI
1561% 'l-masA'i wa-'adfa`u la-ka 'ujraTaN.} fa-qAla \cap{ju.hA}:
1562% \enquote{'anA 'AsifuN jiddaN 'annI lA 'asta.tI`u 'an 'u.haqqiqa
1563% la-ka .garbata-ka fa-'l-.himAru laysa hunA 'l-yawma.} wa-qabla
1564% 'an yutimma \cap{ju.hA} kalAma-hu bada'a 'l-.himAru yanhaqu fI
1565% 'i.s.tabili-hi. fa-qAla la-hu .sadIqu-hu: \enquote{'innI 'asma`u
1566% .himAra-ka yA \cap{ju.hA} yanhaqu.} fa-qAla la-hu \cap{ju.hA}:
1567% \enquote{.garIbuN 'amru-ka yA .sadIqI 'a-tu.saddiqu 'l-.himAra
1568% wa-tuka_d_dibu-nI?}
1569% \end{arab}
1570%
1571% \SetTranslitConvention{loc}
1572% \begin{arab}[trans]
1573% \LR{\textbf{\emph{\enquote*{loc}} standard}:} 'at_A .sadIquN 'il_A
1574% \cap{ju.hA} ya.tlubu min-hu .himAra-hu li-yarkaba-hu fI safraTiN
1575% qa.sIraTiN. wa-qAla la-hu: \enquote{sawfa 'u`Idu-hu 'ilay-ka fI
1576% 'l-masA'i wa-'adfa`u la-ka 'ujraTaN.} fa-qAla \cap{ju.hA}:
1577% \enquote{'anA 'AsifuN jiddaN 'annI lA 'asta.tI`u 'an 'u.haqqiqa
1578% la-ka .garbata-ka fa-'l-.himAru laysa hunA 'l-yawma.} wa-qabla
1579% 'an yutimma \cap{ju.hA} kalAma-hu bada'a 'l-.himAru yanhaqu fI
1580% 'i.s.tabili-hi. fa-qAla la-hu .sadIqu-hu: \enquote{'innI 'asma`u
1581% .himAra-ka yA \cap{ju.hA} yanhaqu.} fa-qAla la-hu \cap{ju.hA}:
1582% \enquote{.garIbuN 'amru-ka yA .sadIqI 'a-tu.saddiqu 'l-.himAra
1583% wa-tuka_d_dibu-nI?}
1584% \end{arab}
1585% \SetTranslitConvention{dmg}
1586%
1587% \section{\LaTeX\ Commands in Arabic environments}
1588% \label{sec:commands-in-arb}
1589% \paragraph{General principle} \LaTeX\ commands are accepted in
1590% Arabic environments. The general principle which applies is that
1591% single-argument commands (\cs{command}\marg{arg}) such as
1592% \cs{emph}\marg{text}, \cs{textbf}\marg{text} and the like, are
1593% assumed to have Arabic text as their arguments:---
1594% \begin{quote}
1595% |\abjad{45}| |kitAbu-hu| |\emph{fI| |'l-\cap{`AdAti}}|
1596% \arb[voc]{\abjad{45} kitAbu-hu \emph{fI l-\cap{`AdAti}}}
1597% \arb[trans]{45 kitAbu-hu \emph{fI 'l-\cap{`AdAti}}}.\footnote{This
1598% is odd in Arabic script, but using such features as \cs{emph} or
1599% \cs{textbf} is a matter of personal taste.}
1525% \end{quote} 1600% \end{quote}
1526% 1601%
1602% The same applies to footnotes:---
1603% \iffalse
1604%<*example>
1605% \fi
1606\begin{arabluacode}
1607\renewcommand{\footnoterule}%
1608 {\hfill\noindent\rule[1mm]{.4\textwidth}{.15mm}}
1609\begin{arab}
1610'inna 'abI kAna mina 'l-muqAtilaTi\footnote{al-muqAtilaTi:
1611al-muqAtilIna.}, wa-kAnat 'ummI min `u.zamA'i buyUti
1612'l-zamAzimaTi\footnote{al-zamAzimaTu: .tA'ifaTu mina
1613'l-fursi.}.
1614\end{arab}
1615\end{arabluacode}
1616% \iffalse
1617%</example>
1618% \fi
1619%
1620% Some commands, however, do not expect running text in their
1621% arguments, or one may wish to insert English text eg. in footnotes
1622% or in marginal notes. \package{arabluatex} provides a set of
1623% commands to handle such cases.
1624%
1625% \DescribeMacro{LR} \cs{LR}\marg{arg} is designed to typeset its
1626% argument from left to right. It may be used in an Arabic
1627% environment, either \cs{arb}\marg{Arabic text} or \cs{begin}|{arab}|
1628% \meta{Arabic text} \cs{end}|{arab}|, for short insertions of left to
1629% right text, or to insert any \LaTeX\ command that would otherwise be
1630% rejected by \package{arabluatex}, such as commands the argument of
1631% which is expected to be a dimension or a unit of measurement.
1632%
1633% \DescribeMacro{RL} \cs{RL}\marg{arg} does the same as
1634% \cs{LR}\marg{arg}, but typesets its argument from left to right. Even
1635% in an Arabic environment, this command may be useful. For example, to
1636% distinguish words with a different color, one may proceed like
1637% so:---
1638% \iffalse
1639%<*example>
1640% \fi
1641\begin{arabluacode}
1642\begin{arab}
1643wa-'at_A _dU 'l-qarnayni 'ummaTaN 'llatI hiya fI
1644\LR{\textcolor{red}{\arb[fullvoc]{((ma.gribi 'l-^samsi))}}}
1645wa-lA binA'a la-hum yu'amminu-hum mina 'l-^samsi.
1646\end{arab}
1647\end{arabluacode}
1648% \iffalse
1649%</example>
1650% \fi
1651%
1652% \DescribeMacro{LRfootnote} \DescribeMacro{RLfootnote}
1653% \cs{LRfootnote}\marg{text} and \cs{RLfootnote}\marg{text} typeset
1654% left-to-right and right-to-left footnotes respectively in Arabic
1655% environments. Unlike \cs{footnote}\marg{text}, the arguments of both
1656% \cs{LRfootnote} and \cs{RLfootnote} are not expected to be Arabic
1657% text. For example, \cs{LRfootnote} may be used to insert English
1658% footnotes in running Arabic text:---
1659% \iffalse
1660%<*example>
1661% \fi
1662\begin{arabluacode}
1663\arb[fullvoc]{\cap{z}ayduN\LRfootnote{\enquote{Zayd
1664is the son of ʿAmr}: the second noun is not in
1665apposition to the first, but forms part of
1666the predicate\ldots} "ibnu \cap{`amriNU}}
1667\end{arabluacode}
1668% \iffalse
1669%</example>
1670% \fi
1671%
1672% When footnotes are typeset from right to left, it may happen that
1673% the numbers of the footnotes that are at the bottom of the page be
1674% typeset in the wrong direction. For example, instead of an expected
1675% number 18, one may get 81. \package{arabluatex} is not responsible
1676% for this, but should it happen, it may be necessary to redefine in
1677% the preamble the \LaTeX\ macro \cs{thefootnote} like so:---\\
1678% \arabluaverb{\renewcommand*{\thefootnote}{\textsuperscript{\LR{\arabic{footnote}}}}}
1679% \DescribeMacro{FixArbFtnmk} Another solution is to put in the
1680% preamble, below the line that loads \package{arabluatex}, the
1681% command \cs{FixArbFtnmk}. However, for more control over the layout
1682% of footnotes marks, it is advisable to use the package
1683% \package{scrextend}.\footnote{See
1684% \url{http://ctan.org/pkg/koma-script}; read the documentation of
1685% \package{KOMA-script} for details about the \cs{deffootnotemark} and
1686% \cs{deffootnote} commands.}
1687%
1688% \DescribeMacro{setRL} \DescribeMacro{setLR} \cs{setRL} and
1689% \cs{setLR} may be used to change the direction of paragraphs, either
1690% form left to right or from right to left. As an example, an
1691% easy way to typeset a right-to-left sectional title follows:---
1692% \iffalse
1693%<*example>
1694% \fi
1695\begin{arabluacode}
1696\setRL
1697\section*{\arb{barzawayhi li-buzurjumihra bni 'l-buxtikAni}}
1698\setLR
1699\begin{arab}
1700qAla barzawayhi bnu 'azhara, ra'su 'a.tibbA'i fArisa...
1701\end{arab}
1702\end{arabluacode}
1703% \iffalse
1704%</example>
1705% \fi
1706%
1707% \paragraph{\package{reledmac}} The two-arguments command
1708% \cs{edtext}\marg{lemma}\marg{commands} is supported inside
1709% \cs{begin}|{arab}| \ldots\ \cs{end}|{arab}|. As an example, one may
1710% get \package{arabluatex} and \package{reledmac} to work together
1711% like so:---
1712% \iffalse
1713%<*example>
1714% \fi
1715\begin{arabluaverbatim}
1716\beginnumbering
1717\pstart
1718\begin{arab}
1719wa-ya.sIru ta.hta 'l-jildi
1720\edtext{\arb{.sadIduN}}{\Afootnote{M: \arb{.sadIdaN} E1}}
1721\end{arab}
1722\pend
1723\endnumbering
1724\end{arabluaverbatim}
1725% \iffalse
1726%</example>
1727% \fi
1728%
1729% \section{Future work}
1730% \label{sec:future-work}
1731%
1527% 1732%
1528% \StopEventually{} 1733% \StopEventually{}
1529% 1734%
@@ -1536,7 +1741,7 @@ consonants, though three of them are also used as vowels
1536% \begin{macrocode} 1741% \begin{macrocode}
1537\NeedsTeXFormat{LaTeX2e} 1742\NeedsTeXFormat{LaTeX2e}
1538\ProvidesPackage{arabluatex}% 1743\ProvidesPackage{arabluatex}%
1539[2016/01/26 v1.0 ArabTeX-like interface for LuaLaTeX] 1744[2016/03/29 v1.0 ArabTeX-like interface for LuaLaTeX]
1540\RequirePackage{ifluatex} 1745\RequirePackage{ifluatex}
1541% \end{macrocode} 1746% \end{macrocode}
1542% \package{arabluatex} requires \LuaLaTeX\ of course. 1747% \package{arabluatex} requires \LuaLaTeX\ of course.
@@ -1654,6 +1859,8 @@ consonants, though three of them are also used as vowels
1654\DeclareDocumentCommand{\Marginpar}{m}{\marginpar{\textdir TLT #1}} 1859\DeclareDocumentCommand{\Marginpar}{m}{\marginpar{\textdir TLT #1}}
1655\DeclareDocumentCommand{\LRfootnote}{m}{\bgroup\pardir 1860\DeclareDocumentCommand{\LRfootnote}{m}{\bgroup\pardir
1656 TLT\LR{\footnote{#1}}\egroup} 1861 TLT\LR{\footnote{#1}}\egroup}
1862\DeclareDocumentCommand{\RLfootnote}{m}{\bgroup\pardir
1863 TRT\LR{\footnote{#1}}\egroup}
1657\NewDocumentCommand{\FixArbFtnmk}{}{% 1864\NewDocumentCommand{\FixArbFtnmk}{}{%
1658 \@ifpackageloaded{scrextend}% 1865 \@ifpackageloaded{scrextend}%
1659 {\AtBeginDocument{\deffootnote{2em}{1.6em}{\LR{\thefootnotemark}.\enskip}}}% 1866 {\AtBeginDocument{\deffootnote{2em}{1.6em}{\LR{\thefootnotemark}.\enskip}}}%