as-com / wp-katex

Integrates the fast KaTeX LaTeX typesetter with WordPress
https://andrewsun.com/projects/wp-katex/
GNU General Public License v2.0
9 stars 5 forks source link

\frac and aligned not Working Combined #12

Open fdeitelhoff opened 7 years ago

fdeitelhoff commented 7 years ago

I'm using the following two LaTeX statements:

[latex display="true"]\begin{aligned}M_{d} = \frac{20\,cm}{17,5895\,cm}\end{aligned}[/latex] 
[latex display="true"]\begin{aligned}M_{d} = 1,1370 \end{aligned}[/latex]

Normally I want to use them in one equation to align both at the '='. But if I'm doing that the horizontal rule of the fraction does not get rendered. The rest is okay.

I'm using the latest WordPress. Maybe I'm doing something wrong?

as-com commented 7 years ago

Gah, this took longer than expected to investigate...

There are three issues here:

  1. The align environment requires formatting the equation like this:
    \begin{aligned}
    M_{d} &= \frac{20\,cm}{17,5895\,cm} \\
    M_{d} &= 1,1370
    \end{aligned}
  2. However, you can't drop that into a shortcode as-is, because of wpautop (#7). So you'll need to put it on a single line:
    [latex display=true]\begin{aligned}M_{d} &= \frac{20\,cm}{17,5895\,cm} \\ M_{d} &= 1,1370\end{aligned}[/latex]

If you're using a clean WordPress install, like in this test instance, you can stop here. But on some installs, like mine...

  1. ...that still doesn't work, because for some reason my own WordPress install is stripping double backslashes from the post content. Sigh...
fdeitelhoff commented 7 years ago

@as-com Thanks for the fast feedback. Solved it for now with a single line. Not quite sure what differs because I already tried the one-liner. But it is working right now.

The real problem is the transformation of line breaks to HTML via WordPress I think.