[XeTeX] [OT, xelatex] Persian text
Zdenek Wagner
zdenek.wagner at gmail.com
Mon Jan 14 11:22:20 CET 2013
2013/1/14 Theodore M Rolle, Jr. <stercor at gmail.com>:
> Thanks so much!
> This should:
> a. get me off and running, and
> b. teach me something. :-)
>
I use another way, I do it in LaTeX but using plain TeX tools. The
format is set by \leftskip, \rightskip and \parfillskip. I do not like
to put any macros to the lines, therefore I took macro \obeylines and
slightly modified it. ^^M is defined in such a way that in horizontal
mode (at the end of the line) it expands to \par \penalty XXXX (where
XXXX is large number, usually 9999) and in vertical mode it expands to
\penalty 0 \vskip \the\baselineskip plus 1fil \penalty 0 \vskip 0pt
plus -1fil
This setting preferse page break between stanzas without reporting
underful vbox even if \flushbottom is used but will break in the
middle of a stanza if it is long. However, this setting may leave a
lot of empty space. In order to prevent it, it might be better to
reduce the XXXX penalty and change the skips to \vskip 12pt plus 48pt
and \vskip 0pt plus -48pt.
Of course, two empty lines will generate two vertical skips. Thus the
definition is:
{\catcode`\^^M\active % the following lines MUST end with a percent
sign, see \obeylines
\gdef\ObeyEndlines{\catcode`\^^M\active \let^^M\auto at par}%
\global\let^^M=\par}% for ^^M in \write
\let\autopar\par % to have an initial definition
\newif\ifDoSkip
\newdimen\VerseLeftIndent \VerseLeftIndent\z@
\newdimen\VerseRightIndent \VerseRightIndent\z@
\let\VerseFont\relax
\newcount\stanzapenalty \stanzapenalty 9999
\def\stanzafil{1fil}
\def\Verse{\begingroup
\everypar{\hskip 0mm plus -1fill\relax}%
\leftskip 0mm plus 1fill
\rightskip 0mm plus 1fil
\parfillskip \z@
\parindent\z@
\advance\leftskip\VerseLeftIndent
\advance\rightskip\VerseRightIndent
\hyphenpenalty\@M
\interlinepenalty\@M
\def\autopar{\ifhmode \par \penalty\stanzapenalty\DoSkiptrue
\else
\ifDoSkip
\penalty\z@
\vskip\the\baselineskip plus \stanzafil
\penalty\z@
\vskip\z@ plus -\stanzafil
\DoSkip at false
\fi
\fi}%
\VerseFont
\def\\{\break}%
\ObeyEndlines}
\def\endVerse {\ifhmode \par \fi \DoSkipfalse \endgroup}
\def\Page{\ifhmode \par \fi \vfill \penalty-\@M \DoSkipfalse}
In LaTeX, \@M means 10000, \z@ means both 0 as a number and 0pt as a
dimension. These macros were prepared for typesetting poetry in
european languages, \leftskip, \rightskip, \parindent and \everypar
are set so that the lines are left aligned and if the line is longer
that the page width, it is broken and the continuation is right
aligned. If your lines are shorter than the page width and should be
centered, do not set \everypar and just use \centering.
> Ted
>
> On 01/14/2013 03:56 AM, John Was wrote:
>> Hello
>>
>> If you are using plain XeTeX, a simple example using \halign (the table
>> function) to centre the poems visually would be:
>>
>> \TeXXeTstate=1 % this turns bidirectional functionality on
>>
>> \font\arabic = "Scheherazade:script=arab" at 13pt
>>
>> \def\intextarab#1{{\arabic {\beginR #1\endR}}}
>> \halign to \hsize{%
>> \hfil #l\cr
>>
>> \intextarab{الله أكبر}\cr
>>
>> \noalign{\nobreak}
>>
>> \intextarab{أشهد أن لا اله إلا الله}\cr
>>
>> \intextarab{أشهد أن محمدا رسول الله}\cr
>>
>> \intextarab{حي على الصلاة}\cr
>>
>> \intextarab{حي على الفلاح}\cr
>>
>> \intextarab{الله أكبر}\cr
>>
>> \noalign{\nobreak}
>>
>> \intextarab{لا إله إلا الله}\cr
>>
>> }\vskip 12pt
>>
>> \halign to \hsize{%
>>
>> #\hfil\cr
>>
>> Translation line\cr
>>
>> \noalign{\nobreak}
>>
>> Translation line\cr
>>
>> Translation line\cr
>>
>> Translation line\cr
>>
>> Translation line\cr
>>
>> Translation line\cr
>>
>> \noalign{\nobreak}
>>
>> Translation line\cr
>>
>> }
>>
>>
>>
>> (That's Arabic rather than Persian, of course.)
>>
>>
>>
>> The \noalign{\nobreak} lines are to glue adjacent lines at the start and
>> end (and of course you may want to insert these at other points too).
>> If you want space between stanzas, then it's e.g. \noalign{\vskip 6pt}
>> or whatever.
>>
>>
>>
>> Hope this helps (I'm neither an Arabist nor acquainted with Persian, but
>> I've occasionally had to do this kind of thing on the hoof).
>>
>>
>>
>>
>>
>> John
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> ----- Original Message ----- From: "Theodore M Rolle, Jr."
>> <stercor at gmail.com>
>> To: "XeTeX Mailing list" <xetex at tug.org>
>> Sent: 14 January 2013 03:34
>> Subject: [XeTeX] [OT, xelatex] Persian text
>>
>>
>>> I wish to typeset Persian text, no math, consisting of poems in Persian
>>> with English translations following.
>>>
>>> I've tried an embarrassing number of "solutions," non of which worked.
>>> Can someone provide me with a minimum working example of how to do this?
>>> I'd like to use Linux Biolinum O text for the English translation.
>>>
>>> Ted
>>>
>>>
>>> --------------------------------------------------
>>> Subscriptions, Archive, and List information, etc.:
>>> http://tug.org/mailman/listinfo/xetex
>>
>>
>>
>> --------------------------------------------------
>> Subscriptions, Archive, and List information, etc.:
>> http://tug.org/mailman/listinfo/xetex
>
>
> --------------------------------------------------
> Subscriptions, Archive, and List information, etc.:
> http://tug.org/mailman/listinfo/xetex
--
Zdeněk Wagner
http://hroch486.icpf.cas.cz/wagner/
http://icebearsoft.euweb.cz
More information about the XeTeX
mailing list