Posted: Jun 27, 2015 8:46 pm
Pulsar's Latex Tutorial Part 5 - reboot
Pulsar wrote:
- Code: Select all
[latex]\textbf{A }\mathbf{\LaTeX\ }\textbf{Tutorial, part 5}[/latex]
Math styles
Symbols can be displayed in one the following styles: \displaystyle{} (for standalone equations), \textstyle{} (for equations in a sentence), \scriptstyle{} (for e.g. sub- and superscripts), and \scriptscriptstyle{} (for e.g. subsub- and supersuperscripts). Latex scales sub- and superscripts automatically, but occasionally the explicit commands \scriptstyle{} and \scriptscriptstyle{} are handy in other situations.
- Code: Select all
[latex]\displaystyle{\int_0^1 f}\qquad \textstyle{\int_0^1 f} \qquad
\scriptstyle{aA} \qquad \scriptscriptstyle{aA}[/latex]
Text and Symbol size
The above styles define relative symbol sizes, which depend on the environment in which they are used. Latex also allows to manually change text font sizes, with the \tiny{}, \scriptsize{}, \small{}, \normalsize{}, \large{}, \Large{}, \LARGE{}, \huge{}, and \Huge{} commands. Surprisingly, MathJax also allows the use of these commands inside formulae.
- Code: Select all
[latex]\tiny{a}\scriptsize{a}\small{a}\normalsize{a}\large{a}\Large{a}\LARGE{a}\huge{a}\Huge{a}[/latex]
Text boxes
Normal text can be written inside \text{}. Alternatively, there is the \mbox{} environment, which is almost the same as \text{}. However, unlike the \text{} command, text inside an \mbox{} does not scale when it is part of a sub- or superscript. Math symbols can be used inside a box by putting it between $ signs; unfortunately MathJax doesn't seem to allow any commands inside a textbox.
- Code: Select all
[latex]\mbox{this works $\forall n \in \mathbb{N} \backslash \{ 0 \}$, I think}[/latex]
NOTE: I'm not sure the image below is being rendered correctly!
\fbox{} is similar to \mbox, but draws a frame around the text.
- Code: Select all
[latex]f_\text{sim} \qquad f_\mbox{sim} \qquad \fbox{text inside a frame}[/latex]
A more general command to draw frames is \boxed{}, which can be used around any formula.
- Code: Select all
[latex]\boxed{\displaystyle{ f(x) = \int \frac{\sin x}{x}\,\text{d}x} }[/latex]
Unfortunately, MathJax does not support more advanced text boxes, like \makebox{} and \parbox{}. This makes it difficult to write multi-line text; possible tricks are stacking text, or using arrays (see below)
Stacking symbols and text
There are various ways to stack two lines of symbols or text on top of each other. The \substack{} command was used before, but there's also the slightly different { \atop } command.
- Code: Select all
[latex]\text{stacking }\substack{a \\ b}\qquad {a \atop b}[/latex]
The size of the symbols is automatically decreased; to change these sizes to normal, put the symbols inside \displaystyle{}. With the \underset{}{} and \overset{}{} commands, you can put smaller-sized symbols or text below/above a normal line:[math]
A similar command is \stackrel{}{}, which puts normal-sized symbols/text on top of a normal line.
- Code: Select all
[latex]a \stackrel{\text{def}}{=} b[/latex]
\stackrel might help to define new symbols. For instance, MathJax does not support the Angstrom symbol, so we could create one as follows:
- Code: Select all
[latex]\text{an ugly }\stackrel{\scriptsize{\circ}}{\text{A}}\text{ symbol}[/latex]
This doesn't look very pretty. Fortunately, there's the \mathring{} command, which I forgot to mention among the accents:
- Code: Select all
[latex]\text{this is better: } $\mathring{\text{A}}$[/latex]
NOTE: Adding in \dot example
- Code: Select all
[latex]\text{this is better: } \dot{\text{A}}[/latex]
I've mentioned the fraction command \frac{}{} before, but the related \tfrac{}{} and \dfrac{}{} are also worth pointing out: they set the font size to small and normal, respectively:
- Code: Select all
[latex]\frac{a}{b} \qquad \tfrac{a}{b} \qquad \dfrac{a}{b} \qquad T^\frac{a}{b} \qquad T^\tfrac{a}{b} \qquad T^\dfrac{a}{b}[/latex]
- Code: Select all
[latex]\displaystyle{ \frac{a}{b} \qquad \tfrac{a}{b} \qquad \dfrac{a}{b} \qquad T^\frac{a}{b} \qquad T^\tfrac{a}{b} \qquad T^\dfrac{a}{b} }[/latex]