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

Support for "equation" environment #445

Open
invkrh opened this Issue Mar 3, 2016 · 16 comments

Comments

Projects
None yet
6 participants
@invkrh
Copy link

invkrh commented Mar 3, 2016

It seems that multi-line auto rendering is not possible for the moment.

For example:

\begin{equation}
  x = a_0 + \cfrac{1}{a_1
          + \cfrac{1}{a_2
          + \cfrac{1}{a_3 + \cfrac{1}{a_4} } } }
\end{equation}

Here is the exception:

KaTeX auto-render: Failed to parse `
    \begin{equation}
    x = a_0 + \cfrac{1}{a_1
            + \cfrac{1}{a_2
            + \cfrac{1}{a_3 + \cfrac{1}{a_4} } } }
  \end{equation}\frac{1}{2} 
    ` with  Error: KaTeX parse error: No such environment: equation at position 21: begin{equation}̲

Any ideas ?

@invkrh

This comment has been minimized.

Copy link

invkrh commented Mar 3, 2016

The equation env has not been implemented yet...

But the aligned* is implemented according to the wiki page: https://github.com/Khan/KaTeX/wiki/Function-Support-in-KaTeX

It does not work neither.

\begin{aligned}
a&=b&c&=d\\
e&=f
\end{aligned}

It gives No such environment: aligned* exception

I also tried array.

\begin{array}{ccc}
a&=&b&c&=&d\\
e&=&f
\end{array}

array env works.

@invkrh

This comment has been minimized.

Copy link

invkrh commented Mar 3, 2016

It seems that aligned is not recognized by the environment.
https://github.com/Khan/KaTeX/blob/master/src/Parser.js#L428

@kevinbarabash

This comment has been minimized.

Copy link
Member

kevinbarabash commented Mar 3, 2016

aligned is supported on master but not in the most recent release. I can see how the wiki page is a little confusing. The * after aligned is supposed indicate that there is a note at the bottom of the wiki page that states *Committed to master but not part of the most current release.

@xymostech

This comment has been minimized.

Copy link
Contributor

xymostech commented Mar 3, 2016

(I replaced * with to make things less confusing maybe)

@invkrh

This comment has been minimized.

Copy link

invkrh commented Mar 3, 2016

Thank you for the clarification. =)

@kevinbarabash kevinbarabash changed the title Rendering multi-line equation Support for "equation" environment Mar 4, 2016

@kevinbarabash kevinbarabash added this to the Backlog milestone Jun 3, 2018

@edigleyalexandre

This comment has been minimized.

Copy link

edigleyalexandre commented Jul 18, 2018

@invkrh I also hope for the implementation of \begin {equation} for Katex. It would be fantastic.

@edemaine

This comment has been minimized.

Copy link
Member

edemaine commented Jul 19, 2018

It is possible to add very basic support for \begin{equation} ... \end{equation} by specifying a custom delimiter in auto-render. For example:

renderMathInElement(document.body, {
  delimiters: [
    {left: "$$", right: "$$", display: true},
    {left: "\\(", right: "\\)", display: false},
    {left: "\\[", right: "\\]", display: true},
    {left: "\\begin{equation}", right: "\\end{equation}", display: true}
  ]
});

See https://codepen.io/edemaine/pen/EpNamj for a demo.

However, equation numbering isn't supported yet; #350 tracks that. Note that manual numbering via \tag is possible, though.

@edemaine

This comment has been minimized.

Copy link
Member

edemaine commented Jul 19, 2018

@edigleyalexandre You can add support for $ by adding another delimiter to the list.

@edigleyalexandre

This comment has been minimized.

Copy link

edigleyalexandre commented Jul 19, 2018

@edemaine I added but it did not work.

@ronkok

This comment has been minimized.

Copy link
Collaborator

ronkok commented Jul 19, 2018

@edigleyalexandre It matters where in the list things are placed. Be sure that "$" comes after "$$", as in:

renderMathInElement(document.body, {
  delimiters: [
    {left: "$$", right: "$$", display: true},
    {left: "$", right: "$", display: true},
    {left: "\\(", right: "\\)", display: false},
    {left: "\\[", right: "\\]", display: true},
    {left: "\\begin{equation}", right: "\\end{equation}", display: true}
  ]
});
@edigleyalexandre

This comment has been minimized.

Copy link

edigleyalexandre commented Jul 19, 2018

I added as indicated, but it does not render. Look here.

@edemaine

This comment has been minimized.

Copy link
Member

edemaine commented Jul 19, 2018

@edigleyalexandre Can you be specific about an example of $...$ text that doesn't render? I tried adding an example to your page, then running the same renderMathInElement, and it worked fine. You might be running into the ignoredTags setting, because you have $...$ text inside <code>...</code> elements; see https://github.com/Khan/KaTeX/tree/master/contrib/auto-render for documentation.

P.S. @ronkok Probably meant display: false as in {left: "$", right: "$", display: false},

@edigleyalexandre

This comment has been minimized.

Copy link

edigleyalexandre commented Jul 19, 2018

@edemaine Here's how to get with Mathjax. On here. The idea is to leave it with Katex. The page shows code and rendering.

@edigleyalexandre

This comment has been minimized.

Copy link

edigleyalexandre commented Jul 20, 2018

\begin {matrix} and \begin {cases} are supported on Katex. I tested the main page of the Katex website and rendered it, but the blog did not render. What happened? Page with \begin {cases} that did not render.

@ronkok

This comment has been minimized.

Copy link
Collaborator

ronkok commented Jul 20, 2018

Well, you did omit a comma that should follow {left: "\(", right: "\)", display: false}. I don't know if that by itself is enough to stop the script.

@edigleyalexandre

This comment has been minimized.

Copy link

edigleyalexandre commented Jul 21, 2018

It worked. Forgive me for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment