Conversation
|
This is awesome! I was trying to the square root rendering again and started comparing against LaTeX manually and noticed that the amount space under the hrule differs quite a bit between KaTeX and LaTeX. I'll post some screenshots later, but I was wondering if you noticed any differences for the square root test case? |
|
Which test case, The horizontal spacing in the second one seems to be largely affected by the proportions of the digits in the root. I guess this is because LaTeX has a separate font for smaller sizes, while KaTeX simply scales the 10pt font down, right? |
I just committed and pushed these diffs to a separate branch. I'm not sure if you want this in repo. I don't think I'd want it there, since they are easily reproduced as long as you have imagemagick around. But it might be convenient to have a look now. |
This certainly causes some deviations. We tend to just ignore it. |
|
@gagern I was look at |
I'm not sure how different those are from the |
|
The difference is that we use If there are, either the code should be fixed so the rendering matches or the reference file should be updated because we fixed/improved the rendering. On the other hand |
|
I was looking through some of the |
That's because I'm aligning the images to maximize overlap, but using the canvas from the Firefox images for reference. So if after that overlap-maximizing alignment, the TeX version extends beyond the margin of the Firefox screenshot, it will get clipped. I fear that without that alignment step, many of the images would have some constant offset over large parts of the canvas, making relative changes harder to see. |
|
@gagern I would like merge this in. I'll try to do a better review next week. Could you add some comments in texcmp.js to describe what's going on? I assume that you're using the fft to align images. I was looking at https://github.com/gagern/KaTeX/blob/diffs/test/screenshotter/diff/SizingBaseline.png and realized that the reason why it's so off is because LaTeX doesn't support sizing inside math. And with respect to https://github.com/gagern/KaTeX/blob/diffs/test/screenshotter/diff/NestedFractions.png I see that it's lining things up with the bigger fractions and b/c our spacing is wrong the LaTeX screenshot gets clipped. Could you make it so that the bounding box of the diffs is the union of the bounding boxes of the images being compared? Also, if there are things that we know are not going to yield invalid comparisons, i.e. sizing commands inside math, can skip those examples? |
|
~~I think the reason why the exponents are a bit off is b/c LaTeX actually stretches them horizontally a bit (or uses different glyphs).~~I really need to re-read the thread before posting. |
|
It uses different glyphs. Same as #268 (comment). |
Without the actual images, right? Will rewrite when I find the time.
The way I implemented things now, I rasterize the PDF to a temporary file, then align that to produce the
Sure, we can add those to the blacklist. |
|
Can we just add a little padding to the katex screenshots so that the pdflatex ones don't later get cut off? |
|
Some of them are nearly exhausting their 1024×768 screenshot size. E.g. |
That's right. Whenever you have time. I think @spicyj meant expanding the bounds of the KaTeX images. After alignment we should know the difference in bounds and be able to pad either image accordingly. We probably want to keep the existing reference screenshots as is so this would be another set of temp images. These images could be used for flipping between and generate visualize diffs without clipping any of the renderings. The clipping doesn't need to be perfect for the images to be useful as indicated by the number of new issues opened due to rendering differences. I think we should merge it and improve the clipping later. |
|
Well, whichever works. We could probably reduce the font size and be okay if we're running out of room. |
The same test cases we use for our screenshots from Firefox are now also being rendered by pdflatex, so the resulting images can be used as reference for how things are supposed to look (if we concentrate on compatibility with LaTeX). To make comparisons even easier, the differences between LaTeX and Firefox snapshots are rendered in a visual way, using different colors. Discussed in pull request KaTeX#268.
The same test cases we use for our screenshots from Firefox are now also being rendered by pdflatex, so the resulting images can be used as reference for how things are supposed to look (if we concentrate on compatibility with LaTeX). To make comparisons even easier, the differences between LaTeX and Firefox snapshots are rendered in a visual way, using different colors. Discussed in pull request KaTeX#268.
|
OK, rewrote things, incorporating your requests. The rasterized images are now not artificially aligned, but use the dimensions of the underlying document. The alignment is computed but used only for the diffs. So these are indeed rendered to the union of both pictures, then trimmed to the area that's actually being used. I added some comments about what's happening in I also implemented some fake math sizing commands (although they still don't work with fractions), a |
|
@gagern Awesome, thanks! I'll try to review this evening. |
dockers/texcmp/Dockerfile
Outdated
There was a problem hiding this comment.
Disable normal updates, so we don't receive any bug fix releases or similar, just security relevant fixes. The benefit is that we don't have to pin the versions of the packages we install (which are quite numerous, with all the indirect deps pulled in), and still rely on the same versions getting installed in subsequent runs unless something drastic forces a security update to one of the packages. It's one more step towards better reproducibility.
There was a problem hiding this comment.
Can you add a comment here to that effect?
dockers/texcmp/README.md
Outdated
There was a problem hiding this comment.
These are files on the host system created by docker, correct?
There was a problem hiding this comment.
Right. I wonder whether we should be streaming out those files via a TCP connection instead of a --volume mount. Or pre-create the files outside. Or anything else like this. But I see that as a separate pull request, once the core functionality is in place.
There was a problem hiding this comment.
Fair enough. Thanks for calling it out in the docs. Pre-creating the files seems like it would be pretty easy to implement.
|
If you are happy with all the new changes, I'd squash everything into a single commit so you can merge that. |
|
@gagern the new changes look great! Squash it and I'll merge it. |
The same test cases we use for our screenshots from Firefox are now also being rendered by pdflatex, so the resulting images can be used as reference for how things are supposed to look (if we concentrate on compatibility with LaTeX). To make comparisons even easier, the differences between LaTeX and Firefox snapshots are rendered in a visual way, using different colors. Discussed in pull request KaTeX#268.
Generate reference images from LaTeX
|
Thanks for the pull request. |
|
Good to have this in. Thanks! |


In #156 (comment), @KevinB7 wrote that he'd like to see TeX renderings of our examples before proceeding. Here they are. The docker may still be improved upon, I guess, in terms of size and similar, but it works. I also added a small tool to compute visual diffs, but haven't committed the results of this. One thing I notice is that in TeX,
\llapand\rlapapparently take an argument in text mode.