[Tex/LaTex] different plus/minus within braket environment

symbols

I m using the braket notation to write a physics report (with the braket package). Writing a plus and a minus within a ket or a bra looks really ugly (bra is < | and ket is | > )
Are there any ideas on how to make it look better? having a line like this:

|1,-1>=<--|1, -1>|-->+<-+|1, -1>|-+>+<+-|1, -1>|+ -> etc

is pretty unreadable in the pdf, as the pluses/minuses inside and outside the braket notation are indistinguishable. The idea is that a smaller or smaller and thicker plus/minus only within the braket notation would make it more readable, only I don't know if such a symbol exists. Would I have to create it manually? I d like to avoid that, as it would decrease my typing speed seriously, even with a shortcut..

Best Answer

I am not too sure what font to use for the internal + and -, so I just used \hbox{\texttt{+}}. In TeX, each character has a \mathcode, describing its behavious in maths. All of them lie between "0000 and "7FFF (in hexadecimal), except the special mathcode "8000, which makes the character act like an active character. Within the group which \bra, \ket and \braket define, I get + and - to be active and expand to \braket@inner@minus and \braket@inner@plus.

\documentclass{article}
\usepackage{braket}

\makeatletter
\newcommand{\braket@inner@minus}{\hbox{\texttt{-}}}
\newcommand{\braket@inner@plus}{\hbox{\texttt{+}}}
\begingroup
\catcode`\-=13\relax %active
\catcode`\+=13\relax %active
\@firstofone{\endgroup %end the local changes to catcodes.
  \newcommand\braket@inner@defs{%
    \edef\restore@mathcode{%
      \mathcode`\noexpand +=\the\mathcode`+%
      \mathcode`\noexpand -=\the\mathcode`-%
    }%
    \mathcode`\+="8000\relax
    \mathcode`\-="8000\relax
    \def+{\begingroup\restore@mathcode\braket@inner@plus\endgroup}%
    \def-{\begingroup\restore@mathcode\braket@inner@minus\endgroup}%
  }%
}
% old definition:
% \newcommand{\bra}[1]{\mathinner {\langle {#1}|}}
% new definition:
\renewcommand{\bra}[1]{\mathinner {\langle \braket@inner@defs {#1}|}}
\renewcommand{\ket}[1]{\mathinner {|\braket@inner@defs{#1}\rangle }}
\renewcommand{\braket}[1]{\mathinner {\langle \braket@inner@defs {#1}\rangle }}
\makeatother

\begin{document}
\[
\bra{++--}A^\dag A\ket{-+-+} = \braket{++--|A^\dag A|-+-+} = \cdots
\]
However, 
\[
\bra{++}(A+B)\ket{--} \neq \braket{++|(A+B)|--}
\]
\end{document}