3 ms·
Thank you, very interesting and helpful. (I ran dvitype on that as you suggested.) I think I'm just going to describe what I'm doing in case you have any more
by Myrmornis 7y ago
Thank you, very interesting and helpful. (I ran dvitype on that as you suggested.)
I think I'm just going to describe what I'm doing in case you have any more helpful words of advice or thoughts! Obviously no worries if not.
I'm working on a project that involves generating images from LaTeX math fragments and displaying them in a text editor buffer inline with the text, to create an environment for editing LaTeX math without needing to constantly regenerate the PDF. So similar to what also exists in various places, e.g. preview-latex and org-mode in Emacs.
In one sentence: I am struggling to produce non-fuzzy images when using dvipng or imagemagick to produce a PNG.
I am at the stage where I am trying to identify the best image-generation workflows to support. Users might have conventional screens, or high res ("4k?") screens, or high res Apple Retina screens. For example, Emacs org-mode offers the following 3 flows:
* dvisvgm - LaTeX DVI output is converted to SVG and Emacs displays the SVG.
* imagemagick - LaTeX PDF output is converted to PNG by imagemagick and Emacs displays the PNG.
* dvipng - LaTeX DVI output is converted to PNG and Emacs displays the PNG.
I personally own a Macbook Pro with a Retina screen and what I have observed is:
Iff your text editor is built with special support for Retina screens:
1. Beautiful crisp results can be obtained via dvisvgm.
2. It is also possible to produce a high resolution PNG and then resize it down in the editor so that it retains its crisp appearance at small size.
However, using dvipng (latex -> dvi -> png) or imagemagick (latex -> pdf -> png) I have not yet managed to obtain any crisp images of math fragments when they are at the size of a conventional line of text on the screen. That's on a Retina screen; I'm also planning to test against a conventional monitor via a raspberry pi.
I believe that dvipng does not include a "pHYs" chunk in the PNG data, and that this may be one reason that I am struggling to create small PNGs with high pixel density.
- svat 7y agoAh rasterization is another rabbit hole that I don't know much about and can't say anything without trial-and-error experimentation on the specific device :-) But first I'd recommend checking whether the image is being displayed at its natural size, pixel-for-pixel (or conversely that it is being generated to have the number of pixels at which it is going to be displayed -- both imagemagick and dvipng take a dpi option). See also some approaches at https://tex.stackexchange.com/questions/44486/pixel-perfect-vertical-alignment-of-image-rendered-tex-snippets https://tex.stackexchange.com/questions/44486/pixel-perfect-...
- Myrmornis 7y agoThanks! (And crikey, that is quite a post!)