# Manually controlled size of delimiters in macros

I am using the amsmath package and I'd like to control the size of my delimiters manually, i.e. using the \bigl, \Bigl, ... , \Bigr, \bigr commands, instead of \left, \middle, \right.

Now I want to create macros which include delimiters and I want to have the size as an argument. For example, if I have a \set macro:

\newcommand{\set}[2]{ \left\{ #1 \,\middle\vert\, #2\right\} }


I want to change it into a command, where I can give the size as an argument, i.e.

\set{A}{B}{Big}


should produce \Bigl\{ A \,\Big\vert\, B\Bigr\} or, even better, \set{A}{B}{2} produces this result.

Is there any command like \leftdelimitersize to implement this kind of macros?

-
The mathtools package has features that should help you. – egreg Mar 17 '13 at 13:20
And also this question. Which has a different way of implementing it than the mathtools package. – Manuel Mar 17 '13 at 13:24
Something here tex.stackexchange.com/questions/100966/… might help. In that case, \scalerel was used, but if you wish to define the size, the sister routine \scaleto or \stretchto might suffice. – Steven B. Segletes Mar 17 '13 at 15:17
Thanks a lot for those links. – Greyfox Mar 17 '13 at 16:29

The package mathtools already provides the necessary features; you just have to add the possibility of using numbers instead of the commands \big and siblings.

\documentclass{article}
\usepackage{mathtools}

\DeclarePairedDelimiterX{\innset}[2]{\lbrace}{\rbrace}{%
#1\;\delimsize\vert\;#2}

\newcommand{\set}[3][0]{%
\ifcase#1\relax
\innset{#2}{#3}\or         % 0
\innset[\big]{#2}{#3}\or   % 1
\innset[\Big]{#2}{#3}\or   % 2
\innset[\bigg]{#2}{#3}\or  % 3
\innset[\Bigg]{#2}{#3}     % 4
\else
\innset*{#2}{#3}
\fi}

\begin{document}
\begin{gather*}
\set{A}{\frac{B}{C}}\\
\set[0]{A}{\frac{B}{C}}\\
\set[1]{A}{\frac{B}{C}}\\
\set[2]{A}{\frac{B}{C}}\\
\set[3]{A}{\frac{B}{C}}\\
\set[4]{A}{\frac{B}{C}}\\
\set[-1]{A}{\frac{B}{C}}
\end{gather*}
\end{document}


With a number not in the range 0–4, the version with \left, \middle and \right would be used.

-
The numbers are much more memorable than the names! – Ryan Reich Mar 17 '13 at 14:44

If you are prepared to take something like Big as an argument then a simple solution to your request is to use \csname ...\endcsname to generate command names as needed, e.g.,

\newcommand\set[3]{\csname #3l\endcsname\{#1%
\,\csname#3\endcsname\vert\,%
#2\csname #3r\endcsname\}}


If you want to generate the needed commands via a numerical argument consider using \ifcase.

-