# Custom environment with fancy text indentation

I am trying to typeset text by breaking it into smaller cameos, numbering each cameo, and putting a heading. See below for an example of how I want the typeset text to look.

The code with which I used to typeset the text is shown below.

\documentclass{article}

\usepackage{verse}

\newlength{\zlindenttext}
\newlength{\zlverticalspace}

\newlength{\saveleftmargini}
\setlength{\saveleftmargini}{\leftmargini}

\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother
\newenvironment{tverse}[1][]{
\compress\ifx\\#1\\\begin{verse}\else\begin{verse}[#1]\fi
}
{
\end{verse}\vspace{-\lastskip}\vspace{-1\baselineskip}
% No left indentation for verses
\setlength{\leftmargini}{\saveleftmargini}
}

\begin{document}

\begin{figure}[h!]
\small
\setlength{\zlindenttext}{5mm}
\setlength{\zlverticalspace}{4mm}
\begin{tabular}{p{6mm}@{\hspace{4mm}}p{100mm}@{\hspace{-5mm}}p{40mm}}
1.
&
\setlength{\leftmargini}{0\zlindenttext}
\begin{tverse}
And now the Lord says,\\
who formed me from the womb to be his servant,
\end{tverse}
&
\begin{tverse}
GOD SAYS:\\
His Servant
\end{tverse}
\\[\zlverticalspace]
2.
&
\setlength{\leftmargini}{1\zlindenttext}%
\begin{tverse}
to bring Jacob back to him,\\
and that Israel might be gathered to him,
\end{tverse}
&
\begin{tverse}
JACOB---RETURN\\
Israel---Gathered
\end{tverse}
\\[\zlverticalspace]
3.
&
\setlength{\leftmargini}{2\zlindenttext}%
\begin{tverse}
for I am honored in the eyes of the Lord,\\
and my God has become my strength---
\end{tverse}
&
\begin{tverse}
SERVANT HONORED\\
\end{tverse}
\\[\zlverticalspace]
4.
&
\setlength{\leftmargini}{0\zlindenttext}%
\begin{tverse}
he says:It is too light a thing,\\
that you should be my servant
\end{tverse}
&
\begin{tverse}
HE SAYS: TOO LIGHT\\
My Servant
\end{tverse}
\\[\zlverticalspace]
5.
&
\setlength{\leftmargini}{1\zlindenttext}%
\begin{tverse}
to raise up the tribes of Jacob\\
and to restore the preserved of Israel;
\end{tverse}
&
\begin{tverse}
JACOB---RAISED\\
Israel---Preserved
\end{tverse}
\\[\zlverticalspace]
6.
&
\setlength{\leftmargini}{2\zlindenttext}%
\begin{tverse}
I will give you as a light to the nations\\
that my salvation may reach to the end of the earth.''
\end{tverse}
&
\begin{tverse}
TO NATIONS\\
Salvation To All\end{tverse}
\end{tabular}
\end{figure}

\end{document}


It works, but I think that it could be better. What I would like is to be able to define a new environment with the following features:

1. Options to change the text size, the vertical spacing between cameos, the indentation of the text and the indentation of the headings.
2. Options to shift the text or headings to the left or right as more space may be needed.
3. A new command to specify the level of the text and the level of the heading.
4. Automatic numbering of the cameos.

What I want is for the following code below to work

\begin{rhetfigure}[text=small,vertical space=5mm,
\rhettext{0}{
And now the Lord says,\\
who formed me from the womb to be his servant,}
GOD SAYS:\\
His Servant}
\\
\rhettext{1}{
to bring Jacob back to him,\\
and that Israel might be gathered to him,}
JACOB---RETURN\\
Israel---Gathered}
...
\end{rhetfigure}


Unfortunately, I don't know enough LaTeX to make this work, and so I would appreciate any help! If you read so far, thank you for reading to the end.

-

I'd probably do something like this, adding more or less key options as needed.

In this updated version the tabular format for the verse is given a fixed width, so that the titles line up. However with this more rigid setting I couldn't make the text fit the specified text width, so I reduced the default indentation to 4mm and added an extra parameter overhang that specifies how much the title may stick in to the margin. (If you do not set this in this example, the setting is the same, but you get over full box warnings on the SERVANT HONORED line).

\documentclass{article}

\usepackage{keyval,array}

\newdimen\vtitlespace
\newdimen\verseindent
\newdimen\initialverseindent

\makeatletter
\define@key{tverse}{titlespace}{\setlength\vtitlespace{#1}}
\define@key{tverse}{overhang}{\def\vtitleoverhang{#1}}
\define@key{tverse}{verseindent}{\stlength\verseindent{#1}}
\define@key{tverse}{initialverseindent}{\setlength\initialverseindent{#1}}
\define@key{tverse}{font}{#1}
\define@key{tverse}{verseskip}{\setlength\parskip{#1}}
\define@key{tverse}{vformat}{%
\let\NC@find@V\relax\newcolumntype{V}{#1}}

\newenvironment{tverses}[1][]{%
\setlength\verseindent{4mm}%
\setlength\vtitlespace{5mm}%
\def\vtitleoverhang{0mm}%
\setlength\initialverseindent{4mm}%
\setlength\dimen@\initialverseindent
\setlength\parskip{\bigskipamount}%
\newcolumntype{V}{l}%
\par
\setkeys{tverse}{#1}%
}
{\par}

\newcommand\tverse[3][0]{
\dimen@\dimexpr\initialverseindent+#1\verseindent\relax
\par
\noindent
\refstepcounter{enumi}%
\theenumi.%
\hspace{\dimen@}%
\begin{tabular}[t]{@{}>{\arraybackslash}V@{}}
#2%
\end{tabular}
\hspace{\vtitlespace}%
\begin{tabular}[t]{@{}l@{}}
#3%
\end{tabular}%
\hspace*{-\vtitleoverhang}%
\par}

\makeatother

\begin{document}

\begin{tverses}[
font=\small,
vformat=>{\raggedright}p{7.6cm},
titlespace=2mm,
overhang=6mm
]

\tverse{
And now the Lord says,\\
who formed me from the womb to be his servant,
}{
GOD SAYS:\\
His Servant
}

\tverse[1]{
to bring Jacob back to him,\\
and that Israel might be gathered to him,
}{
JACOB---RETURN\\
Israel---Gathered
}

\tverse[2]{
for I am honored in the eyes of the Lord,\\
and my God has become my strength---
}{
SERVANT HONORED\\
}
\tverse{
he says:It is too light a thing,\\
that you should be my servant
}{
HE SAYS: TOO LIGHT\\
My Servant
}
\tverse[1]{
to raise up the tribes of Jacob\\
and to restore the preserved of Israel;
}{
JACOB---RAISED\\
Israel---Preserved
}

\tverse[2]{
I will give you as a light to the nations\\
that my salvation may reach to the end of the earth.''
}{
TO NATIONS\\
Salvation To All
}

\end{tverses}

\end{document}

-
Thank you for your answer. It works for the most part. However, it is missing one feature which is for the headings to be aligned. In the example text in my original post, the headings have a {0, 1, 2, 0, 1, 2} indentation pattern that can be clearly seen, but in your answer, that indentation pattern is lost. I wonder if there's any way to preserve the indentation pattern for the heading? That would require some way to control where the headings are placed that is independent of the length of the text. – I Like to Code Dec 28 '12 at 1:31
Code/image updated – David Carlisle Dec 29 '12 at 11:52
This is perfect! Thank you David for your reply and edit. Your code uses some features of LaTeX that are new to me (e.g. keyval, >{\arraybackslash}), so I'm glad I learned something new. Now I'll have to spend some time to understand how the code works. :-) – I Like to Code Dec 29 '12 at 14:18