5

環境に続く次の段落のインデントが抑制されている LaTeX ドキュメントに新しい環境を作成しようとしています。

\everyparに設定する{\setbox0\lastbox}と、TeX タイプセッターは次の段落の先頭でこれを実行し、インデントを削除すると言われました (TeXbook および LaTeX ソース) 。

\everypar{\setbox0\lastbox}

これが私が行うことですが、効果はありません(次の段落はまだインデントされています):

\newenvironment{example}
  {\begin{list}
     {}
     {\setlength\leftmargin{2em}}}
  {\end{list}\everypar{\setbox0\lastbox}}

私は LaTeX の内部構造をできる限り研究しました。LaTeX\endが私の設定を\endgroup無視\parする理由かもしれません。どちらも役に立ちません。私は知っていますが、これを自動的に行いたいです。\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.

関心のある内部ルーチンとスイッチは\@endpetrue、 、\@endparenvおよびその他のようです。ご協力いただきありがとうございます。

4

9 に答える 9

3

I couldn't get anything to work without redefining \end, but I'm certainly no expert.

The following is quite hacky, but worked in my limited testing. Of course this will interfere with nested environments (you should be able to redefine \begin to restore the old \end if you have problems).

\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
}
于 2010-04-30T03:41:17.943 に答える
2

これが私にとってうまくいくのと同じくらい簡単なこと:

\makeatletter
\newenvironment{example}{%
  \bgroup
    \list{}{}
}{%
    \endlist
    \@afterindentfalse
    \@afterheading
  \egroup
}
\makeatother

しかし、最初の \section (クラス "book" と "report" の場合は \chapter) が呼び出される前には機能しません。どうしてか分かりません。

于 2012-07-02T20:13:18.893 に答える
2

環境と次の行の間に空白行を入れないようにすることで、これを回避できませんか?

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}
% (No blank line)
This is more paragraph text. I don't want this indented, please.
于 2010-04-29T20:19:47.427 に答える
1

Ivan's answerを試しましたが、うまくいきませんでした。しかし、私はそれを機能させました!これが私がしたことです:

\makeatletter
\renewenvironment{quotation}{% 
\bgroup%
\let\oldend=\end%
\def\end##1{\oldend{##1}\csname @afterindentfalse\endcsname%
                        \csname @afterheading\endcsname}%
\list{}{\listparindent 1.5em%
\itemindent    \listparindent%
\leftmargin 1.5em%               This controls the size of the indentation
\rightmargin   \leftmargin
\parsep        \z@ \@plus\p@}%      This line reduces inter-paragraph space to normal values.
\item\relax%
}{%
\endlist%%
\egroup%
}
\makeatother

これの利点は、ブロッククォートを非常にうまくタイプセットし、ブロッククォートの後の段落からインデントを削除することです。

于 2011-09-05T10:31:44.583 に答える
0

定義の最後に\@afterindentfalse\@afterheadingを含めます。

于 2010-06-09T22:17:43.633 に答える
0

私も同じ問題を抱えていました。私はちょうどこれを使用しました:

\noindent \newenvironment
于 2016-04-22T12:40:29.380 に答える
-1

\everypar何をしているのか正確にわかっていない限り、トークンリストをいじってはいけません。使用する

\setlength{\parindent}{0pt}

ドキュメント全体のインデントを取り除きます。

于 2010-04-29T15:58:09.280 に答える
-2

環境を \noindent で終了すると、

于 2011-08-07T16:00:43.757 に答える