aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2016-03-30 15:01:45 +0200
committerRobert Alessi <alessi@robertalessi.net>2016-03-30 15:01:45 +0200
commita0cabb9d3873021aadb2accf9addbdb7b7ba6282 (patch)
treedf98d53d141fa14d7f8b503a02f26869c9d1e8d2
parent4668233f36c49ea7a1306aa92b48b4711b7e1d95 (diff)
downloadarabluatex-a0cabb9d3873021aadb2accf9addbdb7b7ba6282.tar.gz
almost done. now tidy up things
-rw-r--r--arabluatex.dtx92
-rw-r--r--arabluatex.ins25
-rw-r--r--arabluatex.lua2
3 files changed, 103 insertions, 16 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx
index c4e6388..89501d9 100644
--- a/arabluatex.dtx
+++ b/arabluatex.dtx
@@ -374,7 +374,7 @@
374% \package{arabluatex}. 374% \package{arabluatex}.
375% 375%
376%\subsection{Typing Arabic} 376%\subsection{Typing Arabic}
377% \DescribeMacro{arb} Once \package{arabluatex} is loaded, a command 377% \DescribeMacro{\arb} Once \package{arabluatex} is loaded, a command
378% \cs{arb}\marg{Arabic text} is available for inserting Arabic text in 378% \cs{arb}\marg{Arabic text} is available for inserting Arabic text in
379% paragraphs, like so:--- 379% paragraphs, like so:---
380% \iffalse 380% \iffalse
@@ -1399,7 +1399,7 @@ consonants, though three of them are also used as vowels
1399% \iffalse 1399% \iffalse
1400%</example> 1400%</example>
1401% \fi % 1401% \fi %
1402% \DescribeMacro{abjad} Then you may use the command 1402% \DescribeMacro{\abjad} Then you may use the command
1403% \cs{abjad}\marg{number} in any of the |voc|, |fullvoc| and |novoc| 1403% \cs{abjad}\marg{number} in any of the |voc|, |fullvoc| and |novoc|
1404% modes, where \meta{number} may be any number between 1 and 1999, 1404% modes, where \meta{number} may be any number between 1 and 1999,
1405% like so:--- 1405% like so:---
@@ -1474,7 +1474,7 @@ consonants, though three of them are also used as vowels
1474% over them. This technique is used to distinguish further words that 1474% over them. This technique is used to distinguish further words that
1475% are proper names or book titles. 1475% are proper names or book titles.
1476% 1476%
1477% \DescribeMacro{aemph} One may use the command \cs{aemph}\marg{Arabic 1477% \DescribeMacro{\aemph} One may use the command \cs{aemph}\marg{Arabic
1478% text} to use the same technique to emphasize words, like so:--- 1478% text} to use the same technique to emphasize words, like so:---
1479% \begin{quote} 1479% \begin{quote}
1480% |\abjad{45}:| |kitAbu-hu| |\aemph{fI| |'l-`AdAti}| 1480% |\abjad{45}:| |kitAbu-hu| |\aemph{fI| |'l-`AdAti}|
@@ -1522,7 +1522,7 @@ consonants, though three of them are also used as vowels
1522% More standards will be included in future releases of 1522% More standards will be included in future releases of
1523% \package{arabluatex}. 1523% \package{arabluatex}.
1524% 1524%
1525% \paragraph{Convention} \DescribeMacro{SetTranslitConvention} The 1525% \paragraph{Convention} \DescribeMacro{\SetTranslitConvention} The
1526% transliteration mode, which is set to |dmg| by default, may be 1526% transliteration mode, which is set to |dmg| by default, may be
1527% changed at any point of the document by the command 1527% changed at any point of the document by the command
1528% \cs{SetTranslitConvention}\marg{mode}, where \meta{mode} may be 1528% \cs{SetTranslitConvention}\marg{mode}, where \meta{mode} may be
@@ -1539,7 +1539,7 @@ consonants, though three of them are also used as vowels
1539%</example> 1539%</example>
1540% \fi 1540% \fi
1541% 1541%
1542% \paragraph{Style} \DescribeMacro{SetTranslitStyle} Any 1542% \paragraph{Style} \DescribeMacro{\SetTranslitStyle} Any
1543% transliterated Arabic text is printed in italics by default. This 1543% transliterated Arabic text is printed in italics by default. This
1544% also can be changed either globally in the preamble or locally at 1544% also can be changed either globally in the preamble or locally at
1545% any point of the document by the command 1545% any point of the document by the command
@@ -1548,7 +1548,7 @@ consonants, though three of them are also used as vowels
1548% \cs{slshape}, and so forth. Any specific font may also be selected 1548% \cs{slshape}, and so forth. Any specific font may also be selected
1549% using the font-selecting commands of the \package{fontspec} package. 1549% using the font-selecting commands of the \package{fontspec} package.
1550% 1550%
1551% \paragraph{Proper names} \DescribeMacro{cap} Proper names or book 1551% \paragraph{Proper names} \DescribeMacro{\cap} Proper names or book
1552% titles that must have their first letters uppercased may be passed 1552% titles that must have their first letters uppercased may be passed
1553% as arguments to the command \cs{cap}\marg{word}. \cs{cap} is a 1553% as arguments to the command \cs{cap}\marg{word}. \cs{cap} is a
1554% clever command, for it will give the definite article 1554% clever command, for it will give the definite article
@@ -1623,7 +1623,8 @@ consonants, though three of them are also used as vowels
1623% 1623%
1624% \section{\LaTeX\ Commands in Arabic environments} 1624% \section{\LaTeX\ Commands in Arabic environments}
1625% \label{sec:commands-in-arb} 1625% \label{sec:commands-in-arb}
1626% \paragraph{General principle} \LaTeX\ commands are accepted in 1626% \paragraph{General principle} \label{ref:cmd-inside-arabic}\LaTeX\
1627% commands are accepted in
1627% Arabic environments. The general principle which applies is that 1628% Arabic environments. The general principle which applies is that
1628% single-argument commands (\cs{command}\marg{arg}) such as 1629% single-argument commands (\cs{command}\marg{arg}) such as
1629% \cs{emph}\marg{text}, \cs{textbf}\marg{text} and the like, are 1630% \cs{emph}\marg{text}, \cs{textbf}\marg{text} and the like, are
@@ -1659,7 +1660,7 @@ al-muqAtilIna.}, wa-kAnat 'ummI min `u.zamA'i buyUti
1659% or in marginal notes. \package{arabluatex} provides a set of 1660% or in marginal notes. \package{arabluatex} provides a set of
1660% commands to handle such cases. 1661% commands to handle such cases.
1661% 1662%
1662% \DescribeMacro{LR} \cs{LR}\marg{arg} is designed to typeset its 1663% \DescribeMacro{\LR} \cs{LR}\marg{arg} is designed to typeset its
1663% argument from left to right. It may be used in an Arabic 1664% argument from left to right. It may be used in an Arabic
1664% environment, either \cs{arb}\marg{Arabic text} or \cs{begin}|{arab}| 1665% environment, either \cs{arb}\marg{Arabic text} or \cs{begin}|{arab}|
1665% \meta{Arabic text} \cs{end}|{arab}|, for short insertions of left to 1666% \meta{Arabic text} \cs{end}|{arab}|, for short insertions of left to
@@ -1667,7 +1668,7 @@ al-muqAtilIna.}, wa-kAnat 'ummI min `u.zamA'i buyUti
1667% rejected by \package{arabluatex}, such as commands the argument of 1668% rejected by \package{arabluatex}, such as commands the argument of
1668% which is expected to be a dimension or a unit of measurement. 1669% which is expected to be a dimension or a unit of measurement.
1669% 1670%
1670% \DescribeMacro{RL} \cs{RL}\marg{arg} does the same as 1671% \DescribeMacro{\RL} \cs{RL}\marg{arg} does the same as
1671% \cs{LR}\marg{arg}, but typesets its argument from left to right. Even 1672% \cs{LR}\marg{arg}, but typesets its argument from left to right. Even
1672% in an Arabic environment, this command may be useful. For example, to 1673% in an Arabic environment, this command may be useful. For example, to
1673% distinguish words with a different color, one may proceed like 1674% distinguish words with a different color, one may proceed like
@@ -1686,7 +1687,7 @@ wa-lA binA'a la-hum yu'amminu-hum mina 'l-^samsi.
1686%</example> 1687%</example>
1687% \fi 1688% \fi
1688% 1689%
1689% \DescribeMacro{LRfootnote} \DescribeMacro{RLfootnote} 1690% \DescribeMacro{\LRfootnote} \DescribeMacro{\RLfootnote}
1690% \cs{LRfootnote}\marg{text} and \cs{RLfootnote}\marg{text} typeset 1691% \cs{LRfootnote}\marg{text} and \cs{RLfootnote}\marg{text} typeset
1691% left-to-right and right-to-left footnotes respectively in Arabic 1692% left-to-right and right-to-left footnotes respectively in Arabic
1692% environments. Unlike \cs{footnote}\marg{text}, the arguments of both 1693% environments. Unlike \cs{footnote}\marg{text}, the arguments of both
@@ -1713,7 +1714,7 @@ the predicate\ldots} "ibnu \cap{`amriNU}}
1713% for this, but should it happen, it may be necessary to redefine in 1714% for this, but should it happen, it may be necessary to redefine in
1714% the preamble the \LaTeX\ macro \cs{thefootnote} like so:---\\ 1715% the preamble the \LaTeX\ macro \cs{thefootnote} like so:---\\
1715% \arabluaverb{\renewcommand*{\thefootnote}{\textsuperscript{\LR{\arabic{footnote}}}}} 1716% \arabluaverb{\renewcommand*{\thefootnote}{\textsuperscript{\LR{\arabic{footnote}}}}}
1716% \DescribeMacro{FixArbFtnmk} Another solution is to put in the 1717% \DescribeMacro{\FixArbFtnmk} Another solution is to put in the
1717% preamble, below the line that loads \package{arabluatex}, the 1718% preamble, below the line that loads \package{arabluatex}, the
1718% command \cs{FixArbFtnmk}. However, for more control over the layout 1719% command \cs{FixArbFtnmk}. However, for more control over the layout
1719% of footnotes marks, it is advisable to use the package 1720% of footnotes marks, it is advisable to use the package
@@ -1722,7 +1723,14 @@ the predicate\ldots} "ibnu \cap{`amriNU}}
1722% \package{KOMA-script} for details about the \cs{deffootnotemark} and 1723% \package{KOMA-script} for details about the \cs{deffootnotemark} and
1723% \cs{deffootnote} commands.} 1724% \cs{deffootnote} commands.}
1724% 1725%
1725% \DescribeMacro{setRL} \DescribeMacro{setLR} \cs{setRL} and 1726% \DescribeMacro{\LRmarginpar} The command \cs{LRmarginpar} does for
1727% marginal notes the same as \cs{LRfootnote} does for footnotes. Of
1728% course, it is supposed to be used in Arabic environments. Note that
1729% \cs{marginpar} also works in Arabic environments, but it acts as any
1730% other single-argument command inserted in Arabic environments. The
1731% general principle laid \vpageref{ref:cmd-inside-arabic} applies.
1732%
1733% \DescribeMacro{\setRL} \DescribeMacro{\setLR} \cs{setRL} and
1726% \cs{setLR} may be used to change the direction of paragraphs, either 1734% \cs{setLR} may be used to change the direction of paragraphs, either
1727% form left to right or from right to left. As an example, an 1735% form left to right or from right to left. As an example, an
1728% easy way to typeset a right-to-left sectional title follows:--- 1736% easy way to typeset a right-to-left sectional title follows:---
@@ -1900,20 +1908,49 @@ wa-ya.sIru ta.hta 'l-jildi
1900 {\NewDocumentCommand{\aemph}{m}{$\overline{\text{#1}}$}}} 1908 {\NewDocumentCommand{\aemph}{m}{$\overline{\text{#1}}$}}}
1901% \end{macrocode} 1909% \end{macrocode}
1902% \end{macro} 1910% \end{macro}
1911% \begin{macro}{\SetTranslitStyle} By default any transliterated
1912% Arabic text is printed in italics. This can be changed globally in
1913% the preamble or at any point of the document:
1903% \begin{macrocode} 1914% \begin{macrocode}
1904\def\al@trans@style{\itshape}% 1915\def\al@trans@style{\itshape}%
1905\NewDocumentCommand{\SetTranslitStyle}{m}{\def\al@trans@style{#1}} 1916\NewDocumentCommand{\SetTranslitStyle}{m}{\def\al@trans@style{#1}}
1917% \end{macrocode}
1918% \end{macro}
1919% \begin{macro}{\SetTranslitConvention}
1920% \cs{SetTranslitConvention}\marg{convention} may be used to change
1921% the convention, which is |dmg| by default:
1922% \begin{macrocode}
1906\def\al@trans@convention{dmg} 1923\def\al@trans@convention{dmg}
1907\NewDocumentCommand{\SetTranslitConvention}{m}{\def\al@trans@convention{#1}} 1924\NewDocumentCommand{\SetTranslitConvention}{m}{\def\al@trans@convention{#1}}
1925% \end{macrocode}
1926% \end{macro}
1927% \begin{macro}{\cap} Proper Arabic names or book titles should be
1928% passed to the command \cs{cap} so that they have their first letters
1929% uppercased. \cs{cap} is actually coded in Lua.
1930% \begin{macrocode}
1908\DeclareDocumentCommand{\cap}{m}% 1931\DeclareDocumentCommand{\cap}{m}%
1909 {\luadirect{tex.sprint(cap(\luastringN{#1}))}} 1932 {\luadirect{tex.sprint(cap(\luastringN{#1}))}}
1933% \end{macrocode}
1934% \end{macro}
1935% \begin{macro}{\txarb} \cs{txarb} sets the direction to right-to-left
1936% and selects the Arabic font. As it is supposed to be used
1937% internally by several Lua functions, this command is not
1938% documented, but available to the user should he wish to insert
1939% |utf8| Arabic text in his document.
1940% \begin{macro}{\txtrans} \cs{txtrans} is used internally by several
1941% Lua functions to insert transliterated Arabic text.
1942% \begin{macrocode}
1910\DeclareDocumentCommand{\txarb}{+m}{\bgroup\textdir 1943\DeclareDocumentCommand{\txarb}{+m}{\bgroup\textdir
1911 TRT\arabicfont#1\egroup} 1944 TRT\arabicfont#1\egroup}
1912\DeclareDocumentCommand{\txtrans}{+m}{\bgroup\textdir 1945\DeclareDocumentCommand{\txtrans}{+m}{\bgroup\textdir
1913 TLT\rmfamily#1\egroup} 1946 TLT\rmfamily#1\egroup}
1914% \end{macrocode} 1947% \end{macrocode}
1948% \end{macro}
1949% \end{macro}
1915% \begin{macro}{\arb} 1950% \begin{macro}{\arb}
1916% Here begins the description of \cs{arb} 1951% The \cs{arb} command detects which Arabic mode is to be used,
1952% either globally if no option is set, or locally, then passes its
1953% argument to the appropriate Lua function.
1917% \begin{macrocode} 1954% \begin{macrocode}
1918\DeclareDocumentCommand{\arb}{O{\al@mode} +m}% 1955\DeclareDocumentCommand{\arb}{O{\al@mode} +m}%
1919{\edef\@tempa{#1}% 1956{\edef\@tempa{#1}%
@@ -1938,7 +1975,8 @@ wa-ya.sIru ta.hta 'l-jildi
1938% \end{macrocode} 1975% \end{macrocode}
1939% \end{macro} 1976% \end{macro}
1940% \begin{environment}{arab} 1977% \begin{environment}{arab}
1941% Here comes the description of the environment |arab| 1978% The |arab| environment does for paragraphs the same as \cs{arb} does
1979% for short insertions of Arabic text.
1942% \begin{macrocode} 1980% \begin{macrocode}
1943\NewEnviron{arab}[1][\al@mode]% 1981\NewEnviron{arab}[1][\al@mode]%
1944{\par\edef\@tempa{#1}% 1982{\par\edef\@tempa{#1}%
@@ -1960,17 +1998,41 @@ wa-ya.sIru ta.hta 'l-jildi
1960 \else \fi\fi\fi\fi}[\par] 1998 \else \fi\fi\fi\fi}[\par]
1961% \end{macrocode} 1999% \end{macrocode}
1962% \end{environment} 2000% \end{environment}
2001% \begin{macro}{\LRmarginpar} \cs{LRmarginpar} is supposed to be
2002% inserted in an Arabic environment. It typsets his argument in a
2003% marginal note from left to right.
2004% \begin{macrocode}
2005\DeclareDocumentCommand{\LRmarginpar}{m}{\marginpar{\textdir TLT #1}}
2006% \end{macrocode}
2007% \end{macro}
2008% \begin{macro}{\LRfootnote} \cs{LRfootnote} and \cs{RLfootnote} are
2009% supposed to be used in Arabic environments for insertions of non
2010% Arabic text. \cs{LRfootnote} typesets its argument left-to-right\ldots
2011% \begin{macro}{\RLfootnote} while \cs{RLfootnote} typesets its
2012% argument left-to-right.
1963% \begin{macrocode} 2013% \begin{macrocode}
1964\DeclareDocumentCommand{\Marginpar}{m}{\marginpar{\textdir TLT #1}}
1965\DeclareDocumentCommand{\LRfootnote}{m}{\bgroup\pardir 2014\DeclareDocumentCommand{\LRfootnote}{m}{\bgroup\pardir
1966 TLT\LR{\footnote{#1}}\egroup} 2015 TLT\LR{\footnote{#1}}\egroup}
1967\DeclareDocumentCommand{\RLfootnote}{m}{\bgroup\pardir 2016\DeclareDocumentCommand{\RLfootnote}{m}{\bgroup\pardir
1968 TRT\LR{\footnote{#1}}\egroup} 2017 TRT\LR{\footnote{#1}}\egroup}
2018% \end{macrocode}
2019% \end{macro}
2020% \end{macro}
2021% \begin{macro}{\FixArbFtnmk} In the preamble, just below
2022% \cs{usepackage}|{arabluatex}|, \cs{FixArbFtnmk} may be of some
2023% help in case the footnote numbers at the bottom of the page are
2024% printed in the wrong direction. This quick fix uses and loads
2025% \package{scrextend} if it is not already loaded.
2026% \begin{macrocode}
1969\NewDocumentCommand{\FixArbFtnmk}{}{% 2027\NewDocumentCommand{\FixArbFtnmk}{}{%
1970 \@ifpackageloaded{scrextend}% 2028 \@ifpackageloaded{scrextend}%
1971 {\AtBeginDocument{\deffootnote{2em}{1.6em}{\LR{\thefootnotemark}.\enskip}}}% 2029 {\AtBeginDocument{\deffootnote{2em}{1.6em}{\LR{\thefootnotemark}.\enskip}}}%
1972 {\RequirePackage{scrextend} 2030 {\RequirePackage{scrextend}
1973 \AtBeginDocument{\deffootnote{2em}{1.6em}{\LR{\thefootnotemark}.\enskip}}}} 2031 \AtBeginDocument{\deffootnote{2em}{1.6em}{\LR{\thefootnotemark}.\enskip}}}}
2032% \end{macrocode}
2033% \end{macro}
2034% That is it. Say goodbye before leaving.
2035% \begin{macrocode}
1974\endinput 2036\endinput
1975% \end{macrocode} 2037% \end{macrocode}
1976% 2038%
diff --git a/arabluatex.ins b/arabluatex.ins
index 8e90665..614184f 100644
--- a/arabluatex.ins
+++ b/arabluatex.ins
@@ -17,6 +17,17 @@
17%% along with this program; if not, write to the Free Software 17%% along with this program; if not, write to the Free Software
18%% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18%% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19%% 19%%
20%% This release of 'arabluatex' consists of the following source files:
21%% - arabluatex.ins
22%% - arabluatex.dtx
23%% - arabluatex.lua
24%% - arabluatex_voc.lua
25%% - arabluatex_fullvoc.lua
26%% - arabluatex_novoc.lua
27%% - arabluatex_trans.lua
28%% - arabluatex.bib
29%%
30
20 31
21\input docstrip.tex 32\input docstrip.tex
22\keepsilent 33\keepsilent
@@ -47,6 +58,16 @@ along with this program; if not, write to the Free Software
47Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 58Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
48USA. 59USA.
49 60
61This release of 'arabluatex' consists of the following source files:
62- arabluatex.ins
63- arabluatex.dtx
64- arabluatex.lua
65- arabluatex_voc.lua
66- arabluatex_fullvoc.lua
67- arabluatex_novoc.lua
68- arabluatex_trans.lua
69- arabluatex.bib
70
50\endpreamble 71\endpreamble
51 72
52\generate{\file{arabluatex.sty}{\from{arabluatex.dtx}{package}}} 73\generate{\file{arabluatex.sty}{\from{arabluatex.dtx}{package}}}
@@ -59,6 +80,10 @@ USA.
59\Msg{*} 80\Msg{*}
60\Msg{* \space\space arabluatex.sty} 81\Msg{* \space\space arabluatex.sty}
61\Msg{* \space\space arabluatex.lua} 82\Msg{* \space\space arabluatex.lua}
83\Msg{* \space\space arabluatex_voc.lua}
84\Msg{* \space\space arabluatex_fullvoc.lua}
85\Msg{* \space\space arabluatex_novoc.lua}
86\Msg{* \space\space arabluatex_trans.lua}
62\Msg{*} 87\Msg{*}
63\Msg{* To produce the documentation run the files ending with} 88\Msg{* To produce the documentation run the files ending with}
64\Msg{* `.dtx' through LuaLaTeX.} 89\Msg{* `.dtx' through LuaLaTeX.}
diff --git a/arabluatex.lua b/arabluatex.lua
index c14e396..15ddeef 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -66,7 +66,7 @@ local function breakcmd(str)
66 body = string.sub(body, 2, -2) 66 body = string.sub(body, 2, -2)
67 return string.format("}\\%s{%s}\\arb{", tag, body) 67 return string.format("}\\%s{%s}\\arb{", tag, body)
68 end) 68 end)
69 -- Marginpar 69 -- Marginpar
70 str = string.gsub(str, "\\(Marginpar.-)(%b{})", 70 str = string.gsub(str, "\\(Marginpar.-)(%b{})",
71 function(tag, body) 71 function(tag, body)
72 body = string.sub(body, 2, -2) 72 body = string.sub(body, 2, -2)