Enrol now for our new online tutoring program. Learn from the best tutors. Get amazing results. Learn more.

August 02, 2021, 01:20:08 pm

### AuthorTopic: $\TeX$ guide V2.0  (Read 6069 times) Tweet Share

0 Members and 1 Guest are viewing this topic.

#### RuiAce

• ATAR Notes Lecturer
• Honorary Moderator
• Great Wonder of ATAR Notes
• Posts: 8786
• "All models are wrong, but some are useful."
• Respect: +2561
##### $\TeX$ guide V2.0
« on: December 11, 2018, 09:38:50 pm »
+25
Two and a half years have passed prior to the original $\LaTeX$ guide. The return of in-line $\LaTeX$ and the incoming new syllabus, well and the fact that I've become more experienced has provided me enough incentive to revamp the guide into something hopefully better to use. (At least, in some way or another.)

The coverage of this guide is designed to be sufficient for up to the new HSC Maths Ext 2 syllabus. It is intended to be suitable for use for just the forum, which uses MathJax to render $\TeX$. The full $\LaTeX$ bundle is far more powerful than MathJax.

As with the previous guide, use of the CODE tags will be used to display what code was typed in first, before showing the result. More features may be added in over time.

Commencing $\LaTeX$ and writing text
Briefly understanding $\LaTeX$
$\LaTeX$ is essentially a typesetting package. It's optimised to handle mathematical objects better than traditional means such as Notepad and even Microsoft Word. It relies on code to produce the desired output.

Much of the code relies on the backslash symbol - the \ symbol. These will typically let you use commands, or open an environment (these are of the form \begin{something} ... \end{something}) that does a bunch of stuff for you. Essentially it symbols the start of a command.

The code also heavily relies on braces - the { } brackets. These are typically used to enclose a block of text for some specific purpose.

Opening a $\TeX$ equation
To begin using $\LaTeX$, you must enclose your code in the suitable brackets. Both the "inline math" mode and "display math" mode can be used on the forum. The difference is that the inline mode displays your equation alongside a bunch of text (so for example you could use it in the middle of a long paragraph), whereas the display mode shows everything with centre-aligning and also in a generally larger/spaced out format. The enclosing brackets are
Code: [Select]
 for inline LaTeX, and  for display LaTeXFor a quick comparison:
Code: [Select]
I can type $\sum x P(X=x)$ inline and it will look like this. Or if I go into display mode, it looks like$\sum xP(x)$I can type $\sum x P(X=x)$ inline and it will look like this. Or if I go into display mode, it looks like
$\sum xP(x)$
Note that if you don't press the enter key and jump into a new line, for the display math mode that'll be automatically done for you.

Writing ordinary text in $\LaTeX$
The $\LaTeX$ on the forum is designed to automatically go into mathematics mode. This makes typing ordinary text somewhat arduous, because you'll see that spaces are ignored. One needs to enter the $\texttt{\text{}}$ environment to type ordinary text. The format is essentially $\texttt{\text{TEXT GOES HERE}}$, for example:
Code: [Select]
$\text{Hello World!}$$\text{Hello World!}$
Entering a new line
Use of the Enter key to create a new line will not work, since $\LaTeX$ relies on code which treats new-lines as spaces. New-line characters are coded efficiently using just two backslashes \\ because they're essentially so commonly used.
Code: [Select]
$\text{Qwerty} \\ \text{Dvorak}$$\text{Qwerty} \\ \text{Dvorak}$
Note that the new-line character can be used in in-line $\LaTeX$, however it produces weird results. It keeps all the text before it in the line above, and all the text in the line after. This is contradictory to the intended use of in-line text, which literally keeps the words going from left to right.

The new-line character is especially useful on the ATAR notes forums, since the $\texttt{\text{}}$ command does not know to do new lines by itself. If you clump everything into one $\texttt{\text{}}$ command, it just keeps going across the row and eventually off the page, requiring you to scroll horizontally to see the stuff that's gone missing. You would likely want to take advantage of this to overcome that problem.

Writing formatted text in $\LaTeX$
There's no point choosing $\LaTeX$ over something like Microsoft Word if the extra text formats cannot be adapted. $\LaTeX$ also encourages the use of bold, italics and underline. For bolding and italicising, we use $\texttt{\textbf{}}$ and $\texttt{\textit{}}$.
Code: [Select]
$\textbf{Bolded} \text{ and } \textit{Italicised}$$\textbf{Bolded} \text{ and } \textit{Italicised}$
Underlining can be used in conjunction with bold, italics or just ordinary text. We essentially enclose the text inside an $\texttt{\underline{}}$.
Code: [Select]
$\underline{\text{Normal}} \text{ v.s. } \underline{\textbf{Bold}} \text{ v.s. } \underline{\textit{Italics}}$$\underline{\text{Normal}} \text{ v.s. } \underline{\textbf{Bold}} \text{ v.s. } \underline{\textit{Italics}}$
Sadly, on the forum, bolding and italicising cannot be used in conjunction with one another. Or at least I don't know of any way yet through my investigations.

There are some other text formats available that you can see by scrolling down at this link, however I haven't found much real need for it at the HSC level.

Coloring in $\LaTeX$
This is another feature that also gets carried over. Essentially, use of color is activated via the $\texttt{\color{}{}}$ command.

In the first set of braces, we declare a color. A full list of colours can be accessed here. Note that all of the basic colours work, but from experimenting I've found that some of the "dvipsnames" colours work whilst some others don't.

In the second set of braces, we include the block of text that should be coloured. This is important, as otherwise either only one letter gets coloured, or you run into a bug.
Code: [Select]
$\color{red}{\text{Here is a block of text in red.} \\ \text{And another.}} \\ \color{blue}{\text{Here is a block in blue.}}$$\color{red}{\text{Here is a block of text in red.} \\ \text{And another.}} \\ \color{blue}{\text{Here is a block in blue.}}$
Note how the code shows that for a bunch of text, you can put the new-line \\ command within the second brace. You can't always do this; for example this will mess up some environments like the align environment.

Resizing in $\LaTeX$
Remark: I don't really see why you would need this on the forums. However it's still important to note.

There are some loose changes that you can make to the size of your text. A list of sizes can be accessed here. Note that unlike with color, the size itself is the change in command.
Code: [Select]
$\Huge{\text{Test }} \text{Test}$$\Huge{\text{Test }} \text{Test}$
Notice how it doesn't work the same way as $\texttt{\color{}{}}$ does. It looks like the whole thing was bolded, when I only really wanted to bold the first "Test"! To overcome this, we enclose the only thing we want to put in huge in it's OWN set of braces like so:
Code: [Select]
${\Huge \text{Test }} \text{Test}$${\Huge \text{Test }} \text{Test}$
Debugging forum $\LaTeX$
There are at least two common mistakes I know of that cause $\LaTeX$ on the forum to break. Broken $\LaTeX$ looks a lot like what I had earlier on with a box enveloping my code. (There may be more common mistakes, but here are the two most common ones I know of.)

Spaces/Enter keys used for whitespacing
This is essentially when you use spaces or newlines to make your code neater, or when you accidentally forget that the enter needs a newline \\ and spaces need something else (coming soon). One new-line or two consecutive spaces can be enough to mess up your code.

(Note that sometimes they don't. But usually they do, so you should always keep an eye out for them when your output looks weird. As a rule of thumb, you should never have more than one space between any two symbols/commands.)

Use of special characters in $\LaTeX$
There are 10 symbols that have special functions in $\LaTeX$. These must be handled with caution - they could cause your program to break when not typed correctly.

The symbols are: & % \$ # _ { } \ ~ ^
The first eight typed in $\LaTeX$ are:
Code: [Select]
$\& \% \ \# \_ \{ \} \backslash$$\& \% \ \# \_ \{ \} \backslash$
I don't know of any way to overcome the issues with the last two, but I don't think you'll need them in the HSC. However, the tilde can be replaced by \sim: $\sim$ if you prefer.

Note that they don't cause problems if you've opened a text environment. But as you'll see right below, you're not always in a text environment and thus you might have problems.

Starting maths and $\LaTeX$
Briefly understanding $\LaTeX$ continued
In the real $\LaTeX$ package, usually the default mode is the text mode. On forums however, the default is actually the math mode. This is part of what makes things weird.

In math mode, spaces are not interpreted as spaces at all. They're just ignored (or on ATAR notes, sometimes treated as bugs when you use consecutive spaces) altogether. This is because normally it doesn't make sense to have extra spacing for your mathematical equations - $\LaTeX$ does a fair bit of the work for you.

Spaces
We saw just now with the ten symbols that there was no space included, despite the fact that I used spaces in my code. There are in fact commands that let you do spacing for you. A nice assortment can be found online, but these ones should be sufficient for now.
- $\texttt{\!}$ does a negative space - it actually makes things tighter
- $\texttt{\,}$ does a thin space
- $\texttt{\:}$ and $\texttt{\>}$ both do a medium space
- $\texttt{\;}$ does a large space
- $\texttt{\quad}$ does a space that's actually equivalent to the font size. It's usually much bigger for this reason
- $\texttt{\qquad}$ does a space double the size of \quad
(The control space $\texttt{\ }$ isn't much useful for the forums... I think)
Code: [Select]
 $x \! x \, x \: x \; x \quad x \qquad x$$x \! x \, x \: x \; x \quad x \qquad x$
I found that $\texttt{\,}$ and $\texttt{\quad}$ were sufficient for me typically.

Ordinary symbols
For things such as the English alphabet, the 10 Hindu-Arabic numbers and various other symbols (e.g. ! ? ,) there really is nothing fancy to it.
Code: [Select]
$\text{Factorials}: \quad 7! = 5040$$\text{Factorials}: \quad 7! = 5040$

Basic Operations
The plus and the minus symbols fall in the same umbrella as the above. For times, we may just use $\texttt{\times}$, whereas for divide we may use $\texttt{\div}$. For the plus/minus symbol we use $\texttt{\pm}$, whereas for the minus/plus symbol we use $\texttt{\mp}$.
Code: [Select]
$|6\times x| = 18\\ x = \pm 3$$|6\times x| = 18\\ x = \pm 3$

Inequalities
The strict greater than/less sign symbols are typed the usual way: < and >. For the unequal, greater than or equal and less than/equal to, we use
- $\texttt{\neq}$ or $\texttt{\ne}$
- $\texttt{\geq}$ or $\texttt{\ge}$
- $\texttt{\leq}$ or $\texttt{\le}$
Code: [Select]
$3 \neq 4 \text{ but } 3 \leq 4$$3 \neq 4 \text{ but } 3 \leq 4$
Fractions
Fractions can be done using the forward slash symbol if you wish: $8/6 = 4/3$. But if you prefer the neater format, the command $\texttt{\frac{numerator}{denominator}}$ is used to help you out. The example shows that you can do fractions inside fractions.
Code: [Select]
$\frac{8}{6} = \frac{4}{3} \\ 1 + \frac{1}{ 1 + \frac{1}{2}} = \frac{5}{3}$$\frac{8}{6} = \frac{4}{3} \\ 1 + \frac{1}{ 1 + \frac{1}{2}} = \frac{5}{3}$
It may be worth remarking that in the real world, sometimes the forward slash is preferred if things are getting tiny. Note how if I use the $\texttt{\frac{}{}}$ command in the inline mode I get a tiny fraction like this: $\frac{4}{3}$! Usually it won't matter too much in the HSC though.

Superscripts and subscripts
The $\texttt{^}$ and $\texttt{_}$ symbols have typically been used for the purpose of introducing superscripts and subscripts. Superscripts are essentially useful for powers, whilst subscripts are used for things such as logarithms. Essentially, whatever needs to be in the power is incorporated after the $\texttt{^}$ or $\texttt{_}$ in a brace.
Code: [Select]
$S_n = \frac{a(r^{n}-1)}{r-1}$$S_n = \frac{a(r^{n}-1)}{r-1}$
Note that when you omit the braces, only the first symbol after the $\texttt{^}$ or $\texttt{_}$ symbol goes in the superscript/subscript. This can be concerning for beginner $\LaTeX$ users, which is why I discourage this laziness and highly encourage use of braces at the start. (However, once you're more experienced, you can feel free to be lazier - see the last sections.)

Brackets
As hinted above, brackets mostly fall under the ordinary symbols category as well. The only exception is the braces $\texttt{{ }}$, which fall under the special symbols category and require $\texttt{\{ \}}$ to be addressed.
Code: [Select]
$(2+2)\div 2 = 2 \qquad \{ \text{some random set} \}$$(2+2)\div 2 = 2 \qquad \{ \text{some random set} \}$
University level students may also like to investigate:
- $\texttt{\lceil \rceil}$ for the ceiling function.
- $\texttt{\lfloor \rfloor}$ for the floor function.
- $\texttt{\langle \rangle}$ for inner product brackets - this is better than abusing < and > which are purposely widened up for the sake of inequalities.
- $\texttt{\| \|}$ for norm brackets - this is better than just doing || || as it has smaller spaces between the bars.

Resizing Brackets
Brackets don't always sync well with superscripts/subscripts, especially when they become nested. They also become really problematic when it comes to fractions:
Code: [Select]
$( \frac{1}{x} )$$( \frac{1}{x} )$
Note that the bracket doesn't envelop the fraction fully. There are ways to overcome this.

Automatic resizing
This is recommended 98% of the time. For beginners, essentially this is recommended 100% of the time. Basically, use of $\texttt{\left}$ and $\texttt{\right}$ before the left and right brackets respectively help fix resizing for you automatically.
Code: [Select]
$\left( \frac{1}{x} \right)$$\left( \frac{1}{x} \right)$
Manual resizing
This is only recommended about 2% of the time. The sizes in ascending order are
- $\texttt{\big}$
- $\texttt{\Big}$
- $\texttt{\bigg}$
- $\texttt{\Bigg}$
These are occasionally useful when we want to reinforce nested brackets and because we don't have superscripts/subscripts/fractions, the \left and \right commands do nothing. For example
Code: [Select]
$\big( x - (2-2x) \big) = 3x - 2$$\big( x - (2-2x) \big) = 3x - 2$
Outside of the HSC, some people like to use \bigg | for evaluation of definite integrals.

Surds
Square roots and cube roots are also taken care of. All of them rely on the \sqrt{} command, however to tweak it for those that aren't actually square roots, it turns out that we use a square bracket for that extra value before the braces. (Which is fair enough - I just don't know why square brackets are used specifically.)
Code: [Select]
$2 = \sqrt{4} = \sqrt[3]{8} = \sqrt[4]{16}$$2 = \sqrt{4} = \sqrt[3]{8} = \sqrt[4]{16}$
Greek Letters
Because Greek letters seem to also get used a lot in mathematics, the Greek alphabet is provided when you're not inside the text mode. They're quite easy to access - simply type a backslash before the English spelling of the Greek letter.
Code: [Select]
$\alpha \beta \gamma \delta \epsilon$$\alpha \beta \gamma \delta \epsilon$
For the capital letters, we simply replace the first letter of the Greek letter with a capital letter instead.
Code: [Select]
$\Gamma \Delta$$\Gamma \Delta$
Note that some capital Greek letters coincide with capital English letters. These won't work - for example $\texttt{\Alpha}$ produces $\Alpha$ - an error. Also, a few greek letters have variants. A table can be accessed here.

The Advanced Mathematics $\LaTeX$ bundle
Therefore and because
These two symbols are things you would've almost surely seen during 5.3 and very likely in 5.2 studies. They are like many of the easier symbols out there to code as they're literally defined based off their name.
Code: [Select]
$\therefore \\ \because$$\therefore \\ \because$
Piece-wise defined functions
You will bump into functions who rule changes depending on the set of $x$ values we're currently interested in. This is the first big time where we see environments and have a begin/end system. Piecewise functions require the 'cases' environment; it gets its name from the fact we're considering the different cases the $x$ values fall under.

The ampersand $\texttt{&}$ is used in any scenario where we want to jump to the next column in a row. The newline \\ switches us to the next row. Both of these come into play here.
Code: [Select]
$f(x) = \begin{cases} e^x & \text{if }x \leq 0\\ \ln x & \text{if }x > 0 \end{cases} \text{ is not continuous.}$$f(x) = \begin{cases} e^x & \text{if }x \leq 0\\ \ln x & \text{if }x > 0 \end{cases} \text{ is not continuous.}$
Common mathematical functions
There are heaps of functions that you'll be using in this course. But if you just type "sin" by itself, it will look no different to your variables like $x$, i.e. in the italicised math mode. It turns out that $\LaTeX$ has objects called "operators" that are predefined, so that all it takes is a backslash in front of the symbol to fix it up. The following are ones you should keep in mind.
- $\texttt{\sin x}$          $\sin x$
- $\texttt{\cos x}$          $\cos x$
- $\texttt{\tan x}$          $\tan x$
- $\texttt{\csc x}$          $\csc x$
- $\texttt{\sec x}$          $\sec x$
- $\texttt{\cot x}$          $\cot x$
- $\texttt{\log x}$          $\log x$
- $\texttt{\log_{2} x}$ $\log_{2} x$ (logarithms with bases)
- $\texttt{\ln x}$            $\ln x$

Code: [Select]
$\sin \frac{\pi}{3} = \frac{\sqrt{3}}{2}$$\sin \frac{\pi}{3} = \frac{\sqrt{3}}{2}$
Some remarks: 'cosec' is not the internationally accepted way of writing the cosecant function, but rather csc is. If you're adamant on using 'cosec', one lengthy (but perhaps the more recommended) way of doing so is to take advantage of the $\texttt{\operatorname{}}$ command. Doing $\texttt{\operatorname{cosec}x}$ will produce $\operatorname{cosec}x$. This is revisited again when talking about statistics.

It is possible to type the shorthand $\sin^2 x$ for $(\sin x)^2$ by simply typing $\texttt{\sin^2 x}$.

Basically, what this does is that you're making your own operator, instead of using a predefined one.

Ensure that you put a single space between your operator and the variable of inteterest. This will be very important from here on - at times like this, if you forget even one space you'll turn a command into being unrecognisable. For example, $\texttt{\logx}$ produces $\logx$, which is really an error message where $\LaTeX$ is complaining to you "I don't know what this command is".)

Degree (angles)
Sadly, there is no degree symbol available, unless you go on the real $\LaTeX$ and include some package. Usually degrees are typed by a cheat way. There is a command $\texttt{\circ}$ that essentially draws a small circle $\circ$, but we combine it with the superscript to get a mock degree symbol by typing $\texttt{^{\circ}}$.
Code: [Select]
$45^{\circ} = \frac{\pi}{4}$$45^{\circ} = \frac{\pi}{4}$
Limits
Limits are actually handled in a way similar to logarithms with bases, i.e. via subscripts. $\LaTeX$ has pre-defined the $\texttt{\lim}$ operator to automatically put subscripts vertically below the text, rather than to the bottom-right. The arrow in limits is usually drawn via the $\operatorname{\to}$ command.
Code: [Select]
$\lim_{x\to 0} \frac{\sin x}{x} = 1$$\lim_{x\to 0} \frac{\sin x}{x} = 1$
After fractions, limits are one of the first objects that illustrate the difference between the display math style and the inline math style. Note that on the other hand, if you choose the inline style, the subscript actually appears in the bottom right instead! $\lim_{x\to 0} \frac{\sin x}{x} = 1$

Infinity
As sometimes you need to deal with the concept of infinity with limits (and also in domains and ranges), it makes sense to have a symbol for it as well. It turns out that it's defined in the acronym $\texttt{\infty}$.
Code: [Select]
$\lim_{x\to \infty} e^{-x} = 0$$\lim_{x\to \infty} e^{-x} = 0$
'Dash' in derivatives
Many of us like to use the shorthands $f^{\prime}(x)$ and $y^{\prime}$ when it comes to differentiation. This apostrophe-like symbol gets called a 'dash' by everyone in Australian high school mathematics. However its real name is actually the "prime" symbol (a dash denotes a long hyphen), which is why $\LaTeX$ has programmed it as $\texttt{\prime}$. It is used in conjunction with the superscript.
Code: [Select]
$f(x) = x^2\\ f^{\prime}(x) = 2x \\ f^{\prime\prime}(x) = 2$$f(x) = x^2\\ f^{\prime}(x) = 2x \\ f^{\prime\prime}(x) = 2$
Set operations - Union, intersection, complement
The union and intersection symbols are predefined based off what they look like interestingly. They are respectively defined by $\texttt{\cup}$ and $\texttt{\cap}$.
Code: [Select]
$\{1,2,3,4\} \cup \{ 3,4,5,6\} = \{1,2,3,4,5,6\}\\ \{1,2,3,4\} \cap \{3,4,5,6\} = \{3,4\}$$\{1,2,3,4\} \cup \{ 3,4,5,6\} = \{1,2,3,4,5,6\}\\ \{1,2,3,4\} \cap \{3,4,5,6\} = \{3,4\}$
The complement is denoted in three different ways. Two of these were somewhat seen before - we can use superscripts with C to denote the complement, or superscripts with the 'dash' just like with the derivative. The other way is to draw a bar over the event variable. There are two ways of achieving this.
Code: [Select]
$P(\bar{A}) = \frac{1}{3}\\ P(\overline{A}) = \frac{1}{3}$$P(\bar{A}) = \frac{1}{3}\\ P(\overline{A}) = \frac{1}{3}$
The only real difference is that $\texttt{\bar}$ puts on a small bar, and it's optimised to only go over one letter. $\texttt{\overline}$ can be made to go over multiple letters. For this reason, I prefer the latter - its function doubles up into other things as well.

University students may like to explore $\texttt{\bigcup}$ and $\texttt{\bigcap}$ for the union/intersection of multiple sets. It works similarly to sigma notation (mentioned in the Extension 2 section): $\bigcup_{i=1}^n A_i = A_1 \cup A_2 \cup \dots \cup A_n$.

Probability, expectation and variance
Again, sadly there's no predefined way of typing any of the above. The proper way to overcome this issue is to create your own operator. Since we aren't editing a full $\LaTeX$ file, we can do this by using $\texttt{\operatorname{}}$. Here, we would just do $\texttt{\operatorname{E}}$, $\texttt{\operatorname{E}}$ and $\texttt{\operatorname{Var}}$.
Code: [Select]
$\operatorname{E}(X) = np\\ \operatorname{Var}(X) = np(1-p)$$\operatorname{E}(X) = np\\ \operatorname{Var}(X) = np(1-p)$
However, to be honest, at the high school level it probably won't matter that much. You could just be lazy with the statistics problems and not format it at all in my opinion, even if I don't like it. (Main thing is, I can understand that typing operatorname is just arduous and copy/paste isn't that much less boring. If you look closely, I didn't even do this for some of the stuff right above!)

For university level students, maybe consider using the $\texttt{\mathbb{}}$ typesetting for the first two.

Conditional probability
There is a way to cheat with conditional probability and that's to use the same bar used for absolute value brackets, which is this symbol $\texttt{|}$. However when you use this, there really is no space between the two symbols: $P(A|B)$. In theory, there should always be some spacing, because the bar representing conditional probability should be treated as its own thing: $P(A \mid B)$.

The "standalone" vertical bar symbol, as I call it, is for some reason defined by $\texttt{\mid}$. This is what should go between your events $A$ and $B$.
Code: [Select]
$\operatorname{P}(A \mid B) = \frac{\operatorname{P}(A \cap B)}{\operatorname{P}(B)}$$\operatorname{P}(A \mid B) = \frac{\operatorname{P}(A \cap B)}{\operatorname{P}(B)}$
But just like the ones above, in the HSC you can probably get away without doing it properly.

Integration
Conveniently, the integral symbol is abbreviated into just $\texttt{\int}$ and thus are very easy to type. However, usually I like to use the $\texttt{\,}$ space to put a gap between the differential $dx$ and the actual integrad.
Code: [Select]
$\int x^2 \, dx = \frac{x^3}{3} + C$$\int x^2 \, dx = \frac{x^3}{3} + C$
Integrals also reflect the difference between the display and in-line style. Essentially the integral symbol just becomes smaller. $\int x^2 \, dx = \frac{x^3}{3} + C$.

Definite integrals are made in conjunction with the superscripts and subscripts.
Code: [Select]
$\int_0^1 x^2\,dx = \frac{1}{3}$$\int_0^1 x^2\,dx = \frac{1}{3}$

Dot dot dot
The ellipsis is used in mathematics typically to denote some kind of sequence/recursion. The trapezoidal formula and the series topic make use of it in Advanced, whilst Extension 1 students will use it in mathematical induction on sums. There's actually a wide variety of dots available to use and it essentially depends on the context whichever one you prefer.
Code: [Select]
$\dots \quad \vdots \quad \ddots\\ 1 + \frac{1}{1 + \frac{1}{1+ \frac{1}{\ddots}}} = \frac{1+\sqrt{5}}{2}\\ a + (a+d) + (a+2d) + \dots + [a + (n-1)d] = \frac{n}{2} [2a + (n-1)d]$$\dots \quad \vdots \quad \ddots\\ 1 + \frac{1}{1 + \frac{1}{1+ \frac{1}{\ddots}}} = \frac{1+\sqrt{5}}{2}\\ a + (a+d) + (a+2d) + \dots + [a + (n-1)d] = \frac{n}{2} [2a + (n-1)d]$
The single dot is accessed by $\texttt{\cdot}$, however it will be explored in the Extension 1 section as it is more relevant there (dot product).

Polynomial degree
There's nothing fancy to explain here. Basically this can be accessed by using $\texttt{\deg}$.
Code: [Select]
$\deg(x^4+2x^2-100x+100) = 4$$\deg(x^4+2x^2-100x+100) = 4$
However, it definitely is interesting how this one has a symbol, yet the degrees for the angles does not

Adding in the Mathematics Extension 1 $\LaTeX$ bundle
Identically Equal-To
An identity is something that is designed to hold true for all of your independent variables (for example, all values of $x$). An example is just the Pythagorean identity $\cos^{2} x + \sin^{2} x = 1$.

In practice, more often than not we just swap it out for the usual equal sign. However in theory, to illustrate an identity we should be using the triple-bar equal sign (also used for congruency in junior level maths). This is coded by $\texttt{\equiv}$ which essentially stands for equivalence. You see this symbol when dealing with polynomial identities where you have to equate coefficients. (Or, at least you should, but maybe you/your teacher/your textbook chooses to be lazy.)
Code: [Select]
$ax^3+(b-3)x^2+(c-1)x+d \equiv 2x^3 + 9x^2 + x\\ \therefore a=2, \, b=12, \, c=2, \, d=0$$ax^3+(b-3)x^2+(c-1)x+d \equiv 2x^3 + 9x^2 + x\\ \therefore a=2, \, b=12, \, c=2, \, d=0$

More common mathematical functions
Extension 1 students are introduced to the inverse trigonometric functions as well. Very conveniently, these are also predefined.
- $\texttt{\arcsin x}$    $\arcsin x$
- $\texttt{\arccos x}$    $\arccos x$
- $\texttt{\arctan x}$    $\arctan x$
The alternate forms of $\sin^{-1}x$ and etc. are typed in the same way as $\sin^{2}x$. Note that this is also used for inverse functions in general: $f^{-1}(x)$.

Motion
The usual notations $\frac{dy}{dx}$ and $\frac{d^2y}{dx^2}$ are typed without anything special - they just use fractions and subscripts. But there's also the "dot" notation of derivatives that has conventionally been reserved for motion type problems. These dots are quite similar to the bar/overline we saw earlier - we basically put what we want the dot on top of, underneath a $\texttt{\dot}$ command!

$\texttt{\dot}$ gives a single dot for the velocity, and $\texttt{\ddot}$ gives a double dot for the acceleration.
Code: [Select]
$x = a \cos (nt + \epsilon) \\ \dot{x} = -an \sin (nt + \epsilon)\\ \ddot{x} = -an^2 \cos (nt + \epsilon)$$x = a \cos (nt + \epsilon) \\ \dot{x} = -an \sin (nt + \epsilon)\\ \ddot{x} = -an^2 \cos (nt + \epsilon)$
Binomial coefficient
There's no proper way to code the permutation $^nP_r$ - I just cheat and use $\texttt{^nP_r}$. This is because this notation is quite outdated in the real world; normally we just use $P(n,r)$. But the vector-like notation for the combination is still coded in because the binomial coefficient is still very powerful. It is coded as $\texttt{\binom{TOP}{BOTTOM}}$
Code: [Select]
$\operatorname{P}(X=k) = \binom{n}{k} p^k (1-p)^{n-k}$$\operatorname{P}(X=k) = \binom{n}{k} p^k (1-p)^{n-k}$
Note that it looks a tiny bit different to a vector in 2-dimensional space. The brackets are a bit narrower. You should certainly not cheat and use the binomial coefficient for a 2-dimensional vector.

Vector notations
Pretty much the bulk of the new stuff for MX1 falls under the vectors topic. We basically need to introduce a lot of new notation to be able to write vectors out.

Position vectors
For the corresponding vector from the origin to a point $A$, or just some vector that you've labelled that way, we have the bold font and the tilde beneath-the-letter notations.

Whilst we can use $\texttt{\textbf{}}$ for the bold font notation, we actually prefer $\texttt{\mathbf{}}$ when it comes to equations. $\texttt{\mathbf{}}$ differs from the former in that it excludes spaces. Whilst I can't see this being a problem in high school maths, it can prove useful if you need maths further down the road at uni.
Code: [Select]
$\mathbf{a}$$\mathbf{a}$
As you can see, it does look like $\texttt{\textbf{a}}$.

For the tilde below-the-variable, in the real world we can include some package that predefines an undertilde for you. But sadly, just like with degrees, this can be pretty hard to do on a forum. Again we use techniques to overcome this issue.

Basically, the tilde character is represented by $\texttt{\sim}$ in the real world. This is because it's what's internationally used for things like similar triangles. We combine this with the $\texttt{\underset{bottom}{text}}$ command to force that tilde below the symbol of interest.
Code: [Select]
$\underset{\sim}{a}$$\underset{\sim}{a}$
It is for this reason I typically prefer the bold font notation when typing, however obviously in the real world I would prefer something like this under-tilde.

(It may be worth mentioning that $\texttt{\tilde{}}$ puts the tilde above the letter instead of below, and is predefined.

Vector from point to point
For vectors going from a point $A$ to a point $B$, we have the options of $\texttt{\vec{}}$ and $\texttt{\overrightarrow{}}$.
Code: [Select]
$\vec{AB}\\ \overrightarrow{AB}$$\vec{AB}\\ \overrightarrow{AB}$
Notice how just like with $\texttt{\bar{}}$ v.s. $\texttt{\overline{}}$, the $\texttt{\vec{}}$ command produces something short (it only goes over one letter at most), whereas $\texttt{\overrightarrow{}}$ goes over everything nice and neatly. This is why usually I prefer the latter.

Vector representations
Component form
In the HSC, and for the most part in the real world, the component form just expresses a vector in terms of the unit vectors $\mathbf{i}$ and $\mathbf{j}$ (and $\mathbf{k}$ if you're an Ext 2 student). There's nothing too fancy about it - it basically just takes advantage of the position vector notation. For example,
Code: [Select]
$\mathbf{x} = 2\mathbf{i} + 3\mathbf{j}$$\mathbf{x} = 2\mathbf{i} + 3\mathbf{j}$
Column vector form
A vector is really just a special class of objects called "matrices" in the real world. Matrices are also created using environments (coincidentally the matrix environments), and the idea is to consider a vector as a matrix with only one column. Therefore the ampersand $\texttt{\&}$ is useless for our purposes. The matrix environments are used somewhat similar to the cases environment.
Code: [Select]
$\mathbf{x} = \begin{matrix} 2 \\ 3 \end{matrix}$$\mathbf{x} = \begin{matrix} 2 \\ 3 \end{matrix}$
Now, the reason why I talk about environments in the plural sense here is because there are multiple. The usual matrix environment is designed in a way so that we don't actually get brackets around the matrix by default. This means, normally we'd need stuff like $\texttt{\left( \right)}$ to help us out.

But obviously this is too tedious. This is why we have environments like pmatrix and bmatrix available. The former gives you the round brackets that are more often used, whilst the latter would put in square brackets.
Code: [Select]
$\mathbf{x} = \begin{pmatrix} 2 \\ 3 \end{pmatrix}$$\mathbf{x} = \begin{pmatrix} 2 \\ 3 \end{pmatrix}$
Of course, university level students should experiment with the ampersand for matrices that have more than one column.

Scalar product
The usual period is more or less reserved for decimal places. For the sake of the dot product, the dot should be written more towards the centre, instead of at the bottom of a letter. The command $\texttt{\cdot}$ exists to help us move the dot a bit further up to the middle, as we want it to.
Code: [Select]
$\mathbf{x} \cdot \mathbf{x} = |\mathbf{x}|^2$$\mathbf{x} \cdot \mathbf{x} = |\mathbf{x}|^2$

The Extension 2 Mathematics $\TeX$-rritory
Element of
Note: In my opinion, this should be a Maths Advanced concept given the introduction of interval notation, however it doesn't seem to be included anywhere in the syllabus so I've just left it here for reference.

Usually we're too lazy to say "is an element of" in the real world, so we just abbreviate it with "in" instead. This is how it is coded in $\LaTeX$.
Code: [Select]
$x \in (-\infty,\infty)$$x \in (-\infty,\infty)$
Implication and Equivalence
In the real world, the standard implication arrows help illustrate your flow of logic. The usual arrow => is coded by $\texttt{\implies}$ whilst the corresponding arrow for the converse is coded by $\texttt{\impliedby}$.
Code: [Select]
$u = x^2 \implies du = 2x\,dx\\ \text{"I have an umbrella"} \impliedby \text{"It's raining and I'm well prepared"}$$u = x^2 \implies du = 2x\,dx\\ \text{"I have an umbrella"} \impliedby \text{"It's raining and I'm well prepared"}$
Because $\texttt{equiv}$ has already been stolen, there's no point using that to code equivalence anymore. Instead, recall that $p \implies q$ can be restated as "$p$ only if $q$", and $p \impliedby q$ can be restated as "$p$ if $q$". Because equivalence is just the forward and reverse implication combined, we can restate it as "$p$ if and only if $q$", and we know that "if and only if" can be abbreviated to "iff". It just so happens that equivalence ends up getting coded by $\texttt{\iff}$!
Code: [Select]
$2x=4 \iff x=2$$2x=4 \iff x=2$
Negation
To represent "not $P$" (which is of course, important for the contrapositive), we can either use the tilde or the internationally used symbol. We already know that the tilde can be achieved by $\texttt{\sim}$, but if we want to use the more common symbol we can just use $\texttt{\neg}$.
Code: [Select]
$p = \text{"I am at school"}\\ \neg p = \text{"I am not at school"}$$p = \text{"I am at school"}\\ \neg p = \text{"I am not at school"}$
Quantifiers
Luckily, "for all" and "there exists" are also coded conveniently for us. We just use $\texttt{\forall}$ and $\texttt{\exists}$. Note that depending on what kind of person you are, you may wish to use spaces with the quantifiers, since by default there seems to be 0 spacing when quantifiers are used.
Code: [Select]
$\forall y \in [0,\infty)\quad \exists x \in [0, \infty) \quad x^2 = y$$\forall y \in [0,\infty)\quad \exists x \in [0, \infty) \quad x^2 = y$
Note that the exclamation mark for the unique existential quantifier is just your usual exclamation mark.

Sigma notation for sums
It is international convention to use sigma notation when denoting the sum of a sequence of terms. Whilst you can use $\texttt{\Sigma}$ for ordinary purposes, if you want the fancy one reserved for sums you can literally just use $\sum$. Sums function very similar to integrals in that you use superscripts and subscripts for the summation indices (indexes), but just as with limits, $\LaTeX$ aligns it all up properly for you.
Code: [Select]
$\sum_{k=1}^{n} T_{k} = T_{1} + \dots + T_{n}$$\sum_{k=1}^{n} T_{k} = T_{1} + \dots + T_{n}$
Note that sums are much like integrals in that they will look somewhat different in the inline math mode and display math mode.

University students may also like to explore the pi notation for the product, denoted $\texttt{prod}$. For example, $\prod_{k=1}^{n} k = n!$.
University students may also like to explore $\texttt{\substack{}}$ which can be used in the subscript of sums. It lets you add multiple lines to the subscript for them, for example if I want to sum over all $1\leq i\leq 2n$ but with $i \neq n$ I can do $\texttt{\sum_{ \substack{i=1\\ i\neq n} } ^{2n} }$. Substacking can also be useful for multivariable limits, when evaluated down a specific path.

Complex conjugate
Essentially, there's no real way to code this properly either. It's at times like this where I prefer the $\texttt{\overline{}}$ syntax for the 'bar', because you can stretch it out into things like this:
Code: [Select]
$\overline{z+w} = \overline{z} + \overline{w}$$\overline{z+w} = \overline{z} + \overline{w}$
Complex argument
The arg is similar to every easy thing we've seen thus far. It's just coded by $\texttt{\arg}$.
Code: [Select]
$\arg(zw) = \arg z + \arg w$$\arg(zw) = \arg z + \arg w$
University students who are well into complex numbers or have started complex analysis may like to keep in mind that the capital Arg (for the principal argument) is sadly NOT defined. Usually we create a new operator for this one instead.

Real and imaginary parts
The real and imaginary parts are coded (in my opinion, quite annoyingly) in the fraktur text style. You can research this on Google if you wish, but the idea is that it looks like this.
Code: [Select]
$\Re(3+4i) = 3\\ \Im(3+4i) = 4$$\Re(3+4i) = 3\\ \Im(3+4i) = 4$
When you do this in front of someone experienced at $LaTeX$, they'd probably shrug it off. But when you show it to someone for the first time, it's very likely they'll ask you why it looks so different. Again, sadly, the only way you can overcome this is to create a new operator.

Elementary number sets
Whilst not explicitly mentioned in the syllabus, at the Extension 2 level you should still be aware of the basic number sets are. (For example, integers, rational numbers, real numbers, complex numbers.) These number sets are written in weird capital letters that turn out to be a part of the "math blackboard bold" family. Any letters put in the $\texttt{\mathbb{}}$ command will be converted into a math blackboard bold text.

For example, to access the set of real numbers, $\texttt{\mathbb{R}}$ will give you $\mathbb{R}$.

University students may like to investigate other font families as well, such as math calligraphy.

Styling the $\LaTeX$ further
It doesn't really makes sense to introduce the remaining in-my-opinion useful annotations without introducing all of the maths stuff first, Now that that's over, we can get into it.

Aligning
In the real world when we're writing equations, we usually try to keep all of our directive symbols all down one line (equal signs, inequalities, implication arrows etc.) One big nifty thing about $\LaTeX$ (and also why I prefer it over Microsoft Word) is that this lining up of symbols is essentially all catered for you! The align and align* environments are what's capable of handling this.

These environments use the ampersand and newline characters in the same way as the earlier ones. The usual convention is to put the equal sign (or whatever symbol you're using) immediately after the ampersand, to split up the "columns". (Note that the columns are literally just the LHS and RHS.)

Note that on the forums, the align and align* environments are essentially identical, so you can use either. But in actual $\LaTeX$, the former will say (1), (2), (3) for each row within your align environment (see - tagging).
Code: [Select]
\begin{align*}x^2 &= 1\\ \implies x &= \pm 1 \end{align*}\begin{align*}x^2 &= 1\\ \implies x &= \pm 1 \end{align*}
Note that in the full package there's an environment called alignat. This one is more flexible in that it somewhat handles multi-column alignment, whereas the standard one only really deals with two columns (stuff before the equal signs, and everything else).

Boxes
Boxes are essentially an alternative to colours to provide emphasis on certain things in your $\LaTeX$. They can help you emphasise an equation or just some remark that you've made. All you need to do is use $\texttt{\boxed{TEXT HERE}}$.
Code: [Select]
$\text{Note that }\boxed{\cos^{2}x + \sin^{2}x = 1}$$\text{Note that }\boxed{\cos^2{x} + \sin^{2}x = 1}$
Take careful note that boxes are much harder to use in environments. The ampersands used in the environments will mess up if you put it inside a box.

Tagging
Tags are essentially text annotations that appear to the right of a bunch of $\LaTeX$ output. They work well with the align environment as they let you make obvious things such as simultaneous equations. However, they can also be used for annotations in general.

When used in the align environment, the tag must be put in the same line you wish for it to be. (Remember that new-line characters split things up.)
Code: [Select]
\begin{align*} a+b &= 4 \tag{1} \\ 2a+3b &= 9 \tag{2}\\ \therefore b &= 1 \end{align*}\begin{align*} a+b &= 4 \tag{1} \\ 2a+3b &= 9 \tag{2}\\ \therefore b &= 1 \end{align*}
When used outside of the align environment they can be weirder. Sometimes the tag doesn't go where it should go, so it's up to you if you want to still use it.
Code: [Select]
$\text{Line 1}\\ \text{Line 2}\\ \text{Line 3} \tag{Tag for line (3)?}$$\text{Line 1}\\ \text{Line 2}\\ \text{Line 3} \tag{Tag for line (3)?}$
Note that the full $\LaTeX$ package actually lets you put math equations in the tag, but this is too hard on the forums due to the limitations of MathJax.

Over/Under brace
Horizontal braces can provide for a different way of annotating your $\LaTeX$. These are perhaps better when you want to annotate only specific parts of your equation. This example is over-stylised but essentially illustrates how $\texttt{\overbrace{}^{}}$ and $\texttt{\underbrace{}_{}}$ are used - the first pair of brackets are used to determine what the brace should go over.
Code: [Select]
$\underbrace{\int_{-5}^{5}\sqrt{25-x^2}dx}_{\text{area of a semicircle with radius 5}} +\overbrace{\int_{-5}^{5}x\sqrt{1-\frac{x^2}{25}}dx}^{\text{integral of an odd function}}=\frac{25\pi}{2}-0$$\underbrace{\int_{-5}^{5}\sqrt{25-x^2}dx}_{\text{area of a semicircle with radius 5}} +\overbrace{\int_{-5}^{5}x\sqrt{1-\frac{x^2}{25}}dx}^{\text{integral of an odd function}} = \frac{25\pi}{2}-0$
(Note that the code for this one appears to go on multiple lines. This is just because this particular one is too long to put in the CODE BBC tags. The actual output is only possible without any enter keys in the code.)

Some of the earlier things such as resizing and colouring also fall under the umbrella of styling.

Experienced $\LaTeX$ usage
Some of the code in the above examples is just arduous. Code takes long enough to type up, so once you're good at $\LaTeX$ and cautious enough with your bugs you can try speeding things up. I certainly do not advise this for new $\LaTeX$ users unless you just so happen to have a strong programming background.

Overcoming the inline/display modes
By default, the parentheses set up an inline mode whilst the square brackets initialise the display mode. However if you want to force "display mode" formatting into inline $\LaTeX$, or for some interesting reason vice versa, there is a way of going about it. To force it into the display mode, just type $\texttt{\displaystyle}$ at the start of your inline LaTeX, or type $\texttt{\textstyle}$ for forcing inline mode in display LaTeX.

Note, however, if you use newlines in your code, the formatting only lasts for that line as shown in this example.
Code: [Select]
$\textstyle \int \frac{4x}{3}\,dx \\ \int \frac{4x}{3}\,dx$$\textstyle \int \frac{4x}{3}\,dx \\ \int \frac{4x}{3}\,dx$

Straight into environments
Quite conveniently, the $\TeX$ has been coded so that an environment doesn't have to be put in the backslash-parentheses/square brackets to be started! Below is a short example of just going straight into the align* environment.
Code: [Select]
\begin{align*}(x-3)(x-4) &= x^2 - 3x - 4x + 12\\ &= x^2 - 7x + 12\end{align*}\begin{align*}(x-3)(x-4) &= x^2 - 3x - 4x + 12\\ &= x^2 - 7x + 12\end{align*}
But of course, as you've seen in the examples above, it certainly can be put in those brackets.

Ditching braces for single characters
Of course, if you do something like $\texttt{e^2x}$, the $x$ just goes floating out in thin air like this: $e^2x$. However if you only wanted to type something like $e^x$, you can just be lazy and ignore the brace! The idea is that the braces are there to keep multiple characters bundled up together into one thing. But if you want just one character there, it really makes no difference. This is an example of a much lazier code but still does what it needs to do.
Code: [Select]
$\int_0^1 x\,dx = \frac12$$\int_0^1 x\,dx = \frac12$
(Note that with $\texttt{\frac{}{}}$ and things that have two arguments in general, the first character afterwards goes in the first brace (and hence the numerator), whilst the second goes into the second brace (and hence the denominator).)

This can be hard to use. For example, if you wanted to type $\frac{x}{y}$, doing $\texttt{\fracxy}$ won't work! This is because "fracxy" will get treated as just one big word - $\LaTeX$ doesn't know how to chop up the frac from the xy! One way to overcome this here is to type "\frac xy" instead, but it is for reasons like this why I don't always encourage this lazy coding at the start - it makes your code messy to debug.

Rarely using spaces
Yet on the other side, if you're really good at coding $\LaTeX$ you will minimise the amount of spaces you use. The previous example can be recoded like this:
Code: [Select]
$\int_0^1x\,dx=\frac12$and it will produce the same output.

But again, you gotta know what you're doing! You can't always ditch the spaces - at times it is just inevitable. But whilst one less keystroke might not seem like much, if you can avoid a lot of spaces it does start to build up.

(A note to programmers: I personally think coding style is heaps less important for $\LaTeX$. Few people actually care about your TeX file/code - only the output, and in the event someone does care it shouldn't be hard for them to figure out what's going on. This is why I'm not really fussed about "gibberish code" to some extent - as long as the output is fine, and the abuse of functionality isn't that significant, it's all good.)
« Last Edit: June 28, 2019, 05:59:02 pm by RuiAce »

#### RuiAce

• ATAR Notes Lecturer
• Honorary Moderator
• Great Wonder of ATAR Notes
• Posts: 8786
• "All models are wrong, but some are useful."
• Respect: +2561
##### Re: $\TeX$ guide V2.0
« Reply #1 on: December 13, 2018, 02:25:16 pm »
+8
Dropping a timestamp - this guide should be complete. Lmk if there's anything else you'd like to see on here. (I tried to make sure I covered every cornerstone of the new syllabus but I may have forgotten stuff.)

There are a few things I've intentionally not included in the former guide. This is because this guide is more or less optimised for HSC purposes and usage on the forum (even though some comments are made to tertiary level students). If you want to enquire about something else I'll probably just answer it in the comments.

#### Springyboy

• Victorian
• Forum Obsessive
• Posts: 249
• Respect: +64
##### Re: $\TeX$ guide V2.0
« Reply #2 on: December 13, 2018, 03:04:42 pm »
+3
Dropping a timestamp - this guide should be complete. Lmk if there's anything else you'd like to see on here. (I tried to make sure I covered every cornerstone of the new syllabus but I may have forgotten stuff.)

There are a few things I've intentionally not included in the former guide. This is because this guide is more or less optimised for HSC purposes and usage on the forum (even though some comments are made to tertiary level students). If you want to enquire about something else I'll probably just answer it in the comments.

Rui this guide is amazing - I'm sure I will use it to post questions about the pure actuarial units that I do next year so it's much clearer to read. Thanks for posting this guide so we can all have a concise guide to refer to rather than having to scour the Internet for LaTex help

#### AlphaZero

• MOTM: DEC 18
• Forum Obsessive
• Posts: 350
• $\Gamma(z)\Gamma(1-z)=\frac{\pi}{\sin(\pi z)}$
• Respect: +157
##### Re: $\TeX$ guide V2.0
« Reply #3 on: December 13, 2018, 03:18:29 pm »
+6
Love the guide Rui!

Just a small note on quotation marks though. One should use  to open quotes and ' to close quotes.

$\TeX$ doesn't support using the same symbol/command for two different outputs.

For example,
Code: [Select]
$\text{"This is some text"}$ produces $\text{"This is some text"}$, but

Code: [Select]
$\text{This is some text"}$ produces $\text{This is some text"}$.

Also note that  should be placed outside the text environment.
2015$-$2017:  VCE
2018$-$2021:  Bachelor of Biomedicine and Mathematical Sciences Diploma, University of Melbourne

#### RuiAce

• ATAR Notes Lecturer
• Honorary Moderator
• Great Wonder of ATAR Notes
• Posts: 8786
• "All models are wrong, but some are useful."
• Respect: +2561
##### Re: $\TeX$ guide V2.0
« Reply #4 on: December 13, 2018, 09:05:22 pm »
+2
Love the guide Rui!

Just a small note on quotation marks though. One should use  to open quotes and ' to close quotes.

$\TeX$ doesn't support using the same symbol/command for two different outputs.

For example,
Code: [Select]
$\text{"This is some text"}$ produces $\text{"This is some text"}$, but

Code: [Select]
$\text{This is some text"}$ produces $\text{This is some text"}$.

Also note that  should be placed outside the text environment.
That hard coding hurts so much wow. I did notice that LaTeX runs into issues with quotation marks but that fix leaves me speechless