Matt Huszagh <[email protected]> writes: > I've created a patch to align the baseline of latex image fragments to > the surrounding text. The patch consists of several parts. First, it > adds a customizable variable that can be set to a user supplied function > to compute the value of :ascent passed to `overlay-put'. It can also be > set to a symbol (e.g., 'center, which is the current setting and still > the default), or an integer (:ascent can take an integer > percentage). The patch also modifies `org--make-preview-overlay' to use > this new variable. > > The other part of the patch is a new function that computes the correct > value for :ascent from an SVG file. > > Unfortunately, this isn't a general-purpose solution to baseline text > alignment. It currently only works with SVG images and requires that > these SVG images encode the text baseline in the viewBox attribute (I've > explained in the function documentation how to achieve this). > > I was not initially planning to include the function because it only > works in certain special cases (though if you setup your SVG image > generation as I've described in the documentation it should work > correctly for all of your LaTeX fragments). However, I ultimately > decided it was beneficial to include it for several reasons: (1) it > would not be obvious for many users how to write this function on their > own, (2) by including it, others can improve upon it, and (3) I tried to > minimize corner cases by leaving the default value as 'center and having > the function return 'center whenever it detects an incorrect :ascent > value.
I should also mention that I've tested this for different image scaling factors (`:image-size-adjust' in `org-preview-latex-process-alist') and it works regardless of the scale factor. That is, the baseline will be correctly aligned irrespective of the scale factor you set (though obviously the text median (https://en.wikipedia.org/wiki/Baseline_(typography))) will only match the surrounding text for the correct scaling factor. Matt
