I would like to vertically align org mode latex previews at the same level than the surrounding text, that is I want the bottom of the surrounding text to be at the same level than the bottom of the preview. Is that possible?

The following screenshot shows the default behavior which is to align the center of the image with the top (or center?) of the surrounding text:

LaTeX preview in Org Mode

  • 2
    Welcome to TeX.SE! I didn't really understood what org mode is, but found out that has to do with emacs. Thus, I suppose that the page emacs.stackexchange.com will give you more possibilities to get an answer. If I am wrong and your question is more relevant with LaTeX than with emacs, please ask me to delete this comment – koleygr Sep 17 '18 at 2:11
  • Just use org-mode with texfrag-mode as minor mode. It replaces the org mode latex stuff with that one of preview.el which works way better. – Tobias Nov 25 '19 at 15:35

I ended up advicing an internal function since there is no clean extension hook nor customization option for this:

(defun my-org-latex-preview-advice (beg end &rest _args)
    (let* ((ov (car (overlays-in beg end)))
           (img (cdr (overlay-get ov 'display)))
           (new-img (plist-put img :ascent 90)))
      (overlay-put ov 'display (cons 'image new-img))))
(advice-add #'org--format-latex-make-overlay
            :after #'my-org-latex-preview-advice)

No quite nice but it does the work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.