Floor Function in LaTeX
The floor function is written with the delimiters \lfloor and \rfloor: \lfloor x \rfloor. The ceiling uses \lceil x \rceil. Both are built into LaTeX; add \left and \right when the contents are taller than one line of text.
Floor and ceiling commands
\lfloor x \rfloorFloor: the greatest integer ≤ x.
\lceil x \rceilCeiling: the least integer ≥ x.
\left\lfloor \frac{a}{b} \right\rfloorFloor brackets that grow with the contents.
\left\lceil \frac{a}{b} \right\rceilCeiling brackets that grow.
\bigl\lfloor x \bigr\rfloorFixed larger size.
\lfloor x \rceilMixed pair, sometimes used for rounding to the nearest integer.
- Text mode, no math preview
\floor{x}Your own macro after
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}(mathtools).
Try it live
Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.
Floor and ceiling examples
Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.
Floor and ceiling of a number
LaTeX\lfloor 3.7 \rfloor = 3, \quad \lceil 3.2 \rceil = 4Negative numbers
LaTeX\lfloor -2.5 \rfloor = -3, \quad \lceil -2.5 \rceil = -2Integer division
LaTeXq = \left\lfloor \frac{a}{b} \right\rfloor, \quad r = a - b qHalves
LaTeX\left\lfloor \frac{n}{2} \right\rfloor + \left\lceil \frac{n}{2} \right\rceil = nNumber of digits
LaTeXd(n) = \lfloor \log_{10} n \rfloor + 1Fractional part
LaTeX\{ x \} = x - \lfloor x \rfloorDefinition of the floor
LaTeX\lfloor x \rfloor = \max \{ n \in \mathbb{Z} : n \le x \}
How to write floor and ceiling
All four symbols are standard delimiters in LaTeX, so no package is needed: \lfloor, \rfloor, \lceil, \rceil. Because they are delimiters, they work with \left / \right and the \big family just like parentheses.
Use \left\lfloor … \right\rfloor around fractions and logarithms, otherwise the brackets stay text height and look cut off.
\floor and \ceil macros
LaTeX has no \floor or \ceil command out of the box, which is why copying \floor{x} from someone else’s notes can fail. Define them with mathtools; the starred form then stretches automatically.
\usepackage{mathtools}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
% ...
\[ \floor*{\frac{n}{2}} \le \ceil{x} \]Common mistakes
\flooris not a built-in command; it only exists after you define it.Instead of\floor{x} (no definition)Write\lfloor x \rfloorFixed-size brackets look too short next to a fraction.
Instead of\lfloor \frac{n}{2} \rfloorWrite\left\lfloor \frac{n}{2} \right\rfloorSquare brackets are an older notation that readers may take as ordinary grouping; the floor symbols are unambiguous.
Instead of[x] (for the floor)Write\lfloor x \rfloor
In Overleaf, MathJax and Word
Overleaf and pdfLaTeX
\lfloor,\rfloor,\lceiland\rceilwork without packages;\bigl/\bigrneed amsmath and\DeclarePairedDelimiterneeds mathtools.MathJax and KaTeX
MathJax and KaTeX render all four delimiters and their
\left/\rightforms.\floorand\ceilare not predefined, so define them as macros in the renderer’s configuration or write the delimiters out.Microsoft Word
Word has floor and ceiling brackets under Bracket, but pasted LaTeX is not converted reliably. Build the expression here and use Copy for Word to paste it as an editable equation.
Floor and ceiling in LaTeX: questions
- What is the LaTeX code for the floor function?
\lfloor x \rfloor, in math mode. The ceiling is\lceil x \rceil.- How do I make floor brackets bigger?
- Use
\left\lfloor … \right\rfloorto fit the contents, or a fixed size such as\bigl\lfloor … \bigr\rfloor. - Why does \floor{x} give an error?
- It is not a standard command. Either write
\lfloor x \rflooror define\floorwith\DeclarePairedDelimiterfrom mathtools. - Is there a symbol for rounding to the nearest integer?
- There is no single standard. Some authors use the mixed pair
\lfloor x \rceil; others write\operatorname{round}(x). Define the notation where you first use it.
Related LaTeX reference
- Absolute Value in LaTeX|x|, \lvert x \rvert, bars that stretch with \left| \right|, double bars for norms, and an \abs macro with mathtools.
- Piecewise Function in LaTeXThe cases environment: one line per piece, & before each condition, \text for words, dcases and rcases variants.
- Real Number Symbol in LaTeXBlackboard bold number sets with \mathbb: ℝ, ℕ, ℤ, ℚ, ℂ, ℝⁿ, and why \R does not work out of the box.
- LaTeX equation editorSymbol panel, live preview, and PNG, SVG, MathML or Word export.
- All LaTeX reference pagesSymbols, math structures and text formatting in one list.
Have the formula as a picture?
Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.
Convert an image to LaTeX