Ask Your Question
1

Sagecells linked cells

asked 2020-09-18 09:55:59 +0100

Cyrille gravatar image

updated 2021-08-11 14:09:37 +0100

FrédéricC 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
2

answered 2020-09-18 15:09:14 +0100

slelievre gravatar image

updated 2020-09-18 19:04:58 +0100

SageCell linked cells

Documentation

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.

Examples

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

Comments

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 18:37:45 +0100 )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 11:01:22 +0100 )edit

Cyrille,

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 12:09:57 +0100 )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 18:22:37 +0100 )edit
0

answered 2020-09-22 05:51:44 +0100

Cyrille gravatar image
<body>

<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 
a
</script>
</div>

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


<div class="sage1">
<script type="text/x-sage">
c=n(sin(a))
show(c)
show(b)
</script>
</div>

<div class="sage2">
<script type="text/x-sage">
show(b)
show(c)
</script>
</div>

<body>
</html>
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

Stats

Asked: 2020-09-18 09:55:59 +0100

Seen: 550 times

Last updated: Sep 22 '20