我写了以下 tex 代码
\documentclass[12pt]{book}
\usepackage[contents={}]{background}
\usepackage{fontspec}
\setmainfont{Constantia}
\begin{document}
\LARGE
\chapter{Prayer}
True Gurus are very rare in this world, and of course, neither the true disciple! Only one who is full of Viveka (discrimination) and Vairagya (dispassion) is a qualified disciple.
\end{document}
我们可以看到,这段文本是左对齐的,但不知何故它也没有右对齐(见第 3 行)。我怎样才能使它对齐(左对齐和右对齐)?为了说明这个问题,我在这里写了一小段文字,但这个问题在很多地方都出现了。我看到默认情况下 latex 中的文本是对齐的,但不确定为什么在这里看不到。有人能告诉我为什么会出现这个问题以及如何解决它吗?谢谢。
答案1
当 TeX 无法换行时,问题就会显现出来。它会发出 Ovefull hbox 消息,然后需要手动干预才能解决问题。
可以通过连字、对齐、右对齐文本、重写等方式解决。任何字体都可能出现这种情况。在这个例子中,我使用了默认的 Latin Modern Regular。
避免行过满的另一种方法是使用
\emergencystretch
允许单词间空间拉伸。
我在 TeX 3.0 中由 Donald E. Knuth 引入,同时引入了 TeX 换行算法的第三遍。(为了阻止作者使用参数的较高值\tolerance
,因为这会影响整个文档。)
默认值为0pt
,如果作者(或编辑)不愿意或无法更改文本,则可以在特定段落上进行增强。
最佳使用值及其美学影响取决于列宽中单词之间的空格数以及移动到下一行的字符数。
无论使用什么参数值
\emergencystretch
,都应检查输出是否会产生难看的行。文本作者在使用 消除过满行之前,应考虑进行文本更改\emergencystretch
。
一些实验:
\documentclass[12pt]{article}
\usepackage{fontspec}
\begin{document}
\hsize=379pt
column width => \the\hsize
emergencystretch default => \the\emergencystretch
\LARGE
True Gurus are very rare in this world, and of course, neither the true disciple! Only one who is full of Viveka (discrimination) and Vairagya (dispassion) is a qualified disciple.
\bigskip
\normalsize \emergencystretch=7pt
emergencystretch => \the\emergencystretch
\LARGE
True Gurus are very rare in this world, and of course, neither the true disciple! Only one who is full of Viveka (discrimination) and Vairagya (dispassion) is a qualified disciple.
\bigskip
\normalsize \emergencystretch=0pt
emergencystretch => \the\emergencystretch\, (Using hyphenation)
\LARGE
True Gurus are very rare in this world, and of course, neither the true disciple! Only one who is full of Viveka (discrimination) and Vai\-ragya (dispassion) is a qualified disciple.
\bigskip
\normalsize \emergencystretch=0pt
emergencystretch => \the\emergencystretch\, (re--written)
\LARGE
True Gurus are very rare in this world, and of course, neither the true disciple! Only one who is full of Vairagya (dispassion) and Viveka (discrimination) is a qualified disciple.
\end{document}
答案2
将以下内容添加到您的文档前言中,看看是否能解决您的问题:
\usepackage{ragged2e}
\justifying