Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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}
share|improve this answer
    
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 '11 at 14:30
    
Have you installed the Devangari font? I edited my answer for a run without the special font setting. –  Herbert Aug 22 '11 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 '11 at 14:46
    
ok, let's try it –  Herbert Aug 22 '11 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. –  ShreevatsaR Sep 21 '11 at 16:07
show 9 more comments

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.