Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
3  
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
3  
Note that \tt is deprecated –  Joseph Wright Jul 25 '12 at 20:24
add comment

1 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.