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?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
hpekristiansen
  • 1,030
  • 3
  • 17
  • 35

2 Answers2

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"))
Sébastien Le Callonnec
  • 26,254
  • 8
  • 67
  • 80
  • 1
    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. – deong Mar 03 '12 at 00:39
  • 1
    @deong 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 (=. – Sébastien Le Callonnec Mar 03 '12 at 09:13
  • @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) – hpekristiansen Mar 03 '12 at 10:59
  • @SébastienLeCallonnec: Do you know why this is working in my `.emacs`, but I can not invoke it from within emacs with `M-x`? – hpekristiansen Mar 03 '12 at 11:01
  • 1
    @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. – Sébastien Le Callonnec Mar 03 '12 at 11:06
  • @Hans-PeterE.Kristiansen I have added the config I usually use, along with some comments. Hope this helps. – Sébastien Le Callonnec Mar 03 '12 at 11:14
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.

N.N.
  • 8,336
  • 12
  • 54
  • 94
deong
  • 3,820
  • 21
  • 18