【问题标题】:Emacs AucTex Latex syntax prevents monospaced fontEmacs AucTex Latex 语法防止等宽字体
【发布时间】:2012-03-02 13:38:22
【问题描述】:

我的 emacs(带有 AucTex 的 Aquamacs)改变字体大小(例如在 LaTeX 模式下)以显示语法 - 像这样:

不幸的是,这破坏了等宽字体的要点 - 例如我的 cmets 不对齐。我该如何解决这个问题?

【问题讨论】:

    标签: emacs syntax-highlighting auctex


    【解决方案1】:

    对于章节、章节等的具体示例,请将以下内容添加到您的.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"))
    

    【讨论】:

    • 你知道一种通用的说法吗,“除了颜色,不要改变面部的任何东西”?理想情况下,我想告诉 Emacs 忽略粗体、斜体、超标和下标、大小变化等,而只使用颜色,但我从未找到这样做的通用方法。我在下面的答案中发布的代码 sn-p 在事后撤消了这些更改,但如果可能的话,直接表达我的意图会更清晰。
    • @deong 恐怕我没有;我将font-latex-script-displayfont-latex-subscript-face 设置为nil,然后将italic-command / bold-command 等添加到font-latex-deactivated-keyword-classes - 我从来不需要做更多的事情(=.
    • @SébastienLeCallonnec:这真的很棒。我可以要求您编辑您的答案以包含您评论中的所有内容吗? - 供将来参考,因为我的 elisp 技能处于复制和粘贴级别:o)
    • @SébastienLeCallonnec:你知道为什么这在我的.emacs 中有效,但我无法在 emacs 中使用M-x 调用它吗?
    • @Hans-PeterE.Kristiansen:我不确定。但是,AUCTeX 文档确实表明必须重新启动 Emacs 才能考虑这些值。
    【解决方案2】:

    如果你能找到解决办法,啤酒就交给我了。到目前为止,我能想到的最好的方法是将以下内容放在我的 .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))))
    

    我不再做家庭的事情了,因为我没有时间想出一个以编程方式正确处理它的好方法,这似乎并不重要,但你的里程可能会有所不同。另外,我没有在“默认”字体上设置任何东西,因为其他一些值是相对的,需要那个固定的参考点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-19
      • 2011-03-17
      • 2013-10-20
      相关资源
      最近更新 更多