6
$\begingroup$

A basic LaTeX feature which I sometimes miss when asking and answering questions in MO (specially when the question and the particularly the answer are longer) is the possibility of numbering equations for cross referencing. I tried to do it naively a couple of times but it never worked. I also looked into the MO help pages to figure out a way to do it, to no avail. I do not know if there is an intrinsic limitation in MathJax for implementing such a feature, but I believe it would be quite helpful to be able to do so. I would be happy enough with just simple numbering and then cross referencing bare-handedly. Fully-fledged, \label-\eqref-style cross referencing would probably be overkill since questions and answers are not that long.

If it is indeed the case that numbering and cross referencing of formulas is currently not possible in MO, is it feasible to implement such a feature? If that is the case, would it be helpful for other people in the MO community as well? Thanks in advance.

$\endgroup$
10
$\begingroup$

MathJax supports manual numbering using $$\tag{…}$$, as in \eqref{grz} below:

$$\tag{1}\label{grz}\Box(\Box(p\to\Box p)\to p)\to p$$

Cross-references work, too, with \label and \eqref. The tags needn't be numbers:

$$\tag{LR}\Box p\to p\vdash p$$

$\endgroup$
  • $\begingroup$ I usurped your label in my answer... $\endgroup$ – Gerald Edgar Jun 15 '16 at 14:38
  • $\begingroup$ Ah, it was the $\verb|\tag|$ command I was missing. Just using $\verb|\label|$ and $\verb|\eqref|$ as in a standard $\mathrm{\LaTeX}$ document wasn't working for me. Thanks a lot! $\endgroup$ – Pedro Lauridsen Ribeiro Jun 15 '16 at 14:45
4
$\begingroup$

Let me try this label feature that Emil pointed out... $$ \tag{1}\label{grz}\Box(\Box(p\to\Box p)\to p)\to p $$ Then I have more material.
Then I have more material.
Then I have more material.

Ready to refer to the equation: In equation ($\ref{grz}$) we see... Wow there is even a link that jumps to the equation if it is off the screen by now.

However: I note that if my answer is above Emil's, then Emil's equation with the same label no longer works. So, to be polite, I should choose labels unique to me. It also means I can put a link in my answer to an equation in a different answer.

$\endgroup$
  • $\begingroup$ Your last paragraph raises an important point to have in mind. It makes sense, since it means MathJax works as if the whole page were a single $\mathrm{\LaTeX}$ document. However, we are only able to "see" the labels of other people if we enter the edit window of the corresponding post. This may be a source of confusion - perhaps a "mouseover" feature would help? $\endgroup$ – Pedro Lauridsen Ribeiro Jun 15 '16 at 14:49
  • 1
    $\begingroup$ Oops, your equation is not being displayed correctly. I tried to edit a MO answer of mine to include cross referencing and the same thing is happening to me. It seems that the \label command alone is doing this (i.e. removing \eqref does not solve it), even if it is the only cross reference in the page (so it's not due to a conflict between labels). Curiously, this bug doesn't show up in the preview of the edit window. Even more curiously, Emil's answer doesn't have this problem, even if I copied his commands verbatim in my post. Would it be the case to add a "bug" tag to the question...? $\endgroup$ – Pedro Lauridsen Ribeiro Jun 15 '16 at 15:24
  • $\begingroup$ Emil's answer is now above mine, so HIS is displayed correctly and mine is not. However my link now goes to his equation! $\endgroup$ – Gerald Edgar Jun 15 '16 at 15:27
  • $\begingroup$ But it's still strange - why is your first equation not being formatted? In my MO answer I tried to edit to incorporate this feature, the same thing happens even if it's the only equation in the page being referenced. $\endgroup$ – Pedro Lauridsen Ribeiro Jun 15 '16 at 15:28
  • $\begingroup$ It seems if a given label already exists, then formatting fails. In normal LaTeX, if you put in a duplicate label, you just get a warning in the log file. Mathjax has no log file, so when something is wrong, it does not format the equation. $\endgroup$ – Gerald Edgar Jun 15 '16 at 15:32
  • $\begingroup$ OK, but in my case I know for sure there is no other equation label in the page. Changing the name of the label doesn't work either. $\endgroup$ – Pedro Lauridsen Ribeiro Jun 15 '16 at 15:32
  • 2
    $\begingroup$ It actually works fine, but you (and you only) may see it corrupted due to the fact that the MathJax script running on the page first saw and learned the label in the preview window, and erroneously thinks that the same label on the final version of the page is a duplicate label. Just reload the page to force the script to restart from a clean state when this happens. $\endgroup$ – Emil Jeřábek supports Monica Jun 15 '16 at 16:39
  • $\begingroup$ @EmilJerabek Hmm, you're right, all formulas render just fine on my smartphone. Thanks! $\endgroup$ – Pedro Lauridsen Ribeiro Jun 15 '16 at 17:43
  • 3
    $\begingroup$ Perhaps there should be a convention to use the same symbols for the label as for the tag (since you have to give the tag explicitly anyway). So \tag{1}\label{1} or `\tag{grz}\label{grz}. Then you don't have to look at the code to see what label to use. $\endgroup$ – Davide Cervone Jun 16 '16 at 0:50
  • 1
    $\begingroup$ @DavideCervone : I think that's a great suggestion! I am also wondering if it wouldn't be helpful in MathJax to obsolete \label (since you won't want to label and refer to untagged questions) and redefine \tag to take an optional argument so \tag{#1} mapsto (what is currently) \tag{#1}\label{#1} while \tag[#1]{#2} maps to \tag{#2}\label{#1}? $\endgroup$ – Willie Wong Jun 16 '16 at 15:02
  • 4
    $\begingroup$ I think differences between MathJax and LaTeX syntax should be minimized. $\endgroup$ – Gerald Edgar Jun 16 '16 at 16:05
  • $\begingroup$ @WillieWong, I agree with Gerald, we don't want to make more changes to standard TeX than are already in MathJax. People want to be able to copy expressions from here directly into LaTeX papers, and such changes would make that harder to do. The reason LaTeX has two separate macros is that LaTeX is set up to number equations automatically (so you rarely use \tag), and also because \label can be used on things other than equations (like headers, figures, etc.). It looks redundant here, but isn't in LaTeX itself. $\endgroup$ – Davide Cervone Jun 17 '16 at 12:33
  • $\begingroup$ @DavideCervone: I am fully aware of the reasons for distinct commands in LaTeX, which is why I specified "in MathJax" in my comment. Furthermore, precisely because \label and \ref are "general purpose" TeX commands that one has the reason to expect that they behave differently in MathJax then in LaTeX. (Similar to \newcommand or any of the non-existent text-mode only commands.) And no one will be able to directly copy-paste code with "references" anyway from a LaTeX document: \ref and \eqref are almost never used in Mathmode but in MathJax you need to surround them by $...$. $\endgroup$ – Willie Wong Jun 17 '16 at 14:23
  • $\begingroup$ On the other hand, looking through the MathJax docs again, I see one much more reasonable objection to doing this, which is the fact apparently automatic equation numbering is available. This would make it bad to obsolete \label. Still, what about a * form of \tag that does what I described? This will not break code that already use \label. $\endgroup$ – Willie Wong Jun 17 '16 at 14:27
  • $\begingroup$ @WillieWong, Note that \ref and \eqref do not need to be surrounded by math delimiters (just as \begin{x}...\end{x} don't). As for \tag*, that already has a meaning (a tag without the parentheses), so that is not available. Also, I didn't mention copying from LaTeX to here, I said copying from here to a LaTeX document. I'm not sure why you expect \label and \ref to act differently in MathJax than in LaTeX (is there a missing "not"?); for example \hbox is general purpose, so do you expect it to work differently in MathJax. I'm afraid I'm missing something. $\endgroup$ – Davide Cervone Jun 17 '16 at 20:03

You must log in to answer this question.

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