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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • li清除圆点_li标签的添加圆点

    li清除圆点_li标签的添加圆点不管是ul还是ol中的li前面始终有个小圆点,以前没有发现问题,都是直接给ul增加list-style:none;属性,可今天屡试不爽的属性出现问题了,上图通过两张截图可以清晰的看到虽然小圆点去掉了,但是还是占着位置。典型的占着**不**,而且还影响视图效果,怎么办?先看看样式,里面没有margin或者padding这类的东东,然后看看盒模型,果然:从盒模型可以看到ul有个padding,外围有m…

    2025年7月7日
    2
  • windows10命令行进入指定目录_命令行返回上一级目录

    windows10命令行进入指定目录_命令行返回上一级目录假定我们想进入指定目录E:\Software\apache-tomcat\apache-tomcat\bin在命令行输入cdE:\Software\apache-tomcat\apache-tomcat\bin+回车发现……啊哦没反应改为先输入E:+回车再输入cdSoftware\apache-tomcat\apache-tomcat\bin+回车问题解决…

    2022年10月15日
    4
  • 最全面、最详细web前端面试题及答案总结

    2021最全面、最详细web前端面试题及答案总结总结不易,希望可以帮助到即将面试或还在学习中的web前端小伙伴,祝面试顺利,拿高薪!本章是HTML考点的⾮重难点,因此我们采⽤简略回答的⽅式进⾏撰写,所以不会有太多详细的解释。我们约定,每个问题后我们标记『✨』的为⾼频⾯试题doctype的作⽤是什么?✨DOCTYPE是html5标准⽹⻚声明,且必须声明在HTML⽂档的第⼀⾏。来告知浏览器的解析器⽤什么⽂档标准解析这个⽂档,不同的渲染模式会影响到浏览器对于CSS代码甚⾄JavaScript

    2022年4月17日
    420
  • js给数组添加数据的方式/js 向数组对象中添加属性和属性值[通俗易懂]

    js给数组添加数据的方式/js 向数组对象中添加属性和属性值[通俗易懂]参考:https://www.cnblogs.com/ayaa/p/14732349.htmljs给数组添加数据的方式有以下几种:直接利用数组下标赋值来增加(数组的下标起始值是0)例,先存在一个有3个数据的数组:letarr=[1,2,3];console.log(arr);  此时输出的结果是[1,2,3]letarr=[1,2,3];arr[3]=5;console.log(arr);  此时的输出结果是[1,2,3,5];通过数组名[数组名.le.

    2022年6月11日
    238
  • 用python字符画生日快乐_如何用特殊符号组成“生日快乐”?

    用python字符画生日快乐_如何用特殊符号组成“生日快乐”?♥¸¸.•*¨*•♫♪祝你生日2113快乐哟♥¸¸.•*¨*•♫♪║╚╦5261═╦4102═╦═╦╦╗║╚╦╦═╣╚╣╚╦╝╠═╦╦╗║║║╬║1653╬║╬║║║║╬║║╔╣╔╣║║╬║╬║║║╚╩╩╩╣╔╣╔╩╗║╚═╩╩╝╚═╩╩╩═╩╩╩╗║ƸӜƷ●•٠·˙❦ஐ❦G☺dBlε§§U❦ஐ❦˙·٠•ƸӜƷ♪♫•*¨*•.¸¸HAPPYBIRTHDAY♪♫•*¨*•.¸¸生日快乐~…

    2022年5月8日
    90
  • java虚拟机内存大小_jvm内存分布

    java虚拟机内存大小_jvm内存分布目录一、虚拟机二、虚拟机组成1.栈栈帧2.程序计数器3.方法区对象组成4.本地方法栈5.堆GCGC案例一、虚拟机​同样的java代码在不同平台生成的机器码肯定是不一样的,因为不同的操作系统底层的硬件指令集是不同的。同一个java代码在windows上生成的机器码可能是0101…….,在linux上生成的可能是1100…….

    2022年10月20日
    3

发表回复

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

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