Emacs AucTex Latex语法无法使用等宽字体

7

我使用的是AucTex插件的Aquamacs,当处于LaTeX模式下时,emacs会改变字体大小以显示语法,就像这样:

enter image description here

不幸的是,这破坏了等宽字体的优势,例如我的注释不对齐。如何解决这个问题?

2个回答

8

如果需要处理节、章节等特定内容,可以在.emacs文件中添加以下内容:

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

编辑 这是我通常用来自定义AUCTeX格式的配置:

;; 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"))

1
你知道一种通用的说法,即“除颜色外,不要更改面部任何内容”吗?理想情况下,我希望告诉Emacs忽略粗体、斜体、上标和下标、大小变化等,只使用颜色,但我从未找到过一种通用的方法。我在下面的答案中发布的代码片段在事后撤消了这些更改,但如果可能的话,直接表达我的意图会更清晰。 - deong
1
@deong,恐怕我没有;我将font-latex-script-displayfont-latex-subscript-face设置为nil,然后将italic-command / bold-command等添加到font-latex-deactivated-keyword-classes中 - 我从来不需要做更多的事情(=. - Sébastien Le Callonnec
@SébastienLeCallonnec:这真的很棒。我能不能请你编辑你的答案,把你评论中的所有东西都包含进去?-为了将来的参考,因为我的elisp技能只是复制和粘贴的水平:o) - hpekristiansen
@SébastienLeCallonnec:你知道为什么这个在我的.emacs中可以工作,但我无法通过M-x在emacs中调用它吗? - hpekristiansen
1
@Hans-PeterE.Kristiansen:我不确定。AUCTeX文档确实指出,必须重新启动Emacs才能考虑这些值。 - Sébastien Le Callonnec
@Hans-PeterE.Kristiansen 我已经添加了我通常使用的配置,以及一些注释。希望这能有所帮助。 - Sébastien Le Callonnec

1
如果你找到了解决方案,我请你喝啤酒。到目前为止,我能想到的最好的方法是在我的 .emacs 文件中添加以下内容,并在加载执行此操作的模式(org-mode 也可以)后运行该函数。
(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))))

我不再处理家庭事务,因为我没有时间找到一个良好的编程方法来正确地处理它,而且似乎也不重要,但你的情况可能会有所不同。此外,我不会在“默认”字体上设置任何东西,因为其他一些值是相对的,需要一个固定的参考点。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接