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)它触发开始一个新的缩进段落
  • \noindent:此命令的效果还取决于它的使用位置:
    • 在垂直模式下(段落之间或 a 中\vbox)它还会触发一个新的非缩进段落
    • 在水平模式(在一个段落或一个\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

LaTeX 段落和换行相关推荐

  1. LaTeX 中的段落和换行

    原  文:Paragraphs and new lines 译  者:Xovee 翻译时间:2020年5月24日 LaTeX 中的段落和换行 LaTeX 默认的排版已经是很好的了,不过我们有时候也需要 ...

  2. java word模板替换多行_java poi word模板替换段落的换行显示

    在poi操作word模板进行数据替换时,会存在替换的段落需要换行的情况,由于传入的都是字符串,之前在网上搜索过一些处理方法都没有效果,如给字符串添加:"\r","\r\n ...

  3. LaTeX 段落:段落缩进、段落间距、行距

    原  文:Paragraph formatting 译  者:Xovee 翻译时间:2021年8月12日 LaTeX 段落 LaTeX 默认的段落是比较容易阅读的.当然,有时候你也需要一种不同的段落样 ...

  4. html标题和段落标记,浅谈html标题,段落,换行,水平线,特殊字符

    原标题:浅谈html标题,段落,换行,水平线,特殊字符 标题 XML/HTML Code复制内容到剪贴板 一级标题 二级标题 对齐方式有left,center,right三种,缺省表示left 段落 ...

  5. day01【HTML基础】HTML表单【重点】、表单控件、水平线标签、段落和换行标签、超链接标签、图像标签、列表标签、div和span标签、 转义(实体)字符、 基本表格、合并表格

    HTML 一 HTML概述 超文本标记语言(Hyper Text Markup Language) 作用:搭建基础网页 超文本:具有普通文本的特性,同时还可以加入图片.视频.超链接等等. 标记:即标签 ...

  6. latex 公式如何换行

    参考latex 公式如何换行 - 云+社区 - 腾讯云 1.如图所示,我们先写个长公式. 2.可以看到,公式没有自动换行,而是跨过了一栏. 3.如图所示,在公式上下两端加上split.同时使用\\指明 ...

  7. Latex 使用\sout 造成段落无法换行

    目前来说我通过在越界单词的指定位置加入\newline进行强制换行可以避免越界的情况发生.譬如上图可以在文本中进行如下操作:Evolu- \newline tionary  划分的位置要正确,不然会出 ...

  8. word如何(以标题)另起一页(段落 --> 换行和分页 --> 段前分页)

    在需要另起一页的标题上右键 --> 段落 点击换行和分页 --> 段前分页,确定 参考文章:如何设置word文档的标题来开始一个新的页面?Word使所有章节分批从另一页开始的技巧

  9. html converttopdf无法换行_超文本标记语言的段落与换行显示!

    HTML 段落 段落是通过 标签定义的. 实际例子 This is a paragraph This is another paragraph 注释:浏览器会自动地在段落的前后添加空行.( 是块级元素 ...

最新文章

  1. 深入解析Angular Component的源码示例
  2. 用匈牙利算法求二分图的最大匹配
  3. apache +php + mysql_apache+php+mysql
  4. 小程序导航组件navigator活学活用
  5. android自定义画板,android 自定义控件 -- 画板
  6. list java语法_java基础语法 List
  7. Qt工作笔记-使用qrand与QTime产生随机数
  8. nginx启动重启停止
  9. MYSQL 调优和使用必读
  10. vue点击下载图片的实现
  11. 3. 什么是icmp?icmp与ip的关系_Java抽象类、内部、类接口到底是什么?
  12. 网站克隆:setoolkit社工软件
  13. JavaCV推流实战(MP4文件)
  14. 谷歌地球(google earth)中文专业版官方下载
  15. c# 图片裁剪并画中线
  16. 书中自有黄金屋系列5:读《正面管教》
  17. 中国货币供应量全球第一的反思
  18. 790. 数的三次方根
  19. 计算机操作系统——银行家算法
  20. Ansys workbench分析应用基础(2)

热门文章

  1. 从云安全到安全云 途隆云10年攻防练就“抗打”本领
  2. sklearn初探(一):sklearn安装
  3. Python模块学习 之zipfile zip文件操作
  4. 小学数学与计算机整合课优质教案,深研数学教材,目标精准把握 记“小学数学拓展性、整合性课程——基于数学的拓展课程”片区教研活动...
  5. 学习笔记(21):第一章: 路由与模板-Web前端技术与框架 2
  6. 墨卡托坐标以及墨卡托坐标转经纬度
  7. python绘制六角形(三个思路)
  8. POI兴趣点在地图显示上进行聚合算法的研究
  9. IDEA、MySQL提示Truncated incorrect DOUBLE value报错解决方法
  10. 智慧城市建设解决方案,智慧公安系统