%% %% This is file `bidipoem.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% bidi.dtx (with options: `bidipoem.sty') %% %% ______________________________________ %% Copyright © 2009–2010 Vafa Khalighi %% %% License information appended. %% %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{bidipoem}% [2010/07/25 Environments for typesetting Persian traditional and modern poems] \def\poemcolsepskip{.1\versewidth plus .1\versewidth minus .05\versewidth} \def\poemmarginskip{1em plus 1fil minus 1em} \def\poemextrabaselineskip{0\baselineskip} \def\poemskip{\medskip} \def\poemblocksep{\quad$\Box$} \newdimen\versewidth \newtoks\bidipoem@p@ftn \def\poem@verse#1{% \ifdim\wd#1>\new@poem@width \xdef\new@poem@width{\the\wd#1}% \ifdim\new@poem@width>\poem@width \xdef\poem@width{\new@poem@width}% \global\let\poem@needrun\relax \fi \fi \hbox to\poem@width{\unhbox#1}% } \def\poem@linebegin{\vadjust{}\hskip\@flushglue\hskip\poemmarginskip\relax} \def\poem@lineend{\nobreak\hskip\poemmarginskip\hskip\@flushglue\vadjust{}} \def\poem@lineversesep{% \nobreak \hskip\z@ plus 1filll% \penalty600% \hskip\poemcolsepskip \hskip\z@ plus -2filll% \vadjust{}% \nobreak \hskip\z@ plus 1filll% } \def\poem@lineparsebegin{% \halign\bgroup \global\setbox\verse@i=\hbox{\ignorespaces##\unskip}&& \global\setbox\verse@ii=\hbox{\ignorespaces##\unskip} \cr } \def\poem@lineparseend{% \crcr\egroup \vskip-\baselineskip } \def\oldpoem@cr{% \cr\poem@line } \newbox\verse@i \newbox\verse@ii \newif\ifpoem@started \def\poem@line{% \poem@lineparseend \ifdim\wd\verse@i>\z@\global\poem@startedtrue\fi \ifdim\wd\verse@ii>\z@\global\poem@startedtrue\fi \ifpoem@started \ifdim\wd\verse@ii>\z@\else \nopagebreak[3] \fi \leavevmode \poem@linebegin \poem@verse\verse@i \ifdim\wd\verse@ii>\z@ \poem@lineversesep \poem@verse\verse@ii \fi \poem@lineend \nopagebreak \endgraf \vskip\poemextrabaselineskip \fi \poem@lineparsebegin } \def\@traditionalpoem{% \stepcounter{poem@no} \ifnum\max@poem@no<\number\c@poem@no% \xdef\poem@width{\z@}% \else \xdef\poem@width{\poem@prop{poem@width}}% \fi \xdef\new@poem@width{\z@}% \global\versewidth=\poem@width \poemskip\leavevmode\par \begingroup \let\@footnotetext\bidipoem@p@ftntext \let\@LTRfootnotetext\bidipoem@p@LTRftntext \let\@RTLfootnotetext\bidipoem@p@RTLftntext \tabskip=\z@ \parskip=\z@ \parindent=\z@ \parfillskip=\z@ \rightskip=\z@ \leftskip=\z@ \widowpenalty=10000% No break between verses of the same line. \clubpenalty=10000% Same as above. Not really needed. \def\newblock{\hfil\poemblocksep\hfil\null}% \def\par{\oldpoem@cr}% Redefine \par for possible \obeylines \def\\{\global\poem@startedtrue\oldpoem@cr}% \global\poem@startedfalse \csname poem@obeylines\endcsname \let\poem@obeylines\relax \poem@lineparsebegin } \def\@endtraditionalpoem{% \cr \ifdim\wd\verse@i>\z@\poem@line\else\ifdim\wd\verse@ii>\z@\poem@line\else \noalign{% \skip0=\poemextrabaselineskip \vskip-\skip0 \vskip-\baselineskip }% \fi\fi \poem@lineparseend \endgroup \the\bidipoem@p@ftn \global\bidipoem@p@ftn{}% \par \vskip\baselineskip \poemskip \ifdim\new@poem@width<\poem@width \global\let\poem@needrun\relax \fi \poem@write@aux{poem@width@\romannumeral\c@poem@no}{\new@poem@width}% \ifx\AtEndDocument\undefined\poem@finish\fi } \long\def\bidipoem@p@ftntext#1{% \edef\@tempx{\the\bidipoem@p@ftn\noexpand\footnotetext[\the\c@footnote]}% \global\bidipoem@p@ftn\expandafter{\@tempx{#1}}}% \long\def\bidipoem@p@LTRftntext#1{% \edef\@tempxi{\the\bidipoem@p@ftn\noexpand\LTRfootnotetext[\the\c@footnote]}% \global\bidipoem@p@ftn\expandafter{\@tempxi{#1}}}% \long\def\bidipoem@p@RTLftntext#1{% \edef\@tempxii{\the\bidipoem@p@ftn\noexpand\RTLfootnotetext[\the\c@footnote]}% \global\bidipoem@p@ftn\expandafter{\@tempxii{#1}}}% \newenvironment{traditionalpoem}{\@traditionalpoem}{\@endtraditionalpoem} \expandafter\def\csname traditionalpoem*\endcsname{\let\poem@obeylines=\obeylines\traditionalpoem} \expandafter\def\csname endtraditionalpoem*\endcsname{\endtraditionalpoem} \def\poem@finish{% \poem@write@aux{max@poem@no}{\number\c@poem@no}% \ifx\poem@needrun\relax \PackageWarning{bidipoem}{Unjustified poem. Rerun XeLaTeX to get poem right}% \global\let\poem@needrun\undefined \fi } \ifx\AtEndDocument\undefined\else\AtEndDocument\poem@finish\fi \newcounter{poem@no}\setcounter{poem@no}{\z@} \ifx\max@poem@no\undefined \def\max@poem@no{0}% \fi \newcommand{\poem@prop}[1]{\@nameuse{#1@\romannumeral\c@poem@no}} \newcommand{\poem@write@aux}[2]{% \def\@x{\immediate\write\@auxout{\global\noexpand\@namedef{#1}{#2}}}% \@x } \def\@modernpoem{% \par \begingroup \let\@footnotetext\bidipoem@p@ftntext \let\@LTRfootnotetext\bidipoem@p@LTRftntext \let\@RTLfootnotetext\bidipoem@p@RTLftntext \parskip=\z@ \parindent=\z@ \def\[{\@settab\@tabplus\ignorespaces}% \def\]{\@tabminus\ignorespaces}% \def\newblock{\poemblocksep}% \let\newpoem@tabcr\@tabcr \def\par{% Redefine \par for possible \obeylines \ifpoem@started\else \ifdim\wd\@curline>\z@\global\poem@startedtrue\else \@stopfield \ifdim\wd\@curfield>\z@\global\poem@startedtrue\fi \@contfield \fi \fi \ifpoem@started\newpoem@tabcr\fi}% \def\@tabcr{\global\poem@startedtrue\newpoem@tabcr}% \global\poem@startedfalse \csname poem@obeylines\endcsname \let\poem@obeylines\relax \begin{tabbing}% } \def\@endmodernpoem{% \global\poem@startedfalse \ifdim\wd\@curline>\z@\global\poem@startedtrue\else \@stopfield \ifdim\wd\@curfield>\z@\global\poem@startedtrue\fi \@contfield \fi \ifpoem@started\else\let\@stopline\@stopfield\fi \end{tabbing}% \endgroup \the\bidipoem@p@ftn \global\bidipoem@p@ftn{}% \par } \newenvironment{modernpoem}{\@modernpoem}{\@endmodernpoem} \expandafter\def\csname modernpoem*\endcsname{\let\poem@obeylines=\obeylines\modernpoem} \expandafter\def\csname endmodernpoem*\endcsname{\endmodernpoem} %% %% Copyright © 2009–2010 Vafa Khalighi %% %% It may be distributed and/or modified under the LaTeX Project Public License, %% version 1.3c or higher (your choice). The latest version of %% this license is at: http://www.latex-project.org/lppl.txt %% %% This work is “author-maintained” (as per LPPL maintenance status) %% by Vafa Khalighi. %% %% In addition to the terms of LPPL any distributed version %% (unchanged or modified) of bidi has to keep the statement %% about the moral obligation for using bidi. In case of major %% changes where this would not be appropriate the author of the %% changed version should contact the copyright holder. %% %% %% %% Moral obligation for using bidi: %% ____________________________________ %% %% Users of bidi who wish to include or use bidi or a modified %% version in a proprietary and commercially market product are asked %% under certain conditions (see below) for the payment of a license %% fee. The size of this fee is to be determined, in each instance, %% by the commercial user, depending on his/her judgment of the value of %% bidi for his/her product. %% %% %% The conditions for this are as follows: %% %% The producer of a proprietary and commercially market product %% that involves typesetting using bidi is asked to determine %% the value of a license fee for using bidi if %% %% - the product is a document and the producer has decided to %% include bidi to typeset (parts of) the document or has %% directed the author of the document to include bidi (for %% example, by providing a class file to be used by the author) %% %% - the product is a LaTeX class or package that includes bidi %% %% %% There is no moral obligation in case %% %% - the product is a document but producer has not directed %% the author to include bidi (in that case the moral obligation %% lies with the author of the document) %% %% - the product does not involve typesetting, e.g., consists, for %% example, of distributing bidi and its documentation. %% %% - the product is not proprietary, i.e., is made available as free %% software itself (which doesn't prohibit its commercial marketing) %% %% - bidi is used for non-commercial purposes %% %% %% Determinating a license fee might result in a license fee of zero %% (i.e., no payment) in case a producer has determined that the use %% of bidi has no enhancing effect on the product. This is a %% plausible scenario, i.e., in the above two cases the producer is %% only asked to evaluate the value of bidi for the product %% not for the payment of a license fee per se (which might or might %% not follow from this evaluation). %% %% The license fee, if any, can be payed to the author of %% the program who can be contacted at %% %% vafakhlgh@gmail.com %% %% %% %% %% End of file `bidipoem.sty'.