New [latex]...[/latex] bbCodes

Post Reply
User avatar
Dave Keenan
Site Admin
Posts: 2180
Joined: Tue Sep 01, 2015 2:59 pm
Location: Brisbane, Queensland, Australia
Contact:

New [latex]...[/latex] bbCodes

Post by Dave Keenan »

You can now include beautiful math expressions in your posts, using \(\LaTeX\) thanks to this MathJax phpBB extension by Kailey Truscott. Thanks to @cmloegcmluin for suggesting this. And of course, thanks to Donald Knuth, Leslie Lamport and the MathJax team.

For example

\(x = {-b \pm \sqrt{b^2 - 4ac} \over 2a}\)

was generated by:

[latex]x = {-b \pm \sqrt{b^2 - 4ac} \over 2a}[/latex]

It can also be written:

[latex]
x = {
    -b \pm \sqrt{b^2 - 4ac}
    \over
    2a
}
[/latex]

Non-breaking spaces were used to achieve the indenting above.

There are many online sources of information about LaTeX. Here's one:
https://en.wikibooks.org/wiki/LaTeX/Mathematics#Symbols

And here's one of several online LaTeX editors:
http://www.hostmath.com/

Now all we need is a way to include Sagittal music scores in our posts.
User avatar
cmloegcmluin
Site Admin
Posts: 1700
Joined: Tue Feb 11, 2020 3:10 pm
Location: San Francisco, California, USA
Real Name: Douglas Blumeyer (he/him/his)
Contact:

Re: New [latex]...[/latex] bbCodes

Post by cmloegcmluin »

The pressure is on, now! (to write some beautiful equations) Good thing I got a little practice with LaTeX earlier this year on the Xen wiki (linking not for self-promotion, of course... but for the benefits of others, including future versions of myself, who may want to leverage some techniques I used there).

Re: Sagittal scores, I think the summary of where we're at on that front is this: Daniel said we shouldn't expect to get Bravura working in the browser without the assistance of a library such as Vexflow, and I've been pestering them for months to get Sagittal support included in their library but with no response. With enough time I could figure out how to do it myself, but perhaps I can wait that battle out.
User avatar
Dave Keenan
Site Admin
Posts: 2180
Joined: Tue Sep 01, 2015 2:59 pm
Location: Brisbane, Queensland, Australia
Contact:

Re: New [latex]...[/latex] bbCodes

Post by Dave Keenan »

Woah. That Metallic MOS article has grown a lot since I last saw it.

Another angle on getting scores into the forum was to get Bravura Text accepted as a Google Font, which required it to have the full ASCII set plus a few other common characters, and therefore required it to use Unicode space characters instead of "=" and "-" for staff spacing.

Another was to get a .woff version of Bravura Text that wasn't broken.
User avatar
Dave Keenan
Site Admin
Posts: 2180
Joined: Tue Sep 01, 2015 2:59 pm
Location: Brisbane, Queensland, Australia
Contact:

Re: New [latex]...[/latex] bbCodes

Post by Dave Keenan »

It looks like the MathJax extension has broken something. There's some weirdness happening with backquote characters ` also called graves. You can see it here with some text that was surrounded by backquotes.

viewtopic.php?p=1327#p1327

My first thought was that `...` might be equivalent to [latex]...[/latex]. But when I surround the following with backquotes

x = {-b \pm \sqrt{b^2 - 4ac} \over 2a}

I get

`x = {-b \pm \sqrt{b^2 - 4ac} \over 2a}`

It fails to interpret the \over macro.

In any case, this is very annoying. I saw nothing in the MathJax extension documentation about commandeering backquotes.

Fortunately this doesn't break the Sagittal smilies that use backquotes :`: :``:
User avatar
cmloegcmluin
Site Admin
Posts: 1700
Joined: Tue Feb 11, 2020 3:10 pm
Location: San Francisco, California, USA
Real Name: Douglas Blumeyer (he/him/his)
Contact:

Re: New [latex]...[/latex] bbCodes

Post by cmloegcmluin »

AsciiMath, I think that must be: http://docs.mathjax.org/en/latest/basic ... math-input

Perhaps this is okay, though. I'm happy to fix the backquotes on that post. For multiple lines of code, we have the [code] bbCode. And for inline tokens of code, it's not like the backquote formats it differently here (as would be the case in code-specific markdown settings e.g. GitHub), so normal quotes should be just fine. Or if you want you can always do something like this: monospace (that's [font=monospace][hilite=white]monospace[/hilite][/font]).
User avatar
Dave Keenan
Site Admin
Posts: 2180
Joined: Tue Sep 01, 2015 2:59 pm
Location: Brisbane, Queensland, Australia
Contact:

Re: New [latex]...[/latex] bbCodes

Post by Dave Keenan »

Ah. Thanks for explaining that. AsciiMath? Who asked for that? (Rhetorical)

I've now learned that not only does MathJax eat backquotes outside of [latex]...[/latex], it also eats the sequences \(...\), \[...\] and $$...$$, all of which I've been forced to escape* so you can see them here. The last two are equivalent and produce a centered "display" expression from LaTeX source, instead of an inline expression. Try them.

In fact the [latex]...[/latex] bbCode simply translates to <span>\(...\)</span> before the whole page is fed through MathJax. Fortunately it doesn't break the :|\): = :|\): smiley either.

Yes. Please escape or replace the backquotes in that post, and any others you're aware of.

* Other readers may not be aware that a hack for escaping bbCode tags and smiley/emoji codes (and now AsciiMath and LaTeX tags) is to surround their first character with [size=100]...[/size].

I've learned that it should be possible to eliminate all these nasties by creating our own local MathJax configuration file, and pointing to it from sagittal/forum/ext/kinerity/mathjax/styles/prosilver/template/event/overall_footer_after.html which contains a single line:

Code: Select all

<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML"></script>
This is explained here:
https://docs.mathjax.org/en/v2.7-latest ... nfig-files
and here:
https://docs.mathjax.org/en/v2.7-latest ... igurations
but it seems like a lot of work.

I guess I can live with the backquotes thing, and the two-character LaTeX tags shouldn't cause a problem.
User avatar
cmloegcmluin
Site Admin
Posts: 1700
Joined: Tue Feb 11, 2020 3:10 pm
Location: San Francisco, California, USA
Real Name: Douglas Blumeyer (he/him/his)
Contact:

Re: New [latex]...[/latex] bbCodes

Post by cmloegcmluin »

Cool beans!

$$F_n = { \phi^n - (-\phi)^{-n} \over \sqrt5}$$

Shouldn't be that hard to modify the extension by those instructions actually. Won't be my first priority though. I've filed it though.
Post Reply