Help:TeX markup

From testwiki
Revision as of 08:42, 25 January 2007 by 128.12.181.238 (talk) (attempting to fix geometric)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Wikibooks uses TeX markup for mathematical formulas. It generates either PNG images or simple HTML markup, depending on user prefs and the complexity of the expression. In the future, as more browsers are smarter, it will be able to generate enhanced HTML or even MathML in many cases.

Math markup goes in between the corresponding inequality signs, where the ellipse are <math> ... </math>. Line breaks within these tags are fine, and aren't rendered. They're a good idea to keep the raw markup clear (for instance, a line break after each term or row of a matrix).

Discussion, bug reports and feature requests should go to the Wikitech-l mailing list or to Wikibooks:TeX requests.

For style issues regarding the typesetting of math, see the mathematics WikiProject. In particular, please avoid using this feature as part of a line of regular text, as the formulas don't align properly and the font is too large.

Regarding color, notice that this page is a special page (its name begins with "Wikibooks:") and has therefore a yellow background. Normal Wikibooks pages are white, just like the formulas, so don't worry. (this isn't true yet...)

Note: Math formulas using <math> ... </math> having special characters (with a \ at the start) in them are displayed in a larger font than math formulas without special characters in them. Because of this, multi-equation mathematical discussions could have an inconsistent mixture of large font and small font equations. In order to keep the font size consistent, one can put at least one special character in every equation, even if a special character is not needed otherwise, so that all the equations will be shown in the larger font. To do this with an equation that otherwise doesn't need a special character, insert   \,   right before </math>.    \, (backslash, comma) stands for a small space, which can be placed at the end of an equation with no visible effect except to enlarge the font size.

Special characters

Feature Syntax How it looks rendered
std. functions (good) \sin x + \ln y +\operatorname{sgn} z sinx+lny+sgnz
std. functions (wrong) sin x + ln y + sgn z sinx+lny+sgnz
Derivatives \nabla \partial dx dx
Sets \forall x\not\in\empty\subseteq A\cap B\cup \exists \{x,y\}

\times C

x∉AB{x,y}×C
Logic p\wedge \bar{q} \rightarrow p\vee \bar{q} \Rightarrow \Leftrightarrow pq¯pq¯
Root \sqrt{2}\approx 1.4 21.4
\sqrt[n]{x} xn
Relations \sim \simeq \cong \le \ge \equiv \approx \ne        
Geometric \angle \perp \[pipe]
Special \oplus \otimes \pm \mp \hbar \dagger \ddagger \star \circ \cdot

\bullet \infty

± 

Subscripts, superscripts

Feature Syntax How it looks rendered
Superscript a^2 a2
Subscript a_2 a2
Accent \dot{x}, \ddot{x}, \hat{x}, \bar{x}, \vec{x}, \tilde{x} x˙,x¨,x^,x¯,x,x~
Grouping a^{2+2} a2+2
a_{i,j} ai,j
Combining sub & super x_2^3 x23
Derivative (good) x' x
Derivative (wrong in HTML) x^\prime x
Derivative (wrong in PNG) x\prime x
Sum \sum_{k=1}^N k^2 k=1Nk2
Product \prod_{i=1}^N x_i i=1Nxi
Limit \lim_{n \to \infty}x_n limnxn
Integral \int_{-N}^{N} e^x\, dx NNexdx
Line Integral \oint_{C} x^3\, dx + 4y^2\, dy Cx3dx+4y2dy

Fractions, matrices, multilines

Feature Syntax How it looks rendered
Fractions \frac{2}{4} or {2 \over 4} 24
Binomial coefficients {n \choose k} (nk)
Matrices \begin{pmatrix} x & y \\ z & v \end{pmatrix} (xyzv)
\begin{bmatrix} 0 & \cdots & 0 \\ \vdots &

\ddots & \vdots \\ 0 & \cdots & 0\end{bmatrix}

[0000]
\begin{Bmatrix} x & y \\ z & v \end{Bmatrix} {xyzv}
\begin{vmatrix} x & y \\ z & v \end{vmatrix} |xyzv|
\begin{Vmatrix} x & y \\ z & v \end{Vmatrix} xyzv
\begin{matrix} x & y \\ z & v \end{matrix} xyzv
Case distinctions f(n)=\left\{\begin{matrix} n/2, & \mbox{if }n\mbox{ is

even} \\ 3n+1, & \mbox{if }n\mbox{ is odd} \end{matrix}\right.

f(n)={n/2,if n is even3n+1,if n is odd
Multiline equations \begin{matrix}f(n+1)&=& (n+1)^2 \\ \ &

=& n^2 + 2n + 1\end{matrix}

f(n+1)=(n+1)2 =n2+2n+1

Fonts

Feature Syntax How it looks rendered
Greek letters \alpha \beta \gamma \Gamma \phi \Phi \Psi\ \tau \Omega α β γ Γ ϕ Φ Ψ τ Ω
Blackboard bold x\in\mathbb{R}\sub\mathbb{C} x
boldface (vectors) \mathbf{x}\cdot\mathbf{y} = 0 𝐱𝐲=0
boldface (greek) \boldsymbol{\alpha}+\boldsymbol{\beta}+\boldsymbol{\gamma} α+β+γ
Fraktur typeface \mathfrak{a} \mathfrak{B} 𝔞𝔅
Script \mathcal{ABC} 𝒜𝒞
Hebrew \aleph \beth \gimel \daleth    
non-italicised characters \mbox{abc} abc

Parenthesizing big expressions

Feature Syntax How it looks rendered
Not good ( \frac{1}{2} ) (12)
Better \left( \frac{1}{2} \right) (12)

You can use various delimiters with \left and \right:

Feature Syntax How it looks rendered
Parentheses \left( A \right) (A)
Brackets \left[ A \right] [A]
Braces \left\{ A \right\} {A}
Angle brackets \left\langle A \right\rangle A
Bars A \right| |A|
Use \left. and \right. if you don't want a delimiter to

appear:

\left. {A \over B} \right\} \to X AB}X

Spacing

Note that TeX handles most spacing automatically, but you may sometimes want manual control.

Feature Syntax How it looks rendered
double quad space a \qquad b ab
quad space a \quad b ab
text space a\ b a b
large space a\;b ab
medium space a\>b [not supported]
small space a\,b ab
no space ab ab
negative space a\!b ab

See also:

it:Wikibooks:Formule matematiche TeX pt:Ajuda:Marcação TeX