
私はmathttフォントでテキストを2行に分けて表示したいのですが、次のようには機能しません
\documentclass{article}
\begin{document}
\title{Scratch}
$$\mathtt{Say\ hello} \newline \mathtt{to\ my\ little\ friend}$$
\end{document}
\newline
を に置き換えても\\
、 が 1 つしかない場合は機能しません。すべてのケースで、結果はまたは が\mathtt{}
存在しないのと同じになります。\newline
\\
定理証明器 Isabelle の JEdit コードのようにテキストをフォーマットする必要があります。これを行う方法について他に何か提案があれば、ぜひ教えてください。
答え1
こういうことですか?
ここは全く必要ありません\mathtt
。
\ttfamily
TeX グループ内で使用するか( をラップするなど)、\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}