I really don't know how to properly modify codes. Still, my problem is that I would like to know how to modify the following code from the package braket (in the link the whole .sty file, which is quite small btw, the code below is more than half of the entire code) to get it work for all sort of brackets.
Here there is the piece of code from the link I think is relevant here:
% \Set{...|...} Only the first | is treated specially.
{\catcode`\|=\active
\xdef\set{\protect\expandafter\noexpand\csname set \endcsname}
\expandafter\gdef\csname set \endcsname#1{\mathinner
{\lbrace\,{\mathcode`\|32768\let|\midvert #1}\,\rbrace}}
\xdef\Set{\protect\expandafter\noexpand\csname Set \endcsname}
\expandafter\gdef\csname Set \endcsname#1{\left\{%
\ifx\SavedDoubleVert\relax \let\SavedDoubleVert\|\fi
\:{\let\|\SetDoubleVert
\mathcode`\|32768\let|\SetVert
#1}\:\right\}}
}
\def\midvert{\egroup\mid\bgroup}
\def\SetVert{\@ifnextchar|{\|\@gobble}% turn || into \|
{\egroup\;\mid@vertical\;\bgroup}}
\def\SetDoubleVert{\egroup\;\mid@dblvertical\;\bgroup}
% If the user is using e-TeX with its \middle primitive, use that for
% verticals instead of \vrule.
%
\begingroup
\edef\@tempa{\meaning\middle}
\edef\@tempb{\string\middle}
\expandafter \endgroup \ifx\@tempa\@tempb
\def\mid@vertical{\middle|}
\def\mid@dblvertical{\middle\SavedDoubleVert}
\else
\def\mid@vertical{\mskip1mu\vrule\mskip1mu}
\def\mid@dblvertical{\mskip1mu\vrule\mskip2.5mu\vrule\mskip1mu}
\fi
Thus, I would like to know how to modify the code to create new commands (e.g. a command \Name) such that I get – say – square brackets, and the delimiter | still adapts in the middle to the size of the brackets.
How to do it?
Any feedback is most welcome!
PS: Actually, the idea of the original developer was exactly to give the flexibility to all users to modify braket in their own way... however I am clearly a not sophisticated enough user. :)
\Name, and how to get the vertical bar by just inserting $|$ (as in braket, which is very handy), instead of writing\given. – Kolmin Oct 07 '16 at 07:27\givenwith the simple symbol|. Do you have any idea on how to implement it? Btw, I edited the original question inserting the piece of code frombraket. – Kolmin Oct 07 '16 at 09:29braket, it should suffice to replace all instances ofsetandset(but not\SetVertand\SetDoubleVert) withnameandName, respectively, and replace\lbraceand\rbracewith the desired left and right brackets. – Emma Oct 07 '16 at 14:44|in place of\givenin themathtoolsexample I gave, add\providecommand\given{\vert} \catcode\|=\active \def|{\given}to the preamble. Note, however, that this will break usage of||as shorthand for a double vertical line (also achievable with\Vertor|, which will not be broken) throughout the document. It looks like this is fixed in thebraketcode, but I haven't been able to adapt the fix to themathtools` setting. – Emma Oct 07 '16 at 14:53\lbraceand\rbrace(from thebraketpackage code) with the desired left and right brackets, also remember that\{is a synonym for\lbraceand similarly\}is a synonym for\rbrace, so these also need to be replaced. For some reason, the (short)braketpackage code uses both versions. – Ari Brodsky Jul 06 '18 at 08:44