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.

4

1 Answer 1

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}
2
  • 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 $$ $$. Feb 12, 2018 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.
    – user31729
    Feb 12, 2018 at 17:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .