Ask Your Question
3

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

asked 2021-09-02 20:38:29 +0200

Masacroso gravatar image

updated 2021-09-03 02:15:47 +0200

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 flag offensive close merge delete

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 ( 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?

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

1 Answer

Sort by ยป oldest newest most voted
3

answered 2021-09-03 14:58:36 +0200

Masacroso gravatar image

updated 2021-09-03 23:27:20 +0200

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.

edit flag offensive delete link more

Comments

1

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

John Palmieri gravatar imageJohn Palmieri ( 2021-09-03 23:46:50 +0200 )edit

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: 2021-09-02 20:38:29 +0200

Seen: 346 times

Last updated: Sep 03 '21