使用 \ttfamily 进行糟糕的文本换行

使用 \ttfamily 进行糟糕的文本换行

这可能是一个愚蠢的问题,但我找不到解决方法。以下是 MWE:

\documentclass{article}

\usepackage[margin=1in]{geometry}

\usepackage{blindtext}

\begin{document}

\ttfamily
What can we do in this case? What should we do about this? What can we do in this case? What should we do about this?

\blindtext

\end{document}

结果是这样的:

结果

如您所见,右侧完全错位了。我尝试过设置,\hyphenpenalty但似乎没用。

怎样修复此问题?

答案1

类似如下: 断词、对齐和 ttfamily

这可能对你有用:

\documentclass{article}

\usepackage[margin=1in]{geometry}

\usepackage{blindtext}


\begin{document}

\ttfamily\hyphenchar\font=`\-\spaceskip=.5em plus .5em\xspaceskip=.5em
    What can we do in this case? What should we do about this? What can we do in this case? What should we do about this?
\blindtext

\end{document}

在此处输入图片描述

相关内容