LaTeX
  • How I learn LaTeX?
  • Installation and Customization
    • Online
    • Offline
  • LaTeX Basics
  • Text Manipulation
    • Fonts, Size and Styles
  • Math Manipulation
  • Advanced Math Manipulation
  • Lists
  • Tables
  • Pictures, Figures
  • Unit in LaTeX
  • Document Structure
  • Document Formatting
    • Headers and Footers, Page Numbering
    • Spacing in Paragraphs
    • Page size, Margins
    • Coloring
    • Footnotes
  • Multi-file LaTeX project
Powered by GitBook
On this page
  • Math mode
  • Inline math mode
  • Display math mode
  • Math Syntax in
  • Subscripts and Superscripts
  • Greek letters and Blackboard-bold letters
  • Brackets and Parentheses
  • Fractions and Binomials
  • Special functions
  • Calculus Notation
  • Sums and Products (Sigma notation and Pi notation)
  • Vectors

Math Manipulation

This is what LaTeX is famous for!

PreviousFonts, Size and StylesNextAdvanced Math Manipulation

Last updated 1 year ago

It's really easy to write basic equations in LaTeX\LaTeXLATE​X. Let's look at this example:

\begin{document}
Định lý Pythagorean \(x^2 + y^2 = z^2\) đã được chứng minh là sai với các số mũ khác 2. Điều đó có nghĩa là phương trình dưới đây vô nghiệm:

\[ x^n + y^n = z^n \]
\end{document}

In this example, mathematical expressions are described inside the delimeter \( \) or \[ \]. However, how it is displayed depends on the choice of delimeter.

Math mode

LaTeX\LaTeXLATE​X allows two writing modes for mathematical expressions: the inline math mode and display math mode.

  • inline math mode is used to write formulas that are part of a paragraph

  • display math mode is used to write expressions that are not part of a paragraph, and are therefore put on separate lines

Inline math mode

There are 3 delimeters than can be used to typeset the mathematical expression:

  • \(...\)

  • $...$

  • \begin{math}...\end{math}

\usepackage{amsmath} % amsmath will enable the use of \iiint - triple intergral

\begin{document}
\( V = \iiint_V\,dx\,dy\,dz \) \\

$V = \iiint_V\,dx\,dy\,dz$ \\ 

\begin{math}
V = \iiint_V\,dx\,dy\,dz
\end{math}
\end{document}

Display math mode

In display math mode, mathematical expressions are displayed on a separate line. You can use these delimeters to typeset your math:

  • $$...$$

  • \[...\]

  • \begin{displaymath}...\end{displaymath}

  • \begin{equation}...\end{equation}

  • \begin{equation*}...\end{equation*} - only available when import amsmath

Let's have a look at this example:

\begin{document}

This is Green's theorem written in display math mode:
\[ \oint_C P\,dx + Q\,dy = \iint_D(Q'_x - P'_y)\,dx\,dy \] \\

This is Green's theorem written in \textit{equation} environment:
\begin{equation}
\oint_C P\,dx + Q\,dy = \iint_D(Q'_x - P'_y)\,dx\,dy
\end{equation}
\\

This is Green's theorem written in \textit{equation*} environment, which can only be used if you imported the \underline{amsmath} package.
\begin{equation*}
\oint_C P\,dx + Q\,dy = \iint_D(Q'_x - P'_y)\,dx\,dy
\end{equation*}

\end{document}

Math Syntax in LaTeX\LaTeXLATE​X

In LaTeX\LaTeXLATE​X, numbers and letters are displayed without the need of any special syntax, numbers in math mode will be printed normally while letters will be printed in italics.

Subscripts and Superscripts

The use of superscripts and subscripts is very common in mathematical expressions involving exponents, indexes, and in some special operators.

Let's define an integral as an example:

\usepackage{amsmath}

\begin{document}
\[ \int\limits_0^1 x^{2x+1} + y^{3x^{4x+5}} \ dx \]
\end{document}

The result is:

By convention, superscripts and subscripts in LaTeX\LaTeXLATE​X are created using the characters ^ and _ respectively. The command \limits changes the way the limits are displayed in the integral, if not present the limits would be next to the integral symbol instead of being on top and bottom:

Greek letters and Blackboard-bold letters

To summary, it just depends on the syntax to write these characters. Let's look at this example:

\usepackage{amsmath}

\begin{document}
\[\pi\]
\[\Pi\]
\[\alpha\]
\[A = \pir^2\]

\begin{center}
In math, the set of real numbers is denoted as $\mathbb{R}$.
\end{center}
\end{document}

Brackets and Parentheses

Parentheses and brackets are very common in mathematical formulas. LaTeX\LaTeXLATE​Xprovides a set of commands that provides you with brackets in different sizes and styles.

Type
LaTeX syntax
Renders as

Parentheses

(x+y)

Brackets

[x+y]

Braces

\{x+y\}

Pipes

|x+y|

Double pipes

\|x+y\|

Let's take this equation for universal gravitation as an example:

\[F = G(\frac{m_1m_2}{r^2})\]

By default, the size of the brackets are fixed, even in display math mode. In order for them to be dynamically resized, we can use the \left and \right command combine with the left/right brackets. Let's look at this example:

\[F = G \left( \frac{m_1 m_2}{r^2} \right)\]

Thanks to the \left and \right command, we can create dynamically-resized pairs of brackets. However, even if you want to use only one bracket, both commands are mandatory. In order to solve this, we just need to put a dot after the command we want. Let's look at this exercise as an example:

\textbf{Câu 1:} (1 điểm): Tìm $a$ để hàm số sau liên tục tại điểm $x = 1$:

\[ 
f(x) =
\left\{  
\begin{array}{ll}
\sqrt[3]{a - x} &, \text{khi } x > 1 \\
\arccos{x} &, \text{khi } 0 < x \leq 1
\end{array}
\right.
\]

Fractions and Binomials

In order to typeset binomial coefficients you need to use the command \binom from amsmath package:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
The binomial coefficient, \(\binom{n}{k}\), is defined by the expression:
\[
    \binom{n}{k} = \frac{n!}{k!(n-k)!}
\]
\end{document}

Fractions, however, is more flexible. Its visual appearance will change depending on whether they appear in inline math mode, or typeset in display math mode. Let's look at this example:

\documentclass{article}
\begin{document}
Fractions can be used inline within the paragraph text, for 
example \(\frac{1}{2}\), or displayed on their own line, 
such as this:
\[\frac{1}{2}\]
\end{document}

As in the example, fraction is typeset using the \frac command with the syntax \frac{numerator}{denominator}

However, if you want to write text as numerator or denominator, you can not typeset it normally, but you need to use the \text command from amsmath, which is used to prevent LaTeX\LaTeXLATE​X from typesetting the text as regular mathematical content. Here is the example:

\documentclass{article}
\usepackage[utf8]{vietnam}
\usepackage{amsmath}
\begin{document}
\[
\frac{tu so}{mau so}
\]

\[
\frac{\text{tử số}}{\text{mẫu số}}
\]
\end{document}

Fractions can be nested, however, if they are deeply nested, may not produce ideal results. You can use \cfrac from amsmath to solve this.

Special functions

Calculus Notation

Square root and more

In order to typeset square root, you can use the following command: \sqrt[index]{radicand}. Here is an example:

Limits

Limits can be displayed differently between inline and display math mode. Let's look at this example:

\documentclass{article}
\begin{document}
\noindent Testing notation for limits
\[
    \lim_{h \rightarrow 0 } \frac{f(x+h)-f(x)}{h}
.\]
This operator changes when used in inline mode 
\( \lim_{h \rightarrow 0} (x-h) \).
\end{document}

Regarding the →\rightarrow→ symbol, you can also use \to from amsmath.

Integrals

Integral expression can be typeset using the \int_{lower}^{upper} command. And in order to get the final result by calculating with the upper and lower limit, you can use \vert. Like limits, its display can be different between display math mode and inline math mode.

\documentclass{article}
\begin{document} 
\noindent Let's try integral in \LaTeX:
\[
\int_{0}^{\infty} \frac{1}{\sqrt{3x+4}}
\] \\
and also integral in a sentence: $\int_{0}^{\infty}2x+1$ \\

It's known that:
\[
\int_{b}^a f(x)\,dx = F(x)\bigg\vert_a^b 
\]
\end{document}

The default length of \vert is pretty short, you can enhance that by using \big or \bigg.

You can also typeset double integrals, triple integrals using \iint, \iiint, respectively.

It's also noteworthy that you can change the place of the integral limits using the command \limits_{lower limit}^{upper_limit}. This is also applied in inline math mode. Let's look at this example:

\documentclass{article}
\begin{document} 
\noindent Some people may not like this way of placing the integral limits:
\[
\int_0^{a} 2x+1\:dx
\] \\
They prefer this more:
\[
\int \limits_0^{a} 2x+1\:dx
\]
\end{document}

If you notice, you may see the dxdxdx notation placing too close to the equation. Therefore, I will introduce a set of command to create small "space" in your mathematical notion, which will beautify your math.

This can also be used in text environment, only integrals.

Sums and Products (Sigma notation and Pi notation)

Like integral, Sigma notation and Pi notation use a similar syntax: \sum_{lower}^{upper} and \prod_{lower}^{upper}. Both of them may be displayed differently when in display math mode or inline math mode. Here is the example:

Sum $\sum_{n=1}^{\infty} 2^{-n} = 1$ inside text
\[ \sum_{n=1}^{\infty} 2^{-n} = 1 \]
\\

Product $\prod_{i=a}^{b} f(i)$ inside text
\[ \prod_{i=a}^{b} f(i) \]

Vectors

Vectors are a widely explored subject within Algebra. Therefore, in order to write this in LaTeX\LaTeXLATE​X, you need to import the esvect package (this package must be manually installed). After that, you can use the command \vv to create vector notations.

However, in some situations, you may have multiple rrr vectors, and you may want to number them.

When it comes to calculating the dot product of 2 vectors, you may need a pair of angle brackets. The correct way to write it is \langle and \rangle ("l" and "r" are left and right, respectively).

\begin{document}
Let's learn some Algebra. \\
The angled brackets represent an inner product. The best known one is the \textit{scalar product} or \textit{the dot product}. If $u=(u_1,u_2,u_3)$ and $v=(v_1,v_2,v_3)$, then the dot product is given by:
\[
\langle u,v \rangle = u_1v_1 + u_2v_2 + u_3v_3
\]

\end{document}

It all works, but it's LaTeX\LaTeXLATE​Xstandard to use \(...\) to express math. If you want to know why, head to this .

It's suggested to use \[...\] instead of $$...$$. You can read more about this .

Every Greek letters can be written using a command. You can have a complete list of Greek characters . In addition, you can also use \mathbb to display letters in blackboard-style. (\mathbb need to be put in inline math mode)

As shown in the previous part of , if you type normal characters in math mode, it will become italics. As a result, when it comes to special functions like sine, cosine, tangent, you need to use a command to properly typeset them. Let's look at this example:

You can find a lot of commands for different operations .

(x+y)(x+y)(x+y)
[x+y][x+y][x+y]
{x+y}\{x+y\}{x+y}
∣x+y∣|x+y|∣x+y∣
∥x+y∥\|x+y\|∥x+y∥
question
here
here
here
Fractions