Skip to main content

The PreTeXt Guide

Subsection 4.9.14 Punctuation After Display Math

If a chunk of displayed math concludes a sentence, then the sentence-ending punctuation should appear at the conclusion of the display. (And certainly not at the start of the first line after the display!) But do not author the punctuation within the mathematics element, put it afterwards, where it logically belongs.
More specifically, place a sentence-ending period (say) immediately after the closing of an <me>, <men>, <md>, or <mdn> element. PreTeXt will place the period in your output in the right place and in the right way. (By using ’s \text{} macro, if you are curious to know the details.) Here is an example. The XML source
<md>
    <mrow>(a+b)^2</mrow>
</md>.  Now...
will render as
\begin{gather*} (a+b)^2\text{.} \end{gather*}
Now…
This all applies more generally to clause-ending punctuation, such as a comma. Take notice of the requirement that the punctuation must be immediately after the closing tag of the math element, otherwise it will not migrate properly. For example, do not interrupt the flow with whitespace, or an XML comment, or anything else.
For inline mathematics (the <m> element) the same authoring principle holds, though you would likely do this naturally. Author the punctuation outside the element, where it will remain.
Here is a technical subtlety that will demonstrate some of the inner machinery of PreTeXt and our conversions. In your work, locate a theorem that has some numbered display mathematics (mdn) which is at the end of a sentence, and which you have authored as described above. In HTML output, test a cross-reference (xref) to the theorem and you will see the period for the end of the sentence at the end of the display, where it should be. Now test a cross-reference (xref) to one of the numbered equations. First, the knowl will contain the entire display, to provide context, but it also will not contain the period, since the rest of the sentence is not in the knowl and so the period is not necessary.

Best Practice 4.9.14.2. Authoring Punctuation after Mathematics.

Always follow the instructions in Subsection 4.9.14 about placing all punctuation following mathematics after the math element, not inside it. PreTeXt will do the right thing for display math for you. But furthermore, there are some special situations where the output format is not visual, such as braille or audio, where the placement of the punctuation is both different and important to not confuse “reader.” You can help ensure your various outputs are of the highest quality by observing these sorts of details.