
我想在兩行中顯示 mathtt 字體的文本,但以下不起作用
\documentclass{article}
\begin{document}
\title{Scratch}
$$\mathtt{Say\ hello} \newline \mathtt{to\ my\ little\ friend}$$
\end{document}
\newline
如果我替換為\\
或如果我有一個 則它不起作用\mathtt{}
。所有情況下的結果都好像沒有\newline
或\\
。
我需要以這種方式格式化我的文本,使其看起來像定理證明者 Isabelle 的 JEdit 程式碼。如果您對如何執行此操作有任何其他建議,我將非常樂意聽到。
答案1
你的意思是這樣的嗎?
\mathtt
這裡根本沒有必要。
要么\ttfamily
在 TeX 組中使用,例如包裝 a \begingroup...\endgroup
,要么為此定義一個特殊環境,例如tttt
,它自動形成自己的組,因此兩個版本提供相同的輸出,儘管背景中的細節不同。
留空行強制“換行”
\documentclass{article}
\title{Scratch}
\newenvironment{tttt}{\ttfamily}{}
\begin{document}
\begingroup
\ttfamily Say hello
to my little friend
\endgroup
\begin{tttt}
Say hello
to my little friend
\end{tttt}
\end{document}