TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a macro in latex to write ceil(x) and floor(x) in short form? The long form

\left \lceil{x}\right \rceil 

is a bit lengthy to type every time it is used.

share|improve this question

migrated from stackoverflow.com Jun 7 '13 at 22:41

This question came from our site for professional and enthusiast programmers.

Welcome to TeX.SX! Your post was migrated here from another Stack Exchange site. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Joseph Wright Jun 8 '13 at 5:31
Thank you, it seems I was asking questions in the wrong forum indeed! – danny Jul 7 '13 at 17:35
up vote 55 down vote accepted

Using \DeclarePairedDelimiter from mathtools, you could define macros \ceil and \floor, which will scale the delimiters properly (if starred):


    \floor*{\frac{x}{2}} < \frac{x}{2} < \ceil*{\frac{x}{2}}


Scaling delimiters with <code>\floor</code> and <code>\ceil</code>

share|improve this answer
That's neat. Didn't know about this command. – Jan Jun 8 '13 at 11:47
Doesn't work here. Any idea how to do it without mathtools? – David 天宇 Wong Mar 5 '15 at 1:54
Just a question: why * when using \floor? I noticed that if the * is omitted from the command, the delimiter does not resize... but why? – Gherardo Jul 11 '15 at 7:26
@Gherardo: Check the documentation of the mathtools package. It's just the way the \DeclarePairedDelimiter macro works — you can also make it use a specific size if you want to: \floor[\Bigg]{\frac{x}{2}}. – You Jul 11 '15 at 10:10
The mathtools package doesn't appear to exist anymore, has it been replaced? – Dimpl Mar 20 at 12:46
  1. You can define your own macro via the \def command anywhere in your document. For example


    and then just write \lc x \rc.

  2. Or you use the \providecommand in the preamble, e.g.

    \providecommand{\myceil}[1]{\left \lceil #1 \right \rceil }

    to simply use \myceil{x} in your document.

  3. Use an editor, like vim, that allows for defining shortcuts for quick and efficient editing.
  4. And, finally, don't forget about readability of your tex document. Check out this thread for some instructive comments on how to write efficient and readable tex math docs.
share|improve this answer

This also seems to work fine witouth using mathtools.

\newcommand{\floor}[1]{\lfloor #1 \rfloor}
share|improve this answer
Welcome to TeX.SX! \floor and \rfloor are amsmath commands, mathtools builds on top of amsmath, so it's no wonder, this would work even without mathtools. The solution with \DeclarePairedDelimiter shows better spacing however. Perhaps you should elaborate on your answer and show some screenshot and a full example, not only fragments of code – Christian Hupfer Jun 24 '15 at 23:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.