Ask Your Question

Sagecells linked cells

asked 2020-09-18 02:55:59 -0500

Cyrille gravatar image

I need the help of some one who is used with sagemath cells. I have seen that in an html page sagemath cells can be linked.I hope this permit to not repeat the code cells after cells when you need a previous result (even if it is recalculated I think). But without exemple on github my nearly zero knowledge on js forbid me to try to manage this.

In advance thank to the one who will help me.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2020-09-18 08:09:14 -0500

slelievre gravatar image

updated 2020-09-18 12:04:58 -0500

SageCell linked cells


The "About" section of the SageCell website home page has these paragraphs:

SageMathCell project is an easy-to-use web interface to a free open-source mathematics software system SageMath.

It allows embedding Sage computations into any webpage: check out short instructions or comprehensive description of capabilities.

with the following links:

That "comprehensive description of capabilities" page has a section dedicated to your question:

which says

When multiple input locations are given, this sets whether the code from these cells is to be executed from the same kernel, so that code executed in one will affect the execution of code from another cell:

{ ..
linked: boolean
.. }

This option is false by default.

So try using linked: true.


Many pages online use SageCell with linked cells.

PreTeXt is an authoring system allowing, in addition to (or instead of) a pdf version of documents, to produce an html version with executable code cells, using SageCell.

The PreTeXt home page links to a few examples, including:

which has a page about using Sage via SageCell:

See in particular

which conveniently has several cells.

Try typing a = 2 in the first one, executing (by hitting Shift+Enter or by clicking the "Execute" button) and then typing a^2 in the second one and executing.

Check the source code of that page and search the word "linked" there (e.g. using cmd-F or ctrl-F).

For many more example, see the PreTeXt gallery or the PreTeXt catalog.

edit flag offensive delete link more


slelievre I have read this but practicaly I do not know how to use it. For instance

1) where do I write this code in my page. 2) how should I say "This code is a part of my new computation".

I would be pleased if you could show me how to write two cells one with A=2 (the input) and for instance A^2 in the second cell. I have asked a computer scientist to help me but he say that the github explanation is not clear enough.

Cyrille gravatar imageCyrille ( 2020-09-18 11:37:45 -0500 )edit

slelievre I appreciate trully your efforts but all this stuff is incomprenhensible for a dummy like me. In revanche, I have founded the solution which was well hidden. But there are some thing I cannot find like how to change the color of the background of the Sagemath cell, the color of the text and of the background of the button and more important to replace the button by an image. If you really know how to do this. I will be please to learn.

Cyrille gravatar imageCyrille ( 2020-09-19 04:01:22 -0500 )edit


Those latter questions relate to HTML design (and have nothing Sage-specific), and would be best asked on an HTML mailing list or forum.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2020-09-19 05:09:57 -0500 )edit

@Cyrille if you have a good answer to your own question, please post it as an answer here.

It could help someone who runs into the same question in the future.

slelievre gravatar imageslelievre ( 2020-09-19 11:22:37 -0500 )edit

answered 2020-09-21 22:51:44 -0500

Cyrille gravatar image

<p> The following cell is likned to the third , the second one to the fourth. </p> 

<script>sagecell.makeSagecell({"inputLocation": ".sage1", linked: true});</script>
<div class="sage1">
<script type="text/x-sage">
a = 2 

<script>sagecell.makeSagecell({"inputLocation": ".sage2", linked: true});</script>
<div class="sage2">
<script type="text/x-sage">

<div class="sage1">
<script type="text/x-sage">

<div class="sage2">
<script type="text/x-sage">

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: 2020-09-18 02:55:59 -0500

Seen: 47 times

Last updated: Sep 21