21

Is there any way of modifying the preamble, so instead of typing

$\mathtt{x}$ ...
\begin{eqnarray}
    \mathtt{y} & \mathtt{=} & \mathtt{z^\pi}
\end{eqnarray}

I can omit the \mathtt{...} commands?

u003f
  • 375

1 Answers1

21

You can add

 \everymath{\mathtt{\xdef\tmp{\fam\the\fam\relax}\aftergroup\tmp}}

to the document preamble (or the part of the document where you need this)

and

 \everydisplay{\mathtt{\xdef\tmp{\fam\the\fam\relax}\aftergroup\tmp}}

if you need display math as well.


In then in addition you may need to force the initialisation by putting

\setbox0\hbox{$ $} 

in the preamble otherwise the first expression may not be initialised correctly. This just makes an empty math expression on a box and discards it to avoid the problem.

David Carlisle
  • 757,742
  • This is great, thank you. How would I reset the presentation of math LaTeX for later use? E.g. if I want monospace for some math blocks in a document using your solution, but want the default math presentation for everywhere else in the document? – Rob Stewart Jul 01 '15 at 10:38