[Tex/LaTex] ny way to set up \ceil and \floor macros without installing the mathtools package

amsmathmathtoolstex-general

I can not install the mathtools package. Is there any way to create the \ceil and \floor macros without this package?

Best Answer

You don't need to load any packages to access the four macros \lfloor, \lceil, \rfloor, and \rceil. It is straightforward to use these macros to create two new macros called, say, \floor and \ceil:

\newcommand\floor[1]{\lfloor#1\rfloor}
\newcommand\ceil[1]{\lceil#1\rceil}

Then, write something such as $\floor{x}$ and $\ceil{y}$ in the body of the document.


Addendum to address @Teepeemm's follow-up comment: To create the option to resize the heights of the symbols produced by \floor and \ceil, I suggest using the \DeclarePairedDelimiter macro of the mathtools package.

enter image description here

\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}
\DeclarePairedDelimiter{\ceil}{\lceil}{\rceil}
\begin{document}
$\floor{x}$, $\ceil{y}$, $\floor*{\frac12}$, $\ceil*{\frac12}$
\end{document}