Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

usepackage and making macros in ipython notebook

Tags:

ipython

latex

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}}
like image 286
keflavich Avatar asked Jun 10 '13 16:06

keflavich


People also ask

What is an iPython notebook?

The IPython notebook combines two components: A web application: a browser-based tool for interactive authoring of documents which combine explanatory text, mathematics, computations and their rich media output.

How does the IPython editor work with arguments?

If arguments are given, the following possibilities exist: If the argument is a filename, IPython will load that into the editor. It will execute its contents with execfile () when you exit, loading any code in the file into your interactive namespace. The arguments are ranges of input history, e.g. “7 ~1/4-6”.

What are macros in Notepad++?

Task automation with macros. Notepad++ is capable of recording some of your actions you perform while editing a document, and replaying those later on to avoid having to repeat that sequence of actions. This is called a macro and can save a great deal of time. Macro’s can be played once, or multiple times, even as long as is required to run ...

How do I record a macro in Notepad++?

Record a macro. To record a macro, select Macro > Start Recording or press the button on the toolbar. Notepad++ will now keep track of the changes you make on a document or certain actions you perform. To stop recording, select Macro > Stop Recording or select the button on the toolbar.


2 Answers

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.

like image 132
Clausen Avatar answered Oct 14 '22 13:10

Clausen


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

like image 34
Matt Avatar answered Oct 14 '22 15:10

Matt