Skip to content

Equations #44

Open
Open

Description

@jayvdb

While looking for optimal solutions for #3, I noticed most of them are caused by the decision to use [] for subscript in equations, along with ^ for superscript.

I am not aware of [] being a common approach for subscript in equations, while ^ is a very common approach for superscript.

_ is the more common syntax for subscript, as in LaTeX, and AsciiMath, etc.

But the only common (and github flavour) markdown solution is <sup> and <sub>. Problem 479 is currently using that approach.

We also have problems using $$ or $ with Latex : problems 431, 450, 463, 471, and 473.

A quick rundown of the options:

Any other options?

Activity

  1. jayvdb commented on Jun 29, 2016

    @jayvdb
    CollaboratorAuthor

    Here is a prototype of using hidden equations rendered to gif https://github.com/jayvdb/PocketEuler/tree/render-latex#problem-431 (https://github.com/jayvdb/PocketEuler/tree/render-latex). For that equation, we should probably use unicode, but it is just a simple example. I'll try some more complicated equations tomorrow. And if the idea works, I could package it up as a JS node remark plugin.
    Using svg didnt work in Github, and using svg -> png created a very large image.
    The attribute name data-expr comes from http://willdrevo.com/latex-equation-rendering-in-javascript-with-jekyll-and-katex/ . It could be named anything.

  2. jayvdb commented on Jun 30, 2016

    @jayvdb
    CollaboratorAuthor

    I've completed 431, and added problems 328, 332 and 335 (these replace existing images with generated images).

    https://github.com/jayvdb/PocketEuler/commits/render-latex

    • problem 328 replaced 994 and 1049 byte gifs with 898 and 739 byte gifs
    • problem 332 replaced 964 bytes with 585 bytes
    • problem 335 replaced 1055 bytes with 871 bytes

    The newly rendered images are no as pretty inline, as the height isnt optimised for the text. But the layout is reasonable, and more importantly the MD now contains the equation in a precise standard format. I should be able to improve the inline display, but IMO that isnt a serious problem - let me know if you disagree.

    Is the syntax ok? Adding class="equation" is redundant, so I think I might remove that to make the source more readable. The renderer will need to be improved slightly, but I'd rather a complex renderer than unreadable MD.

  3. jayvdb commented on Jun 30, 2016

    @jayvdb
    CollaboratorAuthor

    Interesting ![](http://mathurl.com/render.cgi?%5Czeta%28s%29%20%3D%20%5Csum_%7Bn%3D1%7D%5E%5Cinfty%20%5Cfrac%7B1%7D%7Bn%5Es%7D%5Cnocache) was showing a nicely rendered image, but now shows an image with "your domain is not authorized to use mathtex on this server" in red.

  4. imsky commented on Jul 1, 2016

    @imsky
    Owner

    the notation was from the original document by Keen.

    i would strongly prefer we use ASCII/basic UTF8 for equations, and failing that, with LaTeX notation. images in general are a poor format for equations.

  5. jayvdb commented on Jul 1, 2016

    @jayvdb
    CollaboratorAuthor

    ...basic UTF8...

    Most equations need sup or sub support, which isnt complete in UTF8, and doesnt work on some modern devices. Sup 1-3 is all that work on my tab. I can ask around on wikipedia technical forums to see if this problem has been reported by other mobile users.

    We could put a note at the top saying "PocketEuler use these glyphs: ..... If any are missing here please install font.... / PocketEuler is incompatible with your system"

    Are you implying that <sup> and <sub> are undesirable?

    and failing that, with LaTeX notation.

    LaTeX literally in the Github output, enclosed in $?

    Many other markdown tools would then do the right thing. I can build a list of major md tools which will fail to render the latex.

    And my funky <img> prototype with hidden LaTeX isnt an acceptable workaround?
    (I cool with that; imo PE solvers should learn to read literal LaTeX; that is the real world for maths)

  6. imsky commented on Jul 2, 2016

    @imsky
    Owner

    Are you implying that <sup> and <sub> are undesirable?

    I think they're fine, but they fail when copy/pasting.

    LaTeX literally in the Github output, enclosed in $?

    Sure - we can always fall back to pure text, which would work in any LaTeX editor.

    And my funky prototype with hidden LaTeX isnt an acceptable workaround?

    It's acceptable, but I'm slightly biased against using images generated remotely. Even if we can keep raw LaTeX in the Markdown and generate a HTML document with the right equation display, that would be an improvement over embedding images.

  7. jayvdb commented on Jul 2, 2016

    @jayvdb
    CollaboratorAuthor

    I could use <img alt="$eq$" ... which will make it assessible to visually impaired, and should work in any md w/ latex editor.
    Then provide a regex or tool to strip the img tags so the resulting md has literal latex embedded, for use with pandoc etc.

    But the opposite also works for me. Literal latex in the source md, and generate a md with img tags and the img files, or generate pure html versions of the equations.

  8. imsky commented on Jul 2, 2016

    @imsky
    Owner

    The first approach works for me as long as a caption is supplied with text that a user can select.

    The second approach seems to be the best, however readers will need a preamble to explain the notation.

  9. imsky commented on Jul 2, 2016

    @imsky
    Owner

    captions could just be text under the image.

  10. jayvdb commented on Jul 2, 2016

    @jayvdb
    CollaboratorAuthor

    Yea, thats a good idea for block equations, but I cant see that working for equations embedded in prose.
    We could move some of the inline equations to be a new block under the prose, by slightly revising the prose.
    Im guessing that wont work in all cases.

  11. imsky commented on Jul 2, 2016

    @imsky
    Owner

    that's why i think Keen originally used basic ASCII for equations - they fit most of the use cases and require a minimal amount of explanation.

    i'm OK with any solution as long as it's accessible and doesn't require remote servers.

  12. jayvdb commented on Jul 3, 2016

    @jayvdb
    CollaboratorAuthor

    A little more playing ... even with images disabled, most browsers make it difficult to access the img title, except with developer tools. Even Firefox extensions dont make this easy. And Chrome doesnt have developer tools on Android, or the ability to install extensions.

    So I'm giving up renderring img files, and agree we should use literal latex enclosed in $ whenever there are subscript in the equation. And we can use/fix/write a user-script to apply MathJax or similar to the latex, for anyone who needs help parsing the latex in their brain. Again user-scripts are not available for Chrome on Android

  13. jayvdb commented on Jul 4, 2016

    @jayvdb
    CollaboratorAuthor

    @georgenetu , I see you've been adding lots of problems, and have one more to add. Do you have any thoughts on this before we lock in one approach?

  14. jayvdb commented on Jul 6, 2016

    @jayvdb
    CollaboratorAuthor

    Hi @georgenetu , I've created #47 about one aspect of your merged additions, and I view this issue as also being feedback on your additions (at least Problem 479 is mentioned).

    Your additions have a different style from previous additions, but that is mostly because the repository doesnt have any style recommendations, and hasnt had any linting, and probably also because the style of the HTML for Project Euler has been revised also. There is no right answer; just tradeoffs.

    Other than Problem 479, the equations on all your other problems look pretty good as they are simple equations. For Problem 479, the use of sup & sub means information is lost during copy and paste. If we want to avoid that, we would need to switch the equation from using sup & sub to being a LaTeX equations. Then the problem is it is harder to read for people not already familiar with LaTeX equation syntax. Do you disagree with that type of change?

  15. added 4 commits that reference this issue on Jul 7, 2016
    219f105
    01a99f9
    095b2b8
    e5679e3
  16. jayvdb commented on Jul 10, 2016

    @jayvdb
    CollaboratorAuthor

    We now have a new problem with _ in equations becoming italics in problems 186 , 230, 422, 444, and 468 .

    To avoid this, we may need to use a workaround like 29\lower0.5ex\hbox{x} instead of 29_x to achieve subscript in LaTeX and not cause the markdown to render as italics on Github and likely any other tool which doesnt handle $..$ as special. Youch.

  17. reopened this on Jul 10, 2016
  18. imsky commented on Jul 10, 2016

    @imsky
    Owner

    why not just encode those as inline code blocks with backticks?

  19. jayvdb commented on Jul 10, 2016

    @jayvdb
    CollaboratorAuthor

    Ya, backticks would be better than 29\lower0.5ex\hbox{x}.

    However it is only occurring in a few cases where _ are included in the equation, while many other cases of _ are not converted to italics.

    I'd like to find what is causing this, as that may give us other workarounds.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions