Tex:Syntax
lastmod 2024-03-07created 2021-11-0513 edits
Explanation and list of Tex syntax.
Operations
| Name | Syntax | Result |
| Multiplication | | \(\times\) |
| Division | | \(\div\) |
| Addition | | \(+\) |
| Subtraction | | \(-\) |
| Dot product (dot) | | \(\cdot\) |
Special symbols
| Name | Syntax | Result |
| Root (square root; Root) | | \(\sqrt{2}\) |
| Radical with index | | \(\sqrt[3]{5}\) |
| Integral sign | | \(\int_{-\infty}^{\infty}{x}\) |
| Fraction | | \(\frac{1}{2}\) |
| Inline (horizontal) fraction | | \({1}/{2}\) |
| Subscript/superscript | | \(2_{5}^{10}\) |
| Sum (SIGMA) | | \(\sum_{n=0}^{10}\) |
| Product | | \(\prod{x}\) |
| Coproduct | | \(\coprod{x}\) |
| Union | | \(\bigcup{x}\) |
| Intersection | | \(\bigcap{x}\) |
| V | | \(\bigvee{x}\) |
| Wedge | | \(\bigwedge{x}\) |
Brackets
You can just write brackets as (), but then they won't scale to the size of the content inside them. To have them sized automatically, use \left( and \right). Example:
| Name | Syntax | Result |
| Plain | | \((\frac{x}{y})\) |
| Fitted | | \(\left(\frac{x}{y}\right)\) |
Bracket types:
| Name | Syntax | Result |
| Parentheses | | \(\left( x \right)\) |
| Braces | | \(\left\{ x \right\}\) |
| Square brackets | | \(\left[ x \right]\) |
| Angle brackets (chevrons) | | \(\left< x \right>\) |
| Absolute value | | \(\left| x \right|\) |
Accents
| Name | Syntax | Result |
| Dot | | \(\dot{x}\) |
| Double dot | | \(\ddot{x}\) |
| Triple dot | | \(\dddot{x}\) |
| Quadruple dot | | \(\ddddot{x}\) |
| Hat (hat) | | \(\hat{x}\) |
| Check (check) | | \(\check{x}\) |
Spacing
| Name | Syntax | Result |
| Double quad space | | \(a \qquad b\) |
| Quad space | | \(a \quad b\) |
| Space | | \(a\ b\) |
| Space | | \(a\;b\) |
| Space | | \(a\>b\) |
| Small space | | \(a\,b\) |
| Small space | | \(a\ b\) |
| No space | | \(ab\) |
| Negative space | | \(a\!b\) |
Shapes
| Name | Syntax | Result |
| Angle | | \(\angle\) |
| Triangle | | \(\triangle\) |
| Inverted triangle | | \(\nabla\) |
| Triangle left | | \(\triangleleft\) |
| Triangle right | | \(\triangleright\) |
| Square | | \(\square\) |
| Black square | | \(\blacksquare\) |
| Circle | | \(\circ\) |
| Degree | | \(^{\circ}\) |
| Big circle | | \(\bigcirc\) |
| Asterisk | | \(\ast\) |
| Star | | \(\star\) |
| Diamond | | \(\diamond\) |
| Spade | | \(\spadesuit\) |
| Club | | \(\clubsuit\) |
| Diamond | | \(\Diamond\) |
| Heart | | \(\heartsuit\) |
Greek letters
| Category | Uppercase | Lowercase |
| Name | Command | Output |
| Alpha | | \(A\) |
| Beta | | \(B\) |
| Gamma | | \(\Gamma\) |
| Delta | | \(\Delta\) |
| Epsilon | | \(E\) |
| Zeta | | \(Z\) |
| Eta | | \(H\) |
| Theta | | \(\Theta\) |
| Iota | | \(I\) |
| Kappa | | \(K\) |
| Lambda | | \(\Lambda\) |
| Mu | | \(M\) |
| Nu | | \(N\) |
| Xi | | \(\Xi\) |
| Omicron | | \(O\) |
| Pi | | \(\Pi\) |
| Rho | | \(P\) |
| Sigma | | \(\Sigma\) |
| Tau | | \(T\) |
| Upsilon | | \(\Upsilon\) |
| Phi | | \(\Phi\) |
| Chi | | \(X\) |
| Psi | | \(\Psi\) |
| Omega | | \(\Omega\) |
Relational operators
| Name | Command | Output |
| Congruence symbol | | \(\equiv\) |
| Approximately equal | | \(\approx\) |
| Proportional to | | \(\propto\) |
| simeq | | \(\simeq\) |
| Similar | | \(\sim\) |
| Not equal | | \(\neq\) |
| Less than or equal | | \(\leq\) |
| Greater than or equal | | \(\geq\) |
| Much greater than | | \(\gg\) |
| Much less than | | \(\ll\) |
Logic symbols
| Name | Command | Output |
| Bullet | | \(\bullet\) |
| Negation | | \(\neg\) |
| wedge | | \(\wedge\) |
| vee | | \(\vee\) |
| Logical OR | | \(\oplus\) |
| Left arrow | | \(\leftarrow\) |
| Right arrow | | \(\rightarrow\) |
| Left-right arrow | | \(\leftrightarrow\) |
| Left arrow | | \(\Leftarrow\) |
| Right arrow | | \(\Rightarrow\) |
| Left-right arrow | | \(\Leftrightarrow\) |
| There exists | | \(\exists\) |
| For all | | \(\forall\) |
Hats
| Name | Command | Output |
| Hat | | \(\hat{xyz}\) |
| Wide hat | | \(\widehat{x}\ \widehat{xyz}\) |
| Tilde hat | | \(\tilde{x}\ \tilde{xyz}\) |
| Wide tilde hat | | \(\widetilde{x}\ \widetilde{xyz}\) |
| acute | | \(\acute{x}\) |
| grave | | \(\grave{x}\) |
| Dot hat | | \(\dot{x}\) |
| Double dot hat | | \(\ddot{x}\) |
| Check hat | | \(\check{x}\) |
| breve | | \(\breve{x}\) |
| bar | | \(\bar{x}\ \bar{xyz}\) |
| overline | | \(\overline{x}\ \overline{xyz}\) |
| Arrow hat | | \(\vec{x} \vec{xyz}\) |
Set symbols
| Name | Command | Output |
| Intersection | | \(\cap\) |
| Union | | \(\cup\) |
| Superset | | \(\supset\) |
| Superset | | \(\subseteq\) |
| Proper superset | | \(\subsetneq\) |
| Subset | | \(\subset\) |
| Subset | | \(\subseteq\) |
| Proper subset | | \(\subsetneq\) |
| Not a subset | | \(\not\subset\) |
| Not a subset | | \(\nsubseteq\) |
| Empty set | | \(\emptyset\) |
| Set Z | | \(\mathbb{Z}\) |
| Element of | | \(\in\) |
| Not an element of | | \(\notin\) |
| Join | | \(\Join\) |
Vectors
| Name | Command | Output |
| vector | | \(\vec{a}\) |
Matrices
There are the following 5 ways to write matrices in TeX.
| Name | Command | Output |
| array | | \(\begin{array} a & b \\ c & d \end{array}\) |
| matrix | | \(\begin{matrix} a & b \\ c & d \end{matrix}\) |
| bmatrix | | \(\begin{bmatrix} a & b \\ c & d \end{bmatrix}\) |
| pmatrix | | \(\begin{pmatrix} a & b \\ c & d \end{pmatrix}\) |
| vmatrix | | \(\begin{vmatrix} a & b \\ c & d \end{vmatrix}\) |
| Vmatrix | | \(\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}\) |
Alignment
Mainly used when writing proofs of equations.
The result is as follows.
\[ \begin{align} f(x) &= (x + a)^2 \\ &= (x + a) (x + a) \\ &= x^2 + 2ax + a^2 \end{align} \]
Other
| Name | Command | Output |
| Center dot | | \(\cdot\) |
| Ellipsis | | \(\dots\) |
| Ellipsis | | \(\cdots\) |
| Ellipsis | | \(\ldots\) |
| Vertical ellipsis | | \(\vdots\) |
| Diagonal ellipsis | | \(\ddots\) |
| Division | | \(\div\) |
| Tilde | | \(\sim\) |
| Double tilde | | \(\approx\) |
| Plus-minus | | \(\pm\) |
| Minus-plus | | \(\mp\) |
| Prime | | \(\prime\) |
| Infinity | | \(\infty\) |
| Integral (integral sign) | | \(\int\) |
| Partial derivative | | \(\partial\) |
displaystyle
As shown below, the fraction looks small, as if squeezed to fit on one line...
\(y=y_{0}+(y_{1}-y_{0}){\frac {x-x_{0}}{x_{1}-x_{0}}}\)
If you use {\displaystyle ... },
\({\displaystyle y=y_{0}+(y_{1}-y_{0}){\frac {x-x_{0}}{x_{1}-x_{0}}}}\)
it adjusts to the line size and looks nicer.
Document begin and end
If you want a bracket on only one side
For the right side that pairs with the left \left\{, put a dot: \right..
\(\alpha(x) = \left\{ \begin{matrix} A & B \\ C & D \end{matrix} \right.\)
If you want alignment inside a matrix
Put it between \begin{matrix} \begin{align} and \end{align} \end{matrix}.
Alignment is based on &, so place it at the appropriate positions.
\(L \leftarrow \left\{ \begin{matrix} \begin{align} & 116*Y^{1/3}-16 & \textrm{for} Y>0.008856 \\ & 903.3*Y & \textrm{for} Y \le 0.008856 \end{align} \end{matrix} \right.\)
Inserting non-italic text
Use it like \textrm{for}.
\(\textrm{for} vs for\)
Adding tags
Use it like \tag{1}.
\(\begin{align} x^2 +y^2=r^2 \tag{1} \\ x\sin \theta +y\cos\theta =r^2 \tag{2} \end{align}\)
Line breaks
- \\ (backslash twice)
- \newline
- \break