3

This is a related question to:

How to change font size in verse environment?

Although this answer works very well, it does create a new Verse environment without the inherent functions of the verse package. In the case of LyX, it will be cumbersome to implement.

I wondered, if there is a way to define the font styles in the Preamble—font size, leading, style etc—with all the inherent proprieties of verse? It will keep the LyX interface clean and still modifiable through the Preamble.

ps. I tried \renewenvironment with simple \selectfont, it seems to erase the verse functions.

Shi Yuan
  • 895

2 Answers2

4

Aletrnative to Werner's, this solution doesn't rewriting of the whole environment. This goes into the preamble:

\newcommand{\versefont}{\itshape} % put here whatever font commands you want
\let\myoldverse\verse % now we store the original {verse}
\def\verse{\versefont\myoldverse} % and new {verse} just uses the font and original {verse}
yo'
  • 51,322
3

If you're using one of the standard document classes, you can merely add the following to your LaTeX preamble:

\makeatletter
\newcommand{\versefont}{}
\renewenvironment{verse}
               {\let\\\@centercr
                \list{}{\itemsep      \z@
                        \itemindent   -1.5em%
                        \listparindent\itemindent
                        \rightmargin  \leftmargin
                        \advance\leftmargin 1.5em}%
                \item\relax\versefont}
               {\endlist}
\makeatother

This will allow you to redefine \versefont to make your font selections in the preamble, or through the body text using an ERT.

If you're using the verse package, then your preamble should look like this in order to do the same:

\usepackage{verse}
\makeatletter
\newcommand{\versefont}{}
\renewenvironment{verse}[1][\linewidth]{
  \stepcounter{verse@envctr}%
  \setcounter{poemline}{0}\refstepcounter{poemline}%
  \setcounter{vslineno}{1}%
  \let\\=\@vscentercr
  \list{}{\itemsep \z@
          \itemindent  -\vindent%
          \listparindent\itemindent
          \parsep       \stanzaskip
          \ifdim #1 < \linewidth
            \rightmargin        \z@
            \setlength{\leftmargin}{\linewidth}%
            \addtolength{\leftmargin}{-#1}%
            \addtolength{\leftmargin}{-0.5\leftmargin}%
          \else
            \rightmargin        \leftmargin
          \fi
          \addtolength{\leftmargin}{\vindent}%
          \versefont}
  \item[]}{\endlist}
\makeatother

The above code just grabbed the verse environment definition from verse.dtx and inserted \versefont (defined to be empty).

Werner
  • 603,163
  • I'd put \versefont before \list in both cases, so that it can contain also font size changing commands. – egreg Feb 05 '13 at 07:58