Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX math mode support #39

Open
dakusui opened this issue Oct 27, 2018 · 9 comments
Open

LaTeX math mode support #39

dakusui opened this issue Oct 27, 2018 · 9 comments

Comments

@dakusui
Copy link

dakusui commented Oct 27, 2018

It will be very useful if we can use LaTeX's math mode inside ditaa's ascii art.
That is, if we have a following ascii art,


$Box_1$                    $Box^2$
+---------------------+    +------+   /---------\
|$\sum_{i=0}^{n}x^i$  |    |$cBLU$|   |         |
|                     +--->|cRED  +-=-+cGRE$C_k$|
|{io}                 |    |cXYZ  |   |{o}      |
+----------+----------+    +---+--+   \---------/
           |                   |
           |                   :
           |                   V
           |           +-----------------+
           +---------->|$A_i$ hello $B^i$|
                       +-----------------+

$Q_u^i$, $C_k$, $B_r^{own}$, $F_{ox}$ jumps

over a lazy $d\cdot\frac{o}{g}$.


$\forall x \in X, \quad \exists y \leq \epsilon$


$\sin A \cos B =$

    $ \frac{1}{2}\left[ \sin(A-B)+\sin(A+B) \right]$


$\frac{d}{dx}\left( \int_{0}^{x} f(u)\,du\right)=f(x).$


 $v \sim \mathcal{N} (m,\sigma^2)$

I would see it rendered like this.

art-latexmath-1

I have already implemented this feature in my forked repository and am going to open a pull request soon. Please kindly consider merging it when it's opened.

@stathissideris
Copy link
Owner

This is amazing, I would gladly merge it when it's ready!

@stathissideris
Copy link
Owner

Do you think it would work with SVG output as well?

@dakusui dakusui mentioned this issue Oct 27, 2018
@dakusui
Copy link
Author

dakusui commented Oct 27, 2018

It's a great point. It will need to be a limitation for the time being.
My enhancement relies on jlatexmath for LaTeX math rendering and it does not support .svg output apparently.
There seems to be other libraries that can output .svg but not in Java (or JVM based languages), which means we'll need to figure out how to integrate such libraries in ditaa's 'uber' jar.

I would suggest supporting this feature for only .png in this pull request rather than making the change too big.

@dakusui
Copy link
Author

dakusui commented Oct 28, 2018

I have opened a pull request for this feature to have a discussion about its detail. Please have a look at it and leave your thoughts.

@paulvi
Copy link
Contributor

paulvi commented Nov 27, 2018

I wonder if it is possible to make this as addon or option? (if not merging directly because of some limitations)

@paulvi
Copy link
Contributor

paulvi commented Nov 27, 2018

@dakusui
Copy link
Author

dakusui commented Nov 27, 2018

@paulvi , what do you mean by "option"? My current plan is to make it a feature enabled by the "--latex-math" option otherwise defaulting to original behavior.

Making it an addon would be quite a bit challenging, actually.

Actually, I came to think that it might be better to go back to original code base and re-work this pull request since unless otherwise it's difficult to review the enhancement.
And if you want to try this feature, you can simply clone the repo and build it using leiningen (lein uberjar). The artifact should work fine. (If not, please just let me know. I will fix the bug.)

@paulvi
Copy link
Contributor

paulvi commented Nov 28, 2018

OK, so if thi Latext support is optional that is only enabled when "--latex-math" option is passed, than I would like to see it merged as it is.
As will / should not affect users who are not aware about it

@dakusui
Copy link
Author

dakusui commented Aug 24, 2019

Hi, after long period of busy days, I could finally find a time to work on this.
I have reworked the feature from the fresh branch and created a pull request #54 .
Please kindly have a review on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants