6

First of all, I am quite new to TeX - so practically a newbie. I am trying to typeset Devanagari books in the traditional "Pothi" format, which looks pretty much like the manuscript illustrated below. N.B.

Here is a sample of a Devanagari manuscript (sourced from wikipedia)

Classical Rigveda Manuscript

and here's the general structure of these types of books

General structure of Pothi class of books

For starters, there are no headers and footers (so to speak). Instead the information contained therein (page numbers etc.) are placed in the extreme right and left corners of the page - separated to the main content by two parallel vertical-"stripes".

As for Devanagari numbering, I found a "velthuis" package which is capable of devanagari page numbering apart from chapter numbering etc.

I was curious to know if such a "non-standard" page layout is possible in the first place. If so how, or material (preferably on the web), that describes the process of creating/defining custom page layouts would greatly help.

Thank you.

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
  • 1
    Welcome to TeX.SE! Maybe the answers to this question are a starting point? http://tex.stackexchange.com/q/183996 – Christian Clason Oct 14 '14 at 07:50
  • Thank you. I did browse that post and the docuent (although resembles the pothi) is much different from it - for example the 'headers' and 'footers' are facing the edges, whereas here the 'headers' and 'footers' have the same orientation as the main content.

    Nonetheless thanks; I shall peruse that code and see how best to adapt it to my needs.

    – Arunagirinathar Oct 14 '14 at 12:02

2 Answers2

10

This sort of page layout is definitely possible in TeX. I'll first show a way to do it in plain TeX, because I understand it a bit better than I understand LaTeX.

Let's look at what we have in the image from the question:

Main content area

Main content area

This is just running text, with appropriately chosen line breaks and page breaks. This is the bread-and-butter of TeX, what it was written for. It has no problem doing this.

The only unconventional things here are:

  1. The dimensions of this region are different from the defaults:

    % The dimensions of the "main content" area and its offset on the page.
    \hsize=5in \vsize=1.5in
    \hoffset=-0.7in \voffset=-0.7in % Added to the default of 1 inch.
    % The dimensions of the page itself (optional)
    \pdfpagewidth=6.5in \pdfpageheight=2.2in
    
  2. The text is in Devanagari, so we can use XeTeX to load (define) and select a Devanagari font:

    % TECKit mapping=devanagarinumerals converts "1" to "१", etc.
    \font\devaserif="Noto Serif Devanagari:mapping=devanagarinumerals"
    \devaserif
    

The left-side "header"

left-side header

This region (containing the book title, chapter title, and the two vertical lines) can be made up as a set of boxes, skips (glue) and rules (lines):

\def\booktitle{वा॰रा॰}
\def\chaptertitle{बा॰का॰} % Set this up to change with chapter 

\def\leftbar{%
  \vbox to \vsize{\hbox{\booktitle} \vss \hbox{\chaptertitle}}%
  \hskip 1pt%
  \vrule height \vsize depth 5pt%
  \hskip 1pt%
  \vrule height \vsize depth 5pt%
  }

The right-side "header"

Right-side header

This is similar. The only thing to know is that the page number is stored in a counter called \pageno, and that you can turn it into characters (in decimal) with \number. (Or you can directly use \folio instead of \number\pageno.)

\def\chapnumber{स॰ १}
\def\pagenumber{\number\pageno}

% The right-side "header" (or is it "footer"?)
\def\rightbar{%
  \vrule height \vsize depth 5pt%
  \hskip 1pt%
  \vrule height \vsize depth 5pt%
  \hskip 1pt%
  \vbox to \vsize{\hbox{\chapnumber} \vss \hbox{\pagenumber}}%
  }    

Page makeup

Conventionally (in the conventions that TeX was designed for), a page has a header at the top and a footer at the bottom. In TeX, putting these together is handled by the output routine, which ships out all these boxes to a page. It also takes care of increasing the page number after each page is output. What we have here is slightly different (the "headers" are on the left and right: the page as a whole is made up of the left header, the main content area, and the right header), so we can redefine the output routine.

% The output routine: the page to \shipout, given main content in \box255.
\output={\shipout\hbox{%
  \leftbar%
  \hskip 10pt%
  \box255%
  \hskip 10pt%
  \rightbar%
  }\advancepageno}

All together

To get a working document just put all the above together with the text you want:

% The dimensions of the "main content" area and its offset on the page.
\hsize=5in \vsize=1.5in
\hoffset=-0.7in \voffset=-0.7in % Relative to the default of 1 inch.
\pdfpagewidth=6.5in \pdfpageheight=2.2in

% The material that should appear in the left and right bars.
% These should be redefined as the document progresses.
\def\booktitle{वा॰रा॰}
\def\chaptertitle{बा॰का॰}
\def\chapnumber{स॰ १}
\def\pagenumber{\number\pageno}

% The left-side "header"
\def\leftbar{%
  \vbox to \vsize{\hbox{\booktitle} \vss \hbox{\chaptertitle}}%
  \hskip 1pt%
  \vrule height \vsize depth 5pt%
  \hskip 1pt%
  \vrule height \vsize depth 5pt%
  }

% The right-side "header" (or is it "footer"?)
\def\rightbar{%
  \vrule height \vsize depth 5pt%
  \hskip 1pt%
  \vrule height \vsize depth 5pt%
  \hskip 1pt%
  \vbox to \vsize{\hbox{\chapnumber} \vss \hbox{\pagenumber}}%
  }

% The output routine: the page to \shipout, given main content in \box255.
\output={\shipout\hbox{%
  \leftbar%
  \hskip 10pt%
  \box255%
  \hskip 10pt%
  \rightbar%
  }\advancepageno}

% TECKit mapping=devanagarinumerals converts "1" to "१", etc.
\font\devaserif="Noto Serif Devanagari:mapping=devanagarinumerals"

\devaserif

तपःस्वाध्यायनिरतं तपस्वी वाग्विदां वरम् । नारदं परिपप्रच्छ वाल्मीकिर्मुनिपुंगवम् ॥ १ ॥
को न्वस्मिन् साम्प्रतं लोके गुणवान् कश्च वीर्यवान् । धर्मज्ञश्च कृतज्ञश्च सत्यवाक्यो दृढव्रतः ॥ २ ॥
चारित्रेण च को युक्तः सर्वभूतेषु को हितः । विद्वान् कः कः समर्थश्च कश्चैकप्रियदर्शनः ॥ ३ ॥
आत्मवान् को जितक्रोधो मतिमान् को ऽनसूयकः । कस्य बिभ्यति देवाश्च जातरोषस्य संयुगे ॥ 4 ॥
एतद् इच्छाम्यहं श्रोतुं परं कौतूहलं हि मे । महर्षे त्वं समर्थो ऽसि ज्ञातुम् एवंविधं नरम् ॥ 5 ॥
श्रुत्वा चैतत् त्रिलोकज्ञो वाल्मीकेर्नारदो वचः । श्रूयताम् इति चामन्त्र्य प्रहृष्टो वाक्यमब्रवीत् ॥ 6 ॥
बहवो दुर्लभाश्चैव ये त्वया कीर्तिता गुणाः । मुने वक्ष्याम्यहं बुद्ध्वा तैर्युक्तः श्रूयतां नरः ॥ 7 ॥
इक्ष्वाकुवंशप्रभवो रामो नाम जनैः श्रुतः । नियतात्मा महावीर्यो द्युतिमान् धृतिमान् वशी ॥ 8 ॥
बुद्धिमान् नीतिमान् वाग्मी श्रीमाञ् शत्रुनिबर्हणः । विपुलांसो महाबाहुः कम्बुग्रीवो महाहनुः ॥ 9 ॥
महोरस्को महेष्वासो गूढजत्रुररिंदमः । आजानुबाहुः सुशिराः सुललाटः सुविक्रमः ॥ 10 ॥
समः समविभक्ताङ्गः स्निग्धवर्णः प्रतापवान् । पीनवक्षा विशालाक्षो लक्ष्मीवाञ् शुभलक्षणः ॥ 11 ॥
धर्मज्ञः सत्यसंधश्च प्रजानां च हिते रतः । यशस्वी ज्ञानसंपन्नः शुचिर्वश्यः समाधिमान् ॥ 12 ॥
रक्षिता जीवलोकस्य धर्मस्य परिरक्षिता । वेदवेदाङ्गतत्त्वज्ञो धनुर्वेदे च निष्ठितः ॥ 13 ॥
सर्वशास्त्रार्थतत्त्वज्ञो स्मृतिमान् प्रतिभानवान् । सर्वलोकप्रियः साधुर् अदीनात्मा विचक्षणः ॥ 14 ॥
सर्वदाभिगतः सद्भिः समुद्र इव सिन्धुभिः । आर्यः सर्वसमश्चैव सदैकप्रियदर्शनः ॥ 15 ॥
स च सर्वगुणोपेतः कौसल्यानन्दवर्धनः । समुद्र इव गाम्भीर्ये धैर्येण हिमवान् इव ॥ 16 ॥
विष्णुना सदृशो वीर्ये सोमवत् प्रियदर्शनः । कालाग्निसदृशः क्रोधे क्षमया पृथिवीसमः ॥ 17 ॥
धनदेन समस् त्यागे सत्ये धर्म इवापरः । तम् एवंगुणसंपन्नं रामं सत्यपराक्रमम् ॥ 18 ॥
ज्येष्ठं श्रेष्ठगुणैर्युक्तं प्रियं दशरथः सुतम् । यौवराज्येन संयोक्तुम् ऐच्छत् प्रीत्या महीपतिः ॥ 19 ॥
तस्याभिषेकसंभारान् दृष्ट्वा भार्याथ कैकयी । पूर्वं दत्तवरा देवी वरम् एनम् अयाचत ॥ 20 ॥
विवासनं च रामस्य भरतस्याभिषेचनम् । स सत्यवचनाद् राजा धर्मपाशेन संयतः ॥ 21 ॥
विवासयाम् आस सुतं रामं दशरथः प्रियम् । स जगाम वनं वीरः प्रतिज्ञाम् अनुपालयन् ॥ 22 ॥
पितुर्वचननिर्देशात् कैकेय्याः प्रियकारणात् । तं व्रजन्तं प्रियो भ्राता लक्ष्मणो ऽनुजगाम ह ॥ 23 ॥
स्नेहाद् विनयसंपन्नः सुमित्रानन्दवर्धनः । सर्वलक्षणसंपन्ना नारीणाम् उत्तमा वधूः ॥ 24 ॥
सीताप्यनुगता रामं शशिनं रोहिणी यथा । पौरैरनुगतो दूरं पित्रा दशरथेन च ॥ 25 ॥

\medskip
तेन गत्वा पुरीं लङ्कां हत्वा रावणम् आहवे । अभ्यषिञ्चत् स लङ्कायां राक्षसेन्द्रं विभीषणम् ॥ 66 ॥
कर्मणा तेन महता त्रैलोक्यं सचराचरम् । सदेवर्षिगणं तुष्टं राघवस्य महात्मनः ॥ 67 ॥
तथा परमसंतुष्टैः पूजितः सर्वदैवतैः । कृतकृत्यस् तदा रामो विज्वरः प्रमुमोद ह ॥ 68  ॥
देवताभ्यो वरान् प्राप्य समुत्थाप्य च वानरान् । पुष्पकं तत् समारुह्य नन्दिग्रामं ययौ तदा ॥ 69 ॥
नन्दिग्रामे जटां हित्वा भ्रातृभिः सहितो ऽनघः । रामः सीताम् अनुप्राप्य राज्यं पुनरवाप्तवान् ॥ 70  ॥

\bye

If you put the above into a file called ramayana.tex and process it with xetex ramayana.tex, it produces:

ramayana.pdf generated by XeTeX

Compiling in LaTeX

LaTeX provides certain features (automatic numbering, cross-references, bibliographies, indexes, …), and many packages are written only to work with LaTeX. If you need any of those, then you may prefer to use LaTeX instead of plain TeX.

The main challenge translating the above to even compile with LaTeX is that I could not find any useful documentation of LaTeX equivalents of TeX idioms. For instance, LaTeX has its own complicated output routine that does a huge deal (so it's unwise to redefine \output). I had to make the following changes:

  • redefine \@outputpage instead of \output
  • use \box\@outputbox (which is \box23) rather than \box255
  • set \textwidth and \texheight instead of \hsize and \vsize
  • set some more length parameters that affect the offset (\oddsidemargin, \evensidemargin, \topmargin \headheight, \headsep)
  • use a LaTeX counter called "page" instead of \pageno, and \arabic{page} instead of \number\pageno
  • define a new font with \usepackage{fontspec} then \newfontfamily, rather than with \font.

With those changes, a file that compiles with xelatex (but stylistically not a “real” LaTeX document, see below):

\documentclass{article}

\usepackage{fontspec}
% TECKit Mapping=devanagarinumerals converts "1" to "१", etc.
\newfontfamily\devaserif[Mapping=devanagarinumerals]{Noto Serif Devanagari}

% The dimensions of the "main content" area and its offset on the page.
\textwidth=5in \textheight=1.5in
\hoffset=-0.7in \voffset=-0.7in % Relative to the default of 1 inch.
\oddsidemargin=0pt \evensidemargin=0pt \topmargin=0pt \headheight=0pt \headsep=0pt
\pdfpagewidth=6.5in \pdfpageheight=2.2in

% The material that should appear in the left and right bars.
% These should be redefined as the document progresses.
\def\booktitle{वा॰रा॰}
\def\chaptertitle{बा॰का॰}
\def\chapnumber{स॰ १}
\def\pagenumber{\arabic{page}}

% The left-side "header"
\def\leftbar{%
  \vbox to \vsize{\hbox{\booktitle} \vss \hbox{\chaptertitle}}%
  \hskip 1pt%
  \vrule height \vsize depth 5pt%
  \hskip 1pt%
  \vrule height \vsize depth 5pt%
  }

% The right-side "header" (or is it "footer"?)
\def\rightbar{%
  \vrule height \vsize depth 5pt%
  \hskip 1pt%
  \vrule height \vsize depth 5pt%
  \hskip 1pt%
  \vbox to \vsize{\hbox{\chapnumber} \vss \hbox{\pagenumber}}%
  }

% The output routine: the page to \shipout, given main content in \box255.
\makeatletter
\def\@outputpage{\shipout\hbox{%
  \leftbar%
  \hskip 10pt%
  \box\@outputbox%
  \hskip 10pt%
  \rightbar%
  }\stepcounter{page}}
\makeatother

\begin{document}

\devaserif

\parindent=20pt % To match TeX. (Instead of 15pt.)

तपःस्वाध्यायनिरतं तपस्वी वाग्विदां वरम् । नारदं परिपप्रच्छ वाल्मीकिर्मुनिपुंगवम् ॥ १ ॥
को न्वस्मिन् साम्प्रतं लोके गुणवान् कश्च वीर्यवान् । धर्मज्ञश्च कृतज्ञश्च सत्यवाक्यो दृढव्रतः ॥ २ ॥
चारित्रेण च को युक्तः सर्वभूतेषु को हितः । विद्वान् कः कः समर्थश्च कश्चैकप्रियदर्शनः ॥ ३ ॥
आत्मवान् को जितक्रोधो मतिमान् को ऽनसूयकः । कस्य बिभ्यति देवाश्च जातरोषस्य संयुगे ॥ 4 ॥
एतद् इच्छाम्यहं श्रोतुं परं कौतूहलं हि मे । महर्षे त्वं समर्थो ऽसि ज्ञातुम् एवंविधं नरम् ॥ 5 ॥
श्रुत्वा चैतत् त्रिलोकज्ञो वाल्मीकेर्नारदो वचः । श्रूयताम् इति चामन्त्र्य प्रहृष्टो वाक्यमब्रवीत् ॥ 6 ॥
बहवो दुर्लभाश्चैव ये त्वया कीर्तिता गुणाः । मुने वक्ष्याम्यहं बुद्ध्वा तैर्युक्तः श्रूयतां नरः ॥ 7 ॥
इक्ष्वाकुवंशप्रभवो रामो नाम जनैः श्रुतः । नियतात्मा महावीर्यो द्युतिमान् धृतिमान् वशी ॥ 8 ॥
बुद्धिमान् नीतिमान् वाग्मी श्रीमाञ् शत्रुनिबर्हणः । विपुलांसो महाबाहुः कम्बुग्रीवो महाहनुः ॥ 9 ॥
महोरस्को महेष्वासो गूढजत्रुररिंदमः । आजानुबाहुः सुशिराः सुललाटः सुविक्रमः ॥ 10 ॥
समः समविभक्ताङ्गः स्निग्धवर्णः प्रतापवान् । पीनवक्षा विशालाक्षो लक्ष्मीवाञ् शुभलक्षणः ॥ 11 ॥
धर्मज्ञः सत्यसंधश्च प्रजानां च हिते रतः । यशस्वी ज्ञानसंपन्नः शुचिर्वश्यः समाधिमान् ॥ 12 ॥
रक्षिता जीवलोकस्य धर्मस्य परिरक्षिता । वेदवेदाङ्गतत्त्वज्ञो धनुर्वेदे च निष्ठितः ॥ 13 ॥
सर्वशास्त्रार्थतत्त्वज्ञो स्मृतिमान् प्रतिभानवान् । सर्वलोकप्रियः साधुर् अदीनात्मा विचक्षणः ॥ 14 ॥
सर्वदाभिगतः सद्भिः समुद्र इव सिन्धुभिः । आर्यः सर्वसमश्चैव सदैकप्रियदर्शनः ॥ 15 ॥
स च सर्वगुणोपेतः कौसल्यानन्दवर्धनः । समुद्र इव गाम्भीर्ये धैर्येण हिमवान् इव ॥ 16 ॥
विष्णुना सदृशो वीर्ये सोमवत् प्रियदर्शनः । कालाग्निसदृशः क्रोधे क्षमया पृथिवीसमः ॥ 17 ॥
धनदेन समस् त्यागे सत्ये धर्म इवापरः । तम् एवंगुणसंपन्नं रामं सत्यपराक्रमम् ॥ 18 ॥
ज्येष्ठं श्रेष्ठगुणैर्युक्तं प्रियं दशरथः सुतम् । यौवराज्येन संयोक्तुम् ऐच्छत् प्रीत्या महीपतिः ॥ 19 ॥
तस्याभिषेकसंभारान् दृष्ट्वा भार्याथ कैकयी । पूर्वं दत्तवरा देवी वरम् एनम् अयाचत ॥ 20 ॥
विवासनं च रामस्य भरतस्याभिषेचनम् । स सत्यवचनाद् राजा धर्मपाशेन संयतः ॥ 21 ॥
विवासयाम् आस सुतं रामं दशरथः प्रियम् । स जगाम वनं वीरः प्रतिज्ञाम् अनुपालयन् ॥ 22 ॥
पितुर्वचननिर्देशात् कैकेय्याः प्रियकारणात् । तं व्रजन्तं प्रियो भ्राता लक्ष्मणो ऽनुजगाम ह ॥ 23 ॥
स्नेहाद् विनयसंपन्नः सुमित्रानन्दवर्धनः । सर्वलक्षणसंपन्ना नारीणाम् उत्तमा वधूः ॥ 24 ॥
सीताप्यनुगता रामं शशिनं रोहिणी यथा । पौरैरनुगतो दूरं पित्रा दशरथेन च ॥ 25 ॥

\medskip
तेन गत्वा पुरीं लङ्कां हत्वा रावणम् आहवे । अभ्यषिञ्चत् स लङ्कायां राक्षसेन्द्रं विभीषणम् ॥ 66 ॥
कर्मणा तेन महता त्रैलोक्यं सचराचरम् । सदेवर्षिगणं तुष्टं राघवस्य महात्मनः ॥ 67 ॥
तथा परमसंतुष्टैः पूजितः सर्वदैवतैः । कृतकृत्यस् तदा रामो विज्वरः प्रमुमोद ह ॥ 68  ॥
देवताभ्यो वरान् प्राप्य समुत्थाप्य च वानरान् । पुष्पकं तत् समारुह्य नन्दिग्रामं ययौ तदा ॥ 69 ॥
नन्दिग्रामे जटां हित्वा भ्रातृभिः सहितो ऽनघः । रामः सीताम् अनुप्राप्य राज्यं पुनरवाप्तवान् ॥ 70  ॥

\end{document}

The output (when the above is compiled with xelatex) is identical to the output from plain XeTeX above. Of course I may not have done things the right LaTeX way (the same applies even for the plain TeX code).

Towards “real” LaTeX

Although the above compiles with xelatex, stylistically it would not qualify as a “real” LaTeX document. LaTeX comes with its own philosophy (alternate link), and conventions. For example (thanks to @cfr's comments below):

  • It is recommended to use \newcommand rather than \def: as far as I can tell, the main reason is to prevent accidentally redefining commands. It works to just replace each \def above with \newcommand. (But I don't know how much redefinition is a worry in this case, and I definitely do not fully understand the definition of \newcommand.)
  • Set the page dimensions with the geometry package. The idea is that such packages are likely to have anticipated common user needs and pitfalls, and possibly be “battle-tested” code. Of course, it also means there are more layers to understand, and more interactions where failures can occur… [This would look something like \usepackage[width=5in, height=1.5in, top=0.3in, left=0.3in, paperwidth=6.5in, paperheight=2.2in]{geometry} but I wasn't able to get this to work with the redefinition of the output routine.]
  • Use \setmainfont (documented in package fontspec) as most of the document is in the same font: so \setmainfont[Script=Devanagari,Mapping=devanagarinumerals]{Noto Serif Devanagari}.
  • Use the polyglossia package which provides support for common things typical users like to do when they switch languages: change hyphenation patterns, change fonts and typographical conventions, change date and number formats, etc. What the package currently provides for Sanskrit are some crude hyphenation patterns, awareness that । and ॥ are punctuation characters, along with a bunch of other (undocumented) settings like "frenchspacing": turning off the default longer space between sentences. If we think that this is overall an improvement, we could use this with \usepackage{polyglossia} followed by \setdefaultlanguage{sanskrit}, but it doesn't work in this case.
ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
  • Wow! Never expected that this thread would be replied. Infact, I had given all hope of typesetting these type of documents altogether - because of the sheer effort that it takes to create them (in most {other} software). Anyway - this is a great way to get started - I shall definitely look into it. – Arunagirinathar May 06 '17 at 09:36
  • @Arunagirinathar Glad it helped. Given that you're still interested, I edited the answer to make it easier to understand, and hacked together a LaTeX-compatible version that seems to work for this basic document at least. – ShreevatsaR May 08 '17 at 07:09
  • Thanks for a great lecture. More thankful for giving TeX style of doing this. – Rama Krishna Majety May 08 '17 at 07:39
  • Re. your qn. re. LaTeX: do not use \def if you can avoid it. Use \newcommand* for \def and \newcommand for \long\def. Or the \renewcommand or \providecommand versions. (Or use the new LaTeX 3 stuff, of course.) In the case of standard classes, use geometry rather than setting page layout dimensions manually. This will make sure that the backend configuration matches and so on. Set the main document font to what you need so that NFSS macros do the right thing. What if the OP uses a package which relies on e.g. everypage? You are just overwriting everything regardless. – cfr May 11 '17 at 00:50
  • You probably want a language package here. polyglossia or babel. Probably polyglossia is the best choice, if it has appropriate language support, but I'm not sure. – cfr May 11 '17 at 00:54
  • @cfr Yes I was trying to make a minimal set of changes to even get this document to simply compile with xelatex. If you post an answer with your suggestions, that achieves similar output, I'm sure it would be educational. – ShreevatsaR May 11 '17 at 00:54
  • I'm only commenting because of your other question. % These should be redefined as the document progresses. is not at all good, for example. You want \chapter etc. to do the right thing. – cfr May 11 '17 at 00:56
  • @cfr Yes you are right, if writing a full document we would have the redefinition happen automatically, to make it easier to the writer and not clutter up the document. Here I wanted to communicate the ideas to help the reader understand what is going on / what sort of stuff is involved, rather than provide a production-quality solution. (BTW, yes in a real document it would be good to use polyglossia as well, even though what it provides for Sanskrit is quite small compared to what it does for other languages.) And please do post an answer if feasible, I will be sure to upvote it. :-) – ShreevatsaR May 11 '17 at 01:01
  • I do want to make clear that I'm only commenting because I followed the link from your other question. Your answer is certainly a useful proof-of-concept - the can it be done, which the OP asked for. – cfr May 11 '17 at 01:05
  • @cfr I tried to use the geometry package, but it appears that it doesn't like my redefinition of \@outputpage — the margins come out all much larger than specified in its options. (Probably geometry plays with \@outputpage too, internally.) So until I figure it out, I'll manually set all the assorted parameters. :-) Trying out the other suggestions… – ShreevatsaR May 11 '17 at 01:51
  • If you use everypage you can add to the page shipout hook rather than overwriting it. Or you could copy the way it does it. (But lots of things use the hooks it provides, so your code is more likely to be compatible if you use the common hook.) – cfr May 11 '17 at 02:40
  • \geometry{width=5in,height=1.5in,paperwidth=6.5in,paperheight=2.2in,headheight=0pt,headsep=0pt,marginratio=1:1,noheadfoot}. See how the geometry package works with the showframe option for drawing the rules etc. (There are nicer ways interface-wise, but they are all more costly in terms of overhead. The background package is one example.) – cfr May 11 '17 at 02:42
  • I started a coffins answer, but don't have time at the moment. – cfr May 11 '17 at 02:43
  • Note: I can't recommend trying polyglossia. At least, I couldn't get it to work. If you try it, you'll probably need to delete the aux afterwards. – cfr May 11 '17 at 02:44
  • @cfr Well, it appears I just spent the last hour and a bit trying to get the package menagerie working together and didn't succeed, so I'm going to give up for now :-) (The above geometry thing didn't work with my output redefinition either.) This is why I prefer to read others' code and understand what it's doing, and pull out minimal parts from it, rather than use it as a black box… unfortunately so little documentation is written to educate. Thanks for the pointers though; maybe someday I'll understand. :-) For now I'll stick with the solution that works in at least this simple case. – ShreevatsaR May 11 '17 at 02:55
  • Wow! This is by far the most exhaustive answer I have seen on SE, atleast on this topic. Never imagined that one could accomplish this in TeX - or any other WYSISYG software. Tried it in Adobe inDesign previously and it crashed beyond 200 pages - on a i5/8G RAM machine. Generally most of the major documents (manuscripts) written in this style are big and there is one particular manuscript in a collection that is about 1,00,000 verses written across about 1500 hand made pages, each measuring approximately 14 inches by 11 inches. This is about the biggest hand written manuscript I have seen. – Arunagirinathar May 15 '17 at 02:27
4

Based on ShreevatsaR's answer, and on the discussion in LaTeX for plain TeX users? here is a possible “pure LaTeX” solution.

The main problem are the side parts, that can be treated as the header fields for fancyhdr.

\documentclass{article}

\usepackage{fontspec}
\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{color}

% TECKit Mapping=devanagarinumerals converts "1" to "१", etc.
\setmainfont{Devanagari MT}[
  Mapping=devanagarinumerals,
  Scale=.9,
]

% The dimensions of the "main content" area and its offset on the page.
\geometry{
  textwidth=5in,
  textheight=1.5in,
  heightrounded,
  paperwidth=6.5in,
  paperheight=2.2in,
  headsep=0pt,
  headheight=12pt,
}

% The material that should appear in the left and right bars.
% These should be redefined as the document progresses.
\newcommand\booktitle{वा॰रा॰}
\newcommand\chaptertitle{बा॰का॰}
\newcommand\chapnumber{स॰ १}

% The left-side "header"
\fboxsep=-\fboxrule
\newcommand\leftbar{%
  \raisebox{\dimexpr\topskip-\baselineskip}[0pt][0pt]{%
    \color{red}% for debugging
    \parbox[t][\dimexpr\textheight+12pt][s]{1in}{%
      \raggedleft
      \vspace{\medskipamount}
      \strut\booktitle\vfill\strut\chaptertitle\par
      \vspace{\medskipamount}
    }%
    \hspace{1pt}%
    \vrule
    \hspace{1pt}%
    \vrule
    \hspace{1pt}%
  }%
}

% The right-side "header" (or is it "footer"?)
\newcommand\rightbar{%
  \raisebox{\dimexpr\topskip-\baselineskip}[0pt][0pt]{%
    \color{red}% for debugging
    \hspace{1pt}%
    \vrule
    \hspace{1pt}%
    \vrule
    \hspace{1pt}%
    \parbox[t][\dimexpr\textheight+12pt][s]{1in}{%
      \raggedright
      \vspace{\medskipamount}
      \strut\chapnumber\vfill\strut\thepage\par
      \vspace{\medskipamount}
    }%
  }%
}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\makebox[0pt][r]{\leftbar}}
\fancyhead[R]{\makebox[0pt][l]{\rightbar}}
\renewcommand{\headrulewidth}{0pt}

\begin{document}

\parindent=20pt % To match TeX. (Instead of 15pt.)

तपःस्वाध्यायनिरतं तपस्वी वाग्विदां वरम् । नारदं परिपप्रच्छ वाल्मीकिर्मुनिपुंगवम् ॥ १ ॥
को न्वस्मिन् साम्प्रतं लोके गुणवान् कश्च वीर्यवान् । धर्मज्ञश्च कृतज्ञश्च सत्यवाक्यो दृढव्रतः ॥ २ ॥
चारित्रेण च को युक्तः सर्वभूतेषु को हितः । विद्वान् कः कः समर्थश्च कश्चैकप्रियदर्शनः ॥ ३ ॥
आत्मवान् को जितक्रोधो मतिमान् को ऽनसूयकः । कस्य बिभ्यति देवाश्च जातरोषस्य संयुगे ॥ 4 ॥
एतद् इच्छाम्यहं श्रोतुं परं कौतूहलं हि मे । महर्षे त्वं समर्थो ऽसि ज्ञातुम् एवंविधं नरम् ॥ 5 ॥
श्रुत्वा चैतत् त्रिलोकज्ञो वाल्मीकेर्नारदो वचः । श्रूयताम् इति चामन्त्र्य प्रहृष्टो वाक्यमब्रवीत् ॥ 6 ॥
बहवो दुर्लभाश्चैव ये त्वया कीर्तिता गुणाः । मुने वक्ष्याम्यहं बुद्ध्वा तैर्युक्तः श्रूयतां नरः ॥ 7 ॥
इक्ष्वाकुवंशप्रभवो रामो नाम जनैः श्रुतः । नियतात्मा महावीर्यो द्युतिमान् धृतिमान् वशी ॥ 8 ॥
बुद्धिमान् नीतिमान् वाग्मी श्रीमाञ् शत्रुनिबर्हणः । विपुलांसो महाबाहुः कम्बुग्रीवो महाहनुः ॥ 9 ॥
महोरस्को महेष्वासो गूढजत्रुररिंदमः । आजानुबाहुः सुशिराः सुललाटः सुविक्रमः ॥ 10 ॥
समः समविभक्ताङ्गः स्निग्धवर्णः प्रतापवान् । पीनवक्षा विशालाक्षो लक्ष्मीवाञ् शुभलक्षणः ॥ 11 ॥
धर्मज्ञः सत्यसंधश्च प्रजानां च हिते रतः । यशस्वी ज्ञानसंपन्नः शुचिर्वश्यः समाधिमान् ॥ 12 ॥
रक्षिता जीवलोकस्य धर्मस्य परिरक्षिता । वेदवेदाङ्गतत्त्वज्ञो धनुर्वेदे च निष्ठितः ॥ 13 ॥
सर्वशास्त्रार्थतत्त्वज्ञो स्मृतिमान् प्रतिभानवान् । सर्वलोकप्रियः साधुर् अदीनात्मा विचक्षणः ॥ 14 ॥
सर्वदाभिगतः सद्भिः समुद्र इव सिन्धुभिः । आर्यः सर्वसमश्चैव सदैकप्रियदर्शनः ॥ 15 ॥
स च सर्वगुणोपेतः कौसल्यानन्दवर्धनः । समुद्र इव गाम्भीर्ये धैर्येण हिमवान् इव ॥ 16 ॥
विष्णुना सदृशो वीर्ये सोमवत् प्रियदर्शनः । कालाग्निसदृशः क्रोधे क्षमया पृथिवीसमः ॥ 17 ॥
धनदेन समस् त्यागे सत्ये धर्म इवापरः । तम् एवंगुणसंपन्नं रामं सत्यपराक्रमम् ॥ 18 ॥
ज्येष्ठं श्रेष्ठगुणैर्युक्तं प्रियं दशरथः सुतम् । यौवराज्येन संयोक्तुम् ऐच्छत् प्रीत्या महीपतिः ॥ 19 ॥
तस्याभिषेकसंभारान् दृष्ट्वा भार्याथ कैकयी । पूर्वं दत्तवरा देवी वरम् एनम् अयाचत ॥ 20 ॥
विवासनं च रामस्य भरतस्याभिषेचनम् । स सत्यवचनाद् राजा धर्मपाशेन संयतः ॥ 21 ॥
विवासयाम् आस सुतं रामं दशरथः प्रियम् । स जगाम वनं वीरः प्रतिज्ञाम् अनुपालयन् ॥ 22 ॥
पितुर्वचननिर्देशात् कैकेय्याः प्रियकारणात् । तं व्रजन्तं प्रियो भ्राता लक्ष्मणो ऽनुजगाम ह ॥ 23 ॥
स्नेहाद् विनयसंपन्नः सुमित्रानन्दवर्धनः । सर्वलक्षणसंपन्ना नारीणाम् उत्तमा वधूः ॥ 24 ॥
सीताप्यनुगता रामं शशिनं रोहिणी यथा । पौरैरनुगतो दूरं पित्रा दशरथेन च ॥ 25 ॥

\medskip
तेन गत्वा पुरीं लङ्कां हत्वा रावणम् आहवे । अभ्यषिञ्चत् स लङ्कायां राक्षसेन्द्रं विभीषणम् ॥ 66 ॥
कर्मणा तेन महता त्रैलोक्यं सचराचरम् । सदेवर्षिगणं तुष्टं राघवस्य महात्मनः ॥ 67 ॥
तथा परमसंतुष्टैः पूजितः सर्वदैवतैः । कृतकृत्यस् तदा रामो विज्वरः प्रमुमोद ह ॥ 68  ॥
देवताभ्यो वरान् प्राप्य समुत्थाप्य च वानरान् । पुष्पकं तत् समारुह्य नन्दिग्रामं ययौ तदा ॥ 69 ॥
नन्दिग्रामे जटां हित्वा भ्रातृभिः सहितो ऽनघः । रामः सीताम् अनुप्राप्य राज्यं पुनरवाप्तवान् ॥ 70  ॥

\end{document}

The red color is just for debugging. The code, apart from \vrule is covered in the manual of LaTeX and of the used packages.

enter image description here

egreg
  • 1,121,712
  • Thank you very much; this was very informative. I'll take some more passes to digest this fully… thanks again! – ShreevatsaR May 12 '17 at 04:43
  • Thanks a lot. This definitely helps and has partly re-kindled my desire to typeset some old manuscripts in the same format they were written - namely the "Pothi" or "Patravali". Will try out and update this discussion with my results as time permits. Thank you again. – Arunagirinathar May 15 '17 at 02:30