{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\\section{Installing nbextensions}\n",
    "In this example we will create a Jupyter notebook that can be exported in Latex format. In order to have some formulas to work with we will consider a simply supported steel beam, subject to an uniform load \\textbf{q}.\n",
    "\n",
    "Before we start writing any code, however, we need to expand the capabilities of Jupyter using third-party \\textbf{extensions}. To be more specific, we will install a set of extensions called \\textbf{nbextensions}, that will allow as to use Latex syntax in markdown cells and also to hide the code we write.\n",
    "\n",
    "If you followed the Anaconda installation at the beginning of the book, your computer should also have installed \\textbf{anaconda prompt} by default. Anaconda prompt is a command line interface that allows the user to install additional packages using the \\textbf{pip} or \\textbf{conda} package managers. We will use conda to install \\textbf{nbextensions}. Open anaconda navigator, and type:\n",
    "\n",
    "\\textbf{conda install -c conda-forge jupyter_contrib_nbextensions} \n",
    "\n",
    "This will install nbextensions from the anaconda repositories, so you need to be connected to the internet for the command to run. Now when you start jupyter notebook you can access the configuration page by writing \"nbextensions\" in place of \"tree\" in the address bar. The configuration page looks like this:\n",
    "\n",
    "\\begin{figure}[H]\n",
    "\\centering\\includegraphics{configuration.png}\n",
    "\\caption{Nbextensions configuration page}\n",
    "\\end{figure}\n",
    "\n",
    "From here you can activate the extensions that you need. In order to be able to write latex syntax inside markdown cell we will need the extension called \\textbf{(some) LaTeX environments for Jupyter}, and in order to hide code cells we will also need the \\textbf{hide input} extension. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "hide_input": false
   },
   "source": [
    "Now create a new notebook. You should see some new icons in the toolbar:\n",
    "\\begin{figure}[H]\n",
    "\\centering\\includegraphics{toolbar.png}\n",
    "\\caption{Toolbar icons}\n",
    "\\end{figure}\n",
    "The button with the \\^ symbol is used to hide the input of code cells. Now that LaTeX_envs is enable we can also write some simple LaTeX environments inside markdown cells, like \\textbf{section} and \\textbf{itemize} for example, or math formulas using dollar signs."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\\section{Formatting the output of cells in LaTeX}\n",
    "If the final goal is to output the notebookas a LaTeX document (.tex), then we need a way to display the outputs of code cells accordingly. A way to do this is using the \\textbf{Latex} module contained in `IPython.display`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "hide_input": true,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$a+b=15+7=22$"
      ],
      "text/plain": [
       "<IPython.core.display.Latex object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from IPython.display import Latex\n",
    "a=15\n",
    "b=7\n",
    "res=a+b\n",
    "display(Latex(\"$a+b=%d+%d=%d$\"%(a,b,res)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As you can see the output of the cell is now in LaTeX format."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\\section{Converting dataframes to LaTeX tables}\n",
    "Pandas gives the user the possibility to convert any dataframe into a LaTeX table, using `pandas.DataFrame.to_latex()`. Here is an example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "hide_input": true
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "\\begin{tabular}{lll}\n",
       "\\toprule\n",
       "{} &  A &  B \\\\\n",
       "\\midrule\n",
       "\\textbf{0} &  3 &  4 \\\\\n",
       "\\textbf{1} &  2 &  5 \\\\\n",
       "\\textbf{2} &  1 &  9 \\\\\n",
       "\\textbf{3} &  6 &  7 \\\\\n",
       "\\bottomrule\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "<IPython.core.display.Latex object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "df=pd.DataFrame({\"A\":[3,2,1,6], \"B\":[4,5,9,7]}, index=[0,1,2,3])\n",
    "display(Latex(df.to_latex(bold_rows=True, column_format=\"lll\")))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The function accepts a lot of parameters to customize the appearence of the table. Setting \\textbf{bold_rows} to \\emph{True}, for example, will make print the row index in bold font. Another useful parameter is \\textbf{column_format}, to which you can pass a string such as \"rlc\" to specify the alignment of the columns (\"r\"=\\emph{right}, \"l\"=\\emph{left}, \"c\"=\\emph{center}). Notice how in order to display the LaTeX syntax correctly we need to wrap `df.to_latex()` inside `Latex()`. The table however is still very basic: it does not have a caption, and it does not look very good. An easy solution is simply to add more LaTeX code around the output of `Latex(df.to_latex())`. For example, we could use the \\textbf{table} environment like this: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "hide_input": true,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "\\begin{table}[H]\n",
       "\\centering\n",
       "\\begin{tabular}{lll}\n",
       "\\toprule\n",
       "{} &  A &  B \\\\\n",
       "\\midrule\n",
       "\\textbf{0} &  3 &  4 \\\\\n",
       "\\textbf{1} &  2 &  5 \\\\\n",
       "\\textbf{2} &  1 &  9 \\\\\n",
       "\\textbf{3} &  6 &  7 \\\\\n",
       "\\bottomrule\n",
       "\\end{tabular}\n",
       "\\caption{My Table}\n",
       " \\end{table}"
      ],
      "text/plain": [
       "<IPython.core.display.Latex object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(Latex(\n",
    "    \"\\\\begin{table}[H]\\n\\centering\\n\"\\\n",
    "    +df.to_latex(bold_rows=True, column_format='lll')\\\n",
    "    +\"\\caption{My Table}\\n \\end{table}\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The output of `df.to_latex()` is just a simple string, so we can concatenate it with any other strings using $+$. In this case we are wrapping it inside `\\begin{table} \\end{table}` as well as specifying a caption using `caption{My Table}`. Because strings are one-line sequences of characters, we need tell \\textbf{Latex()} where the linebreaks are using `\\n`."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\\section{Deflection of a steel beam}\n",
    "In this example we will consider three different simply supported beams of length $L_1$, $L_2$ and $L_3$ subjected to three different uniform loads $q_1$, $q_2$, and $q_3$. For each beam we will plot the bending moment distributions and calculate the maximum deflection.\n",
    "\\begin{itemize}\n",
    "\\item \\textbf{Beam 1:} $L_1=5m$, $q_1=20\\;KN/m$ \n",
    "\\item \\textbf{Beam 2:} $L_2=6m$, $q_2=18\\;KN/m$ \n",
    "\\item \\textbf{Beam 3:} $L_3=6.5m$, $q_3=13\\;KN/m$ \n",
    "\\end{itemize}\n",
    "\n",
    "All three beams will have the same cross section and material. We will use a standard \\textbf{IPE220}, with a second moment of inertia around the strong axis of $2772\\;mm^4$. The young modulus of the steel is $200000\\;Mpa$. As always, the first step is to save all the relevant data into variables or dataframes:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "hide_input": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "Iy=2772*10**4 #mm^4\n",
    "E=200000 #Mpa\n",
    "\n",
    "loads=np.array([20, 18, 13]) #kN/m\n",
    "lengths=np.array([5, 6, 6.5]) #m"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To demonstrate the capability of exporting \\textbf{matplotlib} plots in LaTeX, let's plot the moment distribution of the first beam: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "hide_input": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3deVyVZf7/8deHTRQEFBCQTQT3XRHNZcotLZ12y5YZ26dpc6Zlauo332/N9ztT823aZ5oyW2yy1CwrG1vMNE1zAfddQWVTQBCRnXO4fn9wahxzQeFwc5/ze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uofrEspDxpgpnnzOrnNb6HroB7xnjPmTiITTzD/btihwpZRSP2WHSyhKKaVOQQtcKaVsSgtcKaVsSgtcKaVsSgtcKaVsSgtcKaVsSgtcKaVs6v8DjddcQJomUgoAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "\n",
    "x=np.linspace(0,lengths[0], 51)\n",
    "M1=loads[0]*lengths[0]*x/2-(loads[0]*x**2)/2\n",
    "fig, ax= plt.subplots()\n",
    "ax.invert_yaxis()\n",
    "ax.plot(M1)\n",
    "plt.savefig(\"plot1.pdf\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we need to calculate the maximum deflection of the beam, using the well-known formula from elastic theory:\n",
    "$$w_{max}=\\cfrac{5}{384}\\cfrac{qL^4}{EI}$$\n",
    "All the calculations will be performed inside a dataframe called \\textbf{results}. Each row represents one of the beams, and we will add more columns as we calculate new quantities. First, we create the dataframe specifying only the index:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "hide_input": true
   },
   "outputs": [],
   "source": [
    "results=pd.DataFrame(index=([\"Beam 1\", \"Beam 2\", \"Beam 3\"]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Then we can start adding columns. Let's add the loads and the lengths first:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "hide_input": true,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "\\begin{table}[H]\n",
       "\\centering\n",
       "\\begin{tabular}{lll}\n",
       "\\toprule\n",
       "{} &    l &   q \\\\\n",
       "\\midrule\n",
       "\\textbf{Beam 1} &  5.0 &  20 \\\\\n",
       "\\textbf{Beam 2} &  6.0 &  18 \\\\\n",
       "\\textbf{Beam 3} &  6.5 &  13 \\\\\n",
       "\\bottomrule\n",
       "\\end{tabular}\n",
       "\\caption{My Table}\n",
       " \\end{table}"
      ],
      "text/plain": [
       "<IPython.core.display.Latex object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "results[\"l\"]=lengths\n",
    "results[\"q\"]=loads\n",
    "\n",
    "display(Latex(\n",
    "    \"\\\\begin{table}[H]\\n\\centering\\n\"\\\n",
    "    +results.to_latex(bold_rows=True, column_format='lll')\\\n",
    "    +\"\\caption{My Table}\\n \\end{table}\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we can use the existing columns to perform calculations and store the results in new ones. If you have used a spreadsheed before you should be familiar with this type of workflow, and will find that pandas dataframes behave very similarly to Excel tables. Let's finish this example by calculating the maximum moments and deflections:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "hide_input": false
   },
   "outputs": [
    {
     "data": {
      "text/latex": [
       "\\begin{table}[H]\n",
       "\\centering\n",
       "\\begin{tabular}{lllll}\n",
       "\\toprule\n",
       "{} &    l &   q &  $M_{max}$ &  $w_{max}$ \\\\\n",
       "\\midrule\n",
       "\\textbf{Beam 1} &  5.0 &  20 &   62.50000 &   0.029358 \\\\\n",
       "\\textbf{Beam 2} &  6.0 &  18 &   81.00000 &   0.054789 \\\\\n",
       "\\textbf{Beam 3} &  6.5 &  13 &   68.65625 &   0.054502 \\\\\n",
       "\\bottomrule\n",
       "\\end{tabular}\n",
       "\\caption{My Table}\n",
       " \\end{table}"
      ],
      "text/plain": [
       "<IPython.core.display.Latex object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "results[\"$M_{max}$\"]=(results.q*results.l**2)/8\n",
    "results[\"$w_{max}$\"]=(5/384)*(results.q*results.l**4)/(E*Iy*0.001**3)\n",
    "\n",
    "display(Latex(\n",
    "    \"\\\\begin{table}[H]\\n\\centering\\n\"\\\n",
    "    +results.to_latex(bold_rows=True, column_format='lllll', escape=False)\\\n",
    "    +\"\\caption{My Table}\\n \\end{table}\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There are a few things to note here. First, the headers of the new columns that have been created contain LaTeX syntax. It will look ugly in jupyter, but once the notebook has been exported in LaTeX format the table will be rendered correctly. Also, there is a new argument passed to `to_latex()` which is \\textbf{escape}, set to \\emph{False}. This prevents pandas from escaping LaTeX special characters in column names."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\\section{Exporting the notebook}\n",
    "Now we come to the final step of this chapter, which is exporting the notebook that we have just created. The tool that we will use is called \\textbf{nbconvert}. It is a command line interface that comes pre-installed with jupyter and can be accessed with anaconda prompt. Maybe you have never used a command line interface, so let's first explain what it is and what you can do with it. \\textbf{anaconda prompt}, type `ls` and hit enter. You should now see a list of all the files and folders contained in the path specified in the command line. To enter one of the folders, simply type `cd` followed by the folder's name. If you type `cd ..` you will enter the parent folder. Using `cd` you can go anywhere in your computer, but sometimes it is faster to navigate to a folder directly. In order to do this simply type `cd` followed by the \\textbf{absolute path} of the folder you want to access. Remember to use forward slashes, and to enclose folder names that have spaces in them using quotation marks."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\\subsection{Using nbconvert}\n",
    "That is pretty much all you need to know about how to navigate your computer using a command line interface, so now let's move on to using nbconvert to export the notebook into a .tex file. Using anaconda prompt, navigate to the folder where the notebook is saved. Once there, type `jupyter nbconvert --to latex --template article notebook_name.ipynb`, where \\emph{notebook_name} is the name of the notebook you want to convert. Press enter, and you should now see that there is a new file in the folder called \\emph{notebook_name.tex}. If you open it and run it using your trusted LaTeX editor, you will most likely get an error. This is because the notebook that we have created in this chapter contains LaTeX code that requires additional packages, such as \\textbf{float} in order to display the tables correctly. We will solve this problem later: first let's explain the command that we have typed to obtain this result. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Think of \\textbf{jupyter nbconvert} as a function call to which you can pass various parameters. \\textbf{--to} specifyes the format of the output. By default this is set to html. \\textbf{--template} specifyes the template that nbconvert will use while performing the conversion. A template is basically a set of rules that the converter has to follow. In this case we set it to \\textbf{article}, which produces a decent enough LaTeX document, but the images don't display correctly and all the code is visible. The solution is to use a custom template that recognizes when the code is hidden and renders the images better. Teaching how to write a custom template is beyond the scope of this book, so we will use one that has already been created. Go to https://python4civil.weebly.com/exporting-in-latex.html and download temp.tplx, and place it in the same folder of your jupyter notebook. Hide every code input in the notebook, and save it. Then in anaconda prompt run `jupyter nbconvert --to latex --template temp.tplx notebook_name.ipynb`. This will update the existing latex file already present in the folder. Now open it with your favourite LaTeX editor and run it: the result should be a nicely typesetted document without any python code showing, and with nice images and tables."
   ]
  }
 ],
 "metadata": {
  "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.7.3"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autoclose": false,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
