4

Probably asked before but these type of search queries are not very google friendly.

In mathmode, you can type \cos to quickly get the cosine, in normal typeset. Can you do something similar for "if"? Preferably a single command rather than \text{if}.

[edit] Bonus: get some spacing after the if, ie. I am looking for the best way to write "if n = 1" after one case of an equation.

  • 2
    Isn't that what macros are for? \newcommand\Mif{\text{if}~}, for example. – Steven B. Segletes May 4 '16 at 15:32
5

There's no such command, but you can create one. As you've probably already noticed, $if$ isn't right: the font and spacing represent i times f, not the word if. $\mathrm{if}$ or the like isn't right either; depending on the choice of fonts, this may or may not look similar to \text{if}. \text{if} is the way to go, either directly or via another command.

\newcommand{\ifm}[1]{\text{if $#1$}}

\[ n! = n (n-1)! \quad \ifm{n \ge 1} \]

Don't call the command \if as it's used internally by TeX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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