Significant EDIT:
Stimulated by the comments of the users egreg and schtandard, I found a solution to my original problem. Now, the problem has slightly changed, but it is still about the control between text and brackets with the braket
page.
As in the title of the question, I would like to modify the package braket (in the link the whole .sty
file, which is quite small) to control the space between the brackets and the text.
This question is a follow up of this previous question of mine: Modify braket package for different brackets forms.
Thus, the idea is that I would like to adapt this sty
file to make it work with other brackets (as in the previous question) and to have different spacings for all those new brackets. If you are wondering why I want to modify braket
instead of writing my own macro, the reason is that doing this would be way above my level (which should not be surprising considering the level of this question).
Here there is an example of what I would like to get in the sty
file.
\documentclass{article}
\usepackage{braket}
\begin{document}
$\Set { a | b }$
$A \Foo { \hspace{-0.1cm} a \hspace{-0.1cm}| \hspace{-0.1cm}b \hspace{-0.1cm} }$
\end{document}
We can call \Foo
the command that should correspond to the second line, which should look something like A(a|b).
To get what I want, the line from braket
should be modified as follows:
{\catcode`\|=\active
\xdef\Foo{\protect\expandafter\noexpand\csname Foo \endcsname}
\expandafter\gdef\csname Foo \endcsname#1{\mathinner
{\lbrace\,{\mathcode`\|32768\let|\midvert #1}\,\rbrace}}
\xdef\Foo{\protect\expandafter\noexpand\csname Foo \endcsname}
\expandafter\gdef\csname Foo \endcsname#1{\left(
%
\ifx\SavedDoubleVert\relax \let\SavedDoubleVert\|\fi
%\:
{\let\|\FooDoubleVert
\mathcode`\|32768\let|\FooVert
#1}
%\:
\right)}
}
\def\midvert{\egroup\mid\bgroup}
\def\FooVert{\@ifnextchar|{\|\@gobble}% turn || into \|
{\egroup
%\;
\mid@vertical
%\;
\bgroup}}
\def\FooDoubleVert{\egroup
%\;
\mid@dblvertical
%\;
\bgroup}
The code above is nothing more than the code from braket
regrouped for readability reasons, with:
Foo
instead ofSet
,\left(
and\right)
instead of\left\{
and\right\}
,- and with the horizontal spacing commands
\:
and\;
commented.
This is enough to get one part of the result.
The bit that is missing is the following:
How do we control in
braket
the space in the line of codeA \Foo { a | b }
between the letter "A" and the bracket "("?
Here there are two examples of commands that should be created in braket
to achieve the following output.
% Command Fou
$A \hspace{3cm} \Set { \hspace{3cm} a \hspace{-0.1cm} | \hspace{-0.05cm} b \hspace{5cm} }$
%Command Fouo
$A \hspace{-0.05cm} \Set { \hspace{-0.05cm} a \hspace{-0.1cm} | \hspace{-0.1cm} b \hspace{-0.05cm} }$
Any help is going to be greatly appreciated!
$\Set { a | b }$
.braket
at all? It seems to me you want to remove the features it provides. Why not just write\(\{a|b\}\)
or define a macro that does that? If you want an explanation of why what you tried did not work, you really should include an MWE showing exactly how you tried it and what did not work. Just describing what you did without actually showing it leaves a lot of room for interpretation (i.e. guessing and misunderstanding).