how to write ceil and floor in latex?
Using \DeclarePairedDelimiter
from mathtools
, you could define macros \ceil
and \floor
, which will scale the delimiters properly (if starred):
\documentclass{minimal}
\usepackage{mathtools}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
\begin{document}
\begin{equation*}
\floor*{\frac{x}{2}} < \frac{x}{2} < \ceil*{\frac{x}{2}}
\end{equation*}
\end{document}
Result:
You can define your own macro via the
\def
command anywhere in your document. For example\def\lc{\left\lceil} \def\rc{\right\rceil}
and then just write
\lc x \rc
.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.- Use an editor, like vim, that allows for defining shortcuts for quick and efficient editing.
- 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.
This will also work fine without using mathtools.
\newcommand{\floor}[1]{\lfloor #1 \rfloor}