-
Notifications
You must be signed in to change notification settings - Fork 43
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
LaTeX recommendations #15
base: master
Are you sure you want to change the base?
Conversation
README.md
Outdated
@@ -55,6 +55,26 @@ This is the place to: | |||
Note: there is no need to repeat everything that is already well-documented in | |||
the code. | |||
|
|||
If you would like to include math equations to explain parts of your code or repo, | |||
it is recommended to use an external renderer and insert prepared svg files here. | |||
For example, it's possible to insert a link to the online CodeCogs equation editor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The quoted links will show up on the rendered README looking like a broken links at first glance.
Why not something like this,
"You can include explanatory math equations in either of the following two ways:
- Link to the online CodeCogs equation editor as shown below
- Link to an image in the in the
readme_imgs
folder as shown below
Users will look at the raw REAME file to see the formats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a fair suggestion - I have slight preference for being overly explicit with what we are recommending so that it's painfully obvious to users how to reproduce what's on the readme. It doesn't seem to me that the quoted links would look broken given the text around them, but I will defer on this.
README.md
Outdated
@@ -55,6 +55,26 @@ This is the place to: | |||
Note: there is no need to repeat everything that is already well-documented in | |||
the code. | |||
|
|||
If you would like to include math equations to explain parts of your code or repo, | |||
it is recommended to use an external renderer and insert prepared svg files here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've also used PNG images. Do you see a quality problem with those or another reason to require SVG? Perhaps we can say image files and note that SVG is preferred but not mandatory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PNG files could be ok, but it seems easy enough to me that we pick a standard for uniformity. SVG will generally always be higher quality and more flexible - GIF and PNG etc. will have pixelation issues at different resolutions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of a use case where a contributor is using typical Windows tools to snapshot an equation from a PDF, for example. These usually have PNG, JPEG, etc but not SVG.
I agree that a high-res image is desirable but just worry that if creating an SVG is an obstacle to some users, they might forgo an equation, and I'd rather a lower quality image than no equation. So far I haven't seen low quality images with PNG. We would comment on those in a PR. (I typically view these in GitHub so maybe it's more problematic in the IDE.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. I think the main quality issues I've seen are with GIF rendered equations, but in general I think uniform SVG would be a good look. A middle ground is to say in the readme/contributing guide any image file, and to have someone on our side take responsibility for translating anything that gets uploaded which isn't SVG? Using the url renderer it's as simple as typing out the Latex.
README.md
Outdated
@@ -55,6 +55,26 @@ This is the place to: | |||
Note: there is no need to repeat everything that is already well-documented in | |||
the code. | |||
|
|||
If you would like to include math equations to explain parts of your code or repo, | |||
it is recommended to use an external renderer and insert prepared svg files here. | |||
For example, it's possible to insert a link to the online CodeCogs equation editor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've used MathJax previously, I'm not familiar with CodeCogs -- @silviacorbellaro
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that MathJax is less supported in GitHub rendering, but I am not really familiar with them. Any url renderer would be acceptable and the preference is just for any that can parse non-percent encoded symbols for readability. Potentially relevant exchange on SO:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Folks, does D-Wave already have a license for CodeCogs? I took a brief look and there are a few options to buy a license to the tool. I can't visualize the license text without signing up. What I can see is that there is a separate licence for commercial use, it's just more expensive.
README.md
Outdated
renders the following expression. | ||
|
||
|
||
<img src="https://latex.codecogs.com/svg.latex?\large%20x_{ik}+x_{jk}-2x_{ik}x_{jk}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not show up well in dark mode. In our conversation, you had talked about a flag that would allow for this to automatically show up in white/black depending on the mode. If we're going to suggest this method, it'd be good to mention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes unfortunately I have not found a satisfying way to keep readable latex in the readme and render well in both light and dark mode. It looks like GitHub is actively working on automating this as of about two months ago. https://github.community/t/support-theme-context-for-images-in-light-vs-dark-mode/147981
Stopgaps for this we recommend could easily be made obsolete, so my current opinion has changed to that it's actually not worth supporting darkmode on repos until GitHub-side support has stabilized... Let me know if that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think this could be a problem in the IDE, which defaults to dark mode. Have you taken a look at how this looks there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just including a white background in the image instead of transparent? I think that's the way most of our current equation images are formatted. It may not be the ideal look in dark mode, but at least it is visible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have, and my conclusion was to set my IDE to light mode. I can't tell which markdown renderer is used behind the scenes in the IDE - I was wrong in my assumption that it was similar to Jupyter and it seems it has most but not all of the issues of GitHub rendering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can expect users to set their IDE to a different mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just including a white background in the image instead of transparent? I think that's the way most of our current equation images are formatted. It may not be the ideal look in dark mode, but at least it is visible.
This is the main stopgap that I was referring to - I think it is more beneficial to have editable latex so we can easily update equations than to require inserting images pre-rendered with white backgrounds to support GitHub darkmode while it is under development unfortunately. If there is a url renderer that allows white background that would be ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I’m missing something here, but what I’m gathering is that there is no current solution for displaying latex via a link to CodeCogs on dark mode (unless there is a url renderer w/ white background?). If that is the case, then I don’t think we should be recommending this as an option right now. This obviously could change later, but right now I’m inclined to just recommend SVG and remind users to use a white background.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One benefit of using the HTML tag might be the ability to add background colors ourselves. I'm currently testing including the tag style="background-color:white" etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because github flavored markdown has such a strict sanitization filter, that was not possible; but the latex command \pagecolor{white} works just fine in the url renderer and keeps the whole insertion sufficiently unobtrusive and readable in my mind.
So now it looks alright in the IDE darkmode, though I wish there was a way to add a thin white border. In darkmode the last character in the equation is just barely frustrating to look at. I don't know a way to do this currently mainly because of the filter.
Added color inversion which will be picked up in IDE; this renders white text transparent background SVG of equations in Leap, and black text transparent background SVG of equations on Github. |
README.md
Outdated
|
||
`![Expression](readme_imgs/expression.svg)` | ||
|
||
![Expression](readme_imgs/expression.svg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a white background to this svg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - just one parameter in the svg file itself. Would you suggest doing so to make it readable on the IDE or in github darkmode? My proposal is to support darkmode only in the IDE by using the invert filter. I suppose we could axe the ![]()
example and show that the html img insert method works with relative paths as well, keeping the same invert flag.
README.md
Outdated
If you would like to include math equations to explain parts of your code or repo, | ||
it is recommended to use an external renderer and insert prepared svg files here. | ||
For example, it's possible to insert a link to the online CodeCogs equation editor; | ||
below includes syntax to be read on darkmode by default in D-Wave's [Leap IDE](https://ide.dwavesys.io). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would putting these options in bullet points make this a bit more readable? (one option, one point)
@@ -55,6 +55,25 @@ This is the place to: | |||
Note: there is no need to repeat everything that is already well-documented in | |||
the code. | |||
|
|||
If you would like to include math equations to explain parts of your code or repo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest this section have a subheader "Adding Equations"
README.md
Outdated
If you would like to include math equations to explain parts of your code or repo, | ||
it is recommended to use an external renderer and insert prepared svg files here. | ||
For example, it's possible to insert a link to the online CodeCogs equation editor; | ||
below includes syntax to be read on darkmode by default in D-Wave's [Leap IDE](https://ide.dwavesys.io). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would more accessible to give two options:
- using online renderer
- Inserting an image file
And then explain in a footnote that the online renderer formulation has thefilter:invert(1)
part to look good in Leap's IDE, where darkmode is the default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the second point, it would also be good to recommend using a white background.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Transparent background is actually preferable if the invert filter is used, since the IDE darkmode background is actually quite noticeably not jet black. It will not look absolutely disgusting though, so I think balancing what looks best with accessibility could be to not express a preference on user image background.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it would be good to just note that the contributor should make sure that the equation is readable on both GitHub and the IDE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd word that as taking into consideration that some users such as IDE users might have dark backgrounds rather than phrasing it as a requirement that contributors ensure readability in multiple environments, that seems a burdensome requirement on 3rd-party contributors
it is recommended to use an external LaTeX renderer, or insert pre-rendered images in the repo. | ||
For example, it's possible to insert a link to the online CodeCogs equation editor which will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we want to recommend the use of external renderers (like CodeCogs). Have you confirmed this with IP/legal?
For example, CodeCogs has a fair use policy, but they require we provide a link back.
|
||
The above text in markdown renders the following expression in your markdown readme. | ||
|
||
<img style="filter:invert(1)" src="https://latex.codecogs.com/svg.latex?\large\,x_{ik}+x_{jk}-2x_{ik}x_{jk}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like GitHub strips the filter:invert(1)
style.
Maybe using mix-blend-mode
would be better? The only downside is it's not supported for SVG on most mobile platforms/browsers.
The HTML tag using the codecogs renderer allows for the most readable latex formula using symbols that do not need to be percent encoded in the url. In the IDE, the url may contain spaces and render just fine, but any spaces will need to be replaced by %20 for proper rendering in GitHub.