Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do superscripts and subscripts in Jupyter Notebook?

I want to to use numbers to indicate references in footnotes, so I was wondering inside of Jupyter Notebook how can I use superscripts and subscripts?

like image 817
PraveenHarris Avatar asked Sep 02 '17 08:09

PraveenHarris


People also ask

How do you add a subscript in markdown?

Subscripts and Superscripts To indicate a subscript, use the underscore _ character. To indicate a superscript, use a single caret character ^ . Note: this can be confusing, because the R Markdown language delimits superscripts with two carets.

How do you subscript in Python markdown?

An extension to the Python Markdown project which adds the ability to subscript text. To do so, the character ~ becomes a Markdown tag for text meant to be subscripted, and is replaced with the HTML sub tag. For example, the extension transforms the text directly below into the HTML shown after it.

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.

What is %% Writefile in Jupyter notebook?

%%writefile lets you output code developed in a Notebook to a Python module. The sys library connects a Python program to the system it is running on.


2 Answers

You can do this inside of a markdown cell. A markdown cell can be created by selecting a cell then pressing the esc key followed by the M key. You can tell when you have converted a cell to markdown when In [ ]: seen to the right of the default code cell is gone. Then you can input the following code that uses latex with markdown to represent sub/super-scripts:

Latex subscript:  $x_{2}$  Latex superscript:  $x^{2}$ 

You can find more detailed examples here.

Please comment below if you are still having difficulty.

like image 128
James Draper Avatar answered Sep 17 '22 13:09

James Draper


<sup>superscript text </sup> also works, and might be better because latex formatting changes the whole line etc.

like image 39
user9179129 Avatar answered Sep 16 '22 13:09

user9179129