How to write square brackets [] in LaTeX?

In LaTeX, you can write square brackets using the standard keyboard characters [ and ]. These characters are treated as normal text and do not require any special commands.

For larger mathematical expressions you can use \left and \right commands to add square brackets in LaTeX.

The following examples shows how to write square brackets in LaTeX.

How to Write Square Brackets in Text

We can directly use square brackets in LaTeX document for text.

Example: Square Brackets in Text

Suppose we want to write square brackets in the text.

We can use the following LaTeX code to do so:

\documentclass{article}
\begin{document}

This is an example of using square brackets [like this] in a sentence.

\end{document}

Output: 👇️

This is an example of using parentheses [like this] in a sentence.

In this example, we use the square brackets to enclose a part of the sentence.

How to Write Square Brackets in Mathematical Expressions

For larger mathematical expressions, we can use the \left and \right commands to automatically adjust the size of the square brackets.

Example: Square Brackets in Mathematical Expressions

Suppose we would like to write mathematical expressions that contain square brackets and ensure the brackets scale appropriately to the size of the content inside.

We can use the following LaTeX code to do so:

\documentclass{article}
\begin{document}

An inline mathematical expression: \[ [a + b] \times c \].

A displayed mathematical expression:
\[
\left[ \frac{a}{b} \right] + \left[ \frac{c}{d} \right]
\]

\end{document}

Output: 👇️

Square Brackets

In this example, we use the \left and \right commands to adjust the size of the square brackets to fit the enclosed fractions. This ensures that the parentheses dynamically resize to match the size of the enclosed contents.

Conclusion

We can use the standard keyboard characters for text and mathematical expressions.

For larger expressions, the \left and \right commands help in adjusting the size of the square brackets automatically.