24
$\begingroup$

There are some things which work slightly different in MathJax+html than in standard TeX/LaTeX.

One of the things is that comma or full stop after MathJax might sometimes get on new line - as pointed out by Michael Hardy in this post: A small bug: period on the next line after MathJaX AFAIK this would no happen in LaTeX. Of course, typesetting a document in LaTeX is a different thing than the interplay between HTML and MathJax on a website.

Should we include punctuation between dollars in order to avoid this. For example, is it better to write $x^2=y^2,$ or $x^2=y^2$,? These two variants render as follows $x^2=y^2,$ and a $x^2=y^2$, and if I am lucky enough, I can get comma on the new line.

I will add that in case of centered formulas there is no doubt that the punctuation should be inside dollars, like for example $$x^2=y^2.$$ and not $$x^2=y^2$$. Certainly $$x^2=y^2.$$ looks better than $$x^2=y^2$$.

This is a minor issue, but still from past discussions on meta I know that:

  • Some users consider this site as a place where aside from teaching mathematics they also teach LaTeX. And it is not inconceivable that somebody might pick up basics here and they might later start using LaTeX. If they gain some bad habits here, it might be difficult ot get rid of them.
  • It was pointed out several times that when using MathJax we should keep also people using screenreaders in mind. However, from this point of view I do not thing that this difference is an issue.
  • On the other hand, if this is something which is fixable and might be fixed in the future, it would not be good to use syntax which looks better with the current settings, but is - in some sense - "incorrect".

For the above reasons I have decided to ask about this here on meta.

EDIT: Based on the responses I got so far, I should perhaps clarify that I understand that $x^2=y^2$, is correct and $x^2=y^2,$ is incorrect usage in LaTeX. I am asking on opinions about how to write these things on this site. Whether this is better to follow the same usage as in LaTeX, or whether we should try to make things look as in LaTeX, even if that means different syntax.

$\endgroup$
  • 11
    $\begingroup$ I remember a colleague telling me that one should write $x,y\in Z$ $x,y\in Z$ and $x\in X$, $y\in Y$ $x\in X$, $y\in Y$ because in the first case this is a "mathematical list" and in the second case it is a "text list". This is to say that whether the coma should be between the dollars or not depends on the context/content. $\endgroup$ – Surb Dec 21 '16 at 16:08
  • $\begingroup$ Inline formatting, that is (single $ sign on each side is not problem, and can be done in with both the comma inside the field of dollars, or out side. $\endgroup$ – Namaste Dec 21 '16 at 18:49
  • $\begingroup$ @Surb Precisely what is the difference between a "math list" and a "text list"? That seems like an arbitrary distinction that would not not be natural in many contexts. $\endgroup$ – Bill Dubuque Dec 21 '16 at 18:58
  • $\begingroup$ As long as nobody is in a coma inside or outside the dollar symbols in MJ. $\endgroup$ – Asaf Karagila Dec 21 '16 at 20:02
  • 4
    $\begingroup$ @BillDubuque, the spacing for a comma in math mode is different from that of a comma in text mode (I suspect you know that). In $x,y\in Z$, the comma is part of the math (as it should be), while in $x\in X$, $y\in Y$, the comma is (correctly) part of the sentence, not the math. Serb's colleague was right. $\endgroup$ – Davide Cervone Dec 21 '16 at 22:41
  • 2
    $\begingroup$ It would be possible for a MathJax extension to post-process the page to put a container around the math and the following punctuation so that no line break could occur between them. Such an extension would not be that complicated to write, and has been suggested for MathJax before. $\endgroup$ – Davide Cervone Dec 21 '16 at 22:44
  • $\begingroup$ @DavideCervone Of course, but my prior remark addresses semantics, not syntax. $\endgroup$ – Bill Dubuque Dec 21 '16 at 22:58
  • 4
    $\begingroup$ @BillDubuque, indeed, that is why I agree with Surb's comment: the comma in the first example is semantically part of the math, while the one in the second example is semantically part of the sentence structure, not the math structure. That was not a syntactic issue, but a semantic one. $\endgroup$ – Davide Cervone Dec 21 '16 at 23:00
  • $\begingroup$ @David Not necessarily, e.g. when one is talking about elements of product structures, etc. Whether it is mathematical or not is highly context dependent (and not clearly a subjective decision, since it may depend on the readers view of the ambient structural or logical context, etc). $\endgroup$ – Bill Dubuque Dec 21 '16 at 23:02
  • 1
    $\begingroup$ @Surb So what kind of comma is it in $\{\,(x,y)\mid x\in Y\color{red},y\in Y\,\}$? $\endgroup$ – Hagen von Eitzen Jan 1 '17 at 21:29
  • $\begingroup$ It's part of the sentence which is inside the math which is in the sentence, of course. If it were possible to enclave the gap, that would be great, but it's not... $\endgroup$ – Nij Jan 1 '17 at 22:03
  • 1
    $\begingroup$ @Nij: It is possible: \{(x,y) \mid \text{$x \in X$, $y \in Y$}\}. Worthwhile, I don't think so, but certainly possible... $\endgroup$ – Rahul Jan 2 '17 at 5:02
  • $\begingroup$ @HagenvonEitzen I don't know the official rule: this is why I posted a comment and not an answer! I tend to add a space \ after the red comma: \{(x,y)\mid x\in X, \ y\in Y\} giving $\{(x,y)\mid x\in X, \ y\in Y\}$ instead of $\{(x,y)\mid x\in X, y\in Y\}$. Anyway, at the end of the day, IMO the most important is to facilitate the reading. $\endgroup$ – Surb Jan 2 '17 at 12:30
13
$\begingroup$

In $\LaTeX$ you would normally write $x^2=y^2$,. In $\LaTeX$ that does not cause the comma or period to get pushed to the next line. In MathJax sometimes it does, so I have begun writing $x^2=y^2,$ instead.

If you use double dollar signs, thus $$ x^2=y^2, $$ then of course (either in $\LaTeX$ or in MathJax) you need the comma inside the display, since otherwise, like everything else that follows the display, it's on a later line.

Calling MathJax "latex", as many here do, is hazardous because if some people learn to use MathJax and think they've learned $\LaTeX,$ they will suffer an unpleasant surprise if they encounter actual $\LaTeX$ and find out that way that they don't know $\LaTeX.$

$\endgroup$
  • 3
    $\begingroup$ As someone who uses both, I find little essential difference between LaTeX and MathJax. Then again, perhaps I don't really know LaTeX. $\endgroup$ – Omnomnomnom Dec 22 '16 at 14:39
  • 2
    $\begingroup$ @Omnomnomnom : Probably many who use LaTeX hardly know it. It is unusual to see a LaTeX document typed by a mathematician that doesn't have lots of the sorts of solecisms that result simply from not knowing much. Do you ever include the \usepackage command before \begin{document}? Do you have use the \setcounter command? Or \input? Or \label and \ref? Or \cite? Or \enumerate? Or \itemize? Or \pagestyle or \thispagestyle? Or \section? Or \verbatim? (I've used \verbatim for ANOVA tables.) You can't do any of those things in MathJax, as far as I know, and that's all really basic stuff in LaTeX. $\endgroup$ – Michael Hardy Dec 22 '16 at 18:11
  • $\begingroup$ I guess I didn't think of anything outside the math formatting. Good point. $\endgroup$ – Omnomnomnom Dec 22 '16 at 19:03
  • 3
    $\begingroup$ You can use \label and \ref in MathJax, and there is \verb in MathJax (which is similar to \verbatim). But you are right, MathJax is not LaTeX, and isn't intended to be. It does not do all the page formatting tasks of LaTeX, only the math formatting ones, by design. $\endgroup$ – Davide Cervone Dec 24 '16 at 10:18
  • 1
    $\begingroup$ To be fair, on my first day in university I was provided with a LaTeX template for assignments, in which I could simpy write text and math and it would compile nicely. For two and a half years this was LaTeX for me. Until I had to write a thesis and an article. And many have even dared to write a thesis in this template... For many LaTeX doesn't do (much) more than what MathJax does. $\endgroup$ – Servaes Dec 25 '16 at 22:06
  • 1
    $\begingroup$ One of the most common issues I see is grouping commas with a thinspace after them; e.g., for a number slightly greater than one billion: $1,234,567,890$ 1,234,567,890. This is because TeX (and MathJax) by default assumes commas to be list commas, for which the space is desired. The proper way is to write $1{,}234{,}567{,}890$ 1{,}234{,}567{,}890. $\endgroup$ – chirlu Jan 1 '17 at 19:35
  • 2
    $\begingroup$ @MichaelHardy I thought your list starting with \usepackage was a list of such "solecisms" and was beginning to feel really concerned about my understanding of LaTeX, until I made it to the end of your comment! $\endgroup$ – Kyle Strand Jan 3 '17 at 23:48
-3
$\begingroup$

If you want to use commas inside mathjax, the way to do it is to put a space after it too, so $E,\ H,\ D,\ B$ is E,\ H,\ D,\ B with a space after the \ symbol. This creates a space in $\LaTeX$, and useful if you don't want your list to fall apart. You can provide bigger spaces with \quad, eg $B\quad D$, is useful if you want to show two equations on a single line.

$\endgroup$

You must log in to answer this question.

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