如何禁用LaTeX中特定部分的缩进?

Rad*_*lak 15 latex indentation

我需要在我的文档的一个部分中禁用缩进(子部分,具体而言).我怎样才能做到这一点?

默认缩进由indentfirst包提供.

god*_*byk 25

这取决于你想要根除缩进的普遍程度.但我想尝试的第一件事是设置\parindent0pt:

Some text with normal indentation...

{\parindent0pt % disables indentation for all the text between { and }

Text with no indentation.

Still no indentation.

}% restore indentation

Indented again.
Run Code Online (Sandbox Code Playgroud)

  • 我认为在LaTeX中你真的应该使用`\ setlength {\ parindent} {0pt}`.`\ parindent0pt`是纯TeX,它的使用可能会混淆LaTeX. (3认同)
  • @David` \noindent`只适用于第一段.以下段落将有其通常的缩进. (2认同)

小智 7

设置缩进的环境可能是一种解决方案?您可以在序言中对其进行定义,如下所示:

\newlength\mystoreparindent
\newenvironment{myparindent}[1]{%
\setlength{\mystoreparindent}{\the\parindent}
\setlength{\parindent}{#1}
}{%
\setlength{\parindent}{\mystoreparindent}
}
Run Code Online (Sandbox Code Playgroud)

在您的文档中,您将编写如下内容:

\begin{myparindent}{0pt}
This paragraph is not indented, ehm well, actually it is indented by 0pt
which is the same as not indented.

And this paragraph neither\ldots
\end{myparindent}
Run Code Online (Sandbox Code Playgroud)

或者,如果您想缩进较大的段落

\begin{myparindent}{5cm}
The first line of this paragraph is indented by 5 cm.

And so is the first line of the next paragraph.
\end{myparindent}
Run Code Online (Sandbox Code Playgroud)

  • @Michał:如果要使用环境,这很有用。 (2认同)