Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use variables on an IPython notebook markup cell?

I have an IPython notebook and I would like to use one of my variables inside a markup cell. Is this even possible? If so, how do you do it?

like image 348
Juan M. Caicedo Avatar asked Sep 18 '13 16:09

Juan M. Caicedo


People also ask

Can you use variables in Markdown Jupyter Notebook?

Surprisingly, Jupyter Notebooks do not support the inclusion of variables in Markdown Cells out of the box. If you still use Jupyter Notebooks there is a readily solution: the Python Markdown extension. It is part of the nbextensions package which is easy to install and configure.

Can you use variables in Markdown?

The idea is pretty simple, Markdown has a concept of reference links or reference-style links that allows us to define a value to a reference variable and then refer to that value later in the same document.

What does %% do in Jupyter Notebook?

Both ! and % allow you to run shell commands from a Jupyter notebook. % is provided by the IPython kernel and allows you to run "magic commands", many of which include well-known shell commands. ! , provided by Jupyter, allows shell commands to be run within cells.


1 Answers

If you don't mind a code cell that does the job, there is a possibility without adding any extensions.

from IPython.display import Markdown as md  fr=2 #GHz  md("$f_r = %i$ GHz"%(fr)) 

This will show a markdown cell in a nicely LaTeX formatted output

like image 117
AS1 Avatar answered Oct 21 '22 02:10

AS1