# Creating three sided boxes that “close in” the floor and ceil functions

Like Cameron Martin who asked this question, I want notation for an operator that replaces the weak inequalities in \floor and \ceil with strict inequalities. Jordan Glen proposed \ceil{\bar{N^\ast}}, etc., which is a good solution but it's typographically not pretty. I think it would be prettier to construct 3-sided boxes, e.g., \strictFloor and strictCeil, which would enclose N^\ast in boxes, with, respectively, the bottom and top sides of the boxes omitted. Using the \xoverline command defined here, (and analogously an \xunderline command along the same lines), I constructed

\def\strictCeil#1{\left|\xoverline[1.1]{#1}\right|}


but then

$\strictCeil{N^\ast}$


is unfortunately a pretty ugly attempt at a 3 sided box:

as the edges don't line up and the fonts don't match. But I've reached the limit of my latex capacity here. Could somebody suggest how to get a nice version of this with the lines all the same style, and touching each other?

Just for the sake of championing the good ol' methods of the past:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{amsmath} % by default... :-)

\makeatletter

\newcommand*\strictceil[1]{%
% "\mathord" is required to get an atom that can carry
% sub-/superscripts:
\mathord{\mathpalette\@strictceil{#1}}%
}
\newcommand*\@strictceil[2]{%
\vbox{\m@th
% Save <default-rule-thickness> in "\dimen@":
\dimen@ \fontdimen 8
\ifx\scriptscriptstyle #1%
\scriptscriptfont
\else\ifx\scriptstyle #1%
\scriptfont
\else
\textfont
\fi\fi \thr@@
\kern \dimen@ % see Appendix G, Rule 9
\hbox{%
\vrule \@width\dimen@
\vbox{%
\kern -\dimen@
\hbox{$#1\overline{% \kern \thr@@\dimen@ \begingroup #2% possible changes to "\dimen@" are kept local \endgroup \kern \thr@@\dimen@ }$}%
}%
\vrule \@width\dimen@
}%
}%
}

\makeatother

\begin{document}

Let's try $\strictceil{N^{\ast}}$, and $$\strictceil{a}+\strictceil{b} = \strictceil{f(x)}+\strictceil{g(y)}$$.

Now in display:
\begin{align*}
x_{\strictceil{t}_{1+\strictceil{q}}} &= \frac{
\strictceil{a}+\frac{\strictceil{m}}{\strictceil{n}}
}{
\strictceil{c}+\frac{\strictceil{r}}{\strictceil{s}}
}
\\ % compare sizes with:
x_{t_{1+q}} &= \frac{
a+\frac{m}{n}
}{
c+\frac{r}{s}
}
\end{align*}

\end{document}


Output:

• So I switched to @GustavoMezzetti's solution because I really liked having the sub and superscripted sized for me, while with the tikz solution I had to do the resizing myself Thanks to both of you! – Leo Simon Feb 11 '17 at 19:50

It's not clear from your posting whether you use plain TeX, LaTeX or some other format. I assume LaTeX, but the solution can be adapted also to other formats.

Solution 1: tikz

\usepackage{tikz}
\newcommand\strictCeil[1]%
{\begin{tikzpicture}[baseline=(A.base)]
\node[inner sep=1pt] (A) {$#1$};
\draw (A.south west) --
(A.north west) --
(A.north east) --
(A.south east);
\end{tikzpicture}%
}


The draw command is pretty self-explanatory and can be easily adapted to a box that is open at the top. It may be an overkill to involve the tikz machinery for a single additional symbol.

Solution 2: negative spacing

\newcommand\strictCeil[1]{\left|\!\xoverline[1.1]{#1}\!\right|}


\documentclass{article}
% Solution 1: Tikz
\usepackage{tikz}
\newcommand\strictCeilA[1]%
{\begin{tikzpicture}[baseline=(A.base)]
\node[inner sep=1pt] (A) {$#1$};
\draw (A.south west) --
(A.north west) --
(A.north east) --
(A.south east);
\end{tikzpicture}%
}

% Solution 2: negative spacing
\makeatletter
\newsavebox\myboxA
\newsavebox\myboxB
\newlength\mylenA
\newcommand*\xoverline[2][0.75]{%
\sbox{\myboxA}{$\m@th#2$}%
\setbox\myboxB\null% Phantom box
\ht\myboxB=\ht\myboxA%
\dp\myboxB=\dp\myboxA%
\wd\myboxB=#1\wd\myboxA% Scale phantom
\sbox\myboxB{$\m@th\overline{\copy\myboxB}$}%  Overlined phantom
\setlength\mylenA{\the\wd\myboxA}%   calc width diff
\ifdim\wd\myboxB<\wd\myboxA%
\rlap{\hskip 0.5\mylenA\usebox\myboxB}{\usebox\myboxA}%
\else
\hskip -0.5\mylenA\rlap{\usebox\myboxA}{\hskip 0.5\mylenA\usebox\myboxB}%
\fi}
\makeatother
\newcommand\strictCeilB[1]{\left|\!\xoverline[1.1]{#1}\!\right|}

\begin{document}
Using TikZ: Some text $\strictCeilA{N^\ast}$ some text.

Using negative space/kerning: Some text $\strictCeilB{N^\ast}$ some text.

\end{document}

• Fabulous, I went with the tikz solution since I'm already using tikz and it seemed a lot simpler. – Leo Simon Feb 11 '17 at 15:15
• @LeoSimon It depends on what you mean by simpler. If you trace what's happening in the background, the tikz solution will generate tons of log file, whereas the other solution (or even better, the solution by @GustavoMezzetti) requires hardly any computation by TeX. – gernot Feb 11 '17 at 15:41