Emacs AucTex Latex syntax prevents monospaced font
Asked Answered
C

2

7

My emacs (Aquamacs with AucTex) changes font size (in e.g. LaTeX mode) to show the syntax - like this:

enter image description here

Unfortunately this ruins the point of a monospaced font - e.g. my comments do not align. How do I solve this problem?

Cellulosic answered 2/3, 2012 at 13:38 Comment(0)
A
8

For the specific example of sections, chapters, etc., add the following to your .emacs:

(setq font-latex-fontify-sectioning 'color)

Edit Here is the config I usually use to customise the AUCTeX formatting:

;; Only change sectioning colour
(setq font-latex-fontify-sectioning 'color)
;; super-/sub-script on baseline
(setq font-latex-script-display (quote (nil)))
;; Do not change super-/sub-script font
(custom-set-faces
 '(font-latex-subscript-face ((t nil)))
 '(font-latex-superscript-face ((t nil)))
 )
;; Exclude bold/italic from keywords
(setq font-latex-deactivated-keyword-classes
    '("italic-command" "bold-command" "italic-declaration" "bold-declaration"))
Asthenopia answered 2/3, 2012 at 20:3 Comment(6)
Do you know of a general way of saying, "don't ever change anything about a face other than color"? Ideally, I'd like to tell Emacs to ignore bold, italics, super and subscripts, size changes, etc., and just use color, but I've never found a general way of doing that. The snippet of code I posted in an answer below undoes those changes after the fact, but it would be cleaner to just express my intent directly if possible.Waverley
@Waverley I’m afraid I don’t; I set font-latex-script-display, font-latex-subscript-face to nil, and then add italic-command / bold-command etc. to font-latex-deactivated-keyword-classes – I have never needed to do more than that (=.Typology
@SébastienLeCallonnec: This is really great. Can I ask you to edit your answer to include all the stuff from your comment? -for future reference, and because my elisp skills is on the level of copy and paste:o)Cellulosic
@SébastienLeCallonnec: Do you know why this is working in my .emacs, but I can not invoke it from within emacs with M-x?Cellulosic
@Hans-PeterE.Kristiansen: I am not sure. The AUCTeX documentation does indicate that Emacs has to be restarted for these values to be taken into account, though.Typology
@Hans-PeterE.Kristiansen I have added the config I usually use, along with some comments. Hope this helps.Typology
W
1

If you find a solution to this, the beers are on me. The best I've been able to come up with so far is to put the following in my .emacs somewhere and run the function after loading a mode that does this (org-mode does it too).

(defun fix-fonts ()
  (interactive)
  (mapc
   (lambda (face)
     (set-face-attribute face nil
                         ;; :family (if (string= system-type "darwin") 
                         ;;             "Menlo" 
                         ;;             "Inconsolata")
                         :width 'normal
                         :height 1.0
                         :weight 'normal 
                         :underline nil
                         :slant 'normal))
   (remove 'default (face-list))))

I don't do the family thing anymore, because I didn't have time to figure out a good way to programatically get it right and it doesn't seem to matter, but your mileage might vary. Also, I don't set anything on the "default" font because some of the other values are relative and need that fixed reference point.

Waverley answered 2/3, 2012 at 14:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.