2013-06-21 38 views
9

我一直使用組織模式來發布科學筆記。我發佈的大部分內容都是編譯乳膠代碼,我正在尋找一種突出組織模式緩衝區中乳膠語法的方法。我遇到了許多解決方案,用於顯示已發佈的乳膠代碼,使用列出的語法突出顯示,鑄造,pygments等。有沒有辦法在org緩衝區中顯示突出顯示的乳膠語法?組織模式緩衝區乳膠語法突出顯示

+0

您能否提供一個您在Org文檔中意味着什麼的例子? –

+0

我想他想在一個'org-mode'緩衝區中突出顯示所有嵌入的latex代碼(例如'\ alpha','S^3','\ dots')。 – AdrieanKhisbe

+0

編輯LaTeX塊時,「C-c」不夠嗎?你想看到它在任何時候突出顯示? – mlt

回答

2

把你的.emacs配置文件如下:

;; fontify code in code blocks 
(setq org-src-fontify-natively t) 

PS-我不明白它不是默認啓用的。

+0

我已經將該變量設置爲true,並且當我的乳膠代碼包含在 #+ BEGIN_SRC乳膠 #+ END_SRC乳膠 中時,它已正確突出顯示。但是我想編譯乳膠代碼,而不是將它顯示爲源代碼。 – user2509577

2

你可能想嘗試這樣的事情。

(font-lock-add-keywords 'org-mode 
     '(("\\(\\\\cite\\)" . font-lock-keyword-face) 
      ("\\[[0-9]+]" . font-lock-type-face) 
      ("\\s-*[a-zA-Z]+[0-9]+[a-z]" . font-lock-constant-face))) 
(font-lock-add-keywords 'org-mode 
     '(("\\(\\\\citep\\)" . font-lock-keyword-face))) 
(font-lock-add-keywords 'org-mode 
     '(("\\(\\\\citet\\)" . font-lock-keyword-face))) 
(font-lock-add-keywords 'org-mode 
     '(("\\(\\\\citealp\\)" . font-lock-keyword-face))) 
(font-lock-add-keywords 'org-mode 
     '(("\\(\\\\citeauthor\\)" . font-lock-keyword-face))) 
(font-lock-add-keywords 'org-mode 
     '(("\\(\\\\citeyear\\)" . font-lock-keyword-face))) 

http://www.emacswiki.org/emacs/AddKeywords http://www.emacswiki.org/emacs/RegularExpression

+0

如果您在已經打開一個要打開的緩衝區時評估這些命令,則必須執行M-x恢復緩衝區或M-x正常模式,以使它們在已打開的緩衝區中生效。 – Mark

8

變量org-highlight-latex-and-related讓你 亮點聯數學。但是,LaTeX碎片只能用一張臉突出顯示。

org-highligh-latex-and-related文檔:

Non-nil means highlight LaTeX related syntax in the buffer. 
When non nil, the value should be a list containing any of the 
following symbols: 
    `latex' Highlight LaTeX snippets and environments. 
    `script' Highlight subscript and superscript. 
    `entities' Highlight entities. 

例如爲:

(setq org-highlight-latex-and-related '(latex script entities)) 

面部org-latex-and-related用於fontify乳膠片段。

+1

這不會突出顯示內聯數學,例如V $中的$ v \。有什麼辦法可以實現這種突出顯示? – AlwaysLearning

+0

@AlwaysLearning我確實觀察到V $中的$ v \被突出顯示。你使用哪個組織模式版本? –

+0

版本9.0.7。除了設置'org-highlight-latex-and-related'外,還有其他需要的設置嗎?另外,有沒有衝突的事情? – AlwaysLearning

1

您可以將您的latex fragments放入#+BEGIN_LaTeX latex#+END_LaTex latex以使其突出顯示。它與逐字輸出的source blocs#+BEGIN_SRC LaTeX ....)不同(如您所述,可能會通過pygments高亮顯示)。

它非常適用環境(方程,對齊...):

emacs screenshot

據我知道它不會爲內聯數學工作(以及它,如果你附上整段,但你鬆散的使用組織模式...)

來源:這個答案在emacs.stackexchangeReddit