Latex 多重换行

发布于 2024-08-20 00:51:34 字数 347 浏览 4 评论 0原文

我使用 LaTeX 来打印课程的编程作业。我需要这样做:

my line of text blah blah blah

new line of text with blank line between 

我知道我可以使用双斜杠来换行 \\,但是 LaTeX 只会采用第一个换行符(抱怨更多)并开始一个新行,它会产生以下内容:

my line of text blah blah blah  
new line of text with blank line between 

我怎样才能获得额外的行在那里打断,以便我可以在文本行之间留出空间?

I use LaTeX to type up programming homeworks for classes. I need to do this:

my line of text blah blah blah

new line of text with blank line between 

I know I can use double slash to break lines \\, but LaTeX will only take the first line break (complains about more) and starts a new line, it produces this :

my line of text blah blah blah  
new line of text with blank line between 

How can I get that extra line break in there so I can have space between my lines of text?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

[浮城] 2024-08-27 00:51:34

换行符接受括号中的可选参数,即垂直长度:

line 1
\\[4in]
line 2

为了使其在字体大小方面更具可扩展性,您可以使用其他长度,例如 \\[3\baselineskip]\\[3ex]

Line break accepts an optional argument in brackets, a vertical length:

line 1
\\[4in]
line 2

To make this more scalable with respect to font size, you can use other lengths, such as \\[3\baselineskip], or \\[3ex].

樱娆 2024-08-27 00:51:34

您想要段落之间有更多空间吗?然后您可以更改参数\parskip

例如,尝试

\setlength{\parskip}{10pt plus 1pt minus 1pt}

这意味着段落之间的间距通常为 10pt,但最多可以增大或缩小 1pt。这意味着您可以让 LaTeX 将其更改为 1pt,以实现更好的页面布局。您可以删除加号和减号部分,使其始终为您指定的长度。

如果您尝试显示源代码,请尝试使用 listings 包或使用 verbatim。如果您尝试排版伪代码,请尝试 algorithm 包。

Do you want more space between paragraphs? Then you can change the parameter \parskip.

For example, try

\setlength{\parskip}{10pt plus 1pt minus 1pt}

This means that the space between paragraphs is usually 10pt, but can grow or shrink by up to 1pt. This means you give LaTeX the ability to change it up to one 1pt in order to achieve a better page layout. You can remove the plus and minus parts to make it always your specified length.

If you are trying to display source code, try the listings package or use verbatim. If you are trying to typeset pseudocode, try the algorithm package.

枫以 2024-08-27 00:51:34

插入一些垂直空格

blah blah blah \\
\vspace{1cm}

来缩放到字体,以ex(小写“x”的高度)为单位,有与可用行间距相关的各种预定义长度,您可能对 baselineskip

Insert some vertical space

blah blah blah \\
\vspace{1cm}

to scale to the font, use ex (the height of a lowercase "x") as the unit, and there are various predefined lengths related to the line spacing available, you might be particularly interested in baselineskip.

再见回来 2024-08-27 00:51:34

您可以使用 setspace 包来为您提供间距环境,例如

\documentclass{article}
\usepackage{setspace}
\begin{document}
\doublespace
my line of text blah blah blah

new line of text with blank line between
\end{document}

:使用逐字环境来精确控制代码的布局。

You can use the setspace package which gives you spacing environments, e.g.:

\documentclass{article}
\usepackage{setspace}
\begin{document}
\doublespace
my line of text blah blah blah

new line of text with blank line between
\end{document}

Or use a verbatim environment to control the layout of your code precisely.

ぃ弥猫深巷。 2024-08-27 00:51:34

对于程序,你最好使用逐字记录或 alltt 环境,但如果你想要一个 LaTeX 不会抱怨的空行,请尝试

my line of text blah blah blah\\
\mbox{ }\\  %% space followed by newline
new line of text with blank line between 

For programs you are really better off with a verbatim or alltt environment, but if you want a blank line that LaTeX will not bitch about, try

my line of text blah blah blah\\
\mbox{ }\\  %% space followed by newline
new line of text with blank line between 
臻嫒无言 2024-08-27 00:51:34

虽然逐字记录可能是最佳选择,但您也可以尝试命令 \smallskip\medskip 或猜猜看,\bigskip< /代码> .

引用此页面

这些命令只能在
段落分隔符(由
一个完全空白的行或
命令 \par)。这些命令输出
柔性或橡胶空间,
大约 3pt、6pt 和 12pt 高
分别,但是这些命令将
自动压缩或扩展
位,取决于要求
页面的其余部分

While verbatim might be the best choice, you can also try the commands \smallskip , \medskip or guess what, \bigskip .

Quoting from this page:

These commands can only be used after
a paragraph break (which is made by
one completely blank line or by the
command \par). These commands output
flexible or rubber space,
approximately 3pt, 6pt, and 12pt high
respectively, but these commands will
automatically compress or expand a
bit, depending on the demands of the
rest of the page

叹倦 2024-08-27 00:51:34

我发现当我在源代码中的 \\ 之后包含一个空行时,我的输出中也会出现一个空行。示例:

It's time to recognize the income tax as another horrible policy mistake like banning beer, and to return to the tax policies that were correct in the Constitution in the first place.  Our future depends on it.
\\

Wherefore the 16th Amendment must forthwith be repealed.

但是您是正确的,LaTeX 只允许您执行此操作一次。对于更通用的解决方案,允许您根据需要创建任意数量的空行,请使用 \null 来创建空段落。例子:

It's time to recognize the income tax as another horrible policy mistake like banning beer, and to return to the tax policies that were correct in the Constitution in the first place.  Our future depends on it.

\null

\null

\null

Wherefore the 16th Amendment must forthwith be repealed.

I find that when I include a blank line in my source after the \\ then I also get a blank line in my output. Example:

It's time to recognize the income tax as another horrible policy mistake like banning beer, and to return to the tax policies that were correct in the Constitution in the first place.  Our future depends on it.
\\

Wherefore the 16th Amendment must forthwith be repealed.

However you are correct that LaTeX only lets you do this once. For a more general solution allowing you to make as many blank lines as you want, use \null to make empty paragraphs. Example:

It's time to recognize the income tax as another horrible policy mistake like banning beer, and to return to the tax policies that were correct in the Constitution in the first place.  Our future depends on it.

\null

\null

\null

Wherefore the 16th Amendment must forthwith be repealed.
习惯成性 2024-08-27 00:51:34

\\\\

这适用于 pdfLatex。它会为您创建 2 条新线。

\\\\

This works on pdfLatex. It creates 2 new lines for you.

友谊不毕业 2024-08-27 00:51:34

也许尝试插入仅包含空格的行?

\ \\
\ \\

Maybe try inserting lines with only a space?

\ \\
\ \\
只有一腔孤勇 2024-08-27 00:51:34

这对我有用:

我试图在 Apple Pages 新的 LaTeX 输入区域中留出一个空间。我输入了以下内容,留下了干净的一行。

\mbox{\phantom{0}}\\

This just worked for me:

I was trying to leave a space in the Apple Pages new LaTeX input area. I typed the following and it left a clean line.

\mbox{\phantom{0}}\\

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文