5

In Vietnamese, there is a type of poem (song thất lục bát -- double seven - six - eight) which goes like this

                       LIPSUM

  Lorem ipsum dolor sit amet, consectetur adipiscing
  Elit, sed do eiusmod tempor incididunt ut
    Labore et dolore magna aliqua. Ut
Enim ad minim veniam, quis nostrud exercitation ullamco
  Laboris nisi ut aliquip ex ea commodo
  Consequat. Duis aute irure dolor in reprehenderit 
    In voluptate velit esse cillum dolore
Eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat.

                                            Lipsum, 2018

(After two 7-word sentences is a 6-word sentence and then a 8-word sentence, and then another two 7-word sentences, and so on)

The alignment of the poem needs to be as above.

JosephHarriott's answer has helped me a lot in 2-level verse. However, I can't edit it so that it can output a 3-level verse.

Also, is it possible to make a n-level verse for any value of n? (this is not necessary right now, but it may help me in the future).

Any helps will be highly appreciated. Thanks in advance!

2 Answers 2

3

This 1st version just types as text, indenting as it goes. Therefore, it is left-aligned to the margin and can break mid-verse across page boundaries.

\documentclass[12pt]{article}
\usepackage{listofitems}
\newcommand\defineverse[1]{%
  \setsepchar{,}%
  \greadlist*\vindent{#1}%
}
\newcommand\setverse[1]{%
  \par\noindent%
  \setsepchar{\\}%
  \readlist*\versedata{#1}%
  \ifnum\listlen\versedata[]=\listlen\vindent[]\relax%
    \foreachitem\x\in\versedata{%
      \ifnum\xcnt=1\relax\else\\\fi%
      \mbox{}\hspace{\vindent[\xcnt]\dimexpr\verseindent\relax}%
      \x%
    }%
  \else%
    \textit{Line count does not correspond to verse definition.}
  \fi%
  \par%
}
\def\verseindent{1em}
\begin{document}
\defineverse{1,1,2,0,1,1,2,0}
\setverse{
Lorem ipsum dolor sit amet, consectetur adipiscing\\
Elit, sed do eiusmod tempor incididunt ut\\
Labore et dolore magna aliqua. Ut\\
Enim ad minim veniam, quis nostrud exercitation ullamco\\
Laboris nisi ut aliquip ex ea commodo\\
Consequat. Duis aute irure dolor in reprehenderit \\
In voluptate velit esse cillum dolore\\
Eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat.}
\bigskip Try to set a poorly composed verse:
\setverse{A\\b\\c\\d}
\end{document}

enter image description here

Here is a version that creates each verse in a stack. Therefore, it can be easily centered. But the verse cannot break across pages.

\documentclass[12pt]{article}
\usepackage{listofitems,stackengine}
\newcommand\defineverse[1]{%
  \setsepchar{,}%
  \greadlist*\vindent{#1}%
}
\newcommand\setverse[2][]{%
  \par%
  \ifx\relax#1\relax\else\centerline{#1}\medskip\fi%
  \setsepchar{\\}%
  \readlist*\versedata{#2}%
  \ifnum\listlen\versedata[]=\listlen\vindent[]\relax%
    \savebox\stackedbox{}%
    \foreachitem\x\in\versedata{%
      \stackengine{0pt}{\usebox{\stackedbox}}{%
      \mbox{\strut}%
      \hspace{\vindent[-\xcnt]\dimexpr\verseindent\relax}%
      \versedata[-\xcnt]}{O}{l}{T}{F}{S}%
    }%
    \centerline{\usebox{\stackedbox}}%
  \else%
    \textit{Line count does not correspond to verse definition.}
  \fi%
  \par\medskip%
}
\newcommand\attribution[1]{%
  \centerline{\hspace{\wd\stackedbox}\makebox[0pt][r]{#1}}%
  \par
}
\def\verseindent{1em}
\begin{document}
\defineverse{1,1,2,0,1,1,2,0}
\setverse[Lipsum]{
Lorem ipsum dolor sit amet, consectetur adipiscing\\
Elit, sed do eiusmod tempor incididunt ut\\
Labore et dolore magna aliqua. Ut\\
Enim ad minim veniam, quis nostrud exercitation ullamco\\
Laboris nisi ut aliquip ex ea commodo\\
Consequat. Duis aute irure dolor in reprehenderit \\
In voluptate velit esse cillum dolore\\
Eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat.}%
\setverse{
Lorem ipsum dolor sit amet, consectetur\\
Elit, sed do eiusmod tempor incididunt ut\\
Labore et dolore magna aliqua. Ut\\
Enim ad minim veniam, quis nostrud exercitation\\
Laboris nisi ut aliquip ex ea commodo\\
Consequat. Duis aute irure dolor in reprehenderit \\
In voluptate velit esse cillum dolore\\
Eu fugiat nulla pariatur. Excepteur sint occaecat.}%
\attribution{Lipsum, 2018}

\bigskip Try to set a poorly composed verse:

\fbox{\setverse{A\\b\\c\\d}}
\end{document}

enter image description here

4

You can try with the verse package.

\documentclass{report}
\usepackage{verse}
\begin{document}
\begin{verse}
\indentpattern{0010} % line indents
\begin{patverse}
First line \\
Second line \\
Third line \\
\hspace{-\vgap}Fourth line \\
\end{patverse}
\begin{patverse}
Fifth line \\
Sixth line \\
Seventh line \\
\hspace{-\vgap}Eifgth line \\
\end{patverse}
\end{verse}

\end{document}

See the verse package documentation (> texdoc verse) for more information.

EDIT

I have updated the above answer showing a better result.

% verseprob.tex  SE 462211
\documentclass{report}
\usepackage{verse}
\begin{document}
\indentpattern{00100} % line indents

\poemtitle{First verse}
\begin{verse}[0.13\textwidth]  % move verse to the right (centering)
\begin{patverse}
First line \\
Second line \\
Third line \\
\hspace{-\vgap}Fourth line \\
\end{patverse}
\begin{patverse}
Fifth line \\
Sixth line \\
Seventh line \\
\hspace{-\vgap}Eigth line \\
\end{patverse}
\end{verse}

\poemtitle{Second verse}
\begin{verse} % verse near left margin
\begin{patverse}
First line \\
Second line \\
Third line \\
\hspace{-\vgap}Fourth line \\
\end{patverse}
\begin{patverse}
Fifth line \\
Sixth line \\
Seventh line \\
\hspace{-\vgap}Eigth line \\
\end{patverse}
\end{verse}

\end{document}

enter image description here

You must log in to answer this question.