LaTeX:诗歌环境中的非诗歌文本。

LaTeX:诗歌环境中的非诗歌文本。

我在 verse 环境中用 LaTeX 编写文本。但有些部分不应该出现在 verse 中。到目前为止,我所做的方式是定义一个以 开头\end{verse}并以 结尾的新环境\begin{verse}。我对明显错误的感觉告诉我这是非常错误的。如果这样做,正确的方法是什么?

以下是一个例子:

\newcommand[1]{\description}{\end{verse}{\itshape#1\/}\begin{verse}}

\begin{document}
\begin{verse}
This is
In verse!

\description{But this is not.}

But this is
Again!

\end{verse}
\end{document}

这确实有效,但这样做对吗?我真正想做的是在 verse 环境中放置一个以“标准”方式定位和对齐的框。但我不知道该怎么做。

答案1

@ eje2,@Stefan - 好的,我要发布我的答案,因为我在 Stefan 发布他的答案之前就研究过了。而且由于他的答案已经被检查为正确答案,我猜这是浪费时间。

但这似乎有效,如果 Stefan 有时间的话,我很想听听他为什么认为这是一个坏事。它不会“脱离”verse环境,而是在verse环境中工作,但也不会停止并重新启动verse环境。它似乎符合eje2的要求。

\documentclass{article}
\begin{document}

\newcommand{\escapefromverse}[1]{%
\itemindent -3em {\item \itshape #1}\itemindent -1.5em}

\begin{verse}
'Twas brillig, and the slithy toves \\
Did gyre and gimble in the wabe; \\
All mimsy were the borogoves, \\
And the mome raths outgrabe. 

\escapefromverse{ the next verse is the part I really like!}

``Beware the Jabberwock, my son! \\
The jaws that bite, the claws that catch!\\
Beware the Jubjub bird, and shun \\
The frumious Bandersnatch!''
\end{verse}

\end{document}

答案2

那个宏定义不能起作用。

  • 的第一个参数\newcommand是宏名称,而不是参数数量。因此, 应该\newcommand[1]{\description}{...}\newcommand{\description}[1]{...}

  • description在列表环境中已经普遍使用,这就是为什么该定义在 article 等标准类中会失败的原因。

如果我在定义中使用环境,我会使用\newenvironment它而不是。\newcommand

verse 环境是 LaTeX 列表环境。简洁的方法是结束该 verse 环境,编写其他文本,然后开始另一个 verse 环境。您的定义似乎只是一条捷径,因此可以节省打字工作。这就像重新定义环境以使其成为命令,只是因为它更短 - 但这样的工作可读性较差。

可以使用 minipage 环境或\parbox“逃离”verse 环境,或许还可以使用负缩进。

但我建议继续使用,\begin{verse} ... \end{verse}而不是引入隐藏发生的事情的命令。

相关内容