LaTeX 换行、换页、空白空间[通俗易懂]

LaTeX 换行、换页、空白空间[通俗易懂]一般来说,我们不推荐你改变默认的LaTeX文档结构。当然,我们有时候也有这个需求。所以,在本文中,我们将解释如何在文档中插入空行,以及插入任意的空白。

大家好,又见面了,我是你们的朋友全栈君。

原  文:Line breaks and blank spaces
译  者:Xovee
翻译时间:2021年8月19日

换行、换页、空白空间

一般来说,我们不推荐你改变默认的 LaTeX 文档结构。当然,我们有时候也有这个需求。所以,在本文中,我们将解释如何在文档中插入空行,以及插入任意的空白。

介绍

分割文字的最佳方法是创建一个新的段落。你只需要在代码中添加一个空白行就可以了:

\documentclass{article}
\begin{document}
This paragraph contains no information
and its purpose is to provide an example on how to start a new paragraph.
As you can see,
single line
break in the code
acts as a space in text.

However, leaving an empty line starts a new paragraph.
\end{document}

在这里插入图片描述

这并不是唯一的添加换行的办法,我们接下来介绍另外两种方法。

换行

\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}
Something in this document. This paragraph contains no information 
and its purposes is to provide an example on how to insert white 
spaces and lines breaks.\\
When a line break is inserted, the text is not indented, there 
are a couple of extra commands do line breaks. \newline
This paragraph provides no information whatsoever. We are exploring 
line breaks. \hfill \break
And combining two commands
\end{document}

在这里插入图片描述
上面的文档中出现的三个命令都有着相同的功能:
\\(两个反斜杠)

  • \newline
  • \hfill \break

换页

你可以使用这两个命令来插入换行符:

  • clearpage
  • newpage
\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}
Something in this document. This paragraph contains no information and 
its purposes is to provide an example on how to insert white spaces 
and lines breaks.\\
When a line break is inserted, the text is not indented, there are a 
couple of extra commands do line breaks. \newline
This paragraph provides no information whatsoever. We are exploring 
line breaks. \hfill \break
And combining two commands
...
...

\begin{figure}
\centering
\includegraphics[width=3cm]{overleaf-logo}
\caption{Overleaf logo}
\end{figure}

Hello,  here  is  some  text  without  a  meaning...
\clearpage

在这里插入图片描述
如果你使用了\clearpage命令,并且页面上有着多个浮动元素(例如表格和图片等),它们将会挤压到下一页。例如,在上面的例子中,我们插入了三张同样的图片。因为换页符插入的位置处于三张图片均展示之前,剩余的图片将会在一个空白页展示,即在换行符之后的文本之后。

如果你不想这样,那么你可以使用\newpage命令。

\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}
\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}
Something in this document. This paragraph contains no information and 
its purposes is to provide an example on how to insert white spaces 
and lines breaks.\\
When a line break is inserted, the text is not indented, there are a 
couple of extra commands do line breaks. \newline
This paragraph provides no information whatsoever. We are exploring 
line breaks. \hfill \break
And combining two commands
...
...

\begin{figure}
\centering
\includegraphics[width=3cm]{overleaf-logo}
\caption{Overleaf logo}
\end{figure}

Hello,  here  is  some  text  without  a  meaning...
\newpage

在这里插入图片描述
在这个例子中,图像的位置将会配合文字的排版。

水平空白空间

插入水平空白空间的命令是\hspace

Horizontal \hspace{1cm} spaces can be inserted manually. Useful 
to control the fine-tuning in the layout of pictures.

Left Side \hfill Right Side

\hspace{1cm}
插入长度为一厘米的水平空白空间。你也可以使用其他类型的 LaTeX 单位。

\hfill
填满剩余的水平空间。

命令\hrulefill\dotfill的行为和\hfill类似,不过它们插入的不是空白,而是线条和点。

垂直空白空间

类似于水平空白空间:

Text at the top of the page. Text at the top of the page. 
Text at the top of the page. Text at the top of the page. 
Text at the top of the page. Text at the top of the page. 
Text at the top of the page.

\vspace{5mm} %5mm vertical space

This text still at the top, 5mm below the first paragraph.

\vfill

Text at the bottom of the page.

在这里插入图片描述
\vspace{5mm}
插入长度为五毫米的垂直空间。你也可以使用其他 LaTeX 长度单位。

\vfill
填满剩余的垂直空间。

\smallskip
插入一个长度为 3pt 加减 1 的垂直空间(具体取决于文档类型、剩余的可用空间等)

\medskip
插入一个长度为 6pt 加减 2 的垂直空间(具体取决于文档类型、剩余的可用空间等)

\bigskip
插入一个长度为 12pt 加减 4 的垂直空间(具体取决于文档类型、剩余的可用空间等)

参考指南

其他换行命令

  • \\*
    (两个反斜杠和一个星号)换行,但不允许换页
  • \break
    换行,但不填满当前行。这样做会使得排版很难看。为了填满当前行,你可以这样做:\hfill\break。这样做的效果与\newline\\相同。
  • \linebreak[number]
    这个命令的效果是换行。命令的参数是零到四,零的意思是这个命令很容易被忽略,四的意思是它无论如何都要换行。如果你使用了这个命令,LaTeX 会尝试找到最佳的换行方式。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/146649.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • IDEA卸载和删除注册表

    IDEA卸载和删除注册表当我们在用idea的时候,idea的环境出现了莫名其妙的问题,怎么也找不到问题原因的时候可以试着把idea卸载重新安装。但是如果你卸载的时候没有删除干净注册表里的信息。就算再次安装回来也还是解决不了问题。如何删除干净IDEA1.卸载程序打开控制面板,选中idea点击卸载;2.删除注册表windows+R输入regedit进入注册表,右键一级菜单HKEY_CURRENT_USER,右键查找,输入idea,会找到jetbrains,…

    2022年6月29日
    545
  • sqlserver事务锁死_sql触发器格式

    sqlserver事务锁死_sql触发器格式一、触发器触发器(trigger)是SQL server 提供给程序员和数据分析员来保证数据完整性的一种方法,它是与表 事件相关的特殊的存储过程,它的执行不是由程序调用,也不是手工启动,而是由事件来触发,当对一个表 进行操作( insert,delete, update)时就会激活它执行。触发器经常用于加强数据的完整性约束和业务 规则等。 触发器可以从 DBA_TRIGGERS ,USER_TR…

    2022年8月18日
    4
  • 倒立摆:Simulink建模[通俗易懂]

    倒立摆:Simulink建模[通俗易懂]倒立摆:Simulink建模内容在此页面中,我们概述了如何建立倒立摆系统的模型,刹车使用Simulink及其附件进行仿真。然后可以使用非线性仿真来测试模型的线性化版本的有效性。仿真模型还可以用于评估基于线性化模型设计的控制方案的性能。物理设置和系统方程式在此示例中,我们将考虑带有手推车的倒立摆系统的二维版本,其中放置被约束为在下图所示的垂直平面中移动。对于该系统,控制输入是使推车水平移动的力,输出是摆的角位置和推车的水平位置。对于此示例…

    2022年8月18日
    18
  • 智能车图像处理-阳光算法[通俗易懂]

    智能车图像处理-阳光算法[通俗易懂]阳光算法见仁见智,多阈值OSTU和模糊OSTU是我参考论文进行改进的,整篇都放在了我的毕业论文中,毕业前不会把程序粘在这里,请读者见谅。

    2022年5月13日
    36
  • alsa sample rate跟踪 <1>

    alsa sample rate跟踪 <1>alsasamplerate跟踪本计划全部放在一篇中,后来发现太长。因此截取成四篇,一口气看800多行,确实够烦的!之前以为alsalib中的rateplugin之所以被调用,是因为在asound.conf中指定了硬件的samplerate,例如rate48000。但实际测试下来,发现不是这么回事。无论asound.conf中是否有rate48000,驱动中得到

    2022年10月16日
    0
  • resnet讲解_resnet50网络结构详解

    resnet讲解_resnet50网络结构详解1、 RestNet网络1.1、 RestNet网络结构ResNet在2015年被提出,在ImageNet比赛classification任务上获得第一名,因为它“简单与实用”并存,之后很多方法都建立在ResNet50或者ResNet101的基础上完成的,检测,分割,识别等领域里得到广泛的应用。它使用了一种连接方式叫做“shortcutconnection”,顾名思义,shortcut就是“…

    2022年10月7日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号