15

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

3
  • 3
    I would suggest to wait for a solution at How should I install mathtools package using linux mint? before trying to hack things.
    – Johannes_B
    Jan 21, 2015 at 14:39
  • 4
    In any event, mathtools is only needed to make the floor and ceil a matched pair. The individual glyphs are available (without packages) as \lceil, \rceil, \lfloor, and \rfloor. Jan 21, 2015 at 14:41
  • 2
    These functions are not defined by mathtools, nor are they defined by any package I know. A \floor command can be defined, and mathtools can help it to adapt automatically to the size of its contents. What is defined in basic LaTeX are de variable-sized delimiters \lfloor, \rfloor, \lceil` and \rceil.
    – Bernard
    Jan 21, 2015 at 14:42

1 Answer 1

25

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}
1
  • 2
    You can also add \left and \right so that they resize according to their contents.
    – Teepeemm
    May 23, 2017 at 20:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .