Fences

A picket fence.

The term fences refers parentheses, brackets, and braces - generally, things that enclose numbers and variables. On this page, we will learn how to typeset different kinds of fences, and to resize fences so that they fit taller expressions in display mode, like fractions or integrals.

Commands for fences

First, let's go over how to typeset different types of fences. Some can be typed as usual, others require special commands.

Resizing fences

Regular-sized parentheses with a fraction in display mode:

Resized parentheses:

The commands \left and \right placed on their respective fences will cause the fences to resize to fit the contents. You can add the examples picture above to your own document:

Compare \(\displaystyle (\frac{1}{x}) \) to \(\displaystyle \left(\frac{1}{x}\right) \).

Note that both \left and \right must be used!

For example, try adding the following code to your project and compiling the preview:

\[ \left(\frac{1}{x}) \]

Overleaf does compile the Preview, but gives an error message noting that there is no matching \right. While the left parenthesis is resized, the right one is not.

Flagged error and the resulting PDF in Overleaf, as described above.

Exercise 7.1.1

Edit the following code so that the parentheses fit the contents.

\[

[(x+1)^2]\cdot|\sin(\frac{1}{x})|

\]

Solution 7.1.1

Add \left and \right to each set of fences that contains a taller expression.

The square brackets contain an exponential, and the vertical bars and parentheses both contain a fraction.

\[

\left[(x+1)^2\right]\cdot\left|\sin\left(\frac{1}{x}\right)\right|

\]

We could add \left and \right to the first set of parentheses, around (x + 1). However, this would not make any visible difference, since x + 1 is of a normal line height.

Note on the other hand, that while \left and \right must be used together, the fences themselves can be mixed and matched.

For example, if we want to write the half-open interval from 1/2 to 1 (including 1/2, excluding 1), we can achieve this with the same \left and \right commands:

\[ \left[\frac{1}{2}, 1\right) \]

Even though the parentheses are different, they are both properly resized. The parentheses themselves are characters, unlike in other instances where we were matching opening and closing tags.

Half-open interval with large mismatched parentheses, described above.

Exercise 7.1.2

Typeset the First Fundamental Theorem of Calculus:

Fundamental Theorem of Calculus. If the function f is continuous on the closed interval [a, b], then d dx of integral from a to x of f of t dt equals f of x.

Solution 7.1.2

The First Fundamental Theorem of Calculus can be typeset as follows:

\textbf{Fundamental Theorem of Calculus.} If the function \(f\) is continuous on the interval \([a, b]\), then \[\frac{d}{dx}\left[\int_a^x f(t) \ dt\right] = f(x)\]

Now that we know how to group items in a single math expression, we will learn a way to group and organize multiple equations or expressions.