Ice Bear SoftTypesetting a bilingual poetry book

This page describes the method of typesetting a book of poetry in Hindi and Czech using XeLaTeX. The macros were developed for typesetting the book entitled Path to Red Sky (Aruna Rai and Zdeněk Wagner).

1. zwpoetry.sty
  1.1. Explanation of the line breaking algorithm
  1.2. Explanation of the page breaking algorithm
2. Packages for bilingual typesetting
  2.1. common.sty
  2.2. zwsizes.sty
  2.3. arunakash.sty
  2.4. Example
3. Download

1. zwpoetry.sty

This package came to life after copying macros from book to book. For this reason usage suggestions are shown between \iffalse and \fi but either without any explanation or with comments in Czech. The license is LPPL and the package will probably be published in the CTAN in the future.

The package is suitable both for typesetting pure poetry and prose containing poems. The source texts are supplied in many forms but very rarely in TeX. The macros were therefore prepared to make typesetting easy. Hardly anybody would like to append \\ to the end of each verse in a book with 100+ pages of poetry. Thus a configurable package was developed as time passed.

\VerseLeftIndent, \VerseRightIndent: If poems are inserted into a middle of a prose, they have usually a different indent on the left and right side. They are set by these dimensions the defaulkt values of which are zero.

\ExtraIndent: It is required that in some poems selected stanzas have larger left indentation. Its value is set in the dimension the default value of which is 5 mm.

\AboveVerse\Skip, \BelowVerseSkip: These length registers are used if the poems are inserted into a prose. They define a flexible vertical space above and below a poem. Their default values are zero.

\VerseFont defines a font for poetry especially if it difers from a forn for a prose. The default definition is empty.

\slokafil is an expandable part of the space between stanzas. Its meaning will be explained later. You will certainly have to change its value as shown in section arunakash.sty.

Verse is the main environment where each line is a verse and empty lines separate stanzas. If a verse is wider that the text width, the second part of the verse must be right aligned. It is done automatically in this environment but it does not find always the best place for the line break. The \\ macro is define in such a way to enable manual setting of the line break.

posun (meaning shift) is an enviroment where the left indent is advanced by \ExtraIndent.

escape is used to escape from a poem to a prose. It is useful for scenic notes in a theatre play written as a poem. It can contain several paragraphs

\Esc has the very same purpose as the escape enviroment but is intended for insertion of a short text.

\Page: It is necessary to enforce a page break in some situation. It is necessary to use this macro inside the Verse environment.

\bv, \ev, \cbv are useful abbreviations with the following definitions

\def\bv{\begin{Verse}}
\def\ev{\end{Verse}}
\def\cbv{\clearpage\bv}

1.1. Explanation of the line breaking algorithm

Line breaking is implemented by two mechanisms, namely the \ObeyEndlines macro and by definition of a paragraph shape. The \ObeyEndlines macro ensures that each verse is typeset as a one-line paragraph and the end of the verse is entered in the source file as an end of line. Its definition is inspired by the \obeylines macro, see Donald E. Knuth: The TeXbook.

The paragraph shape is defined inside the Verse environment. The \VerseLeftIndent and \VerseRightIndent have fixed lengths therefore we can treat them as zero while exmining the effect of individual parameters. Each line has a space of length \leftskip on the left side and \rightskip on the right side. Additionally, the paragraph contains \parindent on the left side of the first line and \parfillskip on the right side of the last line. Both of them are set to zero. Upon entering the horizontal mode, i.e. at the beginning of the paragraph, the contents of the \everypar register is inserted. It contains a space of the same type of expansibility as \leftskip but with an opposite sign. The expansibilities will thus vanish and the line will be left aligned due to infinite expansibility of \rightskip on the right side. If the verse is wider than the text width, it will be broken. The situation on the first line is the same but the second line will not contain the space from the \everypar register. The \leftskip contains infinite expansibility of higher order than \rightskip, therefore the line will be right aligned.

 Top of the page 

1.2. Explanation of the page breaking algorithm

When typesetting poetry, the page break should preferably occur between stanzas, inside a stanza only in case when stanzas are long and too much empty space would remain at the bottom of a page. If just a poetry is being typeset, \raggedbottom can be used and page breaking solved by suitable penalization. However, if we typeset a combination of a poetry and a prose, \flushbottom should be used and page breaking controlled by a different method. Remember that each verse is a paragraph, thus \clubpenalty and \widowpenalty make no sense here. On the contrary, the infinite value of \interlinepenalty prevents a page break between lines of a long, broken verse.

The page break is implemented in the \auto@par macro which contains two conditional statements. The \ifhmode condition tests in which mode the macro is invoked. In horizontal mode, i.e. at the end of a verse, a paragraph is terminated and a penalty of value \slokapenalty is inserted. It penalizes a page break inside a stanza. A material allowing a page break between stanzas is inserted when invoked in the vertical mode. The space should have a height of a single line. If the source file contained several consecutive empty lines, we would get the same number of vertical spaces on the typeset output which is undesirable, therefore the \ifDoSkip@ condition ensures that the vertical material is inserted only once. A stanza ends always with \slokapenalty which must be positive, otherwise it would make no sense. If two penalties meet, the one with the lower value wins. We will thus have the following elements between stanzas:

  1. \penalty\z@
  2. \vskip\the\baselineskip plus \slokafil
  3. \penalty\z@
  4. \vskip\z@ plus -\slokafil

Expansibilities in glues 2 and 4 have opposite signs. If a page is not broken here and a next stanza appears on the same page, they vanish and the vertical space will have a height of a single line. The page break is possible in penalties 1 and 3 only. The first case applies if a stanza ends at the bottom of a page. The latter applies if there is a space for at least one line but the next stanza cannot be started here. In both cases the following elements will be discarded and the following page will start with the first line of the next stanza. The default setting of \slokafil prevents a page break inside a stanza unless the stanza is longer than the page height. A more suitable setting will be shown in the description of the arunakash.stypackage.

 Top of the page 

2. Packages for bilingual typesetting

The license of these files is Public Domain which means that you can do with them whatever you want. Almost certainly you will have to modify them for use in your project.

2.1. common.sty

The macros for the book cover are usually different, at least the dimensions differ. There is, however, a common part, especially the scripts. Notice that we use a commercial font for the Latin alphabet and for Hindi we take advantage of mapping the Arabic numerals to the Devanāgarī digits.

 Top of the page 

2.2. zwsizes.sty

Page dimensions and the layout will be defined by the zwpagelayout package which must know the font sizes in advance. They are therefore defined in a separate file.

 Top of the page 

2.3. arunakash.sty

Macros in this package do not serve for critical editions. Their only purpose is support of typesetting where the left page contains one language variant while the other language variant appears on the right page. In theory, number of pages of some parts can differ in exceptional cases. The following text will explain the main macros.

\ZWnormalsize defines the baselineskip. The value is needed on several places and was changed several times during the book design.

Most poems fit to one page, exceptionally a small part remains to the next page. The design therefore requires the first verse at the same vertical position on the page, the title is positioned higher. It is achieved by a suitable setting of \splittopskip.

The author's name will be printed in the Latin script in the Czech version and in Devanāgarī in the Hindi version. Internal macro \zw@aut stores both variants in the \Author and \Rachnakar macros (rachnakar is a Hindi translation of author). The package defines easy-to-use shortcuts \aruna, \zw.

\pagestyle{kitab} is interesting just by the fact that pagination on the even (Hindi) pages is placed inside the \texthindi macro. As mentioned in section common.sty, the digits will thus be converted to Devanāgarī.

\firstlang, \secondlang, \endlangs serve as language separators. The author name is correspondingly assigned to the \zw@autname macro in each version. The text is stored in a box and \zw@tn defines which table of contents will be used. Hindi is activated on the even pages.

\zw@testlang checks the current state and executes the output procedure. As already mentioned, the macros are not intended for a critical edition thus in case of prose one language version can be one page shorter than the other. First we verify which variant still contains a text. The \ifvoid condition is true if the box is empty (void). A zero is first assigned to an auxiliary counter ad is incremented by one if the Hindi box is nonempty, and by two if the Czech box is nonempty. If the value of the counter is positive, we proceed to the next step, otherwise we are finished.

\zw@dolang forces a new page. If the value of the auxiliary counter is odd, we print the Hindi page, otherwise we emit an empty page. If the value of the counter is greater than 1, the Czech page is printed, otherwise the page is left empty. Afterwards we use again \zw@testlang.

\zw@split processes the box. If it is higher than the page, a corresponding part is split and the rest is kept in the box, otherwise we output the whole box. The discardable elements were removed during splitting therefore the result is almost always lower that the page. We thus have to fill it with \vfill.

\slokafil specifies the minimum size of an incomplete stanza. Why 60pt? Because it is a bug. Originally the baselineskip was 15pt and the minimum size was set to four lines. After changing the baselineskip I forgot to change this value accordingly. The result looked fine therefore I did not notice. The value cannot be defined as 4\ZWnormalsize pt. It would expand to 418pt which is not what we want LaTeX offers auxiliary counter \@tempdima thus the following code can be used:

\@tempcnta=\ZWnormalsize
\multiply\@tempcnta by 4
\edef\slokafil{\the\@tempcnta pt}
      

\bv is a redefined shortcut allowing insertion of a title and writing to the table of contents.

\shirshak is used to typeset the title of the preface and the name of its author.

\tableofcontents typesets both language variants of the table of contents using the algrithm explained above. The \@dottedtocline switches to \normalfont when outputting the page number which we do not want in the Hindi variant. Using the \ifdvng we set it to \relax.

 Top of the page 

2.4. Example

This example shows how the first and last poem and the table of contents were entered. The source code for the opening pages, preface and colophon is not given.

\zw
\firstlang
\bv{ताजमहल}

हे ताजमहल!
तुम्हारे रत्नों में
क्या मोहक फ़साना
छिपा हुआ है?

बिना कुछ कहे
अकेले खड़े हो तुम
यमुना के किनारे पर।
तुम्हारी दीवारों में
शांति से सो रहा है
किसी का अमर प्यार।

दिलों में मुमताज और शाहजहाँ को लेकर
लोग यहाँ रोज़ आया करते हैं।
दिलों में मोहब्बत महसूस करके
लोग प्यार का स्मारक देखते हैं 

हे ताजमहल!
जो इश्क़ की यादें
तुम्हारे अंदर ढूँढ रहे हैं
वे प्यार से मिलेंगे
ख़ूबसूरत मक़बरे में।

हे ताजमहल!
मेरा भी सवाल है।
आज मेरी मुमताज़
कहाँ खो गई है?
शायद चली गई है वह
अरुणाकाश में।
\ev
\secondlang
\bv{Tádžmahal}

Ach, Tádžmahal!
V tvých zdobných skvostech
jaký se skrývá
půvabný příběh?

Zamlkle stojíš,
samotný
na břehu řeky Jamuny.
A ve tvých zdech
v poklidu spí
nesmrtné čísi lásky dech.

S Mumtáz a Šáhdžahánem v srdcích
lidé sem denně vcházejí.
Se srdcem milostně planoucím
památník lásky vídají.

Ach, Tádžmahal!
Kdo lásek památku
vyhledá v tobě,
ten s láskou setká se
v nádherném hrobě.

Ach, Tádžmahal!
Mám taky otázku.
Kde moje Mumtáz
dneska se ztratila?
Snad včera odešla
do červánků.
\ev
\endlangs

\aruna
\firstlang
\bv{मेरी रोशनी}

कुछ प्रकाशवर्षों तक
पहुँचती रहेगी
मेरी रोशनी
तुम तक
तब भी
जब
नहीं रहेगा मेरा अस्तित्व

उस रोशनी को ढूँढते
जब
पहुँचोगे मंजिल तक
मैं बदल चुकी होऊँगी
एक ब्लैकहोल में

फिर
तुम
ना पहुँच सकोगे मुझ तक
न
वापिस जा सकोगे
कहीं भी
इस असीम ब्रह्मांड में…
\ev
\secondlang
\bv{Mé světlo}
Za několik světelných let
dotkne se
mé světlo
tebe,
až tehdy,
kdy
existovat nebudu.

Když budeš hledat to světlo,
až
svého cíle dojdeš,
již proměněna budu
v černou díru.

Pak
ty
nebudeš se moci mě dotknout
ani
zpět jít moci nebudeš,
nikam,
v tomto neomezeném vesmíru…
\ev
\endlangs

\clearpage
\tableofcontents
      

Set the viewing mode to facing pages, center first when viewing the sample in PDF.

 Top of the page 

3. Download

bilinpoe.zip, 8 KiB.

 Top of the page