Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with ampersands in custom preamble (A glitch in the matrix) #20

Open
scoskey opened this issue Mar 14, 2018 · 1 comment
Open

Comments

@scoskey
Copy link
Contributor

scoskey commented Mar 14, 2018

https://wordpress.org/support/topic/problem-with-ampersands-in-custom-preamble-a-glitch-in-the-matrix/

Hi,

Love SImple MathJax, it makes my life as a maths blogger SO MUCH easier. Thanks for doing such great work.

I have one thing I’m struggling with: I’ve added a \newcommand in the custom preamble that looks like this:

\newcommand{\mattwotwo}[4]{\begin{pmatrix} #1 & #2 \ #3 & #4 \end{pmatrix}}

However, it seems that the ampersands are being escaped and turned into & amp; before they’re processed, leaving me with ‘amps’ in my matrix! Escaping the ampersands with a \ leaves literal &s instead of spacing.

I know there’s a warning that this bit is untested and unescaped strings like this may cause problems — my current workaround is to put ampersands in the LaTeX as I do it, which is clunky but works — I wondered if there was a more elegant way to do it that didn’t involve remembering them?

@pkra
Copy link
Member

pkra commented Mar 14, 2018

$preamble = preg_replace('/\\\\/','\\\\\\\\',$preamble);
shows that we've already hacked (PHP?) escaping. We can unescape ampersands the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants