在 LaTeX 中抑制环境后的缩进

glt*_*lts 5 latex indentation

我正在尝试在 LaTeX 文档中创建一个新环境,其中该环境后面的下一段中的缩进被抑制。

我被告知(TeXbook 和 LaTeX 源代码),通过设置\everypar{\setbox0\lastbox},TeX 排字机将在下一段的开头执行此操作,从而删除缩进:

\everypar{\setbox0\lastbox}
Run Code Online (Sandbox Code Playgroud)

这就是我所做的,但没有效果(以下段落仍然缩进):

\newenvironment{example}
  {\begin{list}
     {}
     {\setlength\leftmargin{2em}}}
  {\end{list}\everypar{\setbox0\lastbox}}
Run Code Online (Sandbox Code Playgroud)

我已经尽我所能地研究了 LaTeX 的内部结构。似乎例程在某个时刻\end\endgroupand \par,这可能是 LaTeX 忽略我的设置的原因\everypar\global也没有帮助。我知道\noindent但想自动执行此操作。

示例文档片段:

This is paragraph text. This is paragraph text, too.

\begin{example}
  \item This is the first item in the list.
  \item This is the second item in the list.
\end{example}

This is more paragraph text. I don't want this indented, please.
Run Code Online (Sandbox Code Playgroud)

内部例程和感兴趣的开关似乎是\@endpetrue\@endparenv等等。感谢您的帮助。

Iva*_*rus 3

如果不重新定义,我就无法让任何东西发挥作用\end,但我当然不是专家。

以下内容相当hacky,但在我有限的测试中有效。当然,这会干扰嵌套环境(如果遇到问题,您应该能够重新定义\begin以恢复旧环境)。\end

\newenvironment{example}{%
  \bgroup
  \let\oldend=\end
  \def\end##1{\oldend{##1}\csname @afterindentfalse\endcsname
                          \csname @afterheading\endcsname}
  \begin{list}{}
    {\setlength\leftmargin{2em}}
  }{%
  \end{list}
  \egroup
}
Run Code Online (Sandbox Code Playgroud)