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.