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

Extensible delimiters (\left and \right) #14

Closed
9 tasks done
gsomix opened this issue Feb 12, 2017 · 10 comments
Closed
9 tasks done

Extensible delimiters (\left and \right) #14

gsomix opened this issue Feb 12, 2017 · 10 comments
Assignees

Comments

@gsomix
Copy link
Collaborator

gsomix commented Feb 12, 2017

Full brace list we need to support:

  • \left. \right. (empty delimiter)
  • \left( \right)
  • \left[ \right]
  • \left\{ \right\}
  • \left< \right>
  • \left| \right|

Plan

  • take a look at Java implementation — at least JLatexMath seems to support those delimiters ~ F
  • implement delimiters as a resizable characters (i.e. don't split them into top / top-middle / etc. parts yet)
  • add full support with splitting the characters into parts — it suddenly turned out that we already have those
@ForNeVeR
Copy link
Owner

ForNeVeR commented Feb 13, 2017

I think that we'll need to store brace stack somewhere when interpreting the formula, and try to keep size of the matching braces equal. Note that different braces could match each one. E.g. \left< \frac{a}{\frac{b}{c}} \right\} should be rendered as image.

Here's a good explanation of so-called "extensible delimiters" on StackExchange: http://tex.stackexchange.com/a/77593/109147

@ForNeVeR ForNeVeR changed the title Implement \left( and \right) Implement \left and \right braces Feb 13, 2017
@ForNeVeR ForNeVeR changed the title Implement \left and \right braces Extensible delimiters (\left and \right) Feb 13, 2017
@alexreg
Copy link
Collaborator

alexreg commented Feb 13, 2017

This is definitely a feature that should be prioritised. I'm not sure if the Java library I ported from handled this at all (actually there were two Java libraries; one for plain TeX and one for LaTeX), but it's worth a check. If not, having a look at the LaTeX source code may be informative.

@ForNeVeR ForNeVeR self-assigned this Feb 14, 2017
@ForNeVeR
Copy link
Owner

Aha, it seems like jlatexmath have support for \left and \right.

@ForNeVeR
Copy link
Owner

ForNeVeR commented Feb 14, 2017

Just dumping what I've found regarding this task so far.

It seems that we have the atom definition for the brace-enclosed formula; it's called FencedAtom.

It looks like that FencedAtom isn't used in the current code, but it could be exactly what we need. I plan to add the support for \left and \right commands into TexFormulaParser.ProcessCommand method. It seems like that won't be very hard: just parse the formula part before the corresponding \right command and enclose it in FencedAtom (probably we'll want to keep that stack somewhere; we'll see).

I also want to add unit tests for the parser; I'll file another issue about that.

This was referenced Feb 14, 2017
ForNeVeR added a commit that referenced this issue Feb 19, 2017
We aren't using these definitions anyway.
ForNeVeR added a commit that referenced this issue Feb 19, 2017
We aren't using these definitions anyway.
ForNeVeR added a commit that referenced this issue Feb 19, 2017
@alexreg
Copy link
Collaborator

alexreg commented Feb 20, 2017

Good work on this. I haven't looked at the implementation yet, but I'm slightly concerned that most of the brackets are implemented except for \left|. Did you not do this in a generic way?

@ForNeVeR
Copy link
Owner

Ah, that's a long story. My initial implementation had some flaws, and I thought there were problems with \left|. Actually there're none.

The delimiters are implemented in a generic way (because there's already a metadata on delimiters), \left| is working. I'll mark it now.

\left. and \right. aren't working currently exactly because there aren't any metadata about them. I think we'll handle them in a special way or simple declare as proper delimiters; will decide later.

@alexreg
Copy link
Collaborator

alexreg commented Feb 21, 2017

Oh, right. Fair enough then!

@alexreg
Copy link
Collaborator

alexreg commented Feb 26, 2017

I just noticed that \left| and \right| still don't work.

@ForNeVeR
Copy link
Owner

Oh, that's interesting. | is considered as an opening delimiter only. Look:
image
image

@alexreg
Copy link
Collaborator

alexreg commented Feb 26, 2017

Good spot. That was definitely the problem.

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

No branches or pull requests

3 participants