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

Support \overline command #79

Closed
karlwessel opened this issue Sep 22, 2022 · 3 comments
Closed

Support \overline command #79

karlwessel opened this issue Sep 22, 2022 · 3 comments

Comments

@karlwessel
Copy link

It seems like the \overline command is not supported yet.

I guess it would be rather simple adding it, since it basically does the same as the \sqrt command but without the actual root in front.

I had a quick go on it myself but couldn't exactly understand everything that happens in the tex_layout method. Especially what it is supposed to return.

@Kolaru
Copy link
Owner

Kolaru commented Sep 22, 2022

Thanks for reporting that.

tex_layout works recursively. The general idea is

  1. Reckognize what type of element is being layouted (e.g. sqrt or frac)
  2. Layout each subelements (e.g. the group of elements inside a sqrt or the denominator and numerator of a frac) individually calling tex_layout on their TeXExpr (which all come from the parser).
  3. Now that we have the layout information (typically inkwidth and inkheight) available, we can use them to place the subelements themselves relative to each other and add any additonal one that are needed (e.g. the horizontal bar for sqrt -- knowing the width and height of the content we can compute its position and length)
  4. Return a Group which has 3 parts
    • A list of the subelements (e.g. Group, TeXChar or HLine)
    • A list of their relative positions
    • A list of their relative scale (often just 1 for each subelement)

This may be a bit different from other systems, since each of the element is immutable and doesn't know its own position or scale, only its parent does.

This results in a deeply nested structure that is flatten at a latter point.

If you want to have another go at it and have any question, don't hesitate to ask.

karlwessel pushed a commit to karlwessel/MathTeXEngine.jl that referenced this issue Sep 23, 2022
add tests for parsers and layouts handling of overline
implement \overline command similiar to square root
@karlwessel
Copy link
Author

Thanks for the explanation. I created a pull request with my first take on the implementation. Layout probably needs some fine tuning.

It would probably also be good to add your explanation to the source code, or maybe a file src/layout/readme.md, similiar to parser.md.

@karlwessel
Copy link
Author

Fixed by #80

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

No branches or pull requests

2 participants