# [IPython-dev] Abbreviated LaTeX in Markdown cells in the IPython Notebook

David P. Sanders dpsanders at ciencias.unam.mx
Thu Oct 3 02:12:49 EDT 2013

Hi:

The following is possibly relevant for tomorrow's meeting with the MathJax

I have been playing with the idea of abbreviating LaTeX environments within
Markdown. This is a direct result of live note-taking with the IPython
Notebook in a course that I am co-teaching while the other professor gives
a blackboard class with equations, and finding myself slowed down by
writing verbose LaTeX.

(This is a common problem, which can be (partially) solved in other TeX
editors by judicious use of macro completion.)

It seems to me that the full-blown LaTeX environments, in particular
$$...$$, and particularly align [equation is
easily replaced by $$$$...$$$$, since no equation numbering is yet available],
are unnecessarily wordy for the IPython Notebook.

These full versions are necessary (?) when the relevant equation(s) are
embedded in a full LaTeX document, but in the IPython Notebook, they are
restricted to snippets of mathematics inside a Markdown cell. Thus, in the
spirit of Markdown, we should (in my opinion) search for a more lightweight
syntax for LaTeX snippets.

I have a branch short_latex at
https://github.com/dpsanders/ipython/tree/short_latex
which allows the following syntax inside Markdown cells:

# equation:
$eq y = 3x$

# align:
$al y &= 3x\\ z &= 4x$

That is, it uses $...$ as the delimiters for the environment, and fills
out the environment based on the first word found after the first $. The main benefit is to obviate the redundant \end{...} construction, and in general save typing. $...$ is a natural way to separate LaTeX snippets from surrounding text (and, in particular, one which is already supported by the current code). The implementation currently intercepts the blocks of mathematics after they are found (in the text-cell rendering function in textcell.js), checks if they are of this form, and if so, replaces them by the full LaTeX environment so that they are correctly rendered by MathJax. [Health warning: my JavaScript is still rather shaky...] The cases environment is also supported, but currently has the limitation that it must come at the start of a LaTeX snippet:$y = ca 1 & \text{if } x>0\\
0 & \text{if } x \le 0
$This could be fixed e.g. using$y = ca{...}\$
or some similar notation.

Maybe a better solution would be to simply treat these as some kind of
macro that would expand directly in the text stored in the text cell
itself, so that it would be correctly rendered even in a version of IPython
without this modification. (Though I am not sure how to go about doing
this.)

Is this something that people are interested in pursuing?
(Or does it just look too artificial and weird?) If so, might it be
possible to do something at the level of MathJax itself?

Best wishes,
David.

--
Dr. David P. Sanders

Profesor Titular "A" / Associate Professor
Departamento de Física, Facultad de Ciencias
Universidad Nacional Autónoma de México (UNAM)

dpsanders at ciencias.unam.mx
http://sistemas.fciencias.unam.mx/~dsanders

Cubículo / office: #414, 4o. piso del Depto. de Física

Tel.: +52 55 5622 4965
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20131003/63570ef0/attachment.html>
`