4

I've been using the fontify features of AUCTeX, as well as magic-latex-buffer, to display my TeX code in a more readable way.

But I'm wondering if I can crank this up to 11: is there a way to render the document text in a variable width font, but have any actual LaTeX code (macros, etc.) rendered using a monospace font.

This isn't a true WYSIWYG, but it at least would make the buffer contents feel more like the final document.

2 Answers 2

3

You can make the face used for math and the so-called sedate face used for macro names inherit from fixed-pitch, and activate variable-pitch-mode in the LaTeX mode hook:

(set-face-attribute 'font-latex-sedate-face nil :inherit 'fixed-pitch)
(set-face-attribute 'font-latex-math-face nil :inherit 'fixed-pitch)
(add-hook 'LaTeX-mode-hook #'variable-pitch-mode)
2

Alternatively, you can use the mixed-pitch-mode package to do precisely this.

If you don't like the presets, you can remove/add faces to mixed-pitch-fixed-pitch-faces. For example, if you want to fontify section headers, remove font-latex-sectioning-5-face. To enable by default set the LaTeX mode hook:

(add-hook 'LaTeX-mode-hook #'variable-pitch-mode)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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