{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Markdown, LaTeX Equations\n",
    "\n",
    "<a id=\"the_top\"></a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Markdown Cells"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Markdown is used for formatting text cells. \n",
    "- [Wikipedia page](https://en.wikipedia.org/wiki/Markdown)\n",
    "- [Official website](http://daringfireball.net/projects/markdown/)\n",
    "\n",
    "Double click on the markdown cells in this document (including this cell) for examples.\n",
    "\n",
    "Make new paragraphs with empty lines.  \n",
    "Make new lines when the line above has at least two trailing spaces.\n",
    "\n",
    "You can put raw html in markdown cells if you want.\n",
    "\n",
    "You can insert images, pdf files, etc. into the document.\n",
    "\n",
    "Make horizontal lines with three or more dashes, or underscores, or asterisks:  \n",
    "\n",
    "----------\n",
    "\n",
    "\n",
    "# Heading\n",
    "\n",
    "## Subheading\n",
    "\n",
    "### Subsubheading\n",
    "\n",
    "#### etc"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Lists\n",
    "\n",
    "Make a list like this:  \n",
    "- Item one (note the space after the -)\n",
    "- Item two (note the symbol becomes a circle)\n",
    "    - Sub-bullet 1\n",
    "    - Sub-bullet 2\n",
    "        - Sub-bullet 3\n",
    "    - Sub-bullet 3\n",
    "-Item 3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here is a numbered list:\n",
    "1. Item 1\n",
    "1. Item 2\n",
    "    1. Sub-item\n",
    "    1. Sub-item\n",
    "        1. Sub-Sub-item"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Links"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Make hyperlinks like this `[Link text](http://somesite.com)`  \n",
    "For example: [Google it](http://www.google.com)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can link to locations inside the document. This is convenient for making, say, a linked table of contents. Here's how:\n",
    "- Put an html anchor at the target location: \n",
    "    - `<a id='my_target_name'></a>`\n",
    "- Put the link to the target anywhere else in the notebook: \n",
    "    - `[Link text](#my_target_name)`\n",
    "- For example [here is a link to the top of this page](#the_top)\n",
    "    - Double click the cell at the top to see the anchor `</a id=\"the_top\"></a>`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Bold, Italic, Colored Text"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Italicize** text between `*'s: *This will be italic*` \n",
    "- That is: *This is italic*\n",
    "\n",
    "**Bold** text between `**'s: **This will be bold**`\n",
    "- That is: **This is bold**\n",
    "\n",
    "No markdown for underline, use html tags instead: `<u>This will be underlined</u>`\n",
    "- That is <u>This will be underlined</u>\n",
    "\n",
    "~~strikethrough~~ between `~~'s: ~~this will be strikethrough~~` \n",
    "- That is: ~~this will be strikethrough~~\n",
    "\n",
    "**colored** text, use html `<font>` tags:\n",
    "- For example: `<font color=\"green\">This is colored</font>`\n",
    "- For example: <font color=\"green\">This is colored</font>\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Format Code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To write code snipets, like those above, you can just tab indent them, or surround with back-quotes: \\``this is code`\\`\n",
    "\n",
    "If the first line is like this:   \\`\\`\\````python```\n",
    "then subsequent lines will get syntax coloring, which is nice:\n",
    "\n",
    "```python\n",
    "if a<2.2 :\n",
    "    print(\"Hi there\")\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Blockquotes\n",
    "\n",
    "Block style quotes are offset with > \n",
    "\n",
    "> This text will be a quote. If the quote is really long it will continue onto the next line automatically depending on how wide your browser is. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Tables\n",
    "\n",
    "```\n",
    "| Left-aligned | Center-aligned | Right-aligned |\n",
    "|:-------------|:--------------:|--------------:|\n",
    "| Pressure     | P              | (Pa)          |\n",
    "| Temperature  | T              | (K)           |\n",
    "| Velocity     | v              | (m^3)         |\n",
    "```\n",
    "\n",
    "| Left-aligned | Center-aligned | Right-aligned |\n",
    "|:-------------|:--------------:|--------------:|\n",
    "| Pressure     | P              | (Pa)          |\n",
    "| Temperature  | T              | (K)           |\n",
    "| Velocity     | v              | (m^3)         |\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Images\n",
    "\n",
    "Images can be inserted with this `![alt text](my_image.png)`\n",
    "\n",
    "html is more flexible and allows sizing `<img src=my_image.png width=300>`\n",
    "\n",
    "<img src=http://ignite.byu.edu/img/mpi_strikes_back_viridis_gemini.png width=300>\n",
    "\n",
    "- You can include local pictures, or pictures on a website.\n",
    "    - This is convenient for sharing your notebooks.\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### IFrames \n",
    "* Useful for including other files, like PDFs\n",
    "- These go in code cells and you need to import a library as shown below."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <iframe\n",
       "            width=\"600\"\n",
       "            height=\"300\"\n",
       "            src=\"https://ignite.byu.edu/cbe263/lectures\"\n",
       "            frameborder=\"0\"\n",
       "            allowfullscreen\n",
       "            \n",
       "        ></iframe>\n",
       "        "
      ],
      "text/plain": [
       "<IPython.lib.display.IFrame at 0x12f958550>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from IPython.display import IFrame\n",
    "IFrame(\"https://ignite.byu.edu/cbe263/lectures\", width=600, height=300)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## LaTeX Equations"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "Equations are entered using LaTeX format. \n",
    "- Google \"latex math tutorial\" for details. \n",
    "- Here are some examples. Double click this cell to see how the equations are formatted.\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "**In-line** equations are surrounded with `$` like this: `$a=b$`. That code becomes $a=b$\n",
    "\n",
    "**Single-line** equations are surrounded with `$$` like this:\n",
    "```\n",
    "$$a = b$$\n",
    "```\n",
    "$$a = b$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Greek** symbols are entered as `\\alpha` or `\\gamma`, or `\\Gamma`, etc.\n",
    "\n",
    "So `$\\alpha = \\Gamma$` becomes $\\alpha = \\Gamma$."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Superscripts:** `^`\n",
    "- Example: `$a^b$` gives $a^b$\n",
    "    \n",
    "**Subscripts:** `_`\n",
    "- Example: `$a_b$` gives $a_b$\n",
    "\n",
    "For more than one character, surround with `{}`\n",
    "- Example `$T_max$` gives $T_max$, but `$T_{max}$` gives $T_{max}$.\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Fractions**\n",
    "- Enter as `$\\frac{numerator}{denominator}$`\n",
    "- Example `$P = \\frac{nRT}{V}$` gives $P = \\frac{nRT}{V}$\n",
    "$$P = \\frac{nRT}{V}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Some key symbols**\n",
    "- Partial derivative `\\partial` $\\partial$\n",
    "- Infinity `\\infty` $\\infty$\n",
    "- Right arrow `\\rightarrow` $\\rightarrow$\n",
    "- A dot, as in multiplication `a\\cdot b` $a\\cdot b$ (note the space before b).\n",
    "- Nabla `\\nabla` $\\nabla$\n",
    "- Delta `\\Delta` $\\Delta$\n",
    "- Comparison `\\le` $\\le$, `\\ge` $\\ge$ \n",
    "- [Many more](http://artofproblemsolving.com/wiki/index.php/LaTeX:Symbols)\n",
    "- [Google search](https://www.google.com/search?client=opera&q=latex+symbols&sourceid=opera&ie=UTF-8&oe=UTF-8)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Sums and integrals**\n",
    "\n",
    "- `$\\int_a^bf(x)dx$` $\\int_a^bf(x)dx$\n",
    "- `$\\sum_{i=1}^{n_{pts}} w_i$`  $\\sum_{i=1}^{n_{pts}} w_i$\n",
    "$$\\sum_{i=1}^{n_{pts}} w_i$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Big parenthesis** with `\\left(` and `\\right)`, etc.  \n",
    "\n",
    "`$$\\left(\\frac{a}{b}\\right) = \\left[\\frac{x+y}{2}\\right]^\\delta$$`\n",
    "\n",
    "$$\\left(\\frac{a}{b}\\right) = \\left[\\frac{x+y}{2}\\right]^\\delta$$\n",
    "\n",
    "Use `\\left.` or `\\right.` to skip one side, as in \n",
    "\n",
    "$$\\left.\\frac{\\partial y}{\\partial x}\\right|_{z}$$\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Add space** with ```\\,```\n",
    "\n",
    "```$f(x)=a,\\,\\,x>5$``` \n",
    "\n",
    "$f(x)=a,\\,\\,\\,x>5$\n",
    "\n",
    "```\\phantom{xxx}``` is also useful (puts in the xxx without showing it, xxx is anything you want).\n",
    "\n",
    "$f(x)=a,\\phantom{xxx}x>5$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Add text** with `\\text{some text}`\n",
    "\n",
    "$$f(x) = x^2\\text{    if y holds}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Align equations: use & as the alignment character, and \\\\\\\\ for new line:\n",
    "```\n",
    "\\begin{align*}\n",
    "\\frac{dv}{dt} &= a + b^c + \\alpha^2, \\\\\n",
    "\\frac{dx}{dt} &= x.\n",
    "\\end{align*}\n",
    "```  \n",
    "becomes\n",
    "\\begin{align*}\n",
    "&\\frac{dv}{dt} = \\xi + b^c + \\Gamma^2, \\\\\n",
    "&\\frac{dx}{dt} = x.\n",
    "\\end{align*}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "jupyter": {
     "source_hidden": true
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\\frac{a - \\frac{b}{T+c}}{\\sin(x)}$$\n",
    "\n",
    "$$\\sum_{i=22}^{45} f(x)dx$$\n",
    "\n",
    "$$\\frac{\\partial f(x,y)}{\\partial y}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For math functions:\n",
    "- use `\\sin(x)`, not `sin(x)`\n",
    "- use `\\ln(x)`, no `ln(x)`, etc.\n",
    "$$\\sin(x)$$\n",
    "$$sin(x)$$\n",
    "$$\\ln(x)$$\n",
    "$$ln(x)$$\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Enter greek letters in code cells\n",
    "\n",
    "- Jupyter: type backslash then the letter name then hit the tab key.\n",
    "- VScode: Install the Greek Alphabet Snippets plugin\n",
    "    - Then type the name of the greek letter (or part of it) and                                \n",
    "   \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "π = 3.14159265358979"
   ]
  }
 ],
 "metadata": {
  "hide_input": false,
  "kernelspec": {
   "display_name": "base",
   "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.14.6"
  },
  "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": 4
}
