% Author: Alexey Shipunov, dactylorhiza@gmail.com

\ProvidesPackage{altverse}
	[2008/02/15 v0.3 Typesetting simple verses with `xtab' package]

\RequirePackage{array}
\RequirePackage{xtab}

% Typical environment, stanzas and subverses separated by `\\'
\newenvironment{Verse}[1][\relax]%
        {\tablehead{}%
        \tablefirsthead{}%
        \tabletail{}%
        \tablelasttail{}%
        \begin{center}%
        \global\def\V@TMP{#1}%
        \let\_\Vindent
                \begin{xtabular}{@{}>{\V@TMP}l@{}}}%
                {\end{xtabular}%
        \end{center}}

% Same, ragged left
\newenvironment{VERSE}[1][\relax]%
        {\tablehead{}%
        \tablefirsthead{}%
        \tabletail{}%
        \tablelasttail{}%
        \global\def\V@TMP{#1}%
        \let\_\Vindent
                \begin{xtabular}{@{}>{\V@TMP}l@{}}}%
                {\end{xtabular}}

% Same, with footnotes
\newenvironment{Verse*}[1][\relax]%
        {\tablehead{}%
        \tablefirsthead{}%
        \tabletail{}%
        \tablelasttail{}%
        \begin{center}%
        \global\def\V@TMP{#1}%
        \let\_\Vindent
        \renewcommand{\thempfootnote}{\fnsymbol{mpfootnote}}%
                \begin{mpxtabular}{@{}>{\V@TMP}l@{}}}%
                {\end{mpxtabular}%
        \end{center}}

% If you need to manually break one of these environments:
% Example: `\Vbreak{VERSE}'
\newcommand*{\Vbreak}[1]{\end{#1}\newpage\begin{#1}}

% For indents, abbreviations inside environments `\_'
% One may set indent for whole verse: \begin{Verse}[\Vindent{2}]
\newcommand*{\Vindent}[1][.5]{\hspace*{#1in}}

% Header CONTENTS, needs to be set BEFORE the environment
\newcommand*{\Vhead}[2][\Vhead@TMP]{\def\Vhead@TMP{#2}\V@TOC{#1}\V@MARK{#1}}
% Put information to the table of contents and headers
\newcommand*{\V@TOC}[1]{\markright{#1}}
\newcommand*{\V@MARK}[1]{\addcontentsline{toc}{subsection}{#1}}

% Actual header, centered, should be without `\\'
\newcommand{\VCtitle}{%
        \multicolumn{1}{@{}>{\V@TMP\centering\hspace{0pt}}p{\VheadSize}@{}}%
        {\VheadFormat\Vhead@TMP\par}\\*}
% Alternate header, with less space after
\newcommand{\Vctitle}{%
        \multicolumn{1}{@{}>{\V@TMP\centering\hspace{0pt}}p{\VheadSize}@{}}%
        {\VheadFormat\Vhead@TMP}\\*}
% Alternate header, ragged left, should be without `\\'
\newcommand{\VLtitle}{%
        \multicolumn{1}{@{}>{\V@TMP\raggedright\hspace{0pt}}p{\VheadSize}@{}}%
        {\VheadFormat\Vhead@TMP\par}\\*}
% Heading stars before verse
\newcommand{\Vstars}{\multicolumn{1}{@{}>{\V@TMP}c@{}}%
        {${*}\quad{*}\quad{*}$}\\*[\bigskipamount]}

% Subheader, should be without `\\'
\newcommand{\Vsub}[1]{%
        \multicolumn{1}{@{}>{\centering\hspace{0pt}}p{\VheadSize}@{}}%
        {#1}\\*}

% Dedication, should be _with_ `\\'
\newcommand*{\Vto}[1]{\multicolumn{1}{@{}>{\V@TMP}r@{}}%
        {\VtoFormat#1}}

% Annotation
\newcommand*{\Vat}[1]{\V@TMP\VatFormat#1}

% Hooks for redefinitions
\newcommand*{\VheadFormat}{\reset@font\large\bfseries}
\newcommand*{\VheadSize}{.4\columnwidth}
\newcommand*{\VtoFormat}{\reset@font\itshape}
\newcommand*{\VatFormat}{\reset@font\itshape}

\endinput
