如何使用 `\texttt{Some text}` 进行自动连字?

如何使用 `\texttt{Some text}` 进行自动连字?

关于这个问题如何在 \texttt 内自动连字符?解释了很多事情,但我无法理解,或者无法使它发挥作用。

关于这个问题使用 ttfamily 字体进行连字的示例我展示了如何将其应用于ttfont所有文本,例如:

\ttfamily
Typewriter/teletype family - (encoding: T1, family: pcr, series: m, 
shape: n, size: 10.5, baseline: 11.0pt)

\texttt{Some text}但是我怎样才能将它包装成诸如环境之类的词语呢?

\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage{lmodern}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[main=english]{babel}
\usepackage[showframe,pass]{geometry}

\begin{document}

\frenchspacing
\texttt{Typewriter/teletype family - (encoding: T1, family: pcr, series: m, shape: n, size: 10.5, baseline: 11.0pt)}

\begin{texttt}
Typewriter/teletype family - (encoding: T1, family: pcr, series: m, shape: n, size: 10.5, baseline: 11.0pt)
\end{texttt}

\end{document}

没有texttt连字符,它会生成警告:

test2.tex:182: Overfull \hbox (11.9992pt too wide) in paragraph at lines 182--183[]\T1/lmtt/m/n/10 Typewriter/teletype family - (encoding: T1, family:
test2.tex:182: Overfull \hbox (33.7491pt too wide) in paragraph at lines 182--183\T1/lmtt/m/n/10 pcr, series: m, shape: n, size: 10.5, baseline: 11.0pt) 

enter image description here


有关的:

  1. 文本中的换行符
  2. 断词、对齐和 ttfamily

答案1

除了使用答案这里正如 Ulrike 所说,这基本上是当前的问题,你可以使用fontspec和编译一个更简单的解决方案xelatex

\documentclass[10pt,a5paper,twoside]{memoir}
\usepackage{lmodern}

\usepackage[english]{babel}
\usepackage[showframe]{geometry}

\usepackage{fontspec,lipsum}
\setmonofont{Latin Modern Mono}

\begin{document}

\frenchspacing


\fontspec{Latin Modern Mono}\footnotesize  

\lipsum[1-3]

\rmfamily


\lipsum[1-3]



\end{document}

相关内容