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

Jupyter and tikz picture #19515

Open
sagetrac-elixyre mannequin opened this issue Nov 3, 2015 · 10 comments
Open

Jupyter and tikz picture #19515

sagetrac-elixyre mannequin opened this issue Nov 3, 2015 · 10 comments

Comments

@sagetrac-elixyre
Copy link
Mannequin

sagetrac-elixyre mannequin commented Nov 3, 2015

This code provides a fix to use the function view on object represented by a picture tikz, in the jupyter notebook (or ipython I guess).

I don't understand the goal of #18116 (the code of this ticket does not work on my sage 6.9) and why the function show is better than view but... whatever my code works (see the joint notebook)!

CC: @jplab @seblabbe @vbraun @VivianePons @cheuberg @JeremiasE

Component: notebook

Keywords: notebook, tikz, ipython, jupyter

Author: Jean-Baptiste Priez

Branch/Commit: u/elixyre/jupyter @ c51513c

Issue created by migration from https://trac.sagemath.org/ticket/19515

@sagetrac-elixyre sagetrac-elixyre mannequin added this to the sage-6.10 milestone Nov 3, 2015
@sagetrac-elixyre
Copy link
Mannequin Author

sagetrac-elixyre mannequin commented Nov 3, 2015

Attachment: jupyter vs tikz picture.ipynb.gz

jupyter vs tikz

@sagetrac-elixyre
Copy link
Mannequin Author

sagetrac-elixyre mannequin commented Nov 3, 2015

Attachment: jupyter vs tikz picture.pdf.gz

version pdf...

@dkrenn
Copy link
Contributor

dkrenn commented Nov 6, 2015

comment:2

I've tried your patch, but appearently I'm doing something wrong:

  1. checkout your branch, ./sage -b (or make)

  2. ./sage -n jupyter

3a) New notebook with

view(transducers.GrayCode())

opens a pdf and shows the transducer there (not embedded)

3b) New notebook with

sage.misc.latex.EMBEDDED_MODE = True
view(transducers.GrayCode())

returns

<IPython.core.display.Image object>

Any ideas?

@sagetrac-elixyre
Copy link
Mannequin Author

sagetrac-elixyre mannequin commented Nov 7, 2015

comment:3

Hello Daniel,

I don't if it is significant but I run

sage -ipython notebook

and

sage -n jupyter

fails on my mac os laptop with sage 6.9.

I think the problem is that tikz is not loaded by default. I use the following lines in my config file 00-init.ipy :

from sage.misc.latex import latex
latex.add_package_to_preamble_if_available("tikz")
latex.add_to_mathjax_avoid_list("tikz")
sage.misc.latex.EMBEDDED_MODE = True

This helps?

@dkrenn
Copy link
Contributor

dkrenn commented Nov 10, 2015

comment:4

Replying to @sagetrac-elixyre:

I don't if it is significant but I run

sage -ipython notebook

and

sage -n jupyter

fails on my mac os laptop with sage 6.9.

Makes not difference for me

I think the problem is that tikz is not loaded by default. I use the following lines in my config file 00-init.ipy :

Maybe I have 00-init.ipy in some wrong place (didn't use it up to now). Where should this file be located?

from sage.misc.latex import latex
latex.add_package_to_preamble_if_available("tikz")
latex.add_to_mathjax_avoid_list("tikz")
sage.misc.latex.EMBEDDED_MODE = True

This helps?

I've put this directly into a notebook cell, but this didn't change anything; it still doesn't work.

PS: I have a Linux machine (Linux Mint 17.2; since you mentioned some other OS)

@sagetrac-elixyre
Copy link
Mannequin Author

sagetrac-elixyre mannequin commented Nov 10, 2015

comment:5

The file 00-init.ipy is located in $HOME/.sage/ipython_genutils-0.1.0/profile_default/startup/.
My file contains exactly:

from sage.all import *
from sage.misc.latex import latex
latex.add_package_to_preamble_if_available("tikz")
latex.add_to_mathjax_avoid_list("tikz")
sage.misc.latex.EMBEDDED_MODE = True

If it does not work... I have no idea how to fix that...

@jdemeyer
Copy link

comment:6

You might want to test this on top of #19566.

@dkrenn
Copy link
Contributor

dkrenn commented May 22, 2016

comment:7

Replying to @jdemeyer:

You might want to test this on top of #19566.

Indeed, I now have a transducer viewed within the Jupyter notebook.

@dkrenn
Copy link
Contributor

dkrenn commented May 22, 2016

comment:8

Replying to @sagetrac-elixyre:

The file 00-init.ipy is located in $HOME/.sage/ipython_genutils-0.1.0/profile_default/startup/.
My file contains exactly:

from sage.all import *
from sage.misc.latex import latex
latex.add_package_to_preamble_if_available("tikz")
latex.add_to_mathjax_avoid_list("tikz")
sage.misc.latex.EMBEDDED_MODE = True

Can this be set automatically (by default) when using the (Jupyter) notebook?

@vbraun
Copy link
Member

vbraun commented May 22, 2016

comment:11

Mucking around with EMBEDDED_MODE global variables is phenomenally fugly, we should work to get rid of that. Most certainly we should not build new stuff that relies on it.

Also, this ticket doesn't let you do anything useful with the pdf file besides immediately showing it, it still doesn't work as displayhook, and further deepens the weird differences between view/show/pretty_print.

@mkoeppe mkoeppe removed this from the sage-6.10 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants