![\texttt 前换行](https://linux22.com/image/268205/%5Ctexttt%20%E5%89%8D%E6%8D%A2%E8%A1%8C.png)
我有文本,其中有一些命令应该写入\texttt
。这是一个单词,不应该被断开,应该放在下一行,但 LaTeX 不会在它前面放置换行符,而是将其放在段落的边界上。我不想放在那里\\\\*
或\newline
那里,因为我们的教授对这些命令很生气。
我使用 Texmaker 中的 pdflatex 进行翻译。
答案1
这取决于您是否想在那个地方放置一个明确的命令或使用普遍适用的设置。由于您没有提供示例,我从另一个答案中借用了一个示例,以展示各种可能性。
主要的选择是是否拉伸空白来补偿,或者是否打破这条线并使其变短。
\documentclass{scrartcl}
\usepackage[margin=15mm]{geometry}
\begin{document}
\def\test#1{%
Test test test test. Test test test test. Test test test test. Test test test test. Test test test #1{Supercalifragilisticexpialidocious} test. Test test test test.
Test test test test. Test test test test. Test test test test. Test test test test. Test test test test. #1{Supercalifragilisticexpialidocious} test test test test.
Test test test test. Test test test test. Test test test test. Test test test test. Test test test test. Test #1{Supercalifragilisticexpialidocious} test test test.
Test test test test. Test test test test. Test test test test. Test test test test. Test test test test. Test test #1{Supercalifragilisticexpialidocious} test test.
Test test test test. Test test test test. Test test test test. Test test test test. Test test test test. Test test test #1{Supercalifragilisticexpialidocious} test.
}
\test\texttt
\bigskip\hrule\bigskip
\begin{sloppypar}
\test\texttt
\end{sloppypar}
\bigskip\hrule\bigskip
{\setlength\emergencystretch{3cm}
\test\texttt
}
\bigskip\hrule\bigskip
\test{\hskip 0pt plus 3pt \penalty0 \hskip 0pt plus -3pt \texttt}
\end{document}