7

There are some threads here, in which it is explained how to use \lceil \rceil \lfloor \rfloor.

But generally, in math, there is a sign that looks like a combination of ceil and floor, which means round, aka nearest integer.

Is there a way to draw this sign in Latex's math mode?

  • 1
    You mean square brackets with/out space in the middle? – percusse May 23 '18 at 20:32
  • Yes, generally, but just square brackets do not take into account the width of the expression they contain, their width is fixed and sometimes makes them look like regular brackets that are put so you know what expression to compute first – AgvaniaRekuva May 23 '18 at 20:34
  • Please clarify what you mean by "the width of the expression they contain". – Mico May 23 '18 at 20:34
  • Related: Notation for rounding function – Werner May 23 '18 at 20:35
  • 1
    Rounding to the nearest integer is not well defined, because one doesn't know what to do with 1/2 and, in general, with k+1/2. Apparently there's no consensus about a notation. – egreg May 23 '18 at 21:04
17

The mathtools package has a \DeclarePairedDelimiter command which lets you define such macros. I defined a \nint command which encloses its argument between \lfloor and \rceil. The starred version adds a pair of implicit \left...\right, but you may fine-tune the delimiters size using one of \big, \Big, \bigg, \Biggas an optional argument.

\documentclass[10pt,a4paper]{article}
\usepackage{mathtools, nccmath}

\DeclarePairedDelimiter{\nint}\lfloor\rceil

\DeclarePairedDelimiter{\abs}\lvert\rvert

\begin{document}

    \[ \nint{x}\qquad \nint*{\sqrt{x^2 + \mfrac13}}\qquad\nint[\Big]{\sqrt{x^2}} = \abs{x}\]%

\end{document} 

enter image description here

| improve this answer | |
  • Use \nint* if you want it to automatically resize itself, or use \newcommand{\nint}[1]{\ensuremath\left\lfloor#1\right\rceil} so it always does – Atnas Jul 24 at 10:31
0

The combination of the two answers above:

\newcommand{\round}[1]{\ensuremath{\lfloor#1\rceil}}
| improve this answer | |
-1

Solved it this way:

\newcommand\round[1]{\left[#1\right]}

Then I could use it as a function:

$F = \round{\frac{1}{n}\sum_{i=1}^{n}\norm{F_{i}}}$

This is the result:

round symbol

| improve this answer | |
  • Welcome to TeX SX! There's a problem with your notation: it can also denote the floor of number x (the greatest integer n <= x). – Bernard May 23 '18 at 21:16
  • The present picture is not the result of your code. – Przemysław Scherwentke May 23 '18 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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