# Can I change all math output to use monospaced text?

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?

-
Have a look at the \everymath command, and also eqnarray-vs-align for reasons to avoid eqnarray – cmhughes Jul 11 '12 at 16:46

## 1 Answer

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.

-
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 1 '15 at 10:38