I often write formulas with long identifier names. To get the kerning right I have to put the identifiers into \textit or something similar.

For example this looks wrong:

$\forall x \in Foo: \; Ma(x) \wedge Ha(x)$

And I have to fix it like so:

$\forall x \in \textit{Foo}: \; \textit{Ma}(x) \wedge \textit{Ha}(x)$

Or using mathrm:

$\forall x \in \mathrm{Foo}: \; \mathrm{Ma}(x) \wedge \mathrm{Ha}(x)$

enter image description here

Or by declaring operators:



$\forall x \in \Foo: \; \Ma(x) \wedge \Ha(x)$

My question is: Can I make Latex do this automatically as a default or with a macro? I never had a case, where I would like the default behavior (although I see that it could be useful for mathematics and physics).

  • That has nothing to do with kerning (which is not used in math). Some like more space, some does not.
    – daleif
    Mar 20, 2015 at 14:20
  • 1
    @daleif inter-letter kerns are used with \mathit and \textit Mar 20, 2015 at 14:21
  • 1
    @DavidCarlisle -- yes, \mathit and \textit are kerned, but it's text kerning, not math spacing. i keep saying that we need a glossary. Mar 20, 2015 at 14:32
  • 1
    @barbarabeeton but that is exactly what the OP wants, (as well as closer sidebearings) so there is not a big space between M and a in Ma Mar 20, 2015 at 14:49
  • 1
    @DavidCarlisle -- yes, agreed. i'm just quibbling about terminology. (and this was in reaction to your comment to daleif, not saying that it wasn't what is wanted, because it certainly is wanted.) i'll essay an answer -- please correct it if i goof. Mar 20, 2015 at 14:53

1 Answer 1


latex by default "assumes" that adjacent letters are independent variables being multiplied together, and the italic alphabet tuned for use in math has sidebearings assigned to be appropriate for that use.

there's no reasonable way to change the default

there are several different situations in which strings of letters should be treated as "words": when they act as operators, e.g. "log" or "sin", and when they are identifiers, e.g. "Foo" in the question.

many of the "common" operators have predefined commands: \log, \sin, etc. these are traditionally set in roman (upright) type, and follow strict spacing rules. the difference in spacing between an operator and an ordinary "word" can be seen by comparing $\mathrm{log} x$ and $\log x$. operators are defined with \DeclareMathOperator as noted in the question.

identifiers are set as ordinary words, with kerning appropriate for words. they can be roman, italic, or even something more "exotic" in some contexts. (i have seen both script and fraktur in published works.) they should always be set with a text-appropriate font, but it isn't difficult to make a generic macro.

for identifiers to be set in upright roman:


for identifiers to be set in "regular" italic:


contrary to a frequent misunderstanding, \mathit and \mathrm are actually specific text fonts used in a math context.

(personally, i would only bother with creating an "indirect" command if there were a lot of identifiers that would occur only once. for identifiers that are used frequently, i would define them directly with the font specifier -- it's more obvious in a list of definitions what is meant in each case, and thus easier for an author to change when s/he decides on a change in terminology, and easier for an editor to cope with when readying a manuscript for publication.)

so, bottom line, you do have to specify the font explicitly, and how you do that depends on the function the term or identifier will fulfill in the math expression where it is used.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .