How to define a LaTeX macro in a Markdown cell of a Jupyter Notebook?

Viewed 1567

I want to define a macro in a Markdown cell of a Jupyter notebook. But it seems that we cannot define it.

For example, I want to define a macro which formats vectors. The code in the cell is:

\newcommand{\vect}[1]{{\mathbf{\boldsymbol{{#1}}}}}

This is the vector $\vect{x}$.

The rendering is:

The macro is unused.

PS The question was asked at https://tex.stackexchange.com/questions/281535/latex-macros-in-markdown, but it is not relevant directly to LaTeX, and the question was tagged as off-topic.

1 Answers

The way to define a macro in a Jupyter cell is to put a dollar in front of and after the macro.

$\newcommand{\vect}[1]{{\mathbf{\boldsymbol{{#1}}}}}$
This is the vector $\vect{x}$.

and the rendering is:

Correct rendering

PS This is the trick used at Latex macros in Jupyter (iPython) notebook not rendered by github, but the topic is slightly different.

Related