{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" }, "toc": "true" }, "source": [ "# Table of Contents\n", "

1  Demo of RISE for slides with Jupyter notebooks (Python)
1.1  Title 2
1.1.1  Title 3
1.1.1.1  Title 4
1.2  Text
1.3  Maths
1.4  And code
2  More demo of Markdown code
2.1  Lists
2.1.0.1  Images
2.2  Some code
2.2.0.1  And Markdown can include raw HTML
3  End of this demo
" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Demo of RISE for slides with Jupyter notebooks (Python)\n", "\n", "- This document is an example of a slideshow, written in a [Jupyter notebook](https://www.jupyter.org/) with the [RISE extension](https://github.com/damianavila/RISE).\n", "\n", "> By [Lilian Besson](http://perso.crans.org/besson/), Sept.2017." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "---\n", "## Title 2\n", "### Title 3\n", "#### Title 4\n", "##### Title 5\n", "##### Title 6" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "## Text\n", "With text, *emphasis*, **bold**, ~~striked~~, `inline code` and\n", "\n", "> *Quote.*\n", ">\n", "> -- By a guy." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "## Maths\n", "With inline math $\\sin(x)^2 + \\cos(x)^2 = 1$ and equations:\n", "$$\\sin(x)^2 + \\cos(x)^2 = \\left(\\frac{\\mathrm{e}^{ix} - \\mathrm{e}^{-ix}}{2i}\\right)^2 + \\left(\\frac{\\mathrm{e}^{ix} + \\mathrm{e}^{-ix}}{2}\\right)^2 = \\frac{-\\mathrm{e}^{2ix}-\\mathrm{e}^{-2ix}+2 \\; ++\\mathrm{e}^{2ix}+\\mathrm{e}^{-2ix}+2}{4} = 1.$$" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "## And code\n", "In Markdown:\n", "```python\n", "from sys import version\n", "print(version)\n", "```\n", "\n", "And in a executable cell (with Python 3 kernel) :" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "slideshow": { "slide_type": "-" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3.6.3 (default, Oct 3 2017, 21:45:48) \n", "[GCC 7.2.0]\n" ] } ], "source": [ "from sys import version\n", "print(version)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# More demo of Markdown code" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "## Lists\n", "\n", "- Unordered\n", "- lists\n", "- are easy.\n", "\n", "And\n", "\n", "1. and ordered also ! Just\n", "2. start lines by `1.`, `2.` etc\n", "3. or simply `1.`, `1.`, ..." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "#### Images\n", "With a HTML `` tag or the `![alt](url)` Markdown code:\n", "\n", "\n", "![agreg/images/dooku.jpg](agreg/images/dooku.jpg)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Some code" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [ { "data": { "text/plain": [ "'Embed a YouTube video via its embed url into a notebook.'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# https://gist.github.com/dm-wyncode/55823165c104717ca49863fc526d1354\n", "\"\"\"Embed a YouTube video via its embed url into a notebook.\"\"\"\n", "from functools import partial\n", "\n", "from IPython.display import display, IFrame\n", "\n", "width, height = (560, 315, )" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def _iframe_attrs(embed_url):\n", " \"\"\"Get IFrame args.\"\"\"\n", " return (\n", " ('src', 'width', 'height'), \n", " (embed_url, width, height, ),\n", " )" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def _get_args(embed_url):\n", " \"\"\"Get args for type to create a class.\"\"\"\n", " iframe = dict(zip(*_iframe_attrs(embed_url)))\n", " attrs = {\n", " 'display': partial(display, IFrame(**iframe)),\n", " }\n", " return ('YouTubeVideo', (object, ), attrs, )" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def youtube_video(embed_url):\n", " \"\"\"Embed YouTube video into a notebook.\n", "\n", " Place this module into the same directory as the notebook.\n", "\n", " >>> from embed import youtube_video\n", " >>> youtube_video(url).display()\n", " \"\"\"\n", " YouTubeVideo = type(*_get_args(embed_url)) # make a class\n", " return YouTubeVideo() # return an object" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "#### And Markdown can include raw HTML\n", "\n", "
This is a centered span, colored in green.
\n", "\n", "Iframes are disabled by default, but by using the IPython internals we can include let say a YouTube video:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "youtube_video(\"https://www.youtube.com/embed/FNg5_2UUCNU\").display()" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# End of this demo\n", "\n", "- See [here for more notebooks](https://github.com/Naereen/notebooks/)!\n", "- This document, like my other notebooks, is distributed [under the MIT License](https://lbesson.mit-license.org/)." ] } ], "metadata": { "celltoolbar": "Slideshow", "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.3" }, "toc": { "colors": { "hover_highlight": "#DAA520", "running_highlight": "#FF0000", "selected_highlight": "#FFD700" }, "moveMenuLeft": true, "nav_menu": { "height": "129px", "width": "251px" }, "navigate_menu": true, "number_sections": true, "sideBar": true, "threshold": 4, "toc_cell": true, "toc_section_display": "block", "toc_window_display": false }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }