Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs AucTex Latex syntax prevents monospaced font

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?

like image 758
hpekristiansen Avatar asked Mar 02 '12 13:03

hpekristiansen


2 Answers

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"))
like image 131
Sébastien Le Callonnec Avatar answered Sep 26 '22 08:09

Sébastien Le Callonnec


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.

like image 41
deong Avatar answered Sep 22 '22 08:09

deong