# Applying a style to all math blocks in an environment

I'm writing a math paper, and I want to change the style for the statement of theorems to \tt. However, I want this to affect things within math mode as well as normal text. Is there some way to force all math blocks within an environment to change style?

-
See the command \everymath which can be redefined at the beginning of every theorem env. See: tex.stackexchange.com/questions/62978/… – Marco Daniel Jul 25 '12 at 18:32
Note that \tt is deprecated – Joseph Wright Jul 25 '12 at 20:24

Here's one possible solution implementing the idea proposed by Marco Daniel in a comment; the solution uses:

1. The amsthm package to define a new theorem style to produce theorem-like structures with heading and body text in monospaced font. This style is used to define a theo environment.
2. The etoolbox package to append David Carlisle's answer to Can I change all math output to use monospaced text? to a hook executed by the \begin command at the beginning of the theo environmet.

\documentclass{article}
\usepackage{amsthm}
\usepackage{etoolbox}

\newtheoremstyle{monosp}
{\topsep}{\topsep}
{\ttfamily}{}
{\ttfamily}{.\mbox{}}
{.5em}{}
\theoremstyle{monosp}
\newtheorem{theo}{Theorem}

\AtBeginEnvironment{theo}{%
\everymath{\mathtt{\xdef\tmp{\fam\the\fam\relax}\aftergroup\tmp}}
\everydisplay{\mathtt{\xdef\tmp{\fam\the\fam\relax}\aftergroup\tmp}}
}

\begin{document}

Some test text $a=b$ and some in-line math $c=d$ and a displayed expression
$a=b$
just to test.
\begin{theo}
Some test text $a=b$ and some in-line math $c=d$ and a displayed expression
$a=b$
just to test.
\end{theo}
Some test text $a=b$ and some in-line math $c=d$ and a displayed expression
$a=b$
just to test.

\end{document}


-