0

I want to typeset text in verse environment in memoir, where each line is fully justified without the need of adding \\ after each line.

So, basically I want a way to combine the answers in \obeylines and verse environment in memoir with Fully justify lines in verse environment

I want to use it for Sanskrit text in Devanagari script.

3 Answers 3

0

This can be accomplished by just changing the answer by David slightly, use \let^^M\linebreak instead of \let^^M\\:

\documentclass[ebook]{memoir}

\begin{document}


\linenumberfrequency{10}
\verselinenumbersleft

\begin{verse}\obeylines\let^^M\linebreak%
Herman:
O'er every birth a star of fate presides,
And he that knows his orb of destiny,
May, by the changes of its radiance, tell
Whene'er his good or evil genius reigns.
This knowledge, earned by many a midnight vigil,
Has taught me that yon silver star is mine,
Which nightly, since I conn'd this wond'rous volume,
Hath dimm'd its fires, and warn'd me to forbear.
Yet have I still undaunted read, and now,
While pale and fitfully its beams shrink in,
The ingredients of a potent spell I mingle,
And but three drops of my own blood are wanting,
To give me proof that to my hests and bidding,
A spirit of dread ministry will come.
Why should the glorious planet fade at this?
Is there then peril to my better part
In this mysterious science? If I stop,
Haw shall I know the secrets written here
Are knowledge or phantasma? Can there be
Evil in truth? For to unfold the art
That summons spirits from their dark abode,
Is but to know what is -- and what the gods,
In their eternal mysteries have framed. -- 
Shrink into darkness thou faint trembling light,
I will abide the issues of the spell.
\end{verse}


\end{document}

enter image description here

6
  • Thanks. This works. However, the first line is getting indented to left. How to avoid that?
    – shreeshrii
    Nov 1, 2019 at 12:19
  • @shreeshrii that's the same as if you didn't use \obeylines but used \linebreak at the end of each line.
    – Skillmon
    Nov 1, 2019 at 12:33
  • @shreeshrii accomplishing this inside the verse environment will be non-trivial, but we could try some things.
    – Skillmon
    Nov 1, 2019 at 12:52
  • Please see the answer I posted below with an example with Devanagari. There is extra indentation in the first verse. I can't get it to center on the page.
    – shreeshrii
    Nov 1, 2019 at 12:58
  • In this particular case you can stop the indentation of the first line by: \setlength{\vgap}{0.42in} \begin{verse}... \vin Herman: and the rest. Nov 2, 2019 at 18:59
1

For Devanagari, I was able to get the following to work, though it is not an MWE.

However, there is still some extra indentation which I am not able to remove.

enter image description here

\documentclass[letterpaper,12pt,onecolumn,twoside,openany,landscape,final]{memoir}
\usepackage[letterpaper,landscape,twoside,hmargin=0.9in,vmargin=0.9in]{geometry}
\usepackage{picture,calc}
\usepackage{eso-pic}
\usepackage{polyglossia,etoolbox,fontspec}
%
\XeTeXgenerateactualtext=1
%
% mainfont, englishfont, sanskritfont, romanfont, devanagarifont, englishfont, vedafont
\defaultfontfeatures{Mapping=tex-text}
%Polyglossia 
%Script (default = Devanagari) passed to Fontspec for Sanskrit language if \devanagarifont or \sanskritfont not defined
\defaultfontfeatures{Mapping=tex-text}
\setmainlanguage{english}
\setotherlanguage{sanskrit}
%Fontspec
\setmainfont{FreeSerif}
%
\newfontfamily{\englishfont}[Scale=0.9]{FreeSerif}
\newfontfamily{\vedafont}[Scale=1.0]{Siddhanta}
\newfontfamily{\devanagarifont}[Scale=1.0]{Sanskrit 2003}
\usepackage[Latin, GeneralPunctuation, DevanagariMarks, DevanagariPreMarks, DevanagariExtended, DevanagariPostMarks, Gujarati, Tamil, Telugu, VedicExtensions, SuperscriptsAndSubscripts]{ucharclasses}
\setTransitionsForLatin{\englishfont}{}
\setTransitionTo{GeneralPunctuation}{\englishfont}
\setTransitionTo{SuperscriptsAndSubscripts}{\englishfont}
\setTransitionTo{DevanagariPreMarks}{\devanagarifont}
\setTransitionTo{DevanagariPostMarks}{\devanagarifont}
\setTransitionTo{DevanagariMarks}{\vedafont}
\setTransitionTo{DevanagariExtended}{\vedafont}
\setTransitionTo{VedicExtensions}{\vedafont}
%
\setTransitionsFor{Latin}
{\hyphenrules{english}\englishfont}
{\hyphenrules{sanskrit}\devanagarifont}
\setTransitionsFor{Devanagari}
{\hyphenrules{sanskrit}\devanagarifont}
{\hyphenrules{english}\englishfont}
%
\renewcommand{\small}{\fontsize{18}{22}\selectfont}
\renewcommand{\normalsize}{\fontsize{22}{30}\selectfont}
\renewcommand{\large}{\fontsize{24}{32}\selectfont}
\renewcommand{\Large}{\fontsize{26}{34}\selectfont}
%
\raggedbottom
\tolerance=1000
\emergencystretch=0em
\hyphenpenalty=10000
\hbadness=10000
%
\setcounter{secnumdepth}{-1}
\renewcommand\secheadstyle{\centering\Large\noindent}
\setbeforesecskip{0pt}
\setaftersecskip{4pt}
%
\newcommand{\ctext}[1]{\begin{center}{#1}\end{center}}
\newcommand{\clargetext}[1]{\begin{center}\large{#1}\end{center}}
%
\setlength{\parindent}{0pt}
\setlength{\headheight}{0pt} 
%
%hyperxmp and hyperref settings - pdf metadata and links within pdf
\usepackage{hyperxmp}
\usepackage[dvipdfmx-outline-open,bookmarks=true,bookmarksopen=true,bookmarksopenlevel=2,pdfpagelayout=OneColumn,pdfdisplaydoctitle=true]{hyperref}
%
%% https://tex.stackexchange.com/questions/107071/inserting-automatic-vertical-space-between-blocks-when-obeylines-is-active?noredirect=1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{linewise}
  {\parindent=0pt
   \obeyspaces\obeylines
   \begingroup\lccode`~=`\^^M
   \lowercase{\endgroup\def~}{\par\leavevmode}}
  {\ignorespacesafterend}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\stotra}{\setlength{\leftskip}{0em}\setlength{\rightskip}{0em}\linewise\center}
\newcommand{\bsanskrit}{\begin{stotra}}
\newcommand{\esanskrit}{\end{stotra}}
%%
\AddToShipoutPicture{%
        \ifodd\value{page}
            \newcommand{\vlm}{\thepage \hfill }
            \newcommand{\vrm}{\rightmark \hfill }
            \put(\paperwidth-\marginparsep-0.4in,0.5in)%left side
                {\rotatebox{90}{\parbox[t]{\textheight}{\makebox[\textheight-\topsep][l]{\vlm}}}}%
            \put(\marginparsep0.4in,0.5in)
                {\rotatebox{90}{\parbox[t]{\textheight}{\makebox[\textheight-\topsep][l]{\vrm}}}}%
         \else
            \newcommand{\vlm}{\hfill \rightmark }
            \newcommand{\vrm}{\hfill \thepage }
            \put(\paperwidth-\marginparsep-0.4in,1.2in)%left side
                {\rotatebox{90}{\parbox[t]{\textheight}{\makebox[\textheight-\topsep][l]{\vlm}}}}%
            \put(\marginparsep0.4in,1.2in)
                {\rotatebox{90}{\parbox[t]{\textheight}{\makebox[\textheight-\topsep][l]{\vrm}}}}%
        \fi

   \AtPageLowerLeft{%
     \put(\LenToUnit{0.6in},0){\rule{1pt}{\paperheight}}  % Rule on the left
     \put(\LenToUnit{10.4in},0){\rule{1pt}{\paperheight}}  % Rule on the right
   }
}%
%headings for pages
\copypagestyle{chapter}{plain}
\makeoddfoot{chapter}{}{}{}
\makeevenfoot{chapter}{}{}{}
\makeoddhead{chapter}{}{}{}
\makeevenhead{chapter}{}{}{}
\pagestyle{chapter}
%%%
\newcommand{\jverse}[1]{\begin{verse}[#1]\let\\=\par \setlength{\parskip}{0pt} \setlength{\parfillskip}{0pt}}%
\newcommand{\everse}{\end{verse}}

\begin{document}
\bsanskrit
\section{॥श्रीचण्डी प्रातःस्मरणम्॥}
\jverse{7.5in}
दिव्यायुधोर्जितसुनीलसहस्रहस्तां रक्तोत्पलाभचरणां महतीं परेशाम्॥१॥
श्लोकत्रयमिदं देव्याश्चण्डिकायाः पठेन्नरः। सर्वान्कामानवाप्नोति विष्णुलोके महीयते॥४॥
\everse
॥इति श्रीचण्डी प्रातःस्मरणं सम्पूर्णम्॥
\section{॥दुर्गाष्टोत्तरशतनामस्तोत्रम्॥}
\jverse{9in}
शतनाम प्रवक्ष्यामि शृणुष्व कमलानने। यस्य प्रसादमात्रेण दुर्गा प्रीता भवेत् सती॥१॥
गोरोचनालक्तककुङ्कुमेव सिन्धूरकर्पूरमधुत्रयेण। विलिख्य यन्त्रं विधिना विधिज्ञो भवेत् सदा धारयते पुरारिः॥२०॥
भौमावास्यानिशामग्रे चन्द्रे शतभिषां गते। विलिख्य प्रपठेत् स्तोत्रं स भवेत् सम्पदां पदम्॥२१॥
\everse
\esanskrit
\end{document}
%
0

Not an answer but a concern. I feel that the \obeylines\let^^M\linebreak is of very limited use in the verse environment. I ran some experiments, code below, which result in a 4 page document. I have not yet been able to post a graphic to SE; is it even possible for a 4 page document?

% verseprob5.tex  SE 514469  verse in memoir without \\ line endings
% proposed answer but Herman: left justified
\documentclass[ebook]{memoir}
\begin{document}

\linenumberfrequency{10}
\verselinenumbersleft

\textbf{Default verse}

\begin{verse}%[\versewidth]\obeylines\let^^M\linebreak%
%\vin 
Herman: \\
O'er every birth a star of fate presides, \\
And he that knows his orb of destiny, \\
May, by the changes of its radiance, tell \\
Whene'er his good or evil genius reigns. \\
This knowledge, earned by many a midnight vigil, \\
Has taught me that yon silver star is mine, \\
Which nightly, since I conn'd this wond'rous volume, \\
Hath dimm'd its fires, and warn'd me to forbear. \\
Yet have I still undaunted read, and now, \\
While pale and fitfully its beams shrink in, \\
The ingredients of a potent spell I mingle, \\
And but three drops of my own blood are wanting, \\
To give me proof that to my hests and bidding, \\
A spirit of dread ministry will come. \\
Why should the glorious planet fade at this? \\
\end{verse}

The above produces a result where every line is left-aligned and slightly 
indented from the left margin. Lines are numbered.

\vspace{\baselineskip}
\textbf{Obeylines verse}

\linenumberfrequency{10}
\verselinenumbersleft

\setlength{\vgap}{0.42in}
\begin{verse}\obeylines\let^^M\linebreak%
\vin Herman:
O'er every birth a star of fate presides,
And he that knows his orb of destiny,
May, by the changes of its radiance, tell
Whene'er his good or evil genius reigns.
This knowledge, earned by many a midnight vigil,
Has taught me that yon silver star is mine,
Which nightly, since I conn'd this wond'rous volume,
Hath dimm'd its fires, and warn'd me to forbear.
Yet have I still undaunted read, and now,
While pale and fitfully its beams shrink in,
The ingredients of a potent spell I mingle,
And but three drops of my own blood are wanting,
To give me proof that to my hests and bidding,
A spirit of dread ministry will come.
Why should the glorious planet fade at this?
\end{verse}

The above produces an output where every line is of equal width (except the first)
and well indented from the left margin. The spacing between words varies widely.

\vspace{\baselineskip}
\textbf{0 leftmargin}

\setlength{\vgap}{0.42in}
%\setlength{\vgap}{0pt}
\setlength{\vleftmargin}{0pt}
\begin{verse}\obeylines\let^^M\linebreak%
\vin Herman:
O'er every birth a star of fate presides,
And he that knows his orb of destiny,
May, by the changes of its radiance, tell
Whene'er his good or evil genius reigns.
This knowledge, earned by many a midnight vigil,
Has taught me that yon silver star is mine,
Which nightly, since I conn'd this wond'rous volume,
Hath dimm'd its fires, and warn'd me to forbear.
Yet have I still undaunted read, and now,
While pale and fitfully its beams shrink in,
The ingredients of a potent spell I mingle,
And but three drops of my own blood are wanting,
To give me proof that to my hests and bidding,
A spirit of dread ministry will come.
Why should the glorious planet fade at this?
\end{verse}

The above produces an output of constant width (except for the first line)
with very wide inter-word spacing.

\vspace{\baselineskip}
\textbf{0 leftmargin, 0.7textwidth}

\setlength{\vgap}{0.42in}
%\setlength{\vgap}{0pt}
\setlength{\vleftmargin}{0pt}
\setlength{\versewidth}{0.7\textwidth}
\begin{verse}[\versewidth]\obeylines\let^^M\linebreak%
\vin 
Herman:
O'er every birth a star of fate presides,
And he that knows his orb of destiny,
May, by the changes of its radiance, tell
Whene'er his good or evil genius reigns.
This knowledge, earned by many a midnight vigil,
Has taught me that yon silver star is mine,
Which nightly, since I conn'd this wond'rous volume,
Hath dimm'd its fires, and warn'd me to forbear.
Yet have I still undaunted read, and now,
While pale and fitfully its beams shrink in,
The ingredients of a potent spell I mingle,
And but three drops of my own blood are wanting,
To give me proof that to my hests and bidding,
A spirit of dread ministry will come.
Why should the glorious planet fade at this?
\end{verse}

The above produces an output of constant width (except for the first line)
with reasonable inter-word spacing, but well indented from the left margin.

\vspace{\baselineskip}
\textbf{minipage}

\begin{minipage}{0.7\textwidth}
Herman: \\
O'er every birth a star of fate presides,
And he that knows his orb of destiny,
May, by the changes of its radiance, tell
Whene'er his good or evil genius reigns.
This knowledge, earned by many a midnight vigil,
Has taught me that yon silver star is mine,
Which nightly, since I conn'd this wond'rous volume,
Hath dimm'd its fires, and warn'd me to forbear.
Yet have I still undaunted read, and now,
While pale and fitfully its beams shrink in,
The ingredients of a potent spell I mingle,
And but three drops of my own blood are wanting,
To give me proof that to my hests and bidding,
A spirit of dread ministry will come.
Why should the glorious planet fade at this?
\end{minipage}

\vspace{\baselineskip}
The above is typeset as prose in a narrow textwidth.

\end{document}

The regular verse environment typesets each line to its natural width and also typesets line numbers.

The begin{verse} \obeylines\let^^M\linebreak environments do not typeset line numbers. However, in all cases they produce a rectangular block of text obtained by changing the interword spacing on each line. To me this looks horrible, but by suitably changing the \versewidth this can be minimised but still there will be unequal interword spaces.

Maybe it is alright for Devenagari, about which I know nothing except having seen it when hiking in Nepal 30 years ago, but for latin-based scripts I think not.

You must log in to answer this question.

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