Written and maintained by CASRAI Editorial Board
Published · Last updated
On this page
Searchers for this want to typeset the floor and ceiling brackets (⌊x⌋ and ⌈x⌉) in a LaTeX document and, in a paper or thesis, define short reusable macros that size correctly. The four base commands are \lfloor, \rfloor, \lceil and \rceil; the mathtools package adds a way to declare \floor and \ceil once and get default, auto-sized or manually sized brackets from the same macro.
What floor and ceiling brackets are used for in research
The floor ⌊x⌋ and ceiling ⌈x⌉ brackets appear in algorithm analysis, number theory, discrete mathematics and any methods section that rounds a quantity down or up (for example, a sample size or an array index). LaTeX has no single “floor” command: you build the notation from four delimiter symbols. The LaTeX2e reference manual’s delimiter table lists them as left floor bracket (\lfloor, U+230A), right floor bracket (\rfloor, U+230B), left ceiling bracket (\lceil, U+2308) and right ceiling bracket (\rceil, U+2309).
Install or access (official source only)
The four base commands are part of standard LaTeX math and need no package. The reusable-macro method below needs mathtools, which its manual describes as an extension package to amsmath. The package and its manual are published on CTAN under macros/latex/contrib/mathtools; load it in the preamble with \usepackage{mathtools}. The manual version used for this page is dated 2024/10/04.
Step-by-step: typeset and define floor and ceiling
1. Write the symbols directly
- Work in math mode, for example
$\lfloor x \rfloor$for ⌊x⌋ and$\lceil x \rceil$for ⌈x⌉. - For a tall argument such as a fraction, size the brackets with
\leftand\right:\left\lfloor \frac{n}{2} \right\rfloor. The reference manual lists these four symbols among its delimiters, which\left ... \rightsize to the enclosed content.
2. Define reusable macros with mathtools
- In the preamble, add
\usepackage{mathtools}. - Declare the pairs. The documented syntax is
\DeclarePairedDelimiter{cmd}{left_delim}{right_delim}(the manual’s own example is\DeclarePairedDelimiter\abs{\lvert}{\rvert}). Applying the same pattern:\DeclarePairedDelimiter\floor{\lfloor}{\rfloor} \DeclarePairedDelimiter\ceil{\lceil}{\rceil} - Use the macros in math mode. According to the manual, each declared command has three size behaviours:
\floor{x}(no star, no option): default delimiter size.\floor*{\frac{n}{2}}(starred): delimiters are preceded by\leftand\right, so they scale to the argument.\floor[\Big]{x}(optional argument): a manual size, one of\big,\Big,\bigg,\Bigg.
Defining the macro once in the preamble means a whole paper or thesis uses one consistent notation, and changing the delimiter style later is a one-line edit.
Output and how to read it
The compiled output shows ⌊x⌋ and ⌈x⌉ with brackets that hook inward at the top or bottom edge. With the starred form the brackets grow with a fraction or sum inside; with the unstarred form they stay at default size even around tall content, which is the usual cause of brackets that look too small.
Why a plain \newcommand version is weaker
A common shortcut is \newcommand{\floor}[1]{\lfloor #1 \rfloor}. It works for short arguments, but it fixes the bracket size at the default and offers no starred or optional-size form. \DeclarePairedDelimiter gives the three behaviours above from a single declaration. A second variant, \DeclarePairedDelimiterX, is documented for delimiters that take several arguments.
Troubleshooting
- Undefined control sequence on
\flooror\ceil. These are not built-in commands. Loadmathtoolsand declare them as in step 2, or use\lfloor ... \rfloordirectly. - Undefined control sequence on
\DeclarePairedDelimiter. The command belongs tomathtools; check that\usepackage{mathtools}is in the preamble before the declaration. - Error that a command is allowed only in math mode. The delimiter symbols are math-mode commands; wrap them in
$...$or an equation environment. - Brackets too small around a fraction. Use the starred form (
\floor*) or the\left ... \rightpair.
Free alternatives
| Method | Needs a package | Sizing |
|---|---|---|
\lfloor x \rfloor typed directly |
No | Default size |
\left\lfloor ... \right\rfloor |
No | Scales to content |
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor} |
mathtools | Default, starred auto-size, or optional \big to \Bigg |
Related guides
For other symbols and the packages they need, see LaTeX math signs and required packages, LaTeX subset symbols and the empty set in LaTeX. For the document-level side of a LaTeX paper, see LaTeX bibliography styles and collaborative writing in Overleaf.
FAQ
How do you write the floor function in LaTeX?
Use \lfloor x \rfloor in math mode, which gives ⌊x⌋. The ceiling is \lceil x \rceil, giving ⌈x⌉.
Is there a built-in \floor command?
No. Define it yourself, either with \newcommand or, for auto-sizing and manual sizing, with \DeclarePairedDelimiter from mathtools.
How do I make floor brackets grow with a fraction?
Use \left\lfloor ... \right\rfloor, or declare \floor with mathtools and write \floor*{...}.
Sources (official documentation)
- mathtools package manual, version 2024/10/04, CTAN: ctan.math.illinois.edu/macros/latex/contrib/mathtools/mathtools.pdf (read 2026-11-07).
- LaTeX2e unofficial reference manual, Delimiters: latexref.xyz/Delimiters.html (read 2026-11-07).







