I want to use suggestive variable and function names in math like the in the following:
result = f(input)
or
accumulator = sum(inputs)
I want the formula to stand out in relation to the surrounding text. So if I use the following:
\(\mbox{result} = F(input)\)
it doesn't work because then "result" looks just like the normal surrounding text, while "F(input)" is italicized in math mode. So how can I make the "result" be also italicized correctly and consistently. Maybe I shouldn't use math mode at all but just normal mode and italicize the whole? But I intend it to be a logical unit within the text.
\ensuremath{}only to go back to text mode via\text{}? – Peter Grill Aug 14 '12 at 14:49\mathit{result}instead of that complicated construction? This will ensure italics, while your macro, if used when the current font is italic, will produce upright text. – egreg Aug 14 '12 at 14:50\Resultand\Inputmacros work equally well in text mode and math mode, so that the user won't have to remember to switch into math mode when the variable names are used in running text. – Mico Aug 14 '12 at 14:54\emphgenerating an undesirable effect if the current mode happens to be italics (as could happen in the statement of a theorem). I'll change the code to correct this potential pitfall. – Mico Aug 14 '12 at 14:55\ensuremath{}even though others disagree :-) as in When not to use \ensuremath for math macro?, but\text{}puts you in text mode, so you could just use\text{}without going into math mode first as\text{}works in text mode as well. – Peter Grill Aug 14 '12 at 14:57\Result = f(\Input), it's best to use mathmode explicitly: doing so will not only generate math-appropriate amounts of whitespace around the=symbols automatically but also take care of math-appropriate (i) spacing around the parentheses and (ii) line breaking methods. Separately, to ensure that any variable names are always set in upright-roman mode, use\mathrmin the definitions of these variable names. – Mico Aug 14 '12 at 15:09