26
\$\begingroup\$

We have MathJax

In this meta we discussed, requested, and gathered evidence for the utility of MathJax in RPG.SE posts.

Now it's time to use MathJax

For those familiar with LaTeX it will likely suffice to say that \$ ... \$ are our delimiters ($$ ... $$ for equations centered on their own line), and to let you experiment. Then there's this MathJax reference for your reference, and Math.SE has made a MathJax basic tutorial and quick reference.

Let's put our \$ where our mouths are...

In the previous meta we identified forty-some-odd posts that could benefit from LaTeX treatment. I've copied them below to serve as a punch-list. If you've got five minutes go ahead and edit one, then strike it out on this list. And parse them out over time, to be sure!

List of answers that would might improve with MathJax

[Note: some have found on second pass that an post that looks okay in HTML isn't really worth re-setting into MathJax. I suggest adding "(skipped)" to the end of a link to indicate that the post has been reviewed, but not striking it out in case some later user wants to tilt against that windmill. If you're the original author and think the post should not receive any MathJax I suppose you should either strike it out or remove it wholesale from this list. -nitsua60]


All done!!

mathematical!! -- finn from adventure time

\$\endgroup\$
23
  • \$\begingroup\$ Is this a call-to-arms for an editing spree? Won't such a massive amount of editing negatively affect the recent tab on the front page? \$\endgroup\$
    – Axoren
    Jun 2, 2016 at 23:22
  • 2
    \$\begingroup\$ @Axoren It would, yeah. It's a good idea to do a few at a time, keeping a reasonable pace. These kinds of posts will take more time and attention to adapt correctly and visually-pleasingly anyway, so there's no rush. :) Having a master list like this is even more useful when it's being done at a slow pace, since it's a reminder of what still needs doing. \$\endgroup\$ Jun 2, 2016 at 23:31
  • 1
    \$\begingroup\$ @Axoren You may find this post and this one relevant. \$\endgroup\$
    – BESW
    Jun 2, 2016 at 23:32
  • 4
    \$\begingroup\$ @Axoren funny enough, "call to arms" is exactly the phrase SSD used. You're right to be concerned about flooding the frontpage, but I'm fifteen minutes into editing one of my posts from this list and am seeing this play out slowly.... Turns out the way I laid out my argument knowing markdown would be the display engine is really different from how I'd like to present knowing LaTeX is the display =\ \$\endgroup\$
    – nitsua60 Mod
    Jun 2, 2016 at 23:33
  • 1
    \$\begingroup\$ the lack of \intertext{...} is really... bothersome =( \$\endgroup\$
    – nitsua60 Mod
    Jun 2, 2016 at 23:34
  • \$\begingroup\$ @nitsua60 I'd be inclined toward strikeouts, myself. \$\endgroup\$
    – BESW
    Jun 3, 2016 at 0:56
  • \$\begingroup\$ I think strikeouts make sense. Lets others double-check the work if they're so inclined. \$\endgroup\$ Jun 3, 2016 at 1:07
  • \$\begingroup\$ Aside, it might be useful to do a “first pass” that just involves leaving comments on posts to let the authors know they can use MathJax now. \$\endgroup\$ Jun 3, 2016 at 1:08
  • \$\begingroup\$ @nitsua60 I haven't been doing it on all questions/answers, just the one that sparked the original meta question. It was the most recent math-heavy post in my memory. I agreed with SevenSidedDie on this before he even said anything. I'm fairly certain that the answerer in this case is the best person to faithfully edit their post. I believe that can apply in general. Let the authors edit their own posts if they're around to. Then we can start editing the rest. \$\endgroup\$
    – Axoren
    Jun 3, 2016 at 1:13
  • 2
    \$\begingroup\$ Can we also strike out our own answers if we don't think they really need MathJax? For example, this answer might've been slightly easier to write with MathJax, but now that it's written, I don't see any real improvement to be had by reformatting it. The most advanced math typesetting in it is a bunch of exponents, and HTML does those just fine. \$\endgroup\$ Jun 3, 2016 at 10:58
  • 1
    \$\begingroup\$ Similar question to @IlmariKaronen, on another of his answer, about detecting biased dice. I have MathJax’d the one formula in there that would look somewhat better that way (though even then it’s a really minor use), but the in-line formulas, while no doubt a pain to write the way they were, are already written and look good. \$\endgroup\$
    – KRyan
    Jun 3, 2016 at 13:14
  • \$\begingroup\$ Yeah, that's probably wise. The original list was definitely compiled for an eye towards showing “see! we use maths!”, but now that they're written they may not need MathJax for every single bit of math, to be decently formatted. MathJax isn't always the best choice when HTML can suffice. Considering this list a set of review tasks then, with one possible conclusion being “looks good, no change needed”, is probably a good idea. \$\endgroup\$ Jun 3, 2016 at 22:26
  • 8
    \$\begingroup\$ OMGosh we can do tables now?! \$\endgroup\$ Jun 4, 2016 at 20:01
  • 1
    \$\begingroup\$ @Axoren I've made sheets in it before—LaTeX/ConTeXt is my preferred DTP solution when time isn't an object. But we have only the subset of LaTeX that MathJax implements for math formatting, so I don't think we could do a whole character sheet layout here, even if we wanted to. But tables… well, decent support for basic tables is something that SE seriously lacks. So tables are exciting. \$\endgroup\$ Jun 5, 2016 at 16:55
  • 4
    \$\begingroup\$ It might be useful, now that the punch-list is done/mostly done, to cut it out of the OP and put it in a CW post below just as a reference. Then the OP can serve as our main “we have MathJax support! here's how to use it” meta. \$\endgroup\$ Jun 10, 2016 at 4:26

4 Answers 4

12
\$\begingroup\$

A number of posts would benefit from MathJax's tables, if not its mathematics.

The array environment can do tables quite well. (Thanks nitsua60 for finding this!) Here's an example. Note that because we are \begining an environment, we don't need to have the surrounding $$s.

\begin{array}{r|lll}
\text{Column One} & \text{Two} & \text{Three} & \text{Four} \\
\hline
foo & bar & baz & narf  \\
tinker & tailor & soldier & spy
\end{array}

\begin{array}{r|lll} \text{Column One} & \text{Two} & \text{Three} & \text{Four} \\ \hline foo & bar & baz & narf \\ tinker & tailor & soldier & spy \end{array}

Anatomy of this example:

  • \begin{array}{r|lll} comes in two parts:
    • \begin{array} begins the array environment, like it says.
    • {r|lll} sets up our column layout. This means we'll have a right-aligned column, a column divider, then three left-aligned columns. A center-aligned column would be designated with c, and we can have any number of column dividers anywhere we want, including on either side.
  • \text{Column One} is an instruction to render “Column One” as plain text. If we didn't include the \text{ ... } marker, it would render as \$Column One\$ instead of as \$\text{Column One}\$. Since MathJax is for writing mathematical formulae it defaults to interpreting symbols you give it as mathematical symbols, ignores spacing and uses its own spacing rules, etc — so it has to be told explicitly when you don't mean that.
  • & is the column separator.
  • \\ marks a new line at the end of a row.
  • \hline marks a horizontal line between rows.
  • \end{array} marks the end of the array environment.

As with the rest of the whole MathJax-ificiation, we probably shouldn't actually table-ify anything that's just fine in plain text.

Some potential table-ey posts

Personal tip: Sublime Text does multi-location and multi-line editing and has made converting posts a breeze so far. (Or at least, not quite so tedious as it could be.)

\$\endgroup\$
7
  • \$\begingroup\$ This doesn't seem to work with tables that have spaces in them. The output omits the spaces and you just have a squashed mess. \$\endgroup\$ Jun 4, 2016 at 21:11
  • 1
    \$\begingroup\$ @Thunderforge I suspect that's because math-mode LaTeX collapses spaces intentionally (they're not typically useful in equations). I believe the \text{} macro is how to declare a piece of math input to be text-mode, which might work in these tables. \$\endgroup\$ Jun 5, 2016 at 4:41
  • \$\begingroup\$ @SevenSidedDie I've been using \text{} regularly, that's the one. \$\endgroup\$ Jun 5, 2016 at 5:15
  • 1
    \$\begingroup\$ @Thunderforge \,, \;, \quad, \qquad, \hspace{...}, and \vspace{...} are also going to be things to look into. Remember that TeX input is semantic; if you care about whitespace's size you're going to have to declare it. \$\endgroup\$
    – nitsua60 Mod
    Jun 5, 2016 at 13:44
  • 1
    \$\begingroup\$ I'd been scared off by this, thinking it way over my head, but I bit the bullet, took 5 min. to tinker, and made my first table using copy-and-paste and instructions from this post. If I could bounty a community wiki on Meta, I would. Thank you. \$\endgroup\$ Apr 10, 2018 at 19:48
  • \$\begingroup\$ @HeyICanChan I'm glad this was helpful! :D I realised today I didn't add any guidance at all on decrypting that example, and I'm glad it could help someone figure this stuff out. \$\endgroup\$ Apr 10, 2018 at 20:19
  • \$\begingroup\$ Should we add a disclaimer on the top of this indicating that we now have Markdown tables, and that they are superior for accessibility? \$\endgroup\$
    – KRyan
    Oct 30, 2021 at 21:41
9
\$\begingroup\$

Since it comes up a fair amount in fantasy settings like Faerûn, handling accents in a MathJax setting (i.e. table) is... awkward. The û character uses the wrong font in MathJax, for example \text{Faerûn} produces \$\text{Faerûn}\$, with the û in a glaringly-different font (non-text contexts are even worse: \$Faerûn\$).

Either accents and diacritics have similar problems: \$ú\$, \$ù\$, \$ü\$, \$ū\$.

MathJax has its own way of doing accents though: \hat, \acute, \grave, \ddot, \bar. So \hat u produces \$\hat u\$. Likewise, \acute u for \$\acute u\$, \grave u for \$\grave u\$, \ddot u for \$\ddot u\$, \bar u for \$\bar u\$.

These can wrap around a text block, for example \hat{\text{u}} produces \$\hat{\text{u}}\$. This gets awkward, though, when you are already in a text context: you have to start a new math context with $ to use \hat, so \$\text{Faer$\hat{\text{u}}$n}\$ requires \text{Faer$\hat{\text{u}}$n}.

\$\endgroup\$
13
  • \$\begingroup\$ Interestingly, the first method has no font mismatch issues in my browser (currently: Safari/OSX) apart from not italicising with the rest in “variable” context; but the second method is kinda broken, with the accents coming half-way or farther after the u (so in the last example the hat is on the n). I suspect bugs in MathJax + our site stylesheet's font choices and font fallbacks + varying font support in different browser/OS views. \$\endgroup\$ Apr 28, 2017 at 15:36
  • \$\begingroup\$ @SevenSidedDie That is odd—having better results from the first one doesn’t surprise me overmuch, but the second approach is the “correct” one from a MathJax perspective, so I’m surprised it doesn’t work. \$\endgroup\$
    – KRyan
    Apr 28, 2017 at 15:37
  • \$\begingroup\$ Helpful tip, thanks. \$\endgroup\$ Apr 28, 2017 at 16:47
  • 1
    \$\begingroup\$ @KRyan My guess is that, because it's the “right” way only by tradition (LaTeX used to not be capable of handling Unicode source text and had to compose these characters on-command manually with raw TeX positioning commands), MathJax is likely doing it in a similar manual-composition way, but the wider variety of rendering environments posed by modern browser/OS combinations makes it more fragile / easier to be buggy than in the stable environment of the standard LaTeX renderers. \$\endgroup\$ Apr 28, 2017 at 16:58
  • \$\begingroup\$ @KRyan I don't need to hold the initial 0 and can, instead, hold ALT then type 1, 5, and 0 to get a û, but I'm not a programmer so I also don't count by saying 0, 1, 2, 3 either. ;-) \$\endgroup\$ Apr 28, 2017 at 16:58
  • \$\begingroup\$ @HeyICanChan Actually, I misspoke; with 0, 1, 5, 0 you actually get an en dash (), which I use rather more often that u circumflex. You must use 1, 5, 0 for û. Gonna delete that misleading comment now. (I don’t think the leading 0 has anything to do with the programming habit of 0-indexing things, but I could be wrong—the Alt codes don’t generally seem to have much rhyme or reason to them that I’ve been able to discern.) \$\endgroup\$
    – KRyan
    Apr 28, 2017 at 17:05
  • \$\begingroup\$ @HeyICanChan Actually, looked it up and was able to find info this time. The non-0 codes are for IBM’s Code Page 437 characters, which was the original implementation of Alt codes in DOS. When Microsoft wanted to introduce its own Code Page 1252, too many people had already memorized the CP 437 codes so they left those alone, and added the 0 prefix for their own codes. Today, Alt codes that don’t start with 0 still reference CP 437, while 0-prefixed codes reference CP 1252, and (with a registry change) + prefixed codes reference Unicode. \$\endgroup\$
    – KRyan
    Apr 28, 2017 at 17:15
  • \$\begingroup\$ @HeyICanChan This means that û can be achieved with 1, 5, 0 (referencing the code point 150 in CP 437) or with 0, 2, 5, 1 (referencing the code point 251 in CP 1252) or with +, f, b (referencing code point 0xFB in Unicode), though that last only works if you’ve turned it on in the registry. All three methods require using the number pad (rather than the row of digits above the letters on the keyboard), though the last also uses the characters the main a, b, c, d, e, and f keys because it uses hexadecimal numbers (to better match most Unicode docs). \$\endgroup\$
    – KRyan
    Apr 28, 2017 at 17:19
  • 2
    \$\begingroup\$ @KRyan I know it sounds sarcastic, but that really is fascinating. I am so old that I started with the 3-digit escape codes (I needed (yes, needed) the ½ and ¼ for Champions, for instance, the 3-digit versions of which I just made from muscle memory–I can't tell you the numbers I typed). I always kind of wondered what happened to cause 4-digit escape codes. Thanks. There's my new thing for the day. Time to knock off. \$\endgroup\$ Apr 28, 2017 at 17:20
  • \$\begingroup\$ @HeyICanChan The relevant Wikipedia article is fairly dense and wall-like, but I agree, it is kind of interesting stuff. \$\endgroup\$
    – KRyan
    Apr 28, 2017 at 17:23
  • \$\begingroup\$ @KRyan Since we're on this horribly off-topic, Wikipedia just led me on a goose chase (that I lost--freakin' Wikigeese) trying to find the list of 3-digit ASCII escape codes. Is it at all convenient to link to them real quick? (I need to memorize the m dash and ellipsis.) \$\endgroup\$ Apr 28, 2017 at 17:34
  • 1
    \$\begingroup\$ @HeyICanChan That should be the IBM Code page 437 that I linked earlier, actually. This is what those codes reference. Unfortunately, CP 437 doesn’t include either the em dash or the ellipsis characters. Windows CP 1252 does, at 151 and 133 respectively, but that means typing four digits (0, 1, 5, 1 and 0, 1, 3, 3). \$\endgroup\$
    – KRyan
    Apr 28, 2017 at 17:40
  • \$\begingroup\$ @KRyan Sincerely, thank you! Now to get to Carnegie Hall—practice, practice, practice… \$\endgroup\$ Apr 28, 2017 at 17:45
5
\$\begingroup\$

Reference for Stack-Useful MathJax structures

Mathematics.SE's meta has a nice post detailing many of the tips they've found useful over the years: https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference.

Obviously we should take care around "dialect" issues: their delimiter is $...$, for instance.

TIL you don't even need the \$...\$ delimiters when \begin{...}ing and \end{...}ing an environment!

\$\endgroup\$
5
\$\begingroup\$

List of posts identified as candidates, then edited with MathJax:

(per this comment)

\$\endgroup\$

You must log in to answer this question.

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