字体自动换行失败

字体自动换行失败

当我使用

\usepackage[T1]{fontenc}%A typewriter font.
\renewcommand*\familydefault{\ttdefault}

在序言中,而不是默认字体,漂亮的自动换行功能不再起作用,文字会随意地从页面上消失。我可以使用一些选项/包来让 LaTeX 恢复正常行为吗?

有什么想法吗?

答案1

文本未对齐、未加连字符且未设置右对齐:

在此处输入图片描述

\documentclass{article}

\usepackage[T1]{fontenc}%A typewriter font.
\renewcommand*\familydefault{\ttdefault}

\setbox0\hbox{\texttt{ }}
\dimen0=\wd0
\setlength\textwidth{50\dimen0}

\begin{document}

\bigskip\hrule\bigskip

in the preamble instead of the default font, the beautiful
word-wrapping that happens no longer works and words just go off the
page willy-nilly. Is there some option/package I can use to return
LaTeX to normal behaviour?

\bigskip\hrule\bigskip

{\hyphenchar\font`\- \hyphenation{th-e w-o-r-k-s th-ere l-a-t-e-x}\lefthyphenmin=0 \righthyphenmin=0
in the preamble instead of the default font, the beautiful
word-wrapping that happens no longer works and words just go off the
page willy-nilly.\\ Is there some option/package I can use to return
LaTeX to normal behaviour?

}

\bigskip\hrule\bigskip

{\raggedright

in the preamble instead of the default font, the beautiful
word-wrapping that happens no longer works and words just go off the
page willy-nilly. Is there some option/package I can use to return
LaTeX to normal behaviour?

}

\bigskip\hrule\bigskip

\end{document}

相关内容