Support » Plugin: KaTeX » Aligning on =

  • Resolved omdaddi

    (@omdaddi)


    Thanks, this is super fast and looks great. Brilliant.

    I have not been able to find a LaTeX plugin for WP that will allow me to align on the = sign. e.g.

    \begin{align}
    n &= \frac{1}{sin\ c} \\
    &=\frac{1}{sin\ 48.3^\circ}\\
    \end{align}

    This borks because wordpress escapes the ampersand so the LaTeX looks like &=.

    I have no idea if this is fixable, but worth asking.

    • This topic was modified 1 year, 7 months ago by omdaddi.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Thomas Churchman

    (@beskhue)

    Using the KaTeX block provided by this plugin, ampersands for aligning should work fine! In the source code of the page you would indeed see the ampersand being encoded to HTML as &, but that is expected. The KaTeX library decodes that to the ampersand literal.

    To be clear: you should not be seeing & being rendered in the formula. If that happens, something is not working as intended.

    Your code example almost works, though you have to use the aligned environment instead of align.

    So:

    
    \begin{aligned}
    n &= \frac{1}{sin\ c} \\
    &=\frac{1}{sin\ 48.3^\circ}
    \end{aligned}
    

    When using KaTeX inline in a paragraph block with shortcodes, ampersands should also work as expected: e.g. [katex]a \& b[/katex] renders as “a&b”.

    Thread Starter omdaddi

    (@omdaddi)

    Utterly solved, thank you.

    Not quite sure what I was doing wrong, but now working a treat.

    Thank you for the heads up on aligned rather than align.

    Plugin Author Thomas Churchman

    (@beskhue)

    Great!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Aligning on =’ is closed to new replies.