我的对齐(ragged2e)文本会出现这种可怕的情况,我不明白为什么

我的对齐(ragged2e)文本会出现这种可怕的情况,我不明白为什么

代码:(甚至有一条关于某些可怕之处的评论,但由于我几个月前就写了这个(在 TexLive 上,现在在 Kile 上编辑)我已经不记得了)

%%%%%%%%%% Introduction Page %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\center{
\large\textit{``Y'all just left jail, are the only hope of your neighbourhood, and you're already high as a kite.''}\\~\\
Introduction:
}\\
\justify{ %TODO whats with the justify terribleness?
\normalsize  To play the game, all you need is: a few standard, six sided dice, a supply of snacks and any social lubricant substance of choice. That last part's important.} \\
\justify{Name your characters. The names could just as well be nicknames. You begin the game with no equipment, but the clothes on you - so feel free to describe them. Pick Your Number ranging from two to five as their only numerical stat. Next pick - or come up with -  two skills and one problem, each of which can only appear once in your group.}\\ %TODO  - problem?? seriously no better name?
\justify{Together with your fellow players decide what you were `canned' for. Afterwards come up with - or roll for - a description of your `hood and your best friend, perhaps two of `em (in which case they're inseparable and work pretty much as one).
} \\[40mm]

文本(PDFTeX)最终看起来像这样,段落之间出现了意想不到的巨大间隙:

来自 kile viewer 的截图。

即使将所有 \justify{} 合并为一个似乎也解决不了任何问题。我甚至不知道间隙是什么时候出现的,我当时正忙着添加 fancyhdr 标题,重新调整一些表格,然后突然意识到页面看起来不对劲。可能是什么原因?

答案1

看起来您认为该命令\center需要参数,但事实并非如此。

\center仅因为环境已定义而存在center,但命令应该绝不可以在 LaTeX 文档中使用(但是也可以在另一个环境的定义中使用)。

有一个宣言的形式,center它被称为\centering,但与所有声明一样,它应该在组内使用,因此您无需设置对齐方式。顺便说一句,\justify具有与 相同的状态\center,因此它不带参数,不应在文档中使用;相应的声明形式是\justifying

输入文本更加容易。

\documentclass{article}

\begin{document}

\begin{center}\large\itshape
``Y'all just left jail, are the only hope of your neighbourhood, 
and you're already high as a kite.''
\end{center}

\begin{center}\large
Introduction:
\end{center}

To play the game, all you need is: a few standard, six sided dice, 
a supply of snacks and any social lubricant substance of choice. 
That last part's important.

Name your characters. The names could just as well be nicknames. 
You begin the game with no equipment, but the clothes on you --- 
so feel free to describe them. Pick Your Number ranging from two 
to five as their only numerical stat. Next pick --- or come up 
with ---  two skills and one problem, each of which can only appear 
once in your group.

Together with your fellow players decide what you were `canned' for. 
Afterwards come up with - or roll for - a description of your `hood 
and your best friend, perhaps two of `em (in which case they're 
inseparable and work pretty much as one).

\end{document}

我使用了两个不同的center环境,因为这两个部分在语义上是不同的。您可能希望定义自己的结构,可能修改“简介”的标准分段命令,这将有助于确保整个文档的一致性。

在此处输入图片描述

更多细节

当你打开一个center环境时,LaTeX 会在内部启动基本环境trivlist,并使用 设置文本居中\centeringtrivlist环境还负责添加一些垂直空间。

justify的环境也ragged2e类似,不同之处在于它的设置理由基本与 一样\justifying

一般而言,如果声明在环境中(或在一个组中,但这需要小心)正确地隔离,则不需要再次设置理由{...},它们的效果将随着环境的结束而结束。

因此,在上面的代码中,声明的效果\large\itshape以 结束,\end{center}并且 的效果也\centering以 结束。因此,接下来的段落再次设置了理由,而无需指定它。

您的代码中堆积了四个未完成的trivlist部分,LaTeX 变得非常混乱。

答案2

除了 egreg 所说的,不要\\在普通文本中使用换行符 ( )。要结束一个段落,只需使用一个空行(或\par),不要使用\\[40mm]在段落之间设置垂直空格。仅将此代码保留到表格环境中的行尾。

另一方面,尽可能使用语义命令来告诉 LaTeX 文本的每个部分是什么,而不是如何格式化它。我的意思是,与其命令“以大字体居中输入引言”,不如命令“将引言作为节标题输入”(也就是说只输入)\section*{Introduction}。如果节标题的默认格式不符合您的口味,那么更改节标题的定义会更容易、更清晰、更安全,为每个标题提供几个格式命令。如果您想制作引文、标题或其他纯文本,同样适用。

不清楚您是否遇到了右边距对齐问题或仅仅是垂直间隙问题。对于第一个问题,使用 babel 设置语言并在需要时使用正确的连字符,并 microtype改善段落的适合度(适度以避免难看的副作用)。

最后,关于垂直间隙,序言的许多设置甚至实际页面前后的内容都会影响结果,因此一段文本不足以正确显示问题。您必须制作一个精简版的文档,删除与问题无关的任何内容,但保留运行代码所需的任何内容“按原样”并获得包含此问题且仅包含此问题的 PDF。即最小工作示例 (MWE)。

也就是说,段落之间的间隙通常是由于一页内容不足以完全填满一页而引起的,而不是将所有多余的空间留在底部,而是将其分布在内容中,以使页面的底部边距与完全填满的页面相同。这是一个不错的功能,但只有当多余的空间很小时才适用,否则获得的边距\flushbottom甚至比\raggedbottom边距更差。

下面的 MWE 显示第一页的空间过大,因为框太大,必须跳转到下一页。如果使用,空间将被分配\flushbottom。用 替换此命令\raggedbottom(或直接删除它),只有一个难看的结尾间隙,但由 控制的段落之间也可能有一些空间\parskip。但是,如果删除框,则无论是否使用,都不会出现难看的间隙,\flushbottom因为没有框,就不需要大幅拉伸前几段:

平均能量损失

\documentclass{article}
% this produce only gaps:
\setlength{\parskip}{1em plus 1em}
\usepackage[
font={itshape,raggedright,large,centering},
indentfirst=false]{quoting}
\usepackage[english]{babel} 
\usepackage[stretch=50,shrink=70]{microtype}
\usepackage{titlesec}
\titleformat{\section}[block]{\Large\filcenter}{}{1em}{}
\usepackage{lipsum} % just for dummy text after the box

\begin{document}

% this produce huge gaps only if you acthe \fbox of line 45
% \flushbottom


\begin{quoting} 
``Y'all just left jail, are the only hope of your neighbourhood, 
and you're already high as a kite.''
\end{quoting}

\section{Introduction:}

To play the game, all you need is: a few standard, six sided dice, 
a supply of snacks and any social lubricant substance of choice. 
That last part's important.

Name your characters. The names could just as well be nicknames. 
You begin the game with no equipment, but the clothes on you --- 
so feel free to describe them. Pick Your Number ranging from two 
to five as their only numerical stat. Next pick --- or come up 
with ---  two skills and one problem, each of which can only appear 
once in your group.

Together with your fellow players decide what you were `canned' for. 
Afterwards come up with - or roll for - a description of your `hood 
and your best friend, perhaps two of `em (in which case they're 
inseparable and work pretty much as one).

% box that cause one/several horrible gaps
\fbox{\begin{minipage}[b][.7\textheight][c]{1cm}    foo \end{minipage}}

\lipsum[1-5]

\end{document}

相关内容