usepackage and making macros in ipython notebook

可紊 提交于 2019-12-03 16:39:21

问题


How can user macros and packages be included in the latex rendered in markdown cells in ipython?

e.g.:

\usepackage{amssymb}
\newcommand{kms}{\ensuremath{\mathrm{km~s}^{-1}}

回答1:


It is possible to define macros in cells with markdown. Just put the \newcommand between $'s:

$\newcommand{kms}{{\mathrm{km~s}^{-1}}}$

(Note that I removed the \ensuremath command, as it is not accessible.)

In any following statement (in the whole notebook) you can call the macro (in a markdown cell only, of course):

$\kms$

I do not know a way to include extra packages :( If you ever learn how, I would also encourage you to use the siuntx package to format units.




回答2:


The Html notebook use mathjax to render LaTeX, I suggest reading its doc to know wether it is possible and how.



来源:https://stackoverflow.com/questions/17028342/usepackage-and-making-macros-in-ipython-notebook

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!