PreTeXt version of \intertext in multi-line display math

8 views
Skip to first unread message

Matthew Leingang

unread,
Aug 14, 2025, 1:14:45 PMAug 14
to pretext...@googlegroups.com
Hi everybody,

The LaTeX amsmath package provides an \intertext command to interrupt one of its math alignment modes. You can use it to insert text between stages in a long sequence of equalities. For instance:

First, we use the half-angle identity for $\sin^2(x)$:
\begin{align*}
\int \sin^4(x)\,dx
&= \int\left(\sin^2(x)\right)^2\,dx
 = \int\left(\frac{1 - \cos(2x)}{2}\right)^2 \,dx
\\  &= \int\frac{1 - 2 \cos (2x) + \cos^2(2x)}{4} \,dx
\\  &= \int\left(
\frac{1}{4}
- \frac{1}{2} \cos(2x)
+ \frac{1}{4} \cos^2(2x)\right)\,dx
\\
\intertext{Now we use the half-angle identity for $\cos^2(2x)$:}
&= \int\left(
\frac{1}{4}
- \frac{1}{2} \cos(2x)
+ \frac{1}{4} \cdot\frac{1+\cos(4x)}{2}\right)\,dx
\\ &= \int\left(
\frac{3}{8}
- \frac{1}{2} \cos(2x)
+ \frac{1}{8}\cos(4x)\right)\,dx
\\
\intertext{Now we just do it!}
&= \frac{3}{8}x - \frac{1}{4} \sin(2x)
+ \frac{1}{32}\sin(4x) + C
\end{align*}

The output looks like this:

image.png

I'm trying to do the same thing in PreTeXt. I don't know how to “interrupt” a <md> element to drop back into paragraphs. If I end the <dm> element, it forgets the column widths. So I put it back in using some \phantom commands. Here is my best effort:

<p>
              First, we use the half-angle identity for <m>\sin^2(x)</m>:
              <md>
                <mrow> \int \sin^4(x)\,dx\amp= \int\left(\sin^2(x)\right)^2\,dx = \int\left(\frac{1 - \cos(2x)}{2}\right)^2 \,dx</mrow>
                <mrow> \amp = \int\frac{1 - 2 \cos (2x) + \cos^2(2x)}{4} \,dx </mrow>
                <mrow> \amp = \int\left( \frac{1}{4} - \frac{1}{2} \cos(2x) + \frac{1}{4} \cos^2(2x)\right)\,dx</mrow>
              </md>
              Now we use the half-angle identity for <m>\cos^2(2x)</m>:
              <md>
                <mrow> \phantom{\int \sin^4(x)\,dx} \amp = \int\left( \frac{1}{4} - \frac{1}{2} \cos(2x) + \frac{1}{4} \cdot\frac{1+\cos(4x)}{2}\right)\,dx </mrow>
                <mrow> \amp = \int\left( \frac{3}{8} - \frac{1}{2} \cos(2x) + \frac{1}{8}\cos(4x)\right)\,dx</mrow>
              </md>
              Now we just do it!
              <md>
                <mrow> \phantom{\int \sin^4(x)\,dx} \amp = \frac{3}{8}x - \frac{1}{4} \sin(2x) + \frac{1}{32}\sin(4x) + C  </mrow>
              </md>
              We did some small <m>u</m>-substitutions on the <m>2x</m> and <m>4x</m> terms.
            </p>

image.png
It's pretty close, but you'll notice the equals signs in each block are not aligned. That's because while the left-hand sides have the same width in each block (thanks to \phantom), the widest right-hand side varies.

A hacky LaTeX way to do this would be to find the widest right-hand side, and use a combination of \phantom and \rlap to make sure each right-hand side was at least as wide as that widest column. Or maybe there's a better LaTeX way. But is there a PreTeXt way? 

Best,
Matthew

--

Matthew Leingang (he/his)
Clinical Professor of Mathematics
Assistant Director of Undergraduate Studies

Department of Mathematics
Courant Institute of Mathematical Sciences
New York University

Schedule an appointment with me at https://calendly.com/leingang

Mark Fitch

unread,
Aug 14, 2025, 1:21:37 PMAug 14
to pretext...@googlegroups.com

PreTeXt has <intertext> tags as well.

<md>

<mrow>stuff</mrow>

<intertext>other stuff</intertext>

<mrow>finish math</mrow>

</md>

I can't find an entry in the documentation. If I have missed it, someone suggest I add it.

--
You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/CACG4xxihhJpt6H%2B%3DOzfy-sP6226HcFq3Zp8ZGPZmkuoS1%3DpW3Q%40mail.gmail.com.

Rob Beezer

unread,
Aug 14, 2025, 1:51:10 PMAug 14
to pretext...@googlegroups.com
On 8/14/25 10:21, 'Mark Fitch' via PreTeXt support wrote:
> PreTeXt has <intertext> tags as well.

Right. Maybe it works well in LaTeX/PDF, but it is only as good as MathJax for
HTML. Right now we fake it for HTML, and just get "misaligned" equal signs,
iirc. Maybe MathJax will do better in v4?

https://github.com/mathjax/MathJax/issues/736

> I can't find an entry in the documentation. If I have missed it, someone suggest
> I add it.

Probably because I've never been real wild about this. Certainly addressed in
the sample article.

So, yes, adding it into the *real* documentation would be good. Stress that the
contents of #intertext should be really simple, like a phrase, or a sentence or
two. Like your example. (No footnotes!)

Thanks,
Rob


Matthew Leingang

unread,
Aug 14, 2025, 8:50:55 PMAug 14
to PreTeXt support
This is great news. Sorry that I didn't find it on my own—I didn't think to look in the sample article as well as the guide.

Best,
Matthew

Reply all
Reply to author
Forward
0 new messages