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.Tue, 22 Sep 2020 05:51:44 +0200Sagecells linked cellshttps://ask.sagemath.org/question/53486/sagecells-linked-cells/ 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.Fri, 18 Sep 2020 09:55:59 +0200https://ask.sagemath.org/question/53486/sagecells-linked-cells/Answer by slelievre for <p>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.</p>
<p>In advance thank to the one who will help me.</p>
https://ask.sagemath.org/question/53486/sagecells-linked-cells/?answer=53490#post-id-53490## SageCell linked cells
### Documentation
The "About" section of the [SageCell website home page](https://sagecell.sagemath.org)
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:
- [short instructions](https://sagecell.sagemath.org/static/about.html)
- [comprehensive description of capabilities](https://github.com/sagemath/sagecell/blob/master/doc/embedding.rst)
That "comprehensive description of capabilities" page
has a section dedicated to your question:
- [linked cells](https://github.com/sagemath/sagecell/blob/master/doc/embedding.rst#linked-cells)
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](https://pretextbook.org) 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:
- [a sample of Thomas W. Judson's *Abstract Algebra* book](https://pretextbook.org/examples/sample-book/noparts/html/sets-sage.html)
which has a page about using Sage via SageCell:
- ["Sage via SageCell" in sample of Thomas W. Judson's *Abstract Algebra* book](https://pretextbook.org/examples/sample-book/noparts/html/sets-sage.html)
See in particular
- [Section 1.3.1 Executing Sage Commands](https://pretextbook.org/examples/sample-book/structural/html/sets-sage.html#subsection-5)
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](https://pretextbook.org/gallery.html)
or the [PreTeXt catalog](https://pretextbook.org/catalog.html).Fri, 18 Sep 2020 15:09:14 +0200https://ask.sagemath.org/question/53486/sagecells-linked-cells/?answer=53490#post-id-53490Comment by Cyrille for <h2>SageCell linked cells</h2>
<h3>Documentation</h3>
<p>The "About" section of the <a href="https://sagecell.sagemath.org">SageCell website home page</a>
has these paragraphs:</p>
<blockquote>
<p>SageMathCell project is an easy-to-use web interface
to a free open-source mathematics software system SageMath.</p>
<p>It allows embedding Sage computations into any webpage:
check out short instructions or
comprehensive description of capabilities.</p>
</blockquote>
<p>with the following links:</p>
<ul>
<li><a href="https://sagecell.sagemath.org/static/about.html">short instructions</a></li>
<li><a href="https://github.com/sagemath/sagecell/blob/master/doc/embedding.rst">comprehensive description of capabilities</a></li>
</ul>
<p>That "comprehensive description of capabilities" page
has a section dedicated to your question:</p>
<ul>
<li><a href="https://github.com/sagemath/sagecell/blob/master/doc/embedding.rst#linked-cells">linked cells</a></li>
</ul>
<p>which says</p>
<blockquote>
<p>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:</p>
<pre><code>{ ..
linked: boolean
.. }
</code></pre>
<p>This option is <code>false</code> by default.</p>
</blockquote>
<p>So try using <code>linked: true</code>.</p>
<h3>Examples</h3>
<p>Many pages online use SageCell with linked cells.</p>
<p><a href="https://pretextbook.org">PreTeXt</a> 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.</p>
<p>The PreTeXt home page links to a few examples, including:</p>
<ul>
<li><a href="https://pretextbook.org/examples/sample-book/noparts/html/sets-sage.html">a sample of Thomas W. Judson's <em>Abstract Algebra</em> book</a></li>
</ul>
<p>which has a page about using Sage via SageCell:</p>
<ul>
<li><a href="https://pretextbook.org/examples/sample-book/noparts/html/sets-sage.html">"Sage via SageCell" in sample of Thomas W. Judson's <em>Abstract Algebra</em> book</a></li>
</ul>
<p>See in particular</p>
<ul>
<li><a href="https://pretextbook.org/examples/sample-book/structural/html/sets-sage.html#subsection-5">Section 1.3.1 Executing Sage Commands</a></li>
</ul>
<p>which conveniently has several cells.</p>
<p>Try typing <code>a = 2</code> in the first one, executing (by hitting <code>Shift</code>+<code>Enter</code>
or by clicking the "Execute" button) and then typing <code>a^2</code> in the second one
and executing.</p>
<p>Check the source code of that page and search the word "linked" there
(e.g. using cmd-F or ctrl-F).</p>
<p>For many more example, see the <a href="https://pretextbook.org/gallery.html">PreTeXt gallery</a>
or the <a href="https://pretextbook.org/catalog.html">PreTeXt catalog</a>.</p>
https://ask.sagemath.org/question/53486/sagecells-linked-cells/?comment=53493#post-id-53493slelievre 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.Fri, 18 Sep 2020 18:37:45 +0200https://ask.sagemath.org/question/53486/sagecells-linked-cells/?comment=53493#post-id-53493Comment by Cyrille for <h2>SageCell linked cells</h2>
<h3>Documentation</h3>
<p>The "About" section of the <a href="https://sagecell.sagemath.org">SageCell website home page</a>
has these paragraphs:</p>
<blockquote>
<p>SageMathCell project is an easy-to-use web interface
to a free open-source mathematics software system SageMath.</p>
<p>It allows embedding Sage computations into any webpage:
check out short instructions or
comprehensive description of capabilities.</p>
</blockquote>
<p>with the following links:</p>
<ul>
<li><a href="https://sagecell.sagemath.org/static/about.html">short instructions</a></li>
<li><a href="https://github.com/sagemath/sagecell/blob/master/doc/embedding.rst">comprehensive description of capabilities</a></li>
</ul>
<p>That "comprehensive description of capabilities" page
has a section dedicated to your question:</p>
<ul>
<li><a href="https://github.com/sagemath/sagecell/blob/master/doc/embedding.rst#linked-cells">linked cells</a></li>
</ul>
<p>which says</p>
<blockquote>
<p>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:</p>
<pre><code>{ ..
linked: boolean
.. }
</code></pre>
<p>This option is <code>false</code> by default.</p>
</blockquote>
<p>So try using <code>linked: true</code>.</p>
<h3>Examples</h3>
<p>Many pages online use SageCell with linked cells.</p>
<p><a href="https://pretextbook.org">PreTeXt</a> 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.</p>
<p>The PreTeXt home page links to a few examples, including:</p>
<ul>
<li><a href="https://pretextbook.org/examples/sample-book/noparts/html/sets-sage.html">a sample of Thomas W. Judson's <em>Abstract Algebra</em> book</a></li>
</ul>
<p>which has a page about using Sage via SageCell:</p>
<ul>
<li><a href="https://pretextbook.org/examples/sample-book/noparts/html/sets-sage.html">"Sage via SageCell" in sample of Thomas W. Judson's <em>Abstract Algebra</em> book</a></li>
</ul>
<p>See in particular</p>
<ul>
<li><a href="https://pretextbook.org/examples/sample-book/structural/html/sets-sage.html#subsection-5">Section 1.3.1 Executing Sage Commands</a></li>
</ul>
<p>which conveniently has several cells.</p>
<p>Try typing <code>a = 2</code> in the first one, executing (by hitting <code>Shift</code>+<code>Enter</code>
or by clicking the "Execute" button) and then typing <code>a^2</code> in the second one
and executing.</p>
<p>Check the source code of that page and search the word "linked" there
(e.g. using cmd-F or ctrl-F).</p>
<p>For many more example, see the <a href="https://pretextbook.org/gallery.html">PreTeXt gallery</a>
or the <a href="https://pretextbook.org/catalog.html">PreTeXt catalog</a>.</p>
https://ask.sagemath.org/question/53486/sagecells-linked-cells/?comment=53505#post-id-53505slelievre 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.Sat, 19 Sep 2020 11:01:22 +0200https://ask.sagemath.org/question/53486/sagecells-linked-cells/?comment=53505#post-id-53505Comment by Emmanuel Charpentier for <h2>SageCell linked cells</h2>
<h3>Documentation</h3>
<p>The "About" section of the <a href="https://sagecell.sagemath.org">SageCell website home page</a>
has these paragraphs:</p>
<blockquote>
<p>SageMathCell project is an easy-to-use web interface
to a free open-source mathematics software system SageMath.</p>
<p>It allows embedding Sage computations into any webpage:
check out short instructions or
comprehensive description of capabilities.</p>
</blockquote>
<p>with the following links:</p>
<ul>
<li><a href="https://sagecell.sagemath.org/static/about.html">short instructions</a></li>
<li><a href="https://github.com/sagemath/sagecell/blob/master/doc/embedding.rst">comprehensive description of capabilities</a></li>
</ul>
<p>That "comprehensive description of capabilities" page
has a section dedicated to your question:</p>
<ul>
<li><a href="https://github.com/sagemath/sagecell/blob/master/doc/embedding.rst#linked-cells">linked cells</a></li>
</ul>
<p>which says</p>
<blockquote>
<p>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:</p>
<pre><code>{ ..
linked: boolean
.. }
</code></pre>
<p>This option is <code>false</code> by default.</p>
</blockquote>
<p>So try using <code>linked: true</code>.</p>
<h3>Examples</h3>
<p>Many pages online use SageCell with linked cells.</p>
<p><a href="https://pretextbook.org">PreTeXt</a> 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.</p>
<p>The PreTeXt home page links to a few examples, including:</p>
<ul>
<li><a href="https://pretextbook.org/examples/sample-book/noparts/html/sets-sage.html">a sample of Thomas W. Judson's <em>Abstract Algebra</em> book</a></li>
</ul>
<p>which has a page about using Sage via SageCell:</p>
<ul>
<li><a href="https://pretextbook.org/examples/sample-book/noparts/html/sets-sage.html">"Sage via SageCell" in sample of Thomas W. Judson's <em>Abstract Algebra</em> book</a></li>
</ul>
<p>See in particular</p>
<ul>
<li><a href="https://pretextbook.org/examples/sample-book/structural/html/sets-sage.html#subsection-5">Section 1.3.1 Executing Sage Commands</a></li>
</ul>
<p>which conveniently has several cells.</p>
<p>Try typing <code>a = 2</code> in the first one, executing (by hitting <code>Shift</code>+<code>Enter</code>
or by clicking the "Execute" button) and then typing <code>a^2</code> in the second one
and executing.</p>
<p>Check the source code of that page and search the word "linked" there
(e.g. using cmd-F or ctrl-F).</p>
<p>For many more example, see the <a href="https://pretextbook.org/gallery.html">PreTeXt gallery</a>
or the <a href="https://pretextbook.org/catalog.html">PreTeXt catalog</a>.</p>
https://ask.sagemath.org/question/53486/sagecells-linked-cells/?comment=53507#post-id-53507Cyrille,
Those latter questions relate to HTML design (and have nothing Sage-specific), and would be best asked on an HTML mailing list or forum.Sat, 19 Sep 2020 12:09:57 +0200https://ask.sagemath.org/question/53486/sagecells-linked-cells/?comment=53507#post-id-53507Comment by slelievre for <h2>SageCell linked cells</h2>
<h3>Documentation</h3>
<p>The "About" section of the <a href="https://sagecell.sagemath.org">SageCell website home page</a>
has these paragraphs:</p>
<blockquote>
<p>SageMathCell project is an easy-to-use web interface
to a free open-source mathematics software system SageMath.</p>
<p>It allows embedding Sage computations into any webpage:
check out short instructions or
comprehensive description of capabilities.</p>
</blockquote>
<p>with the following links:</p>
<ul>
<li><a href="https://sagecell.sagemath.org/static/about.html">short instructions</a></li>
<li><a href="https://github.com/sagemath/sagecell/blob/master/doc/embedding.rst">comprehensive description of capabilities</a></li>
</ul>
<p>That "comprehensive description of capabilities" page
has a section dedicated to your question:</p>
<ul>
<li><a href="https://github.com/sagemath/sagecell/blob/master/doc/embedding.rst#linked-cells">linked cells</a></li>
</ul>
<p>which says</p>
<blockquote>
<p>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:</p>
<pre><code>{ ..
linked: boolean
.. }
</code></pre>
<p>This option is <code>false</code> by default.</p>
</blockquote>
<p>So try using <code>linked: true</code>.</p>
<h3>Examples</h3>
<p>Many pages online use SageCell with linked cells.</p>
<p><a href="https://pretextbook.org">PreTeXt</a> 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.</p>
<p>The PreTeXt home page links to a few examples, including:</p>
<ul>
<li><a href="https://pretextbook.org/examples/sample-book/noparts/html/sets-sage.html">a sample of Thomas W. Judson's <em>Abstract Algebra</em> book</a></li>
</ul>
<p>which has a page about using Sage via SageCell:</p>
<ul>
<li><a href="https://pretextbook.org/examples/sample-book/noparts/html/sets-sage.html">"Sage via SageCell" in sample of Thomas W. Judson's <em>Abstract Algebra</em> book</a></li>
</ul>
<p>See in particular</p>
<ul>
<li><a href="https://pretextbook.org/examples/sample-book/structural/html/sets-sage.html#subsection-5">Section 1.3.1 Executing Sage Commands</a></li>
</ul>
<p>which conveniently has several cells.</p>
<p>Try typing <code>a = 2</code> in the first one, executing (by hitting <code>Shift</code>+<code>Enter</code>
or by clicking the "Execute" button) and then typing <code>a^2</code> in the second one
and executing.</p>
<p>Check the source code of that page and search the word "linked" there
(e.g. using cmd-F or ctrl-F).</p>
<p>For many more example, see the <a href="https://pretextbook.org/gallery.html">PreTeXt gallery</a>
or the <a href="https://pretextbook.org/catalog.html">PreTeXt catalog</a>.</p>
https://ask.sagemath.org/question/53486/sagecells-linked-cells/?comment=53510#post-id-53510@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.Sat, 19 Sep 2020 18:22:37 +0200https://ask.sagemath.org/question/53486/sagecells-linked-cells/?comment=53510#post-id-53510Answer by Cyrille for <p>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.</p>
<p>In advance thank to the one who will help me.</p>
https://ask.sagemath.org/question/53486/sagecells-linked-cells/?answer=53538#post-id-53538 <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> Tue, 22 Sep 2020 05:51:44 +0200https://ask.sagemath.org/question/53486/sagecells-linked-cells/?answer=53538#post-id-53538