Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
3

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

asked 3 years ago

Masacroso gravatar image

updated 3 years ago

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?

Preview: (hide)

Comments

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.

John Palmieri gravatar imageJohn Palmieri ( 3 years ago )

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

Masacroso gravatar imageMasacroso ( 3 years ago )

1 Answer

Sort by » oldest newest most voted
3

answered 3 years ago

Masacroso gravatar image

updated 3 years ago

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}
\usepackage{adjustbox}
\begin{document}
\adjustbox{scale=3,center}{%
    \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.

Preview: (hide)
link

Comments

1

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

John Palmieri gravatar imageJohn Palmieri ( 3 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 3 years ago

Seen: 487 times

Last updated: Sep 03 '21