簡體   English   中英

帶有'$'字符的AucTeX / emacs問題

[英]AucTeX/emacs problem with '$' character

關於emacs的AucTeX是非常了不起的工具,但是當我寫一個單獨的'$'時,所有的顏色都被打破了。

通常一個'$'伴隨着另一個'$'表示數學方程式,但對於源列表,經常使用單個'$'。

\begin{Verbatim}
(let ((buffer (url-retrieve-synchronously
...
    (re-search-forward "^$" nil 'move) <-- It breaks the coloring 
...
\end{Verbatim}

簡單的解決方案如下匹配'$'。

(re-search-forward "^$" nil 'move) ;; $

AucTeX中有任何選項可以防止出現這個單一的'$'問題嗎?

AUCTeX知道$在逐字環境中不是特別的,但你必須告訴它Verbatim是一個逐字環境,安排它出現在LaTeX-verbatim-environments-local

如果AUCTeX以最佳方式安裝,它已經知道了,因為AUCTeX為你通過\\usepackage和friends加載的每個文件加載一個樣式掛鈎。 您可能需要告訴它使用Cc CnTeX-normal-mode )解析頭文件。

如果這還不夠,則意味着在樣式文件中定義了Verbatim ,而AUCTeX沒有足夠的信息。 您可以告訴AUCTeX解析您安裝的部分或全部樣式文件; 請參閱AUCTeX手冊中的“自動”章節。

有時AUCTeX無法解析樣式文件; 然后你可以手工完成這部分。 下面的代碼假設您從fancyvrb包獲得了Verbatim環境; 否則改編名稱。 TeX-style-path提到的一個目錄中創建一個名為fancyvrb.el的文件,其中包含以下內容(可能還有其他值得投入的內容,我剛剛調整了alltt.el ):

(TeX-add-style-hook
 "fancyvrb"
 (lambda ()
   (LaTeX-add-environments "BVerbatim" "LVerbatim" "SaveVerbatim" "Verbatim")
   (make-local-variable 'LaTeX-indent-environment-list)
   (add-to-list 'LaTeX-indent-environment-list '("BVerbatim" current-indentation))
   (add-to-list 'LaTeX-indent-environment-list '("LVerbatim" current-indentation))
   (add-to-list 'LaTeX-indent-environment-list '("SaveVerbatim" current-indentation))
   (add-to-list 'LaTeX-indent-environment-list '("Verbatim" current-indentation))
   (make-local-variable 'LaTeX-verbatim-regexp)
   (setq LaTeX-verbatim-regexp (concat LaTeX-verbatim-regexp "\\|\\([BL]?\\|Save\\)Verbatim"))
   (add-to-list 'LaTeX-verbatim-environments-local "BVerbatim")
   (add-to-list 'LaTeX-verbatim-environments-local "LVerbatim")
   (add-to-list 'LaTeX-verbatim-environments-local "SaveVerbatim")
   (add-to-list 'LaTeX-verbatim-environments-local "Verbatim")
   (when (and (featurep 'font-latex)
              (eq TeX-install-font-lock 'font-latex-setup))
     (font-latex-set-syntactic-keywords)
     (setq font-lock-set-defaults nil)
     (font-lock-set-defaults))))

(我認為你也可以通過文件變量手動完成,但事實證明這不起作用,因為字體鎖設置是在文件局部變量初始化之前構建的,我沒有看到解決方法。)

是否有理由使用逐字與逐字? 逐字會使該部分中的所有內容都適合我。 順便說一句,我更喜歡使用列表包。 用於顯示乳膠中的程序代碼。

使用包列表,您可以像添加\\ begin {verbatim}一樣添加非格式化文本,但其主要目的是在文檔中包含任何編程語言的源代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM