诗句中可以省略 \\ 吗?

诗句中可以省略 \\ 吗?

据我所知,双行换行符会引入一个新段落。其中verse用于分隔节,也可以使用\\!。因此,在长篇独立诗歌的 LaTeX 源代码中,几乎每一行都以 结尾\\。是否可以改用单行换行符来换行?

本质上我有

\begin{verse}
There was a young lady of Niger \\
Who smiled as she rode on a tiger; \\
They returned from the ride \\
With the lady inside, \\
And the smile on the face of the tiger.

Second verse.
\end{verse}

而是希望能够写

\begin{verse}
There was a young lady of Niger
Who smiled as she rode on a tiger;
They returned from the ride
With the lady inside,
And the smile on the face of the tiger.

Second verse.
\end{verse}

答案1

这是一种可能性,使用\obeylines和变体egreg 的回答当 \obeylines 处于活动状态时,在块之间插入自动垂直空间重新定义标准verse环境:

\documentclass{article}

\makeatletter
\renewenvironment{verse}
  {\let\\\@centercr
    \list{}{\itemsep \z@
    \itemindent -1.5em
    \listparindent\itemindent
    \rightmargin \leftmargin
    \advance\leftmargin 1.5em}
    \item\relax\obeylines\begingroup\lccode`~=`\^^M
    \lowercase{\endgroup\def~}{\par\leavevmode}%
    \parskip=0pt plus 1pt%
  }
  {\endlist}
\makeatother               

\begin{document}

\begin{verse}
There was a young lady of Niger
Who smiled as she rode on a tiger;
They returned from the ride
With the lady inside,
And the smile on the face of the tiger.

Second verse.
\end{verse}

\end{document}

在此处输入图片描述

答案2

Gonzalo Medina 的问题很棒,回答也很棒!效果很好!针对当前版本的 MiKTeX 2.9 进行了改进:

\makeatletter
\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}}%
    \item\relax\obeylines\begingroup\lccode`~=`\^^M
    \lowercase{\endgroup\def~}{\par\leavevmode}%
    \parskip=0pt plus 1pt%
}
{\endlist}
\makeatother    

相关内容