文本超出右边距,使用 \texttt{}

文本超出右边距,使用 \texttt{}

我之前问过这个问题,但它与其他问题相关联,并被视为已关闭。我检查了链接问题的答案,它们没有回答我的问题,所以我再试一次。以下文本开始一个段落。排版时,第二句中的单词“the”打破了右边距:

Graunt decided to pen a scientific paper to show to Petty. In 1662 he produced
a series of tables based on mortality records. His article was called \texttt{Natural and
Political Observations Mentioned in a Following Index, and Made Upon the
Bills of Mortality.}

我可能可以通过改写前面的文字来解决这个问题,但如果能理解为什么这种情况会在这里发生,而不是在文档的其他地方发生,那就更好了。

答案1

我可以以某种方式重现该问题:

\documentclass[12pt]{article}

\begin{document}

Graunt decided to pen a scientific paper to show to Petty. In 1662 he produced
a series of tables based on mortality records. His article was called
\texttt{Natural and Political Observations Mentioned in a Following Index,
and Made Upon the Bills of Mortality.}

\end{document}

在此处输入图片描述

关于打字机类型,您应该了解以下几点:

  1. 它没有设置词间空间的灵活性;
  2. 它不受连字符的限制;
  3. 单词间距与字母宽度相同;
  4. 它完全不适合这份工作。

第 4 个问题与其他三个问题无关,可以得到修复。

\documentclass[12pt]{article}

\newcommand{\opus}[1]{%
  \begingroup
    \spaceskip=\fontdimen2\font plus \fontdimen3\font minus \fontdimen4\font
    \xspaceskip=\fontdimen7\font\relax
    \ttfamily
    %\hyphenchar\font=`\-
    #1%
  \endgroup
}

\begin{document}

Graunt decided to pen a scientific paper to show to Petty. In 1662 he produced
a series of tables based on mortality records. His article was called
\opus{Natural and Political Observations Mentioned in a Following Index,
and Made Upon the Bills of Mortality.}

\end{document}

在此处输入图片描述

您可能决定取消注释该\hyphenchar行(但请注意,打字机类型的所有文本都可能会被连字符连接)。

然而,这并不能解决问题 4:结果非常糟糕。

将定义替换\opus

\newcommand{\opus}[1]{\textit{#1}}

结果会看起来好得多:

在此处输入图片描述

现在您可以选择。

相关内容