LaTeX 段落和换行
目录
- LaTeX 段落和换行
- 第一个例子
- 开始一个新段落
- 段落对齐
- flushleft and flushright environments
- `\raggedright和\raggedleft`
- 段落缩进
- 缩进相关命令注意事项
本文介绍了基本的 LaTeX 段落格式,包括如何更改文本对齐方式。可以在文章文本对齐和段落格式中找到更多详细信息和更多示例。
第一个例子
center让我们从一个示例开始,该示例通过在环境中编写两个居中的段落来排版它们。请注意如何通过在它们之间插入一个空行来开始一个新段落——尽管这是一种常用的方法,但这并不是开始一个新段落的唯一方法。
\begin{center}
Example 1: The following paragraph (given in quotes) is an
example of centred alignment using the center environment. ``La\TeX{} is a document preparation system and document markup
language. \LaTeX{} uses the \TeX{} typesetting program for formatting
its output, and is itself written in the \TeX{} macro language.
\LaTeX{} is not the name of a particular (executable) typesetting program, but
refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents."
\end{center}
此示例产生以下输出:

开始一个新段落
如上所述,开始新段落的一种方法是插入一个空行,但以下代码片段显示了使用该\par命令的替代解决方案:
This is text contained in the first paragraph.
This is text contained in the first paragraph.
This is text contained in the first paragraph.\par
This is text contained in the second paragraph.
This is text contained in the second paragraph.
This is text contained in the second paragraph.

段落对齐
默认情况下,LaTeX 中的段落是完全对齐的,即与左边距和右边距齐平。如果你想排版一个不合理的段落,你可以使用flushleft或者flushright环境。
flushleft and flushright environments
下一个示例演示了在flushleft和flushright环境中排版段落- 有关环境示例:
\section*{A paragraph typeset flush left}\begin{flushleft}
La\TeX{} is a document preparation system and document markup
language. \LaTeX{} uses the \TeX{} typesetting program for formatting
its output, and is itself written in the \TeX{} macro language.
\LaTeX{} is not the name of a particular (executable) typesetting program, but
refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.
\end{flushleft}\section*{A paragraph typeset flush right}\begin{flushright}
La\TeX{} is a document preparation system and document markup
language. \LaTeX{} uses the \TeX{} typesetting program for formatting
its output, and is itself written in the \TeX{} macro language.
\LaTeX{} is not the name of a particular (executable) typesetting program, but
refers to the suite of commands (\TeX{} macros) which form the markup
conventions used to typeset \LaTeX{} documents.
\end{flushright}
此示例产生以下输出:

\raggedright和\raggedleft
使用环境的替代方法,例如flushleft,flushright或center是所谓的“切换”命令:
\raggedright, 替代使用flushleft环境
\raggedleft, 替代使用flushright环境
\centering, 替代使用center环境
这些切换命令会更改从插入点到文档末尾的文本对齐方式——除非它们的效果被限制在一个组中或被另一个切换命令更改。
在以下示例中\raggedright,\raggedleft和的效果\centering已本地化,因为它们在由创建的组\begingroup ... \endgroup中使用。此外,请注意,在每种情况下,段落文本后面都有一个空行,在\endgroup命令之前,这会触发 LaTeX 排版段落,同时\raggedright,\raggedleft和应用的设置\centering仍然有效。

段落缩进
默认情况下,新段落的缩进量通常由一个参数控制,该参数\parindent的值可以使用命令设置\setlength;例如:
\setlength { \parindent }{ 20pt }
设置\parindent为 20pt。\parindent您可以通过设置为 0pt(或 0mm、0cm 等)或\noindent在段落开头使用命令来避免缩进。默认情况下,LaTeX 不会缩进文档部分中包含的第一段,如下例所示:
\setlength{\parindent}{20pt}\section*{This is a section}
\textbf{First paragraph} of a section which, as you can see, is not indented. This is more text in the paragraph. This is more text in the paragraph.\textbf{Second paragraph}. As you can see it is indented. This is more text in the paragraph. This is more text in the paragraph. \noindent\textbf{Third paragraph}. This too is not indented due to use of \texttt{\string\noindent}. This is more text in the paragraph. This is more text in the paragraph. The current value of \verb|\parindent| is \the\parindent. This is more text in the paragraph.

缩进相关命令注意事项
段落缩进受三个命令控制或影响:
\parindent: 存储段落缩进当前大小的参数\indent:此命令的效果取决于它的使用位置:-
-
- 在水平模式(在一个段落或一个
\hbox)或数学模式下,它插入一个宽度的空格(一个空框)\parindent
- 在水平模式(在一个段落或一个
-
-
-
- 在垂直模式下(在段落之间或在 a 中
\vbox)它触发开始一个新的缩进段落
- 在垂直模式下(在段落之间或在 a 中
-
\noindent:此命令的效果还取决于它的使用位置:-
-
- 在垂直模式下(段落之间或 a 中
\vbox)它还会触发一个新的非缩进段落
- 在垂直模式下(段落之间或 a 中
-
-
-
- 在水平模式(在一个段落或一个
\hbox)或数学模式下它没有效果:它被忽略
- 在水平模式(在一个段落或一个
-
以下示例演示\indent:
\noindent A new paragraph with some text, then an \verb|\indent|\indent command. Next, some inline math which also has an indent $y\indent x$. \verb|\indent| also works when used in an \verb|\hbox| such as \verb|\hbox{A\indent B}| which produces \hbox{A\indent B}.

PS:该文是从overleaf帮助文档翻译,链接:Paragraphs_and_new_lines


















