4

I have a Sanskrit Verse that I want to appear at the center of the page. I am using verse environment as shown below.

\begin{verse}
तपः स्वाध्याय निरतम् तपस्वी वाग्विदाम् वरम् | \\
नारदम् परिपप्रच्छ वाल्मीकिः मुनि पुंगवम् ||
\end{verse}

This does not appear at the center of the page, it appears more to the left of the page. Is there a way to make it appear at the center. I attached the screenshot of the output.

enter image description here

2 Answers 2

5

Run the example with xelatex or lualatex or use the definition of Verse if you want to run it with pdflatex

\documentclass{article}
\usepackage{fontspec}
\newfontface\Devangari{Devanagari MT}
\usepackage{varwidth}
\newenvironment{Verse}[1][\Devangari]
  {\center#1\varwidth{\linewidth}}
  {\endvarwidth\endcenter}

\usepackage{lipsum}

\begin{document}

\lipsum[1]
\begin{Verse}
तपः स्वाध्याय निरतम् तपस्वी वाग्विदाम् वरम् | \\
नारदम् परिपप्रच्छ वाल्मीकिः मुनि पुंगवम् ||    
\end{Verse}

\begin{Verse}[]
foo bar\\
baz
\end{Verse}

\end{document}

enter image description here

Without defining the Devangari font:

\documentclass{article}
\usepackage{fontspec}
\usepackage{varwidth}
\newenvironment{Verse}
  {\center\varwidth{\linewidth}}
  {\endvarwidth\endcenter}    
\usepackage{lipsum}
\begin{document}

\lipsum[1]
\begin{Verse}
foo bar\\
baz
\end{Verse}

\end{document}
14
  • I am using XeLatex, this example as it is working however its not working with my file. I am not sure if any of the packages I am using are in conflict with each other. Can you help me that please.
    – Aku
    Aug 22, 2011 at 14:30
  • Have you installed the Devangari font? I edited my answer for a run without the special font setting.
    – user2478
    Aug 22, 2011 at 14:42
  • Yes I did define the Devanagari font. your example is working like a charm. but not in the file I am working with and could not figure it out whats wrong with it. if you are ok to take a look at then I can upload on google docs and share the link here.
    – Aku
    Aug 22, 2011 at 14:46
  • ok, let's try it
    – user2478
    Aug 22, 2011 at 14:54
  • 1
    BTW, the Sanskrit text in your image is incorrectly typeset: it has messed up ligatures and complex script positioning (where a later Unicode character must be displayed to the left of an earlier Unicode character). Compare with the OP's image, which is fine. Presumably he/she has got it working, so it's not important now; just pointing it out. Sep 21, 2011 at 16:07
2

You could define a new length to store the width of the longest verse and use this length as a \parbox's width to be centered using a center environment:

\documentclass{article}
\usepackage{lipsum}

\newlength\mylen
\settowidth\mylen{bbbbbbbbbbbbbbbbbbbbb}

\begin{document}

\lipsum[1]
\begin{center}
\parbox{\mylen}{aaaa \\
bbbbbbbbbbbbbbbbbbbbb}
\end{center}

\end{document}

enter image description here

Another option would be to use the verse package and its facilities:

\documentclass{article}
\usepackage{verse}
\usepackage{lipsum}

\begin{document}

\lipsum[1]
\settowidth\versewidth{bbbbbbbbbbbbbbbbbbbbb}
\begin{verse}[\versewidth]
aaaa \\
bbbbbbbbbbbbbbbbbbbbb
\end{verse}

\end{document}

If you want each verse to appear centered in its own line, you could simply use a center environment:

\begin{center}
तपः स्वाध्याय निरतम् तपस्वी वाग्विदाम् वरम् | \\
नारदम् परिपप्रच्छ वाल्मीकिः मुनि पुंगवम् ||    
\end{center}

You must log in to answer this question.

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