12

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}}
keflavich
  • 18,278
  • 20
  • 86
  • 118

2 Answers2

6

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.

Clausen
  • 694
  • 8
  • 19
2

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

Matt
  • 27,170
  • 6
  • 80
  • 74