ForNeVeR / xaml-math

A collection of .NET libraries for rendering mathematical formulae using the LaTeX typesetting style, for the WPF and Avalonia XAML-based frameworks
MIT License
634 stars 100 forks source link

Commutator Diagrams #459

Open JohnPiwinski opened 10 months ago

JohnPiwinski commented 10 months ago

Hello,

I would first like to thank you for your heroic effort in modernizing the JMathTex library. I had previously been attempting to wrangle the CSharpMath library but to no avail due to the extreme age of the Typography library.

Would it be possible to add support for category theory diagrams?

image

If it would run the development too far afield for an existing programmer to implement, I would be happy to try my best. For simple diagrams, I image being able to create a two dimensional array of labels for the variables of a uniform spacing and then defining an interface or parent class for the arrows specifying how the rendering code should connect two labels. I do not believe that my idea would give comparable rendering to LaTeX, and I would be unlikely to assemble the glyphs from font characters so the verisimilitude of my approach would undoubtedly suffer. But, if you all are interested in a temporary solution, I would be happy to give it my best shot!

My use case is defining an interactive presentation software for my algebraic topology class. I would like to be able to embed 3d interactive diagrams into an application allowing the user to interact with the math, while a prerecorded voiceover describes the content. It would also have forward and back buttons to behave more akin to a slideshow.

ForNeVeR commented 10 months ago

I am not against that, but note that this would require some work in the area XAML-Math is lacking the most: drawing of vector lines and figures between arbitrarily placed blocks.

Also, I'm not sure about including this (if it's not directly related to any other known LaTeX implementation) in the default set of commands, though we eventually want to allow user-provided plugins and packages extending XAML-Math.

(since we have no extension mechanism in place for now, if any contributor implemented that, I think it would be okay to include it for now, until we've added such a mechanism)

If you are looking to implement this, then take a look at how the MatrixAtom is implemented. It is one of the most complex implemented atoms, and it does some things to calculate custom positioning for the nested atoms (i.e. the matrix cells).

Horizontal and vertical arrows would be pretty easy to add, though I'm not sure about the diagonal ones. The arrowheads may be drawn using a set of custom font glyphs (so you'd need to bundle a special font for several glyphs specifically, though at least we already support that and bundle several different fonts). And for diagonal/vertical lines, I think you'd also need an ability to rotate the glyphs (we currently don't have it, but it's possible to add).