this post was submitted on 12 Nov 2023
1 points (100.0% liked)

Emacs

312 readers
1 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

How do I use the fixed-pitch font for math fragments in org-mode buffers? I.e., I want to use a monospace font for all strings of the form \(...\) or \[...\], where ... may include newline characters as well, as is common for equations written in math display mode.

I'm an Emacs newb, so the best I could come up with was a regex-based font-lock:

(progn
  (setq-local font-lock-keywords
              `((,(rx (group
                       (or "\\[" "\\(")
                       (zero-or-more anything)
                       (or "\\]" "\\)"))) (1 'fixed-pitch))))
  (font-lock-fontify-buffer))

And then running this on an org-mode-hook.

But this is definitely wrong. Not only does it remove all the nice org-mode styling applied to things like section headers, but it's also applying the fixed-pitch font to more than just the intended math fragments, suggesting issues with the regex at least.

you are viewing a single comment's thread
view the rest of the comments
[–] 00-11@alien.top 1 points 1 year ago