Added the bra and ket commands for Dirac notation support#134
Added the bra and ket commands for Dirac notation support#134Happypig375 merged 4 commits intoverybadcat:masterfrom
Conversation
Happypig375
left a comment
There was a problem hiding this comment.
Additional tests should also be added to CSharpMath.Rendering.Tests. Test cases are located in TestRenderingMathData.cs, run all tests once to generate a reference picture so that future changes will render correctly.
CSharpMath/Atom/LaTeXParser.cs
Outdated
| return new LargeOperator(operatorname, null); | ||
| case "bra": | ||
| var braContents = BuildInternal(true); | ||
| return new Inner(new Boundary("〈"), braContents ?? new MathList(), new Boundary("|")); |
There was a problem hiding this comment.
When BuildInternal returns null, an parsing error has occured. braContents and kerContents should be checked for null and return null.
There was a problem hiding this comment.
Fixed in the latest commit.
| }) | ||
| ); | ||
| Assert.Equal(@"\ket{i}", LaTeXParser.MathListToLaTeX(list).ToString()); | ||
| } |
There was a problem hiding this comment.
Additional tests regarding parsing errors inside \bra and \ket should be added to TestErrors at the bottom of this file. The current implementation doesn't handle these cases correctly.
There was a problem hiding this comment.
Ok, I replicated some of the parsing error tests for powers and \sqrt.
|
The documentation states that Also, a comment should be left linking to the package provided in the post. |
- Changed \bra and \ket to \Bra and \Ket - Added a comment linking back to the original LaTeX package - Added parse error unit tests for \Bra and \Ket
|
I've made all of the requested changes. Let me know if there's anything else you need. |
|
@jclapis Thank you for your contribution! |
This pull request adds the
\bra{}and\ket{}commands, which are useful shorthand commands for work involving quantum mechanics and Dirac notation.Example of a common use case:

Their implementation is inspired by the popular braket LaTeX package.