9
$\begingroup$

MathJax, at least as used on MO, recognises many multi-line environments, like {multline}, {align}, and {gather}. However, it does not seem to recognise \intertext for a quick interjection in the middle of a group of related equations. Is there any analogue of \intertext in MathJax, possibly by \requireing an appropriate package?

Here's what I want to work, although it does not (edited in response to @FrançoisG.Dorais's comment to explain why I don't just end one environment and begin another—namely, that I want to preserve alignment points):

\begin{align*}
1 + 1 & {}= 2
\intertext{and}
1 + 2 & {}= 3.
\end{align*}
$\endgroup$
5
  • 3
    $\begingroup$ This is interesting but I don't think there's a meaningful way to implement this. The reason behind \intertext is to add less space between the two equations than the trivial solution \begin{gather*}...\end{gather*}and\begin{gather*}...\end{gather*}. There is no better way to do this while making sure that the inter-text is processed just as regular text, but then regular spacing rules apply. $\endgroup$ Commented Mar 5, 2022 at 6:57
  • 1
    $\begingroup$ Another workaround \begin{gather}1 + 1 = 2\\ \text{and}\\1 + 2 = 3.\end{gather} \begin{gather}1 + 1 = 2\\ \text{and}\\1 + 2 = 3.\end{gather} $\endgroup$ Commented Mar 5, 2022 at 15:15
  • 2
    $\begingroup$ @FrançoisG.Dorais, that solution certainly works fine for {gather*}; but, despite my poor choice of that as an example, I'm mainly interested in {align*}, and ending an {align*} and beginning a new one loses all the alignments (I think?). $\endgroup$
    – LSpice
    Commented Mar 5, 2022 at 18:51
  • $\begingroup$ @GeraldEdgar, that I guess is the best possible (since it avoids ending the environment, and so would remember positions within an {align*}, which was, despite my puzzlingly not saying so, my reason for not wanting to end a multi-line environment). It's not left-aligned, and unfortunately \hfill does not convince it to be either, but beggars can't be choosers. $\endgroup$
    – LSpice
    Commented Mar 5, 2022 at 18:53
  • 1
    $\begingroup$ @FrançoisG.Dorais : The effect of \intertext is NOT only to have less space between two displayed lines than there would otherwise be. Rather, it makes the vertical alignment below \intertext match the vertical alignment above \intertext. $\endgroup$ Commented Mar 6, 2022 at 17:08

2 Answers 2

8
$\begingroup$

No, MathJax doesn't have an implementation \intertext, as MathJax's internal format is MathML and there is no natural way to accomplish it within the MathML that MathJax supports.

$\endgroup$
6
  • $\begingroup$ Thank you. For some reason I neglected to mention the most important point for why I want to do this, which is that I want equations separated by text but nonetheless enjoying mutual alignment points. Is that possible? $\endgroup$
    – LSpice
    Commented Mar 5, 2022 at 18:55
  • 1
    $\begingroup$ Yes, I understand the need, but no, as I said, it is not possible in MathJax. There is no mechanism within MathML to perform this, and MathJax uses MathML as its internal format, so it has no way of expressing this. $\endgroup$ Commented Mar 6, 2022 at 0:38
  • $\begingroup$ Ignoring all the MathML niceties around formatting the equations, doesn't <mtable><mtr><mtd>1 + 1</mtd><mtd>= 2</mtd></mtr><mtr><mtd colspan="2">and</mtd></mtr> <mtr><mtd>1 + 2</mtd><mtd>= 3</mtd></mtr></mtable> work? (EDIT: Ah, no, at least on Mozilla's MathML Tester, colspan is accepted but ignored, as became clear when I tried something longer than and as intertext.) $\endgroup$
    – LSpice
    Commented Mar 6, 2022 at 17:15
  • 1
    $\begingroup$ No, that would not be the same as what \intertext would produce. In LaTeX, \intertext produces text that is outside the table, flush left (unless you are in a centering environment). If the text is long, for example, it will not affect the sizes of the columns in the table. Using colspan would make the text be part of the table, it would not be flush left with the rest o the page, but only within the table (if you also used align="left"), and it would affect the column sizes if the text were longer than the combined columns it spans. $\endgroup$ Commented Mar 6, 2022 at 18:10
  • 1
    $\begingroup$ As for the MathML tester, that is unrelated to MathJax and tests the native MathML handling of your browser, so your results will depend on which browser you are using. Even Firefox's relatively complete MathML implementation doesn't seem to handle colspan, however. But it's also true that MathJax doesn't yet implement colspan either, so while this could be a work-around for some situations, it is not yet available in MathJax, either. $\endgroup$ Commented Mar 6, 2022 at 18:15
  • 1
    $\begingroup$ You could probably use \rlap{\hspace{...}\text{and}} the proper distance for the \hspace to get what you want, but it is a hack and would need to have the spacing determined by hand for each expression. $\endgroup$ Commented Mar 6, 2022 at 18:17
1
$\begingroup$

Reply to @LSpice 's comment: (Sorry, I don't have enough rep to comment, so posted as answer)

I tested your example in mathml tester in Firefox, colspan and align don't have effect.

In MDN I find that the attribute names should be columnspan and columnalign in MathML.

<math xmlns="http://www.w3.org/1998/Math/MathML">
<mtable><mtr><mtd>1 + 1</mtd><mtd>= 2</mtd></mtr>
<mtr><mtd columnalign="left" columnspan="2">and</mtd></mtr>
<mtr><mtd>1 + 2</mtd><mtd>= 3</mtd></mtr>
</mtable>
</math>

$$\begin{aligned}1 + 1&= 2\\ \text{and}\;\;\\1 + 2&= 3\end{aligned}$$

$\endgroup$

You must log in to answer this question.

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