10

For my thesis I need particular brackets for defining some operators. I found \llceil, \rrceil, \llfloor and \rrfloor in the stmaryrd package, which are just what I was looking for. Unfortunately, they do not support \left and \right and therefore they look very ugly with tall formulas. Probably they are not designed for such formulas.

Is there a simple way to make them supporting \left and \right or to define other brackets that do support them?

5

It's not perfect, because the stretching of the glyph thickens up the horizontal stroke, but it may be sufficient for your needs. The \stretchleftright{}{}{} macro will stretch arguments 1 and 3 to meet the vertical extent of argument 2.

A related answer is Defining scalable "white curly brackets" {| and |} (⦃ and ⦄)

\documentclass{article}
\usepackage{stmaryrd}
\usepackage{scalerel}
\begin{document}
\[
\llceil x\rrceil  ~~~\llfloor y \rrfloor
\]
\[
\stretchleftright{\llceil}{\frac{x^2}{y_2}}{\rrceil}~~~
\stretchleftright{\llfloor}{\sqrt{y^2}}{\rrfloor}
\]
\end{document}

enter image description here

The other approach is to stick two of the normal "ceil"s together. This will avoid the thickening of the horizontal stroke, but it must be matched with another "double" glyph.

\documentclass{article}
\def\llceil{\left\lceil\kern-3.5pt\left\lceil}
\def\rrceil{\right\rceil\kern-3.5pt\right\rceil}
\begin{document}
\[
\llceil\frac{x^2}{y_2}\rrceil
\]
\end{document}

enter image description here

  • This is great. I used the second approach, but with 3pt instead of -3.5pt, in order to make the presence of both brackets more visible for small arguments. Thank you very much, you saved my notation! – Spiros Oct 22 '13 at 15:38
6

The \llceil, \rrceil, \llfloor and \rrfloor symbols of stmaryrd are available at a single size.

You can define macros \dceil and \dfloor that take an argument; with \dceil* automatically extensible delimiters are produced and a numeric optional argument adds some negative kern between the two \lceil or \rceil that are used. Without the *, the optional argument can be \big, \Big, \bigg or \Bigg. The same for \dfloor.

\documentclass{article}
\usepackage{amsmath,xparse,stmaryrd}
\ExplSyntaxOn
\NewDocumentCommand{\dceil}{sO{0}m}
 {
  \IfBooleanTF{#1}
   {
    \spiros_ceilfloor_ext:nnnn { #2 } { #3 } { \lceil } { \rceil }
   }
   { 
    \spiros_ceilfloor:nnnn { #2 } { #3 } { \lceil } { \rceil }
   }
 }
\NewDocumentCommand{\dfloor}{sO{0}m}
 {
  \IfBooleanTF{#1}
   {
    \spiros_ceilfloor_ext:nnnn { #2 } { #3 } { \lfloor } { \rfloor }
   }
   {
    \spiros_ceilfloor:nnnn { #2 } { #3 } { \lfloor } { \rfloor }
   }
 }
\cs_new_protected:Npn \spiros_ceilfloor_ext:nnnn #1 #2 #3 #4
 {
  \left#3
  \mkern-\muskip_eval:n { 4.5mu + #1mu }
  \left#3
  #2
  \right#4
  \mkern-\muskip_eval:n { 4.5mu + #1mu }
  \right#4
 }
\cs_new_protected:Npn \spiros_ceilfloor:nnnn #1 #2 #3 #4
 {
  \mathopen{\str_if_eq:nnF { #1 } { 0 } { #1 }#3}
  \mkern\spiros_kern:n { #1 }
  \mathopen{\str_if_eq:nnF { #1 } { 0 } { #1 }#3}
  #2
  \mathclose{\str_if_eq:nnF { #1 } { 0 } { #1 }#4}
  \mkern\spiros_kern:n { #1 }
  \mathclose{\str_if_eq:nnF { #1 } { 0 } { #1 }#4}
 }
\cs_new:Npn \spiros_kern:n #1
 {
  \str_case:nnF { #1 }
   {
    { \big }{ -4.5mu }
    { \Big }{ -5.5mu }
    { \bigg }{ -6.5mu }
    { \Bigg }{ -7.5mu }
   }
   { -4.5mu }
 }
\ExplSyntaxOff
\begin{document}
\[
\llceil x\rrceil\\
\dceil*{x} \quad
\dceil*{\frac{x}{2}}\quad
\dceil*[1]{\frac{x}{2}}\quad
\dceil*[3]{\frac{\dfrac{x}{2}}{\dfrac{y}{3}}}
\]
\[
\dceil{x}\quad
\dceil[\big]{x}\quad
\dceil[\Big]{x}\quad
\dceil[\bigg]{x}\quad
\dceil[\Bigg]{x}
\]
\[
\llfloor x\rrfloor\\
\dfloor*{x} \quad
\dfloor*{\frac{x}{2}}\quad
\dfloor*[1]{\frac{x}{2}}\quad
\dfloor*[3]{\frac{\dfrac{x}{2}}{\dfrac{y}{3}}}
\]
\[
\dfloor{x}\quad
\dfloor[\big]{x}\quad
\dfloor[\Big]{x}\quad
\dfloor[\bigg]{x}\quad
\dfloor[\Bigg]{x}
\]
\end{document}

The result seems acceptable without correction in the case of \dceil* and \dfloor* up to a certain size (corresponding to \bigg); after it a correction is needed.

Maybe the correction could be made automatic based on the size of the mandatory argument.

enter image description here

  • Very impressive! (as always) – Steven B. Segletes Oct 22 '13 at 23:26
  • This is indeed a perfect solution. The brackets look really perfect at all sizes. Unfortunately, this solution is not backward compatible, in the sense that my tex code that uses \llceil would have to be adapted eveywhere in order to make use of your proposed commands (and automatic replacemnt is not an option with my document). For my new documents I will use it, if I still need these brackets. – Spiros Oct 23 '13 at 9:19
  • @Spiros You can leave \llceil and similar commands, since at the normal size the result is pretty the same. – egreg Oct 23 '13 at 10:40

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.