From 5cb80b16444930b670871aeefe21749c26b4162d Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sun, 11 Dec 2016 19:44:32 +0100 Subject: new environment arabverse and new command \bayt. both still need work --- arabluatex.dtx | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 10 deletions(-) diff --git a/arabluatex.dtx b/arabluatex.dtx index c1633da..cc4aa16 100644 --- a/arabluatex.dtx +++ b/arabluatex.dtx @@ -2965,10 +2965,11 @@ wa-ya.sIru ta.hta 'l-jild-i \else \fi\fi\fi\fi}[\par] % \end{macrocode} % \end{environment} -% \begin{environment}{arbverse} -% \changes{v1.6}{2016/11/30}{New environment \texttt{arbverse} for -% typesetting Arabic poetry} The environment |arbverse| shall -% receive different options. Let us define them first. +% \begin{environment}{arabverse} +% \changes{v1.6}{2016/11/30}{New environment \texttt{arabverse} for +% typesetting Arabic poetry} The environment |arabverse| may receive +% different options: |width|, |metre|, |utf| and |mode|; all of them +% are defined here just before the environment |arabverse|: % \begin{macrocode} \newlength{\al@bayt@width} \setlength{\al@bayt@width}{.3\textwidth} @@ -2978,16 +2979,71 @@ wa-ya.sIru ta.hta 'l-jild-i \define@choicekey[al]{verse}{mode}{fullvoc, voc, novoc, trans}{\def\al@mode{#1}} \presetkeys[al]{verse}{utf=false}{} -\NewDocumentEnvironment{arbverse}{O{} O{}}% -{\bgroup\setkeys[al]{verse}[metre]{#1}% +% \end{macrocode} +% Then follows the environment itself: +% \begin{macrocode} +\NewDocumentEnvironment{arabverse}{O{}}% +{\noindent\bgroup\setkeys[al]{verse}[metre]{#1}% \ifx\al@mode\al@mode@trans% \ifal@verse@utf\setRL\else\setLR\fi% \else\setRL\fi% - \begin{center} -}% -{\end{center}% -\hfill\setkeys[al]{verse}[width,utf,mode]{#1}\egroup\par} + \ifx\al@mode\al@mode@trans\else% + \begin{center}\fi}% +{\ifx\al@mode\al@mode@trans\else\end{center}\fi% +\hfill\setkeys[al]{verse}[width,utf,mode]{#1}\egroup} +% \end{macrocode} +% \begin{macro}{\bayt} +% \changes{v1.6}{2016/11/30}{New macro \cs{bayt} for typesetting +% each verse inside the \texttt{arabverse} environment} Each verse +% consists of two hemistichs; therefore the command \cs{bayt} takes +% two arguments, the first receives the \arb[trans]{.sadr} and the +% second the \arb[trans]{`ajuz}. That two subsequent hemistishs +% should be connected with one another is technically named +% \arb[trans]{tadwIr}. In some of these cases, the hemistishs may be +% connected by a prominent horizontal flexible stroke which is drawn +% by the command \cs{al@verse@stroke}. +% \begin{macro}{\SetHemistichDelim} +% \changes{v1.6}{2016/11/30}{New command \cs{SetHemistichDelim} for +% changing the default delimiter between hemistichs} A hemistich +% delimiter also must be defined for there is no gutter between +% hemistichs in |trans| mode. By default, it is set to the +% \enquote*{star} character: |*|. The command +% \cs{SetHemistichDelim}\marg{delimiter} may be used at any point of +% the document to change this default setting. +% \end{macro} +% \begin{macrocode} +\def\al@hemistich@delim{*} +\NewDocumentCommand{\SetHemistichDelim}{m}{\def\al@hemistich@delim{#1}} +\def\al@verse@stroke{\leavevmode\xleaders\hbox{\arb{--}}\hfill\kern0pt} +\NewDocumentCommand{\bayt}{m o m}{% + \edef\al@tatweel{--}% + \ifx\al@mode\al@mode@trans\arb{#1}\else% + \makebox[\al@bayt@width][s]{\arb{#1}}\fi% + \IfNoValueTF{#2}{% + \ifx\al@mode\al@mode@trans\hskip .5em + \al@hemistich@delim\hskip .5em% + \else + \hspace{.25\al@bayt@width}% + \fi}{% + \edef\@tempa{#2}% + \ifx\@tempa\al@tatweel% + \ifx\al@mode\al@mode@trans\hskip .5em + \al@hemistich@delim\hskip .5em% + \else + \makebox[.25\al@bayt@width][s]{\al@verse@stroke}% + \fi% + \else% + \ifx\al@mode\al@mode@trans% + \hskip 1em\arb{#2}\hskip 1em% + \else% + \makebox[.25\al@bayt@width][c]{\arb{#2}}% + \fi\fi}% + \ifx\al@mode\al@mode@trans\arb{#3}\else% + \makebox[\al@bayt@width][s]{\arb{#3}}% + \fi} % \end{macrocode} +% +% \end{macro} % \end{environment} % \begin{macro}{\abjad} \cs{abjad}\marg{number} expresses its argument % in Arabic letters in accordance with the \arb[trans]{'abjad} -- cgit v1.2.3