ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 03 Sep 2021 23:46:50 +0200There is a way to use tikz-cd in a sage notebook?https://ask.sagemath.org/question/58808/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?Thu, 02 Sep 2021 20:38:29 +0200https://ask.sagemath.org/question/58808/there-is-a-way-to-use-tikz-cd-in-a-sage-notebook/Comment by Masacroso for <p>Using sagemath via jupyterlab I saw that in a code cell we can use the magic command <code>%%latex</code> 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?</p>
https://ask.sagemath.org/question/58808/there-is-a-way-to-use-tikz-cd-in-a-sage-notebook/?comment=58814#post-id-58814I see @JohnPalmieri, maybe there is a way to produce images directly from latex in a different way?Fri, 03 Sep 2021 02:17:03 +0200https://ask.sagemath.org/question/58808/there-is-a-way-to-use-tikz-cd-in-a-sage-notebook/?comment=58814#post-id-58814Comment by John Palmieri for <p>Using sagemath via jupyterlab I saw that in a code cell we can use the magic command <code>%%latex</code> 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?</p>
https://ask.sagemath.org/question/58808/there-is-a-way-to-use-tikz-cd-in-a-sage-notebook/?comment=58813#post-id-58813I think that in the notebook, `%%latex` is restricted to what MathJax can handle: https://docs.mathjax.org/en/v2.5-latest/tex.html. You can use AMS-cd, I believe, but not tikz-cd.Fri, 03 Sep 2021 00:56:47 +0200https://ask.sagemath.org/question/58808/there-is-a-way-to-use-tikz-cd-in-a-sage-notebook/?comment=58813#post-id-58813Answer by Masacroso for <p>Using sagemath via jupyterlab I saw that in a code cell we can use the magic command <code>%%latex</code> 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?</p>
https://ask.sagemath.org/question/58808/there-is-a-way-to-use-tikz-cd-in-a-sage-notebook/?answer=58825#post-id-58825I found a solution, installing the package for ipython `itikz` from [there](https://github.com/jbn/itikz) and also installing `pdf2svg`from [here](https://github.com/dawbarton/pdf2svg). 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`.Fri, 03 Sep 2021 14:58:36 +0200https://ask.sagemath.org/question/58808/there-is-a-way-to-use-tikz-cd-in-a-sage-notebook/?answer=58825#post-id-58825Comment by John Palmieri for <p>I found a solution, installing the package for ipython <code>itikz</code> from <a href="https://github.com/jbn/itikz">there</a> and also installing <code>pdf2svg</code>from <a href="https://github.com/dawbarton/pdf2svg">here</a>. Then you can run in a cell <code>%load_ext itikz</code> and after, in another cell, write</p>
<pre><code>%%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}
</code></pre>
<p>and it works perfectly.</p>
<p>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 <code>sage -pip install</code> instead of just <code>pip install</code>.</p>
https://ask.sagemath.org/question/58808/there-is-a-way-to-use-tikz-cd-in-a-sage-notebook/?comment=58827#post-id-58827Maybe from within the notebook, `%pip install itikz` would work.Fri, 03 Sep 2021 23:46:50 +0200https://ask.sagemath.org/question/58808/there-is-a-way-to-use-tikz-cd-in-a-sage-notebook/?comment=58827#post-id-58827