TransWikia.com

Mingled math and text in math mode

TeX - LaTeX Asked by LSpice on December 8, 2020

I frequently encounter the situation of wanting to, say, write a set where the set-membership condition involves some text. If I wanted to describe, say, the set of all even integers this way, then would it be better to write

{x in mathbb Z : text{$x$ is even}}

or

{x in mathbb Z : xtext{ is even}}

? Of course there are obvious quibbles (maybe you like mathbb{Z} rather than mathbb Z; maybe you like some other delimiter than :, or some manual space around it), but I’m asking only which way is preferable for writing intermingled text and math in math mode—and, if possible, a reason why other than personal preference.

(I was convinced long ago to use the former by someone who argued that it’s semantically more sensible, but I don’t know if it’s the best practice, or, if it is, whether there’s any TeXnical reason for it.)

3 Answers

Note Do not use this method for your actual work or in your professional capacity. It is a mere jeu d'esprit. This is not recommended for actual maths, which is 99% layout (such as glyph shapes, spacings and proportions and so on, to convey meaning in a standardized way), but is meant only to illustrate that all unicode glyphs are just that, glyphs, and so are "text-able" (as far as that can take anyone). There is a (natural) tendency to consider the (996) mathematical alphanumeric symbols as just a text glyph with formatting applied (e.g. bold, italic), or originating from a different font file/style altogether (e.g., sans, fraktur, script), but, in Unicode, all these ????????????? are completely different glyphs (in the same font), not just the same text x codepoint in fancy dress (from potentially a mixture of different fonts).


Just to celebrate end-of-year, without delimiters ...

If I type directly in unicode:

? ∈ ℤ : ? is even

(and the font has text Latin in it as well, like XITS Math does), then I get:

everything is text

MWE

documentclass[border=6pt]{standalone}
usepackage{fontspec}
setmainfont{XITS Math}
%usepackage{unicode-math}
%setmathfont{XITS Math}
begin{document}
%[x in mathbb Z : text{$x$ is even}]

? ∈ ℤ : ? is even

end{document}

... so the question is moot, perhaps. :)

Answered by Cicada on December 8, 2020

I’d say the best practice is to write

x textnormal{ is even}

As for x textnormal{...} versus textnormal{$x$ ...}, the former is simpler and the latter can easily lead to mismatched $ signs. You could at least alleviate that with textnormal{(x) is even}, but that takes even more characters.

Unlike text, this resets all formatting. If you’ve changed the formatting of the surrounding text—such as an italicized theorem statement, or a bold header, that would bleed through into math mode if you use text. (Which might be what you want in some cases.)

Answered by Davislor on December 8, 2020

{x in mathbb Z : text{$x$ is even}}

is semantically correct and preferable.

The output of both options will be identical in terms of spacing, but semantically, the x in “x is even” belongs to the phrase which is text mode and not to the surrounding context.

Answered by Don Hosek on December 8, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP