Latex 多重换行
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
换行符接受括号中的可选参数,即垂直长度:
为了使其在字体大小方面更具可扩展性,您可以使用其他长度,例如
\\[3\baselineskip]
或\\[3ex]
。Line break accepts an optional argument in brackets, a vertical length:
To make this more scalable with respect to font size, you can use other lengths, such as
\\[3\baselineskip]
, or\\[3ex]
.您想要段落之间有更多空间吗?然后您可以更改参数
\parskip
。例如,尝试
这意味着段落之间的间距通常为 10pt,但最多可以增大或缩小 1pt。这意味着您可以让 LaTeX 将其更改为 1pt,以实现更好的页面布局。您可以删除加号和减号部分,使其始终为您指定的长度。
如果您尝试显示源代码,请尝试使用
listings
包或使用verbatim
。如果您尝试排版伪代码,请尝试algorithm
包。Do you want more space between paragraphs? Then you can change the parameter
\parskip
.For example, try
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 useverbatim
. If you are trying to typeset pseudocode, try thealgorithm
package.插入一些垂直空格
来缩放到字体,以
ex
(小写“x”的高度)为单位,有与可用行间距相关的各种预定义长度,您可能对baselineskip
。Insert some vertical space
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 inbaselineskip
.您可以使用 setspace 包来为您提供间距环境,例如
:使用逐字环境来精确控制代码的布局。
You can use the setspace package which gives you spacing environments, e.g.:
Or use a
verbatim
environment to control the layout of your code precisely.对于程序,你最好使用逐字记录或 alltt 环境,但如果你想要一个 LaTeX 不会抱怨的空行,请尝试
For programs you are really better off with a
verbatim
oralltt
environment, but if you want a blank line that LaTeX will not bitch about, try虽然逐字记录可能是最佳选择,但您也可以尝试命令
\smallskip
、\medskip
或猜猜看,\bigskip< /代码> .
引用此页面:
While
verbatim
might be the best choice, you can also try the commands\smallskip
,\medskip
or guess what,\bigskip
.Quoting from this page:
我发现当我在源代码中的 \\ 之后包含一个空行时,我的输出中也会出现一个空行。示例:
但是您是正确的,LaTeX 只允许您执行此操作一次。对于更通用的解决方案,允许您根据需要创建任意数量的空行,请使用 \null 来创建空段落。例子:
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:
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:
这适用于 pdfLatex。它会为您创建 2 条新线。
This works on pdfLatex. It creates 2 new lines for you.
也许尝试插入仅包含空格的行?
Maybe try inserting lines with only a space?
这对我有用:
我试图在 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}}\\