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


相关推荐

  • 什么是光栅化?_光栅成像

    什么是光栅化?_光栅成像光栅化首先,光栅化(Rasterize/rasteriztion)。这个词儿Adobe官方翻译成栅格化或者像素化。没错,就是把矢量图形转化成像素点儿的过程。我们屏幕上显示的画面都是由像素组成,而三维物体都是点线面构成的。要让点线面,变成能在屏幕上显示的像素,就需要Rasterize这个过程。就是从矢量的点线面的描述,变成像素的描述。如下图,这是一个放大了1200%的屏幕,前面是告诉计算机我有一个圆形,后面就是计算机把圆形转换成可以显示的像素点。这个过程就是Rasterize。参考链接如何理解Open

    2022年10月19日
    1
  • Tomcat安装及配置教程[通俗易懂]

    Tomcat安装及配置教程[通俗易懂]步骤一:下载Tomcat链接如下:https://tomcat.apache.org/注意:要根据自己的JDK版本选择Tomcat的版本。因本人java版本为10.0.2,故选择Tomcat9.0.31版本(Windows请自行选择64位或32位)步骤二:配置环境变量新建系统环境变量:修改系统Path(变量值末尾添加%CATALINA_HOME%\bin…

    2022年6月4日
    31
  • T-SQL之DECLARE,SET,PRINT语句[通俗易懂]

    T-SQL之DECLARE,SET,PRINT语句[通俗易懂]1.DECLARE语句DECLARE语句是数据声明语句,主要作用是声明局部变量、函数、存储过程或游标变量等;基本语法格式:DECLARE{{@local_variable[AS]data_type}|[=value]}[,…n]@local_variable即变量的名称,一定要以@开头,data_type为变量的数据类型,value是声明的变量的值(可选)…

    2022年8月20日
    5
  • 秒杀多线程第一篇 多线程笔试面试题汇总

    系列前言   本系列是本人参加微软亚洲研究院,腾讯研究院,迅雷面试时整理的,另外也加入一些其它IT公司如百度,阿里巴巴的笔试面试题目,因此具有很强的针对性。系列中不但会详细讲解多线程同步互斥的各种“招式”,而且会进一步的讲解多线程同步互斥的“内功心法”。有了“招式”和“内功心法”,相信你也能对多线程挥洒自如,在笔试面试中顺利的秒杀多线程试题。              ————-

    2022年4月11日
    45
  • ubuntu外接显示器无信号_ubuntu笔记本外接显示器

    ubuntu外接显示器无信号_ubuntu笔记本外接显示器Overview 主机配置 启用远程控制 安装软件和支持 其它 注意事项 Reference 主机配置系统:Ubuntu18.04 显卡:Intel集成显卡启用远程控制首先要确保开机能够自动启动远程控制。Ubuntu18自带远程桌面控制服务软件;这里不具体写步骤,自行上网搜索。确保上述远程桌面控制能够开机自启动!!!确保上述远程桌面控制能够开机自启动!!!确保上述远程桌面控制能够开机自启动!!!Ubuntu18自带的远程桌面控制

    2022年8月21日
    6
  • 免费手机号码归属地API查询接口

    免费手机号码归属地API查询接口

    2021年10月17日
    69

发表回复

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

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