1

I want to display text in the mathtt font in two separate lines, but the following doesn't work

\documentclass{article}
\begin{document}
\title{Scratch}

$$\mathtt{Say\ hello} \newline \mathtt{to\ my\ little\ friend}$$

\end{document}

It's not working if I replace \newline by \\ nor if I have a single \mathtt{}. The result in all cases is as if there is no \newline or \\.

I need my text to be formatted this way to look like JEdit code for the theorem prover Isabelle. If you have any other suggestions for how to do this I'll be more than happy to hear.

1 Answers1

2

Do you mean something like this?

enter image description here

There is no need for \mathtt here at all.

Either use \ttfamily in a TeX group, e.g. wrapping a \begingroup...\endgroup or define a special environment for this, say tttt, which forms its own group automatically, so both versions provide the same output, although the details in the background are different.

Leave an empty line to force a 'linebreak'

\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}
  • Thanks. I also need to include some math symbols like \leq, \forall \cup etc. Is there a neater way to do it that wrapping them with $ $? Also, sometimes I need to have empty lines between the preceding and the following text, as with $$ $$. – Kyriakos Kats Feb 12 '18 at 12:33
  • @KyriakosKats: That's a different question. $$...$$ is deprecated and should not be used any longer. Either use \[....\] instead or something like an equation or align environment. –  Feb 12 '18 at 17:59