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 have a custom command defined as

\newcommand{\transition}[1]{$\stackrel{\texttt{#1}}{-->}$}

The argument that I pass to the command can sometimes be normal text and thus is formatted using \texttt{text} and sometimes I want to pass a math symbol such as \tau or \alpha or a combination of these.

Is there a way how I can reason on the argument being passed, such as introduce an if then else depending on the type of the parameter?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Use \mathtt instead.

\documentclass{article}
\usepackage{amsmath}
\newcommand{\transition}[1]{\ensuremath{\xrightarrow{\mathtt{#1}}}}
\begin{document}
\transition{foo}
\transition{\alpha}
\end{document}

You can use \textstyle before #1 if you want lager text.

share|improve this answer
3  
Maybe you should explain, that you've used \ensuremath instead of $$ to make \transition work not only in text but also inside of math. –  Schweinebacke Dec 9 '11 at 8:41
    
works great! thanks –  aseychell Dec 9 '11 at 9:54

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.