Skip to main content

The PreTeXt Guide

Section 21.1 SageMathCells

Including computational SageMath cells is pretty easy with <sage>, <input>, and <output>. The last tag is useful for producing formats intended for offline reading so that they can include the result of the code’s execution.
<sage>
<input>
2+2
</input>
<output>
4
</output>
</sage>
Listing 21.1.1. SageMath cell
The code in Listing 21.1.1 produces the following output:
SageMathCells on a single HTML page are automatically linked so that a cell can use the results of computations done in earlier cells on the same page.