Ask Your Question

how to render html or latex tables in jupyter notebook?

asked 2016-09-09 07:34:33 -0500

stan gravatar image

Dear all, I moved a few of my sagenb worksheets to jupyter, but I don't seem to be able to nicely display tables. For example:

blah = [('Header1', 'Header2'), (1,2), (3,4), (5,6)]

returns the html code for the table, but does not render it. Is there a way to display a nicely typeset table in the jupyter notebook using the sage kernel? Cheers Stan

edit retag flag offensive close merge delete


Did you try pretty_print() around the html? That may be the new way to do it.

kcrisman gravatar imagekcrisman ( 2016-09-09 07:52:53 -0500 )edit
kcrisman gravatar imagekcrisman ( 2016-09-09 09:44:56 -0500 )edit

And finally, you may want to add %%html or %html at the top of such a cell and see if that gives what you want.

kcrisman gravatar imagekcrisman ( 2016-09-09 09:45:22 -0500 )edit

on sage 7.4beta1 I get in the jupyter notebook:

DeprecationWarning: use table() instead of html.table()

(and a nicely rendered html table) If I do:


I get the desired result immediately. I'm not sure if 7.3 already does this as well, but upgrading or waiting until 7.4 is released and then upgrading should make your life easier.

nbruin gravatar imagenbruin ( 2016-09-09 14:15:36 -0500 )edit

Thanks a lot! I hadn't realised that I was still running Sage 6.8, as I had problems with 7.3. I can confirm now that table(blah) displays nicely in 7.3

stan gravatar imagestan ( 2016-09-13 06:42:20 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-09-10 03:03:39 -0500

Just use table(blah) instead of html.table(blah).

In the Sage REPL the table will be rendered as text:

sage: blah = [('A', 'B', 'C'), (0, 1, 2), (3, 4, 5), (6, 7, 8)]
sage: table(blah)
  A   B   C
  0   1   2
  3   4   5
  6   7   8

In a Juypter notebook Sage worksheet the table will be rendered as html.

Here is a screenshot from this sage-devel post by Volker Braun.

HTML table in Jupyter notebook Sage worksheet

edit flag offensive delete link more

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


Asked: 2016-09-09 07:34:33 -0500

Seen: 749 times

Last updated: Sep 10 '16