1

I am typesetting a document in devanagari and a minimal working example is below:

\documentclass{book}
\usepackage{fontspec}
\usepackage{setspace}
\usepackage{xcolor}
\usepackage{csquotes}

\renewcommand{\baselinestretch}{1.5}
\usepackage{titlesec}

\newcommand{\perror}[1] {{\color{red}#1}}
\newcommand{\psutra}[1] {{\color{blue}#1}}


\begin{document}
\setmainfont[Script=Devanagari]{Sanskrit 2003}
\chapter{प्रथमोऽध्यायः}

\section{पाणिनीयसूत्राणां वैविध्यम्}
एवं महति परिकरे सत्यपि पाणिनीये अपरिहार्यः कशर्चनक्लोशो वर्तते । यतो हि तत्र सूत्राणि षोढा रचितानि । यदाहुः 
 \par
\centering{\textbf{
संज्ञा च परिभाषा च विधिर्नियम एव च । \\
अतिदेशश्चाधिकारः षड्विधं सूत्रलक्षणम्  ।। \\
}} 

\section{पाणिनीयस्य महत्त्वम्}
\centering{\textbf{
पाणिनीयं महाशास्त्रं पदसाधुत्वलक्षणम् । \\
सर्वोपकारकं ग्राह्यं कृत्स्नं त्याज्यं न किञ्चन ।। \\
}}
अद्यत्वे शब्दसाधुत्वप्रबोधकं व्याकरणं पाणिनीयमेव । पाणिनिर्महेश्वरं तपसा सन्तोष्य तदनुग्रहेण ``अइउण्" इत्यादिचतुर्दश सूत्राणि उपलभ्य लौकिकवैदिकवाङ्मयोः संपूर्णं व्याकरणं रचयामास । तदेव व्याकरणमधुना अष्टाध्यायीनाम्ना विराजते ।\\  \hfill \break
पाणिनिना सूत्रपाठः धातुपाठः गणपाठः लिङ्गानुशासनं च व्यरच्यत । प्रत्यध्यायं चत्चारः पादाः वर्तन्ते । तत्र सूत्रसंख्या एव वर्तते ।

\end{document}

In the generated pdf, the name for section 1.2 i.e पाणिनीयस्य महत्त्वम्, stretches all the way to the end of the page. How can I enforce that there be only one space between each word in the section name?

enter image description here

4
  • 1
    Two totally off-topic comments. (1) You should use the separate character ॥ for the double daṇḍa, rather than two consecutive daṇḍas, unless this is a deliberate design choice, but I would not really recommend it, they're too far apart. (2) I've found it's wise to add a non-breaking space ~ before daṇḍas. It's a bit annoying, yes, because your Devanagari keyboard might well not have it, but otherwise you get line-breaks at daṇḍas, which is a big no. The line must obviously not start with a daṇḍa. This is especially a problem with the common ॥ १ ॥ style of numbering
    – Au101
    Commented Dec 25, 2016 at 23:20
  • 1
    Oh, also, Sanskrit 2003 does not have a bold face as far as I know, so \textbf{} is kinda meaningless. Your document looks really nice though, but I'm not sure about the wisdom of having Chapter 1 and then the title being just "first chapter" in Sanskrit. Might be a good idea to look at customising the chapter title if this is an all-Sanskrit text. Anyway, sorry, I couldn't help myself, this was three years of my life :P :P
    – Au101
    Commented Dec 25, 2016 at 23:23
  • @Au101 Do you have an example on how to concoct a separate character to represent the double danda ? Likewise, can you share with me an example about adding the non-breaking space? I had customizing the title on my todo list already.
    – linuxfan
    Commented Dec 26, 2016 at 3:33
  • 1
    Well the double daṇḍa is not concocted, it's a separate unicode character U+0965 ॥ It should therefore be input as the one separate character. In my case it's on my keyboard layout as ~. । is # and ॥ is ~ I'm on Ubuntu so yours may actually be the same, but if not, you can try using shift + daṇḍa and see if you're in luck, otherwise it should be on the keyboard somewhere. As for non-breaking space, so like: संज्ञा च परिभाषा च विधिर्नियम एव च~। or अतिदेशश्चाधिकारः षड्विधं सूत्रलक्षणम्~॥~१~॥
    – Au101
    Commented Dec 26, 2016 at 13:05

1 Answer 1

3

If you use wrong syntax, you should not be surprised of getting wrong results.

The command \centering does not take an argument: it is a declaration telling LaTeX to center from that point on.

\documentclass{book}
\usepackage{fontspec}
\usepackage{setspace}
\usepackage{xcolor}
\usepackage{csquotes}
\usepackage{titlesec}

\setmainfont[Script=Devanagari]{ITF Devanagari}

\renewcommand{\baselinestretch}{1.5}

\newcommand{\perror}[1] {{\color{red}#1}}
\newcommand{\psutra}[1] {{\color{blue}#1}}


\begin{document}
\chapter{प्रथमोऽध्यायः}

\section{पाणिनीयसूत्राणां वैविध्यम्}
एवं महति परिकरे सत्यपि पाणिनीये अपरिहार्यः कशर्चनक्लोशो वर्तते । यतो हि तत्र सूत्राणि षोढा रचितानि । यदाहुः 

\begin{center}\bfseries
संज्ञा च परिभाषा च विधिर्नियम एव च । \\
अतिदेशश्चाधिकारः षड्विधं सूत्रलक्षणम्  ।। 
\end{center} 

\section{पाणिनीयस्य महत्त्वम्}

\begin{center}\bfseries
पाणिनीयं महाशास्त्रं पदसाधुत्वलक्षणम् । \\
सर्वोपकारकं ग्राह्यं कृत्स्नं त्याज्यं न किञ्चन ।। 
\end{center}
अद्यत्वे शब्दसाधुत्वप्रबोधकं व्याकरणं पाणिनीयमेव । पाणिनिर्महेश्वरं तपसा सन्तोष्य तदनुग्रहेण ``अइउण्" इत्यादिचतुर्दश सूत्राणि उपलभ्य लौकिकवैदिकवाङ्मयोः संपूर्णं व्याकरणं रचयामास । तदेव व्याकरणमधुना अष्टाध्यायीनाम्ना विराजते ।\\  
पाणिनिना सूत्रपाठः धातुपाठः गणपाठः लिङ्गानुशासनं च व्यरच्यत । प्रत्यध्यायं चत्चारः पादाः वर्तन्ते । तत्र सूत्रसंख्या एव वर्तते ।

\end{document}

I had to use a different font, as I don't have Sanskrit 2003. Also \hfill\break after \\ makes no sense.

enter image description here

With Sanskrit 2003 and faked bold:

\documentclass{book}
\usepackage{fontspec}
\usepackage{setspace}
\usepackage{xcolor}
\usepackage{csquotes}
\usepackage{titlesec}

\setmainfont{Sanskrit 2003}[
  Script=Devanagari,
  BoldFont=*,
  BoldFeatures={FakeBold=3},
]

\renewcommand{\baselinestretch}{1.5}

\newcommand{\perror}[1] {{\color{red}#1}}
\newcommand{\psutra}[1] {{\color{blue}#1}}


\begin{document}
\chapter{प्रथमोऽध्यायः}

\section{पाणिनीयसूत्राणां वैविध्यम्}
एवं महति परिकरे सत्यपि पाणिनीये अपरिहार्यः कशर्चनक्लोशो वर्तते । यतो हि तत्र सूत्राणि षोढा रचितानि । यदाहुः 

\begin{center}\bfseries
संज्ञा च परिभाषा च विधिर्नियम एव च । \\
अतिदेशश्चाधिकारः षड्विधं सूत्रलक्षणम्  ।। 
\end{center} 

\section{पाणिनीयस्य महत्त्वम्}

\begin{center}\bfseries
पाणिनीयं महाशास्त्रं पदसाधुत्वलक्षणम् । \\
सर्वोपकारकं ग्राह्यं कृत्स्नं त्याज्यं न किञ्चन ।। 
\end{center}
अद्यत्वे शब्दसाधुत्वप्रबोधकं व्याकरणं पाणिनीयमेव । पाणिनिर्महेश्वरं तपसा सन्तोष्य तदनुग्रहेण ``अइउण्" इत्यादिचतुर्दश सूत्राणि उपलभ्य लौकिकवैदिकवाङ्मयोः संपूर्णं व्याकरणं रचयामास । तदेव व्याकरणमधुना अष्टाध्यायीनाम्ना विराजते ।\\ 
पाणिनिना सूत्रपाठः धातुपाठः गणपाठः लिङ्गानुशासनं च व्यरच्यत । प्रत्यध्यायं चत्चारः पादाः वर्तन्ते । तत्र सूत्रसंख्या एव वर्तते ।

\end{document}

enter image description here

12
  • 1
    @linuxfan Note that in this font (I love Sanskrit 2003 by the way, use it always, except for Vedic) the bold bits are actually bold, you can clearly see that the Devanagari is heavier in egreg's output. It isn't in yours, there is no difference between the text in \textbf{} and the text outside
    – Au101
    Commented Dec 25, 2016 at 23:26
  • @Au101 I looked for Sanskrit 2003 and found there is apparently no boldface version. It can be faked, though. I added the code.
    – egreg
    Commented Dec 25, 2016 at 23:33
  • 1
    @linuxfan I got it with my OS; it is not free, I'm afraid. And I know nothing about Devanagari or mantras.
    – egreg
    Commented Dec 26, 2016 at 10:25
  • 1
    @linuxfan For Vedic I always use Chandas (or Uttara if you prefer the Northern style) which has absolutely excellent support. sanskritweb.net/itrans/index.html
    – Au101
    Commented Dec 26, 2016 at 13:11
  • 1
    @linuxfan That's an interesting username you've got for yourself then ... Errr, well, Chandas/Uttara are actually a little out of date, but if you go to that same link you can see the font below them, Siddhanta, uses Unicode 6.0 and it uses the Unicode Vedic codepoints as far as possible, too. A lot of characters are also to be found in the Private Use Area. Myself, I made my own keyboard layout specifically for Chandas. There's a mac program called Ukelele which might help with that, though I found it buggy years ago
    – Au101
    Commented Dec 26, 2016 at 18:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .