# There is a way to use tikz-cd in a sage notebook?

Using sagemath via jupyterlab I saw that in a code cell we can use the magic command %%latex at the beginning to write after custom $\LaTeX$. However I didn't see a way to setup a preamble or so to use latex libraries like tikz-cd. So my question is, there is a way to use latex libraries like tikz-cd with sagemath?

edit retag close merge delete

1

I think that in the notebook, %%latexis restricted to what MathJax can handle: https://docs.mathjax.org/en/v2.5-late.... You can use AMS-cd, I believe, but not tikz-cd.

( 2021-09-03 00:56:47 +0200 )edit

I see @JohnPalmieri, maybe there is a way to produce images directly from latex in a different way?

( 2021-09-03 02:17:03 +0200 )edit

Sort by » oldest newest most voted

I found a solution, installing the package for ipython itikz from there and also installing pdf2svgfrom here. Then you can run in a cell %load_ext itikz and after, in another cell, write

%%itikz
\documentclass{standalone}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
X \arrow[r, hook] \arrow[dr, dashrightarrow]
& \bar{X} \arrow[d]\\
& Y
\end{tikzcd}
}
\end{document}


and it works perfectly.

P.S.: be careful, if you are using sagemath from a binary (not installed in the system) then the above packages must be installed with sage -pip install instead of just pip install.

more

1

Maybe from within the notebook, %pip install itikz would work.

( 2021-09-03 23:46:50 +0200 )edit