5

Recently I started to play with LaTeX again just to train for when I have to use it again. I like to write mathematical formulas and I am trying to nail down floor and ceil symbols with fractions. However the results I get are kind of weird, in my opinion. Example code below:

    $\left\lfloor\dfrac{2}{3}\right\rfloor$
    $\left\lfloor\dfrac{a}{n}\right\rfloor$ 
    $\left\lfloor\dfrac{A}{n}\right\rfloor$
    $\left\lfloor\dfrac{a}{N}\right\rfloor$

This code generates this output (compiling with PDFLaTeX):

enter image description here

The height of the floor symbol is inconsistent, it is smaller when the fraction contains a lowercase letter in the numerator and larger when the fraction contains numbers or uppercase letters in the numerator. Why is that the case? How can I produce floor symbols that are always the larger size shown in the picture?

5
  • 2
    better use \bigl and \bigr rather than \left to get consistent size, or use \strut in all cases eg \dfrac{\strut a}{\strut n} so your fractions are the same size. Sep 29 at 14:16
  • @DavidCarlisle It would be nice if some struts where there by default. Or at least via a setup. Maybe something to take up?
    – mickep
    Sep 29 at 16:40
  • @mickep I suppose you are going to tell me that some other format does this better? Sep 29 at 16:42
  • \bigl and \bigr did not work here... \strut kind of worked but it made the floor signs a little bit too high
    – MR. PROD
    Sep 29 at 17:36
  • by \bigl I meant choose a suitable size (\biggl or whatever you need) note the accepted answer is a primitive tex construct that should never be used in latex (and will generate warnings if used with amsmath) Sep 30 at 9:03

3 Answers 3

7

TeX uses a discrete set of five bracket sizes (not counting the massive brackets around matrices, etc.). Using \left and \right invokes an algorithm that calculates which to use, based on what appears inside. Sometimes this algorithm results in a choice that is not visually appealing.

If you want to create a sequence of objects contained in brackets of the same size, it's simplest to choose the size yourself, using \bigl, \Bigl, \biggl or \Biggl along with the associated commands ending in r. Another option is to influence \left and \right by inserting vertical rules (struts). Note that the optional argument to \rule is used to move it up and down, whereas the mandatory arguments are the width followed by the height. You can change the width to 0pt once you are happy with the result.

\documentclass{article}
\usepackage{mathtools}
\begin{document}
$\biggl\lfloor\dfrac{2}{3}\biggr\rfloor$
$\biggl\lfloor\dfrac{a}{n}\biggr\rfloor$
$\biggl\lfloor\dfrac{A}{n}\biggr\rfloor$
$\biggl\lfloor\dfrac{a}{N}\biggr\rfloor$

\bigskip

$\left\lfloor\rule[-8pt]{1pt}{20pt}\dfrac{2}{3}\right\rfloor$
$\left\lfloor\rule[-8pt]{1pt}{20pt}\dfrac{a}{n}\right\rfloor$
$\left\lfloor\rule[-8pt]{1pt}{20pt}\dfrac{A}{n}\right\rfloor$
$\left\lfloor\rule[-8pt]{1pt}{20pt}\dfrac{a}{N}\right\rfloor$
\end{document}

enter image description here

4

You can use \overwithdelims TeX primitive:

\let\ds=\displaystyle
$\ds {2\overwithdelims\lfloor\rfloor 3}$
$\ds {a\overwithdelims\lfloor\rfloor n}$
$\ds {A\overwithdelims\lfloor\rfloor n}$
$\ds {a\overwithdelims\lfloor\rfloor N}$
1

You can use \DeclarePairedDelimiter from the mathtools package to create your own \floor command that lets you freely choose between inferred and manually-specified delimiter sizes:

\usepackage{mathtools}

\DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}

Use \floor as \floor*{...} for interfered delimiter sizes or as \floor[\SIZE]{...} for \SIZE-sized delimiters.

\documentclass{article}
\usepackage{enumitem}  
\usepackage{mathtools}

\DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}

\begin{document}
\begin{description}[labelwidth=\widthof{\bfseries Inferred:}]
    \item[Inferred:]
    $\floor*{\dfrac{2}{3}}$
    $\floor*{\dfrac{a}{n}}$ 
    $\floor*{\dfrac{A}{n}}$
    $\floor*{\dfrac{a}{N}}$

    \item [\texttt{\textbackslash{}big}:]
    $\floor[\big]{\dfrac{2}{3}}$
    $\floor[\big]{\dfrac{a}{n}}$ 
    $\floor[\big]{\dfrac{A}{n}}$
    $\floor[\big]{\dfrac{a}{N}}$
    
    \item [\texttt{\textbackslash{}Big}:]
    $\floor[\Big]{\dfrac{2}{3}}$
    $\floor[\Big]{\dfrac{a}{n}}$ 
    $\floor[\Big]{\dfrac{A}{n}}$
    $\floor[\Big]{\dfrac{a}{N}}$
    
    \item [\texttt{\textbackslash{}bigg}:]
    $\floor[\bigg]{\dfrac{2}{3}}$
    $\floor[\bigg]{\dfrac{a}{n}}$ 
    $\floor[\bigg]{\dfrac{A}{n}}$
    $\floor[\bigg]{\dfrac{a}{N}}$
    
    \item [\texttt{\textbackslash{}Bigg}:]
    $\floor[\Bigg]{\dfrac{2}{3}}$
    $\floor[\Bigg]{\dfrac{a}{n}}$ 
    $\floor[\Bigg]{\dfrac{A}{n}}$
    $\floor[\Bigg]{\dfrac{a}{N}}$
\end{description}
\end{document}

\floor with various delimiter sizes

You must log in to answer this question.

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