LaTeX for Math Crash Course
(It’s easy, don’t worry)
CodeCogs is a website that’ll allow you to test your LaTeX math code in real time. A stable internet connection is required for the ‘real time’ part.
I highly recommend following along with this tutorial.
Note that LaTeX is not only for math, so if you google “how to… latex,” you might see results for non-math related stuff.
What is LaTeX for Math?
It’s a way to let you type math as code, and make it look pretty.
Typing operators
, and are intuitive. Just type +, -, or =.
Example
1 + 1 - 1 = 1
Multiply and divide use symbols that you can’t normally type on the keyboard, so instead, you type \times or \div instead.
Don’t forget the \ at the beginning! This is the ‘escape character’ and is how you type most symbols.
Example
4 \times 2 \div 3 = 2.6666667...
Note that you won’t be using much, as most of the time you use fractions. We’ll show fractions later in this document.
Superscript and subscript
This is pretty intuitive too – you probably already use these symbols.
^ for superscript
_ for subscript
Example
y = v_i t + a_g t^2 \div 2
You can combine them too. Order doesn’t matter.
Example
v^2_1andv_1^2are the same.
and are the same.
Note that LaTeX doesn’t care about spaces.
Example
x = v_1tandx = v_1 tare the same.
and are the same.
Example (bad)
v^42
If your superscript or subscript is longer than 1 character, you must use { curly braces } to surround them.
Example (fixed)
v^{42}
Example
v_{1 f}
Example
v^{42}_{final\ of\ the\ first\ object}
Notice the \ before the spaces. Inserting a backslash before a space tells LaTeX that you want to insert the space character.
Fractions
Fractions use \frac, and require 2 parameters (a numerator and denominator).
Example
\frac 12
If you want more than 1 character in the fraction, you need to surround them in curly braces.
Example
\frac{42}{18}
Example
\frac{x^2 - 1}{(x + 1)(x - 4)} = \frac{x - 1}{x - 4}
Exercise 1
Try to copy this equation exactly:
Square root
Uses \sqrt
Example
\sqrt{x^2 + y^2}
You can also do cube root (or any root) using \sqrt[n]{...}
Example
\sqrt[3]{x^2 + y^2 + z^2}
Dot multiply
People don’t really use that much either… you tend to see instead.
You can type that thing with \cdot. (center dot)
Example
4 N \cdot m
Vectors
You can add \vec to add a vector arrow above your
Example
\vec F = q \vec v \times \vec B
Other symbols
You can type other symbols by remembering their (greek) names.
Note that if you capitalize the code, you will get the capitalized letter.
| Symbol | Code |
|---|---|
\delta |
|
\Delta |
|
\theta |
|
\Theta |
|
\mu |
|
\Mu |
|
\nu |
|
\varepsilon |
|
\omega |
|
\alpha |
etc…
Other math symbols you might find useful:
| Symbol | Code | Mnemonic |
|---|---|---|
\approx |
approximately equal |
|
\sum |
||
\neq |
not equal |
|
\pm |
plus or minus |
|
\int |
integral |
|
\therefore |
Exercise 2
Copy this equation exactly:
Trig functions
While you can just type sin, it’ll look slightly better if you type \sin or \cos or \tan, etc.
Example (bad)
sin \theta = \frac{opp}{adj}
Example (fixed)
\sin \theta = \frac{opp}{adj}
Adding \ before trig functions removes the italics that LaTeX applies on variables.
Without \ |
With \ |
|---|---|
Big brackets
Sometimes, you just need big brackets.
Example (bad)
x \cdot (\frac{a}{d} + v_i)
LaTeX will auto-size brackets for you if you do \left ( ... \right )
Example
x \cdot \left ( \frac{a}{d} + v_i \right )
Units
Units aren’t variables, and therefore are usually not in italics. You can remove italics yourself using \textup
Example (bad)
4 N \cdot m
yes that is the same example for dot multiply
Example (fixed)
4 \textup N \cdot \textup m
Colors
Colors are nice sometimes.
Some escape codes have already been defined for you.
| Result | Code |
|---|---|
\red{red} |
|
\green{green} |
|
\blue{blue} |
There are lots more you can discover yourself.
Exercise 3
Copy this equation exactly:
Cancel
You can cross out stuff to show cancelling out.
Example
\frac{1}{\cancel{22}} \times \cancel{22} = 1
Appendix
Deriving exercise 2
I made up a question in my head where you’re asked to calculate the velocity of some object on a vertical spring. (These equations don’t come from thin air, you know!)
Answers to exercises
Answer 1
m_1\frac{v_{1i}^2}{r} = qv \times B - m_1g
Answer 2
v = \pm \sqrt{\frac{2mg_{Earth}h - k_{sp}x^2}{m}}
Answer 3
\red{\textup E} \green{\tan \left [ \blue{\sin \left ( \frac \Mu \alpha \right )} \right ]}
Comments
Post a Comment