Skip to main content
1 of 2
Ilia
  • 237
  • 1
  • 6

Need a new Latex command for square brackets

I've already encountered in this site complaints that in the standard font, the horizontal lines (serifs) in the image of square brackets are too short and difficult to visually distinguish. As a workaround, some suggest using overlapping "ceil" and "floor" symbols instead of square brackets. However, this results in unacceptably long serifs.

I need a new command for something intermediate and very limited in use. I don't intend to use it for matrices or any other multi-line environment. Just one short text string between brackets. Unable to find a suitable ready-made solution, I decided to write such a command myself. After all, it's just one vertical bar and two horizontal serifs. This is what I got so far.

\newcommand{\LBR}{
    \hspace{0.2em}\rule[0.75em]{0.2em}{0.05em}% top serif
    \hspace{-0.2em}\rule[-0.2em]{0.2em}{0.05em}% bottom serif
    \hspace{-0.3em}\rule[-0.2em]{0.1em}{1.0em}% vertical bar
    \hspace{0.2em}
}
\newcommand{\RBR}{
    \hspace{0.1em}\rule[0.75em]{0.2em}{0.05em}% top serif
    \hspace{-0.2em}\rule[-0.2em]{0.2em}{0.05em}% bottom serif
    \rule[-0.2em]{0.1em}{1.0em}% vertical bar
    \hspace{0.2em}
}
\newcommand{\opni}[1] {{\RBR #1 \LBR}}
\newcommand{\opcli}[1]{{\RBR #1 \RBR}}
\newcommand{\clopi}[1]{{\LBR #1 \LBR}}
\newcommand{\clsi}[1] {{\LBR #1 \RBR}}

Although not very pretty, this solution is more or less satisfactory - except for two problems. First, in some random cases the vertical bar and one of serifs are too thick. Second and more important, the brackets are not scaled inside superscript, for example, in an expression like $\mathbb{R}^\clsi{a,b}$.

The reason for the first problem I don't understand. The reason for the second I understand, but have no idea what to do about it. Any help is appreciated.

Ilia
  • 237
  • 1
  • 6