Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed code for illustration in Jupyter

New to Jupyter.

Want to embed code for illustration without execution in a Markdown cell.

http://jupyter-notebook.readthedocs.org/en/latest/examples/Notebook/rstversions/Working%20With%20Markdown%20Cells.html

This link basically says one may do it but does not say how to do it. It says for example to make the text a heading, you use the pound sign #. But it does not say how to embed the code but just showed it is doable.

Tried to search online and find the same info as in the link provided.

like image 648
StayLearning Avatar asked Feb 25 '16 01:02

StayLearning


People also ask

How do I embed code in Jupyter Notebook?

On the GitHub Gist page, type a file name with the extension for the code you want to make and write down/paste the code. 4. In case you have the code saved as a file or a jupyter notebook (. ipynb file), you can directly drag-and-drop the file into the code section as shown, and create the gist.

How do I embed code in Jupyter markdown?

Press Esc key, type m for markdown cell, press Enter key. The cursor is now in the markdown cell waiting for instructions. Type your code or paste a code block.


2 Answers

You can contain the code in three backslashes backticks. If you specify the language in the beginning it will also color code as usual.

e.g.

```python
from pyomo.environ import *
model = Concretemodel()
```
like image 196
mxnoqwerty Avatar answered Nov 07 '22 02:11

mxnoqwerty


I am a new to Jupyter Notebook too, must say that their documentation is awful as they say what we can do instead of HOW to do it. I have opened already made '.ipynb' notebook and figured it out, I will list a couple of them from unexplained documentation:

  1. Make text ITALIC: *Italic*
  2. Make text BOLD: **Bold**
  3. List item as a bullet: dash and space -
  4. List item as a number: Simple as number and dot 1.
  5. Indenting text: Greater than and space >
  6. Inline code span: Back quotation mark " ` "
  7. Block of code: Triple back quotation marks " ``` "
  8. Link a section: [Title of Section](#title-of-section)
  9. Hyperlink: [Text](URL)

I hope everyone has found their solution.

like image 40
Uki. Avatar answered Nov 07 '22 03:11

Uki.