[Tex/LaTex] When to use Roman and Italic Font in Math

formattingmath-mode

I am wondering when to use roman or italic font in math mode. I found that variables should be italicized and functions like max should be put in roman.

I found some sites on the topic, e.g. this or this, but I still have some uncertainties.
Somewhere else I found that concrete entities should be put in roman font.

  • I am not sure what a concrete entity is.
  • In the following example: should letter or startmarker etc. appear in roman font?
  • The subscript free is not a variable, but descriptional text. Thus, it should be romanized?

Picture of some formulas I defined, for which I'd like formatting advice

Edit 1: The formulas startmarker, letter, only etc. are abbreviations for formulas in some logic such as First Order Logic.

Best Answer

This is going to be opinion-based, so I'll first suggest a strategy for typing your document.

\usepackage{amsmath}

\newcommand{\func}[1]{\operatorname{\mathit{#1}}}  % or \mathrm
\newcommand{\const}[1]{\mathit{#1}}                % or \mathrm
\newcommand{\wsub}[1]{\mathrm{#1}}                 % 'word' subscript

Then you can type

$\func{letter}(\sigma,c)\equiv\func{startmarker}(c)$
$\func{only}_{\wsub{free}}(\{c_{0}\})$

Of course you can add shorthands for the functions you use most often

\newcommand{\letter}{\func{letter}}
\newcommand{\startmarker}{\func{startmarker}}
\newcommand{\only}[1][]{%
  \func{only}%
  \if\relax\detokenize{#1}\relax _{\wsub{#1}}\fi
}

and the above formulas would be

$\letter(\sigma,c)\equiv\startmarker(c)$
$\only[free](\{c_{0}\})$

The definition of \only with an optional textual subscript can be simpler if xparse is used:

\usepackage{xparse}
\NewDocumentCommand{\only}{o}{%
  \func{only}%
  \IfValueT{#1}{_{\wsub{#1}}}%
}

Or you can opt for an even simpler \newcommand{\only}{\func{only}} and type

$\only_{\wsub{free}}(\{c_{0}\})$

Now my opinions. A function such as startmarker is not a “standard” function like max, log or sin. Those function names should always be typeset upright in order to emphasize their “fixed” meaning. The function you define in your document are not of universal use, so you can choose between upright or italic. Just be consistent and that's the purpose of the definitions I propose.

If you later decide that functions such as startmarker should be typeset upright, just remove \mathit from the definition of \func (or replace it by \mathrm, but since we are already under \operatorname this is not needed).

For constants it's a similar problem. I never typeset constants upright (that's something I leave to physicists), but I understand others can have different ideas.

Surely you won't place two multiletter constants next to each other without an explicit multiplication sign: so

\const{foo}\cdot\const{bar}

and not \const{foo}\const{bar}.

Related Question