• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

MathJax/LaTex BB Code

#1
I can't seem to find anything in the RM for this. I can't imagine there's a huge demand by forum goers wanting to embed math into their posts, but I'm one that does.

Here's a CDN based system that can be used to embed math into web pages.

http://docs.mathjax.org/en/latest/start.html

And here's a description of LaTeX.

https://en.wikibooks.org/wiki/LaTeX/Mathematics

I imagine that a BB Code would replace the LaTeX delimiter with [math][/math] or [latex][/latex] type codes.

Anyway, just putting it out there that there seems to be a lack of an add-on/BB Code of this type. Maybe someone looking to practice some coding might be interested in a project like this?
 
#3
Would this get it working on XenForo?

https://www.checkmyworking.com/2012/01/how-to-get-beautifully-typeset-maths-on-your-blog/

If you have the ability to edit the HTML of your blog’s header, paste the following code just below the line with the <title> tag on it:
Code:
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']],
                       displayMath: [['\\[','\\]'], ['$$','$$']]}});
</script>
<script type="text/javascript"
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
Warning: This could mess up code big time, cause XenForo's title isn't coded like on some blog. Where's is XenForo's title and and any free or paid tutorials on how to put in the code safely?
 
Last edited:

Andy.N

Well-known member
#6
@Chris D
Seems prismjs support Latex, I'm trying to test it but it didn't seem to work. Any idea?
Code:
\frac{1}{2}
Code:
\[ \frac{1}{2} \]
Code:
\( \frac{1}{2} \)
 

Chris D

XenForo developer
Staff member
#7
Prism supports the languages you ask it to support. If we supported all of the languages we'd be loading pretty much 300KB extra on every page which has a code block which doesn't seem reasonable IMO.

Support for additional languages could be considered but I'd recommend posting a suggestion.

In the mean time you could download the language yourself from GitHub: https://raw.githubusercontent.com/PrismJS/prism/gh-pages/components/prism-latex.min.js then include it in the prism_macros template just below the <xf:js line. You'd then just add the language name in the "Allowed code BB code block languages" option in the Admin CP.
 
#8
Is prismjs a mod? Anyway, a latex thing where the notation would be the same color as the text (as my background isn't white (black text on white thing)).