2013-06-02 46 views
2

我想在ipython筆記本中呈現來複雜的數學在this answeripython notebook demonstrating the Rich Display System (scroll down to the bottom is is the last example)這兩個都提到了%%latex單元格的可用性。但是,當我嘗試製作乳膠單元時出現以下錯誤:ipython筆記本有%%乳膠魔法單元嗎?

ERROR: Cell magic function %%latex not found.

我運行的是版本0.13.2,我錯過了什麼?我需要以某種方式導入這個魔術功能嗎?

回答

6

%%latex Magic已經在SciPy 12中寫過,而0.13已經在這個日期發佈(實際上SciPy 12「是發佈的理由......)。由於0.13.xx>0只是錯誤修正,很可能是它沒有在它的方式。你應該能夠反向移植,代碼是死的簡單,但需要適應的魔法系統稍微改變(IPython/core/magics/display.py,樣板刪除):

@cell_magic 
def latex(self, line, cell): 
    """Render the cell as a block of latex""" 
    display(Latex(cell)) 
+0

你好@馬特,感謝您的幫助。我會嘗試應用這些更改。我進入ipython代碼,我可以在IPython/core/magics目錄中找到display.py文件。我看着github master和0.13.2。有任何想法嗎? –

+0

[這裏](https://github.com/ipython/ipython/blob/master/IPython/core/magics/display.py#L40)關於master和[0.13.2 doc](http:// ipython .org/ipython-doc/stable/interactive/reference.html #define-your-own-magics) – Matt

+0

我不知道我是怎麼錯過的!無論如何,解決方案很簡單:只需從主分支安裝,'pip install git + git://github.com/ipython/ipython.git#egg=ipython --upgrade' –