詩句中的\\可以省略嗎

詩句中的\\可以省略嗎

據我所知,雙換行引入了一個新段落。其中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和變體艾格格的回答當 \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

貢薩洛·梅迪納提出了很好的問題,給出了很棒的答案!工作正常!目前版本 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    

相關內容