7

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?

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
yrudoy
  • 477

1 Answers1

5

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}
    

enter image description here

Gonzalo Medina
  • 505,128