Is there any command for typesetting constants in mathematical formulas?
I would imagine something similar to \operatorname
or \DeclareMathOperator
, but for constants.
I want the constant to be typeset in roman font as in the text mode (with proper spacing and ligatures – this concerns constants denoted by a couple of letters).
Best Answer
(updated to incorporate the comments by @egreg, barbara beaton, and @DCh)
I assume your document uses a roman (serif) font rather than a sans-serif font for mathematics. To ensure that constants are typeset consistently using upright Roman letters, it's handy to create a dedicated macro named, say,
\ct
that uses the following macros in a nested fashion:\text
(from theamsmath
package),\rmfamily
(just in case the surrounding material is non-roman), and\upshape
.Then, use this macro to typeset an equation such as
Suppose, furthermore, that your documents contains two frequently-occurring constants named
ab-cd
andfi-fi
. (You did say that the names of the constants might contain ligatures...) To help speed up typing, you could define two macros\abcd
and\fifi
as follows:The result of a full MWE: