Moderators: kiore, The_Metatron, Blip
gifcy wrote:Under the section ' A LATEX Tutorial, part 1 > accents' , the 'a' with vector symbol is not loading properly in Chrome. Its displayed as small box.
I'm using this in one of my applications and have the same issue. So how can we fix it? This issue is seen only with Chrome browser - ver 17.0.963.83 m. OS is Win XP.
Thanks,
Gifcy
orpheus wrote:I thought this thread was going to be about something else...
Pulsar wrote:This thread is meant as a small Latex manual to help the Equations thread and its discussion. In its current form the MathJax editor doesn't allow every standard Latex command, so I will also explore some workarounds and tricks.
To view any source code, right-click on the formula. Make sure that Settings, Math Renderer is set to HTML-CSS.
- Code: Select all
[latex]\textbf{A }\mathbf{\LaTeX\ }\textbf{Tutorial, part 1}[/latex]
Font styles
Latex's default font in mathematical equations is a form of italics. But different styles are available; for instance, if you want a normal upright character a, type \mathrm{a} (rm stands for Roman). The most common styles are the following:
- Code: Select all
[latex]\begin{align}
\text{(default)}\hspace{1cm} & ABCDEFGHIJKLMNOPQRSTUVWXYZ\\
& abcdefghijklmnopqrstuvwxyz\\
\backslash\text{mathrm}\hspace{1cm} & \mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\
& \mathrm{abcdefghijklmnopqrstuvwxyz}\\
\backslash\text{mathbf}\hspace{1cm} & \mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\
& \mathbf{abcdefghijklmnopqrstuvwxyz}\\
\backslash\text{mathcal}\hspace{1cm} & \mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\
\backslash\text{mathtt}\hspace{1cm} & \mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\
& \mathtt{abcdefghijklmnopqrstuvwxyz}\\
\backslash\text{mathbb}\hspace{1cm} & \mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\
\backslash\text{boldsymbol}\hspace{1cm} & \boldsymbol{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\
& \boldsymbol{abcdefghijklmnopqrstuvwxyz}
\end{align}[/latex]
Note that you need the command \boldsymbol{} to type a bold math symbol; \mathbf{} renders a bold upright character. If you want to include normal text inside an equation, use the \text{} command. Unfortunately, MathJax doesn't seem to like Latex commands inside the \text{} environment.
Spaces
There are various commands for horizontal spaces: a backslash follow by a blank space, \ , inserts a normal space. For smaller spaces, use one of these \, \; \: For larger, there is \quad and \qquad . For a space of any length, there's the \hspace{} command: just insert a unit between the brackets.
For instance, \hspace{1cm} will render a 1cm space. Other units are available as well, such as mm, in (inch), or pt (point).
There is also a command for a tiny negative space, to place two characters closer together: \!
And the \phantom{} commands provides a neat trick to insert a space with the length of the characters inside the brackets.
In standard Latex, a vertical line-break can be inserted by two backslashes: \\, and a line space of any length can be achieved by e.g. \\[1cm]. Unfortunately, MathJax is more limited: I only managed to get \\ to work inside a \begin{align}\end{align} environment (see below). In standard Latex, there's also the \vspace{} command, but that doesn't seem to work either. Here are a few examples:
- Code: Select all
[latex]\begin{align}
&ab \quad a\,b \quad a\;b \quad a\: b \quad a\ b \qquad a\!b \\
&a\hspace{34pt}b \qquad c\phantom{abc} d
\end{align}[/latex]
Accents
Here are a few common accents and over- and underlines:
- Code: Select all
[latex]a' \quad a'' \quad \dot{a} \quad \ddot{a} \quad \dddot{a} \quad \vec{a} \quad \hat{a} \quad \tilde{a}
\quad \widetilde{a} \quad \bar{a} \quad \overline{a} \quad \underline{a} \quad \overbrace{a} \quad \underbrace{a}[/latex]
Sub- and superscript
To add a subscript to a character, use an underscore _, or _{} if you want to add more than one subscript character. For superscript, use ^ or ^{}. If you want a standalone sub- or superscript (i.e. not preceded by a normal character), you have to precede _ or ^ by empty brackets; see the example for a hypergeometric function.
- Code: Select all
[latex]a_i \quad a_{ij} \quad M_\text{tot} \quad a^2 \quad a^{-3/2} \quad {}_2 F_1 \qquad {} 15^\circ 02'15''
\qquad 2\times 10^{15}\;\text{km}\,\text{s}^{-2}[/latex]
Note the \circ for degrees. It's also common practice to use upright text for units, like km and s in the last example.
To be continued...
Pulsar wrote:
- Code: Select all
[latex]\textbf{A }\mathbf{\LaTeX\ }\textbf{Tutorial, part 2}[/latex]
Greek letters
- Code: Select all
[latex]\begin{align}
& \alpha \beta \gamma \delta \epsilon \varepsilon \zeta \eta \theta
\vartheta \iota \kappa \varkappa \lambda \mu \nu \xi \omicron \pi \varpi \rho \varrho \sigma \varsigma \tau
\upsilon \phi \varphi \chi \psi \omega\\
& \Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega
\end{align}[/latex]
Miscellaneous symbols
- Code: Select all
[latex]\aleph \quad \hbar \quad \infty \quad \partial \quad \nabla \quad \Im \quad \Re \quad \forall \quad
\exists \quad \nexists \quad \emptyset \quad \varnothing \quad \square \quad \triangle \quad \triangledown \quad \prime \quad \backprime \quad \sphericalangle[/latex]
- Code: Select all
[latex]\& \quad \_ \quad \# \quad \$ \quad \%[/latex]
Standard function names
- Code: Select all
[latex]\begin{align}
&\sin \quad \cos \quad \tan \quad \exp \quad \lim \quad \min \quad \max \quad \sinh \quad \arcsin \quad\\
&\deg \quad \log \quad \ln \quad \sup \quad \inf \quad \arg \quad \cot \quad \det \quad \gcd \quad \mod
\end{align}[/latex]
And various others.
Binary symbols
- Code: Select all
[latex]\leq \quad \leqslant \quad \geq \quad \geqslant \quad \neq \quad \sim \quad
\simeq \quad \approx \quad \propto \quad \cong \quad \equiv \quad \ll \quad \gg \quad \perp[/latex]
- Code: Select all
[latex]\times \quad \div \quad \pm \quad \mp \quad \cdot \quad \ast \quad \star \quad
\odot \quad \oplus \quad \ominus \quad \otimes \quad \Box \quad \lhd \quad \rhd[/latex]
- Code: Select all
[latex]\wedge \quad \vee \quad \subset \quad \supset \quad \in \quad \ni \quad \notin \quad \cup
\quad \cap \quad \setminus \quad \backslash \quad \therefore \quad \because \quad \bullet \quad \diamond[/latex]
Dots
- Code: Select all
[latex]1,2,\ldots,10 \qquad
a_1 + a_2 + \cdots + a_n \qquad
\vdots \qquad \ddots[/latex]
Pulsar wrote:
- Code: Select all
[latex]\textbf{A }\mathbf{\LaTeX\ }\textbf{Tutorial, part 3}[/latex]
Arrows
- Code: Select all
[latex]\begin{align}
&\leftarrow \quad \longleftarrow \quad \Leftarrow \quad \Longleftarrow \quad
\rightarrow \quad \longrightarrow \quad \Rightarrow \quad \Longrightarrow \quad
\overleftarrow{abc} \quad \overrightarrow{abc} \\
&\leftrightarrow \quad \longleftrightarrow \quad \Leftrightarrow \quad \Longleftrightarrow \quad
\leftrightarrows \quad \leftleftarrows \quad \rightrightarrows \quad
\uparrow \quad \Uparrow \quad \downarrow \quad \Downarrow \quad \updownarrow \quad \Updownarrow
\end{align}[/latex]
If you want an arrow with additional text, use \xleftarrow or \xrightarrow. Be aware of the precise format: text below is placed between square brackets [] and can be omitted, while text above is placed between mandatory curly brackets {}.
- Code: Select all
[latex]\xrightarrow{\text{above the arrow}} \qquad
\xleftarrow[\text{below}]{}\qquad
\xrightarrow[\text{below}]{\text{above the arrow}}[/latex]
In combination with the \lim operator, you can write something like this:
- Code: Select all
[latex]\lim_{x \rightarrow +\infty} f(x) = 0[/latex]
This doesn't look very pretty, but it can be tidied up by enclosing the equation by a \displaystyle{} environment:
- Code: Select all
[latex]\displaystyle{
\lim_{x \rightarrow +\infty} f(x) = 0}[/latex]
Various operators
Again, use \displaystyle{} for nice results:
- Code: Select all
[latex]\displaystyle{
\sum \quad \sum_{i=1}^{n} \quad \sum_{\substack{i,j \\ i > j}} \quad \prod \quad \prod_{n=0}^{\infty} \quad \coprod
\quad \int \quad \int_0^1 \quad \oint \quad \iint \quad \iiint \quad \sqrt{x} \quad \sqrt[3]{26}
}[/latex]
Note the \substack{} command in the third sum, to stack multiple limits. Fractions and binomials looks as follows, without and with \displaystyle{}:
- Code: Select all
[latex]\frac{1}{2} \quad \binom{n}{k}
\qquad
\displaystyle{\frac{1}{2} \quad \binom{n}{k}}[/latex]
Brackets
- Code: Select all
[latex]\displaystyle{
() \quad [] \quad \{ \} \quad | \quad \langle \rangle \quad \lfloor \rfloor \quad \lceil \rceil \quad \Vert
}[/latex]
Note the backslash in \{ and \} to produce curly brackets. The size of these delimiters can be increased manually by preceding them with \big, \Big, \bigg or \Bigg. You can also let Latex determine an appropriate size, by using \left and \right. However, every \left delimiter has to be followed by a similar \right delimiter; in case you want only one delimiter, use a dot for the other, i.e. \left. or \right. to generate an empty delimiter. See the examples:
- Code: Select all
[latex]\displaystyle{\Bigg( \bigg( \Big( \big( () \big) \Big) \bigg) \Bigg)
\qquad \left(\frac{a}{b}\right) \qquad \left[\frac{A}{B} + \left( C + \sqrt{D}\right) \right]
\qquad \left\langle\left. \psi_1 \right. \right|}[/latex]
The \underbrace{} and \overbrace{} commands produce
- Code: Select all
[latex]\underbrace{\underbrace{a + b}_\text{brace 1} +\overbrace{c + d}^\text{brace 2}}_\text{brace 3}= e[/latex]
Pulsar wrote:
- Code: Select all
[latex]\textbf{A }\mathbf{\LaTeX\ }\textbf{Tutorial, part 4}[/latex]
Equations
I've used the \begin{align} \end{align} environment several times already, without discussing its use: with align, you can type multiple, aligned equations. The ampersand & serves as a tab stop; usually, you want the lines to be aligned on the equation sign:
- Code: Select all
[latex]\begin{align}
\binom{5}{3} &= \frac{5!}{2!\; 3!}\\
&= \frac{5\cdot 4 \cdot 3 \cdot 2}{3 \cdot 2 \cdot 2}\\
&= 10
\end{align}[/latex]
You can also align two sets of equation side by side, as follows:
- Code: Select all
[latex]\begin{align}
y & =d & z & =1\\
y & =cx+d & z & =x+1
\end{align}[/latex]
If you want even more, use the alignat environment. It has a parameter denoting the amount of aligned columns. Here's an example with three:
- Code: Select all
[latex]\begin{alignat}{3}
i_{11} & =0.25 & i_{12} & =i_{21} & i_{13} & =i_{23}\\
i_{21} & =-i_{11} & i_{22} & =0.5\,i_{12}& i_{23} & =i_{31}\\
i_{31} & =0.33\,i_{22}\qquad & i_{32} & =0.15\,i_{32}\qquad & i_{33} & =i_{11}
\end{alignat}[/latex]
Alternatively, you can centre equations rather than align them. To do this, use the gather environment.
NOTE: I couldn't get the original code to generate an image.
Original code:
- Code: Select all
[latex]\begin{gather}\displaystyle{
\Gamma(x) = \int_0^{+\infty} t^{x-1} \, \text{e}^{-t} \, \text{d}t\\
B(x,y) = \int_0^1 t^{x-1}\,(1-t)^{y-1}\,\text{d}t}
\end{gather}[/latex]
So I switched the way the gather and displaystyle were nested with respect to one another.
- Code: Select all
\begin{gather}\displaystyle{
\Gamma(x) = \int_0^{+\infty} t^{x-1} \, \text{e}^{-t} \, \text{d}t\\
B(x,y) = \int_0^1 t^{x-1}\,(1-t)^{y-1}\,\text{d}t}
\end{gather}
Long equations can be split with the multline environment. In the example below, you see that the \left( bracket has to be followed by a \right. (an invisible right bracket) at the end of the first line, otherwise Latex will raise an error. Likewise, the second line starts with \left. (an invisible left bracket) and ends with \right).
However, to ensure that the closing \right) is as big as the opening \left( , we need another trick: the command \vphantom{} inserts an invisible vertical space, given by the text inside the brackets - analogous to the horizontal \phantom{}. On the first line, the summation \sum_{i<j} is the largest symbol, so \vphantom{\sum_{i<j}} inserts an equally large, but invisible symbol on the second line, which guarantees that \left( and \right) are of the same size.
I had a similar problem with the original code.
- Code: Select all
[latex]\displaystyle{
\begin{multline}
\frac{1}{2}\Delta(f_{ij}f^{ij}) = 2\left( \sum_{i<j}\chi_{ij}(\sigma_{i} -
\sigma_{j})^{2} + f^{ij}\nabla_{j}\nabla_{i} (\Delta f) + \right.\\
\left. + \nabla_{k}f_{ij}\nabla^{k}f^{ij} + f^{ij}f^{k}\left[2\nabla_{i}R_{jk} -
\nabla_{k}R_{ij}\right] \vphantom{\sum_{i<j}}\right)
\end{multline}}[/latex]
So I reversed the nesting order of multline and displaystyle
- Code: Select all
[latex]
\begin{multline}\displaystyle{
\frac{1}{2}\Delta(f_{ij}f^{ij}) = 2\left( \sum_{i<j}\chi_{ij}(\sigma_{i} -
\sigma_{j})^{2} + f^{ij}\nabla_{j}\nabla_{i} (\Delta f) + \right.\\
\left. + \nabla_{k}f_{ij}\nabla^{k}f^{ij} + f^{ij}f^{k}\left[2\nabla_{i}R_{jk} -
\nabla_{k}R_{ij}\right] \vphantom{\sum_{i<j}}\right)
}\end{multline}[/latex]
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]
Pulsar wrote:
- Code: Select all
[latex]\textbf{A }\mathbf{\LaTeX\ }\textbf{Tutorial, part 6}[/latex]
Colors
MathJax allows different colors, with the command \color{color}{text} (this syntax is different from standard Latex). I don't know which colors are permitted, but all of these work, and probably more:
- Code: Select all
[latex]\color{red}{b} \color{darkred}{b} \color{pink}{b} \color{blue}{b} \color{lightblue}{b} \color{green}{b} \color{darkgreen}{b} \color{yellow}{b} \color{orange}{b} \color{cyan}{b} \color{magenta}{b} \color{violet}{b} \color{purple}{b} \color{brown}{b} \color{white}{b} \color{grey}{b} \color{black}{b}[/latex]
NOTE: Some of colors didn't render.
Arrays
The \begin{array}{} \end{array} environment is very useful to create content in several rows and columns. Each column can be left-, right- or center- aligned, which has to be specified with l,r,c respectively inside the brackets following \begin{array}. For example, \begin{array}{l r c} starts an array with three columns; column 1 is left-aligned, column 2 is right-aligned and column 3 is center-aligned. Columns are separated with the ampersand & symbol, and a row is ended by a linebreak \\. Two common examples are
- Code: Select all
[latex]f(n) = \left\{
\begin{array}{l l}
n/2 & \quad \mbox{if $n$ is even}\\
-(n+1)/2 & \quad \mbox{if $n$ is odd}
\end{array}
\right.[/latex]
and matrices
- Code: Select all
[latex]A_{m,n} =
\left(
\begin{array}{cccc}
a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m,1} & a_{m,2} & \cdots & a_{m,n}
\end{array}
\right)[/latex]
In fact, these examples are so common that Latex contains special commands for them: the first example can be written with the \begin{cases} \end{cases} environment, which also takes care of the initial left bracket (and notice that the lines are slightly closer to each other). No column format specification is needed: cases always defines two left-aligned columns.
- Code: Select all
[latex]f(n) =
\begin{cases}
n/2 & \quad \mbox{if $n$ is even}\\
-(n+1)/2 & \quad \mbox{if $n$ is odd}
\end{cases}[/latex]
Matrices can be defined with the \begin{pmatrix} \end{pmatrix} environment, which includes the parentheses, and defines every column as center-aligned:
- Code: Select all
[latex]A_{m,n} = \begin{pmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\ a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m,1} & a_{m,2} & \cdots & a_{m,n} \end{pmatrix}[/latex]
Apart from pmatrix, there are also matrix, bmatrix, vmatrix, Bmatrix, Vmatrix, and smallmatrix.
- Code: Select all
[latex]\begin{matrix} a & b \\ c & d \end{matrix}\qquad
\begin{bmatrix} a & b \\ c & d \end{bmatrix}\qquad
\begin{vmatrix} a & b \\ c & d \end{vmatrix}\qquad
\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}\qquad
\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}\qquad
\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}[/latex]
With the array environment, one can simulate multi-line text:
- Code: Select all
[latex]\begin{array}{r}
\text{Right-aligned}\\
\text{text, nothing}\\
\text{really important}
\end{array}
\quad \textit{and} \quad
\begin{array}{c}
\text{Center-aligned}\\
\text{text, nothing}\\
\text{really important}
\end{array}
\quad \textbf{and} \quad
\begin{array}{l}
\text{Left-aligned}\\
\text{text, nothing}\\
\text{really important}
\end{array}[/latex]
This example also contains the \textit{} and \textbf{} commands, to write italics and bold text.
Finally, the array environment can serve to create a simple table. One can add vertical lines by adding | symbols in the column format header, and horizontal lines with the \hline command inside the array.
- Code: Select all
[latex]\begin{array}{|c|r|}
\text{symbol} & \quad\text{value} \\
\hline
\pi & 3.1415 \\
e & 2.7182
\end{array}[/latex]
-------------------------------------------------------------------------
I think I have now covered most of the Latex formatting that is currently possible with MathJax.
A full overview of Latex commands supported by MathJax can be found here:
http://www.mathjax.org/docs/1.1/tex.html#supported-latex-commands
If you have any comments, questions or additions, feel free to post!
chango369 wrote:Muhuhuhuhahahahahaaaaaaaaa! I saw some of the frustration on threads asking for the math tag back. So I used Thwoth's excellent suggestion and circumvented the problem, at least as far as this part of Pulsar's Latex Tutorial goes.Pulsar wrote:This thread is meant as a small Latex manual to help the Equations thread and its discussion. In its current form the MathJax editor doesn't allow every standard Latex command, so I will also explore some workarounds and tricks.
To view any source code, right-click on the formula. Make sure that Settings, Math Renderer is set to HTML-CSS.
- Code: Select all
[latex]\textbf{A }\mathbf{\LaTeX\ }\textbf{Tutorial, part 1}[/latex]
Font styles
Latex's default font in mathematical equations is a form of italics. But different styles are available; for instance, if you want a normal upright character a, type \mathrm{a} (rm stands for Roman). The most common styles are the following:
- Code: Select all
[latex]\begin{align}
\text{(default)}\hspace{1cm} & ABCDEFGHIJKLMNOPQRSTUVWXYZ\\
& abcdefghijklmnopqrstuvwxyz\\
\backslash\text{mathrm}\hspace{1cm} & \mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\
& \mathrm{abcdefghijklmnopqrstuvwxyz}\\
\backslash\text{mathbf}\hspace{1cm} & \mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\
& \mathbf{abcdefghijklmnopqrstuvwxyz}\\
\backslash\text{mathcal}\hspace{1cm} & \mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\
\backslash\text{mathtt}\hspace{1cm} & \mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\
& \mathtt{abcdefghijklmnopqrstuvwxyz}\\
\backslash\text{mathbb}\hspace{1cm} & \mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\
\backslash\text{boldsymbol}\hspace{1cm} & \boldsymbol{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\
& \boldsymbol{abcdefghijklmnopqrstuvwxyz}
\end{align}[/latex]
Note that you need the command \boldsymbol{} to type a bold math symbol; \mathbf{} renders a bold upright character. If you want to include normal text inside an equation, use the \text{} command. Unfortunately, MathJax doesn't seem to like Latex commands inside the \text{} environment.
Spaces
There are various commands for horizontal spaces: a backslash follow by a blank space, \ , inserts a normal space. For smaller spaces, use one of these \, \; \: For larger, there is \quad and \qquad . For a space of any length, there's the \hspace{} command: just insert a unit between the brackets.
For instance, \hspace{1cm} will render a 1cm space. Other units are available as well, such as mm, in (inch), or pt (point).
There is also a command for a tiny negative space, to place two characters closer together: \!
And the \phantom{} commands provides a neat trick to insert a space with the length of the characters inside the brackets.
In standard Latex, a vertical line-break can be inserted by two backslashes: \\, and a line space of any length can be achieved by e.g. \\[1cm]. Unfortunately, MathJax is more limited: I only managed to get \\ to work inside a \begin{align}\end{align} environment (see below). In standard Latex, there's also the \vspace{} command, but that doesn't seem to work either. Here are a few examples:
- Code: Select all
[latex]\begin{align}
&ab \quad a\,b \quad a\;b \quad a\: b \quad a\ b \qquad a\!b \\
&a\hspace{34pt}b \qquad c\phantom{abc} d
\end{align}[/latex]
Accents
Here are a few common accents and over- and underlines:
- Code: Select all
[latex]a' \quad a'' \quad \dot{a} \quad \ddot{a} \quad \dddot{a} \quad \vec{a} \quad \hat{a} \quad \tilde{a}
\quad \widetilde{a} \quad \bar{a} \quad \overline{a} \quad \underline{a} \quad \overbrace{a} \quad \underbrace{a}[/latex]
Sub- and superscript
To add a subscript to a character, use an underscore _, or _{} if you want to add more than one subscript character. For superscript, use ^ or ^{}. If you want a standalone sub- or superscript (i.e. not preceded by a normal character), you have to precede _ or ^ by empty brackets; see the example for a hypergeometric function.
- Code: Select all
[latex]a_i \quad a_{ij} \quad M_\text{tot} \quad a^2 \quad a^{-3/2} \quad {}_2 F_1 \qquad {} 15^\circ 02'15''
\qquad 2\times 10^{15}\;\text{km}\,\text{s}^{-2}[/latex]
Note the \circ for degrees. It's also common practice to use upright text for units, like km and s in the last example.
To be continued...
Return to General Science & Technology
Users viewing this topic: No registered users and 1 guest