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

Rendering multi-line equations in KaTex? #208

Closed
drbunsen opened this issue Mar 24, 2015 · 13 comments

Comments

@drbunsen
Copy link

commented Mar 24, 2015

Can KaTex render multi-line equations? It seems that AMS Math mode is currently not supported. How can I render this multi-line equation in KaTex?

\begin{equation} \label{eq1}
\begin{split}
A & = \frac{\pi r^2}{2} \\
 & = \frac{1}{2} \pi r^2
\end{split}
\end{equation}

This is a great project, thanks for the help!

@PeterBocan

This comment has been minimized.

Copy link

commented Mar 24, 2015

This relates with all other issues, for example: #206 so as you can see we are all waiting for the miracle...

@sophiebits

This comment has been minimized.

Copy link
Contributor

commented Mar 24, 2015

Right – not yet, but we'd like to add it.

@sophiebits sophiebits closed this Mar 24, 2015

@PeterBocan

This comment has been minimized.

Copy link

commented Mar 24, 2015

@spicyj what does it mean "we'd like to add it"? What does it require to contribute a brand new functionality? I mean this require a lot of new stuff to introduce.

@xymostech

This comment has been minimized.

Copy link
Contributor

commented Mar 24, 2015

We haven't figured out a good cross-browser-compatible way to lay out equations in a way that would let us line them up to do multi-line equations. We've looked into couple approaches, but none of them have worked.

Right now, almost all formatting in KaTeX is done through CSS, and we only calculate heights of elements to do vertical alignment. Thus, to get multi-line equations to work, we have to figure out how to get CSS to do consistent-across-browsers horizontal alignment of elements in such a way that we can then vertically position the elements where we want them. Just based on what most browsers support and what CSS lets us do, the only feasible method for doing this is to use HTML <table>s. However, due to browser differences and the semi-unspecified spec surrounding them, it's hard to find the right CSS magic to get everything to work.

Neither @spicyj nor I are working full-time on this, so we haven't been able to spend enough time on this to find a suitable solution, but we know people want this, and would like to add it in the future.

@xymostech

This comment has been minimized.

Copy link
Contributor

commented Mar 24, 2015

(Also, once we figure out how to actually do the layout, we need to change the parser to understand the funky syntax, figure out how the different kinds of alignment work, etc.)

@PeterBocan

This comment has been minimized.

Copy link

commented Mar 24, 2015

@xymostech I see, but we are here too! Don't do it yourself, it's a community project, isn't it? :) Can you clarify what didn't work?

@utensil

This comment has been minimized.

Copy link
Contributor

commented Oct 11, 2015

With #268 merged, is this issue easier to address now?

@kevinbarabash

This comment has been minimized.

Copy link
Member

commented Oct 11, 2015

#268 will help a little bit with implementing any new command in KaTeX, but it doesn't provide a clear path forward in this case.

@utensil

This comment has been minimized.

Copy link
Contributor

commented Oct 12, 2015

But this and #350 are fundamental to any serious math writing. Would there be a plan or a series of milestones for this kind of features, to help the community to participate and collaborate?

@pnsaevik

This comment has been minimized.

Copy link

commented Nov 27, 2015

@xymostech

Just based on what most browsers support and what CSS lets us do, the only feasible method for doing this is to use HTML <table>s.

Is this a bad thing? HTML tables would be the way to go I guess (or CSS tables for that matter), or are there any problems with this approach?

@xymostech

This comment has been minimized.

Copy link
Contributor

commented Nov 30, 2015

@pnsaevik The problem with HTML tables is that the layout algorithm isn't actually specified, so it's really hard to get things to look correct in all the different browsers. Most of KaTeX is getting the layout of things exactly right, so having to deal with browser differences would be a huge pain.

As it turns out though, that statement is out-of-date and we did figure out a good way of solving this without the use of tables. :)

@mull

This comment has been minimized.

Copy link

commented Apr 27, 2016

@xymostech your last comment gave me some hope! Could you update us on the status of this? Would love to help out any way I can.

@xymostech

This comment has been minimized.

Copy link
Contributor

commented Apr 27, 2016

@mull This has been solved! We now have various multi-line environments, like \begin{array} and \begin{aligned}. The code to render them is here: https://github.com/Khan/KaTeX/blob/master/src/buildHTML.js#L517 We basically stack columns next to each other to get the desired effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.