Using cases in wordpress site

59 views
Skip to first unread message

Assaf Manor

unread,
Sep 20, 2022, 6:55:28 PM9/20/22
to MathJax Users
Hello all,

I am trying to use the cases package using the "Simple Mathjax" plugin for Wordpress. I added this code to the Custom MathJax config:
window.MathJax = { loader: {load: ['[tex]/cases']}, tex: {packages: {'[+]': ['cases']}} };

As I found online that one has to add to load the cases package, but I'm not sure if I added this to the correct location.

After that I used this code on webpage:

 \( f(n) =  \begin{cases} n/2 & n \text{ is even} \\ 3n+1 & n \text{ is odd} \end{cases} \)

But alas, this doesn't work. I tried googling this and also searching in this forum, but for no avail. To note - I am using \( and \) to start and end a mathematical expression. This is what starts latex inside the html text.


Would very much appreciate you assistance!

Davide Cervone

unread,
Sep 28, 2022, 6:26:39 AM9/28/22
to mathja...@googlegroups.com
The "cases" package implements the "numcases" and "subcases:" environments; the "cases" environment itself is part of the "ams" package.  You can see which package  defines a given environment in the documentation at


So unless you have changed the URL for the CDN, it should have the ams package preloaded, and you can just use the "cases" environment directly.

After that I used this code on webpage:

 \( f(n) =  \begin{cases} n/2 & n \text{ is even} \\ 3n+1 & n \text{ is odd} \end{cases} \)

You may need to use \\( and \\) around the command (though $...$ is easier), since the WordPress processor uses backslashes as escape characters, you may need to escape them so that they are available in the page for MathJax to find them.  (That is why it may be easier to use dollar signs.)

See if that works for you.

Davide


Assaf Manor

unread,
Oct 4, 2022, 3:09:27 PM10/4/22
to MathJax Users
Thank you for your help Davide!
I was able to load the ams package, or something else happend, but anyway the cases works!

For me the \( ... \) works fine in WordPress. I tried using the the dollar sign and the double dollar sign, but all the time this is what is rendering (in the attached image). For some unexplained reason - it doesn't let the \begin{cases} ...\end{cases} be inside another formula.

This is the code I used:

$ f(n) = \begin{cases}
\frac{n}{2}, & \text{if $n$ is even} \\[2ex]
3n+1, & \text{if $n$ is odd}
\end{cases}

$


When I encircle just the f(n) with $ - it shows up in latex styling, but the cases appear on a new line.

Would very much appreciate your help!
cases.jpg

Assaf Manor

unread,
Oct 4, 2022, 3:22:08 PM10/4/22
to MathJax Users
Okay, I think my LMS plugin (LearnDash) messed things up. But now everything is working. Thank you!!!

Davide Cervone

unread,
Oct 4, 2022, 3:26:06 PM10/4/22
to mathja...@googlegroups.com
OK, great.  Glad everything seems to be working for you now.

Davide


-- 
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/8c31a923-2649-472c-942b-23e235d40c6bn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages