【问题标题】:Does ipython notebook have a %%latex magic cell?ipython 笔记本有 %%latex 魔法单元吗?
【发布时间】:2013-05-28 20:43:33
【问题描述】:

我正在尝试在 ipython 笔记本中呈现复杂的数学,遇到this answer 和这个ipython notebook demonstrating the Rich Display System (scroll down to the bottom is is the last example),它们都提到了%%latex 单元的可用性。但是,尝试制作乳胶单元时出现以下错误,

错误:未找到单元格魔术函数%%latex

我运行的是 0.13.2 版,我遗漏了什么?我需要以某种方式导入这个神奇的功能吗?

【问题讨论】:

    标签: latex ipython-notebook


    【解决方案1】:

    %%latexMagic 是在 SciPy 12" 期间编写的,0.13 在这个日期已经发布(实际上 SciPy 12" 是发布的原因......)。由于0.13.xx>0 只是错误修复,因此很有可能它没有进入其中。您应该可以向后移植,代码非常简单,但需要适应 Magic System 的轻微变化(IPython/core/magics/display.py,样板已删除):

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

    【讨论】:

    • 您好@matt,感谢您的帮助。我将尝试应用这些更改。我进入了 ipython 代码,我可以在 IPython/core/magics 目录中找到一个 display.py 文件。我查看了 github master 和 0.13.2。有什么想法吗?
    • here on master 和 the 0.13.2 doc
    • 我不知道我是怎么错过的!无论如何,解决方案很简单:只需从主分支安装,pip install git+git://github.com/ipython/ipython.git#egg=ipython --upgrade
    • 是的,这也有效,我通常会假设人们不想逃避主人。 setup.py develop 也适用于 git pull 并且无需重新安装即可更新。
    猜你喜欢
    • 2014-03-14
    • 1970-01-01
    • 1970-01-01
    • 2015-12-10
    • 1970-01-01
    • 2015-04-23
    • 1970-01-01
    • 2018-09-03
    • 1970-01-01
    相关资源
    最近更新 更多