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

Enhancement: latex to SVG #317

Closed
ea42gh opened this issue Aug 25, 2020 · 8 comments
Closed

Enhancement: latex to SVG #317

ea42gh opened this issue Aug 25, 2020 · 8 comments
Labels
other packages Integration with other Julia packages

Comments

@ea42gh
Copy link

ea42gh commented Aug 25, 2020

It might be nice to support a latex to SVG capability, something along the lines
https://github.com/jbn/itikz
for jupyter

@fonsp
Copy link
Owner

fonsp commented Aug 25, 2020

Could you elaborate?

@ea42gh
Copy link
Author

ea42gh commented Aug 25, 2020

I could write a function taking a string of valid tex:
      write it to a file,
      run latex a suitable number of times,
      convert the result to an SVG
      read and display the SVG file.

I don't know how best to incorporate such a facility.
With itikz in jupyter, I can write

%%itikz --temp-dir --implicit-standalone --tex-packages=nicematrix,tikz --nexec=4
\NiceMatrixOptions{code-for-last-row = \color{red}, code-for-first-row = \color{red}}
$\begin{pNiceArray}{cccc|c}[left-margin = 4pt, first-col, last-row,
    code-before =
    {
    \tikz \draw[red] (row-1-|col-1) -- (row-2-|col-1) -- (row-2-|col-3) -- (row-3-|col-3) -- (row-3-|col-6);
    }
]
                               & \color{red}{1}   & 2 & 1                  & 1 & \;  5 \\
                               & 0                    & 0 & \color{red}{2} & 1 & \; -1 \\
                               & 0                    & 0 & 0                  & 0 &     0 \\
\color{blue}{\begin{matrix} \text{basic variables} \\ \text{free variables} \end{matrix}} & \begin{matrix}\ x_1 \\ \\ \end{matrix} & \begin{matrix}\\ \ x_2=\alpha \\ \end{matrix} & \begin{matrix}\ x_3\\ \\ \end{matrix} & \begin{matrix} \\ \ x_4=\beta \\ \end{matrix} & \\
\end{pNiceArray}$

and get a display of a matrix with some annotations (using a latex package and tikz),
i.e., I am not limited by the capabilities of markdown

@Masacroso
Copy link

It might be nice to support a latex to SVG capability, something along the lines
https://github.com/jbn/itikz
for jupyter

If there is support for tikzcd also (not just tikz) this would be amazing to embed directly commutative diagrams in SVG format instead of doing it externally with LaTeX and after putting the SVG in the notebook using some link.

@fonsp
Copy link
Owner

fonsp commented Aug 30, 2020

This sounds like something that an external package should do, right?

Julia macros can support the syntax that you are looking for, run latex, etc, and Pluto can display SVGs.

@fonsp
Copy link
Owner

fonsp commented Aug 30, 2020

You could ask in the Julia slack about packages that wrap TeX.

@fonsp fonsp added the other packages Integration with other Julia packages label Aug 30, 2020
@ea42gh
Copy link
Author

ea42gh commented Aug 30, 2020

I succeeded doing this using PyCall and a modified version of itikz
Look at my cloned itikz repository at
GitHub
and the two test_* jupyter notebooks.

added a commutative diagram example from tikzcd :)
note there is a function that returns the SVG text, rather than the SVG image.
I imagine it could be used to incorporate the output in a more elaborate layout

@fonsp
Copy link
Owner

fonsp commented Aug 30, 2020

Cool! Can we close this then?

@ea42gh
Copy link
Author

ea42gh commented Aug 30, 2020

If you choose too, sure.
I think Lluto.jl might profit from having such a capability built in from the outset.

Now while I am wishing for the stars,
if I could also get the pyviz tool stack going!
:)

@ea42gh ea42gh closed this as completed Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
other packages Integration with other Julia packages
Projects
None yet
Development

No branches or pull requests

3 participants