Markdown, LaTeX Equations

Markdown Cells

Markdown is used for formatting text cells.

Double click on the markdown cells in this document (including this cell) for examples.

Make new paragraphs with empty lines.
Make new lines when the line above has at least two trailing spaces.

You can put raw html in markdown cells if you want.

You can insert images, pdf files, etc. into the document.

Make horizontal lines with three or more dashes, or underscores, or asterisks:


Heading

Subheading

Subsubheading

etc

Lists

Make a list like this:

  • Item one (note the space after the *)
  • Item two (note the symbol becomes a circle)
    • Sub-bullet 1 (note the sub-bullet is a square)
    • Sub-bullet 2
      • Sub-bullet 3 (the sub-sub-bullet is an open circle)
    • Sub-bullet 3
  • Item 3

Here is a numbered list:

  1. Item 1
  2. Item 2
    1. Sub-item ( the "1." in the code becomes "A." in output)
    2. Sub-item
      1. Sub-Sub-item (The "1." becomes "a." in output)

Make hyperlinks like this [Link text](http://somesite.com)
For example: Google it

You can link to locations inside the document. This is convenient for making, say, a linked table of contents. Here's how:

  • Put an html anchor at the target location:
    • <a id='my_target_name'></a>
  • Put the link to the target anywhere else in the notebook:
    • [Link text](#my_target_name)
  • For example here is a link to the top of this page
    • Double click the cell at the first cell at the top to see the anchor </a id="the_top"></a>

Bold, Italic, Colored Text

Here is how to make colored text:

  • For example: <font color='green'>This is colored</font>
  • For example: This is colored

Italicize text between *'s: *This will be italic*

  • That is: This is italic

Bold text between **'s: **This will be bold**

  • That is: This is bold

No markdown for underline, use html tags instead: <u>This will be underlined</u>

  • That is This will be underlined

strikethrough between ~~'s: ~~this will be strikethrough~~

  • That is: this will be strikethrough

Format Code

To write code snipets, like those above, you can just tab indent them, or surround with back-quotes: `this is code`

If the first line is like this: ```python```
then subsequent lines will get syntax coloring, which is nice:

if a<2.2 :
    print("Hi there")

Blockquotes

Block style quotes are offset with >

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.

Tables

| Left-aligned | Center-aligned | Right-aligned |
|:-------------|:--------------:|--------------:|
| Pressure     | P              | (Pa)          |
| Temperature  | T              | (K)           |
| Velocity     | v              | (m^3)         |
Left-aligned Center-aligned Right-aligned
Pressure P (Pa)
Temperature T (K)
Velocity v (m^3)

Images

Images can be inserted with this ![alt text](my_image.png)

But in Jupyter, html is much more flexible <img src=my_image.png width=300>

  • You can include local pictures, or pictures on a website.
    • This is convenient for sharing your notebooks.

IFrames

  • Useful for including other files, like PDFs
  • These go in code cells and you need to import a library as shown below.
In [1]:
from IPython.display import IFrame
IFrame("https://ignite.byu.edu/che263/lectureNotes/lecture_06_review.pdf", width=600, height=300)
Out[1]:

LaTeX Equations

Equations are entered using LaTeX format.

  • Google "latex math tutorial" for details.
  • Here are some examples. Double click this cell to see how the equations are formatted.

In-line equations are surrounded with $ like this: $a=b$. That code becomes $a=b$

Single-line equations are surrounded with $$ like this:

$$a = b$$
$$a = b$$

Greek symbols are entered as \alpha or \gamma, or \Gamma, etc.

So $\alpha = \Gamma$ becomes $\alpha = \Gamma$.

Superscripts: ^

  • Example: $a^b$ gives $a^b$

Subscripts: _

  • Example: $a_b$ gives $a_b$

For more than one character, surround with {}

  • Example $T_max$ gives $T_max$, but $T_{max}$ gives $T_{max}$.

Fractions

  • Enter as $\frac{Numerator}{Denominator}$
  • Example $P = \frac{nRT}{V}$ gives $P = \frac{nRT}{V}$ $$P = \frac{nRT}{V}$$

Some key symbols

  • Partial derivative \partial $\partial$
  • Infinity \infty $\infty$
  • Right arrow \rightarrow $\rightarrow$
  • A dot, as in multiplication a\cdot b $a\cdot b$ (note the space before b).
  • Nabla \nabla $\nabla$
  • Delta \Delta $\Delta$
  • Comparison \le $\le$, \ge $\ge$
  • Many more
  • Google search

Sums and integrals

  • $\int_a^bf(x)dx$ $\int_a^bf(x)dx$
  • $\sum_{i=1}^{n_{pts}} w_i$ $\sum_{i=1}^{n_{pts}} w_i$ $$\sum_{i=1}^{n_{pts}} w_i$$

Big parenthesis with \left( and \right), etc.

$$\left(\frac{a}{b}\right)$$ = \left[\frac{x+y}{2}\right]^\delta$$

$$\left(\frac{a}{b}\right) = \left[\frac{x+y}{2}\right]^\delta$$

Use \left. or \right. to skip one side, as in

$$\left.\frac{\partial y}{\partial x}\right|_{z}$$

Add space with \,

$f(x)=a,\,\,x>5$

$f(x)=a,\,\,\,x>5$

\phantom{xxx} is also useful (puts in the xxx without showing it, xxx is anything you want).

$f(x)=a,\phantom{xxx}x>5$

Add text with \mbox{some text}

$$f(x) = x^2\mbox{ if y holds}$$

Align equations: use & as the alignment character, and \\ for new line:

\begin{align}
\frac{dv}{dt} &= a + b^c + \alpha^2, \\
\frac{dx}{dt} &= x.
\end{align}

becomes \begin{align} &\frac{dv}{dt} = \xi + b^c + \Gamma^2, \\ &\frac{dx}{dt} = x. \end{align}

In [ ]:
 
$$\frac{a - \frac{b}{T+c}}{\sin(x)}$$$$\sum_{i=22}^{45} f(x)dx$$$$\frac{\partial f(x,y)}{\partial y}$$
$$\sin(x)$$$$sin(x)$$$$ln(x)$$$$\ln(x)$$

Enter greek letters in Code cells

Type backslash then the letter name then hit the tab key.

In [1]:
π = 3.14159265358979
In [2]:
π
Out[2]:
3.14159265358979