11

I have the following equation:

<trigger threshold> = average - (<trigger fraction> * average)

I want to print this in math mode in a very specific way: <trigger threshold> and <trigger fraction> need to be in a fixed-width font. They should appear exactly as they do in this paragraph. I can't figure out how to get LaTeX to ignore < and > and still print in a fixed-width font. Things I've tried:

\[ \mathtt{<trigger threshold>} = \mathrm{average} - (\mathtt{<trigger fraction>} * \mathrm{average}) \]

The above doesn't work for 2 reasons: the < and > symbols are interpreted as less than and greater than, and also, there is no space between the words "trigger" and "threshold". Another attempt:

\[ \mathtt{\mathrm{<trigger threshold>}} = \mathrm{average} - (\mathtt{\mathrm{<trigger fraction>}} * \mathrm{average}) \]

Here, trigger threshold doesn't appear with a space and also doesn't appear in a fixed-width font. I've played around with a lot of things, but I just can't get this. I'm guessing I may have to resort to a package to do this, but I'm not sure where to look. Does anyone know how to accomplish this?

1 Answer 1

7

You could just use a text-version of "tt", called \texttt:

enter image description here

\documentclass{article}
\begin{document}
\[
  \texttt{<trigger threshold>} = \mathrm{average} - (\texttt{<trigger fraction>} \times \mathrm{average})
\]
\end{document}

In the above example I've included both, just to show you that you can mix and match what you want. However, if you're interested in such things on a more global scale, it's best to define something like

\newcommand{\variable}{\texttt}% or \newcommand{\variable}[1]{\texttt{#1}}

and then use

\variable{<trigger threshold>} = \mathrm{average} - (\variable{<trigger fraction>} \times \mathrm{average})

See Consistent typography. If you're not using a macro-form, a plain short-hand \verb also suffices.

1
  • Nice, that worked! I didn't even think that \texttt would work in math mode, so I didn't try it. Thanks.
    – Geoff
    Commented Oct 31, 2012 at 20:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .