# How to decide if a comma or punctuation between math mode content should be inside math mode or in text mode?

Which of the two is the preferred way of writing LaTeX code that has punctuation between math mode content?

Example 1:

``````Therefore the solutions to the given equation are \( 2 \), \( 4 \), \( 6 \), \( 8 \), \( 10 \).
``````

Example 2:

``````Therefore the solutions to the given equation are \( 2, 4, 6, 8, 10 \).
``````

I am confused about when the punctuation goes inside math mode and when the punctuation remains in text mode. For example, I think I am pretty sure in the following example, the commas are supposed to be in math mode.

Example 3:

``````Let us consider numbers of the form \( 4k + 1 \) where \( k = 0, 1, 2, 3, \dots \).
``````

Is there a general rule I can follow to decide whether the punctuation between math mode content should be in math mode or text mode?

Is there a general rule I can follow to decide whether the punctuation between math mode content should be in math mode or text mode?"

Slightly longer answer: The commas should be rendered in math mode if they're a fundamental part of the math expression(s), and in text mode otherwise.

But how to decide in whether the commas are fundamental parts of a math expression? Let's consider your first example:

Therefore the solutions to the given equation are \$2\$, \$4\$, \$6\$, \$8\$, [and~]\$10\$.

One way to make progress is to ask if one can either replace the math components with non-mathy words, say

Therefore the solutions to the given equation are red, orange, yellow, green, blue, indigo, and violet.

This sentence parses fine; the commas are mainly needed to provide visual separators between objects (here: nouns). Another way is to ask if changing the ordering of the math components would change the message fundamentally. E.g.,

Therefore the solutions to the given equation are \$8\$, \$2\$, \$4\$, \$10\$, and~\$6\$.

The fact the numbers that form the solution set belong to a short sequence of even numbers does not require them to be listed in ascending order in order for the sentence to form a valid statement, right? By either of these semantic criteria, then, the commas are part of the sentence -- and therefore should be typeset in text mode. (Aside: Do note that the sentence-ending period should also be rendered in text mode.)

Let us consider numbers of the form \$4k + 1\$ where \$k = 0, 1, 2, 3, \dots\$.

Here, the commas separate elements of a (very simple) arithmetic sequence, and it's obviously meaningful to list the numbers in ascending order. Since they're part of a math expression, they should be typeset in math mode.

By the way, I recommend omitting the `.` (period) at the end of this sentence; the output of `\dots` will easily be understood to denote both a typographic ellipsis and the end of the sentence it's a part of.

• Presumably in the list example there will be implications for line-breaking too. May 8, 2021 at 10:23
• @dbmag9 - Not sure I fully understand the gist of your comment. It is certainly true that TeX has no problem inserting a line break between a comma and a whitespace character if this combination occurs in text mode -- and that TeX disables line breaks after commas while in inline math mode by default. However, this default is easily overridden via suitably-placed `\allowbreak` directives. Hence, I would not say that the potential need for line breaks after some commas should influence whether the comma should be typeset in text or math mode.
– Mico
May 8, 2021 at 11:05
• Very nice answer, and I agree, but allow me a suggestion: in the first example I would add a tie to the last element after the "and", so something like `[...] \$10\$, and~\$6\$.` May 8, 2021 at 19:46
• @campa - Thanks for your very good suggestion, which I've implemented.
– Mico
May 8, 2021 at 20:16

I have slowly (several years) been writing a document Mathematics with Style about good practices regarding typesetting maths. The following is an extract from that dealing with punctuation.

Reading this again after a couple of years it could do with some improvement; perhaps something the effect to treat a math expression as a "word" within the text.

• Are you the same Peter Wilson who worked on the STEP standards for geometry in ancient times? If so, thank you, they have served us well. Also, thanks for the Memoir package, which I have used to write a nice CAD geometry book over the past few decades. May 9, 2021 at 7:45
• @bubba Yes, I am that ancient Peter Wilson. Unfortunately I can't do now what I did then. Thank you for remembering me. May 9, 2021 at 17:44
• @PeterWilson Where can we find your document "Mathematics with Style"? Jun 19, 2021 at 22:19
• @CampanIgnis I am still working on it so general release is delayed for some, probably long, indefinite period. Perhaps, though, TUG might be willing to add the draft to its website. Jun 21, 2021 at 17:50
• @PeterWilson Thank you for your response. Perhaps you could also sent the draft to CTAN or add it to memdesign. But I am sure you already thought of that. Jun 21, 2021 at 21:17