Section 14 Interactive Elements, Server
When outputting Web page versions, it is possible to embed a variety of dynamic interactive elements. In a LaTeX/PDF version, these will necessarily need to be replaced by some static substitute, such as a screenshot. See Section 3 for the specifics of embedding instances of the Sage Cell Server, which is more elaborate, and not entirely similar.
Interactives in this section have code that lives on a server somewhere (in the “cloud”). So maybe you uploaded an interactive demonstration, or maybe somebody else did. In this sense, these are easier to create or use. But pay attention, the code may come with restrictive licenses, even if you are the author originally. See Section 13 for more interactives that can be free as in “freedom” or liberté. CalcPlot3D is the notable exception here.
(2018-06-22) Almost everything in this section is under active development and not stable yet. Feel free to experiment and make suggestions and requests. This page takes a while to completely load, so be patient.
Subsection 14.1 GeoGebra
A Geogebra material is something you might use in a class. It could also be called an interactive demonstration. Go browsing at
www.geogebra.org/materials/ and find something appropriate for your project. Or make an account and create your own.
Once you find a material that looks instructive, it will be at a URL such as
and you want to pick off the identifier on the end, in this case
KGn2d4Qd. Then author
<interactive geogebra="KGn2d4Qd" />
At this writing (2018-02-04) you will want to place this inside a
figure, with a caption, as we do right now with material
The shape of the material will be fixed, so guess (or measure with an on-screen ruler), the aspect ratio and use that in the
<interactive> element. If the width of the original material is anything other than 800 pixels, you should add
@material-width with the actual material width (units are pixels).
There are some optional control elements that Geogebra provides, such as the presence of the toolbar and the reset button. These can be controlled by adding the following additional attributes to the
toolbar="yes": add the Geogebra toolbar above the material
algebra-input="yes": add an entry box below the material to add graphical objects using algebra formulas or Geogebra graphical commands
reset-icon="yes": enable the reset icon
shift-drag-zoom="yes": enable ability to drag and zoom the viewing context
Note that materials hosted at
geogebra.org have a non-standard, non-commercial license you must agree to before you can download them as source code. Perhaps you must forfeit your copyright when you upload a material? We have not investigated this thoroughly.
Subsection 14.2 Desmos Graphs
Desmos provides interactive graphing applications. The following example was created by Ann Cary and made available via the “Share” function of Desmos. You can make your own Desmos graph, choose the “Share” icon, and the “Embed” option, to get a URL such as
You want to pick off the identifier on the end, in this case
ttox1bvxku, then author
<interactive desmos="ttox1bvxku" width="60%" aspect="2:3" />
as we have done here.
The static image employed in the LaTeX version of this article was obtained by viewing the graph at the Desmos site (i.e., not the embedded version in the PreTeXt HTML version), and using the Share button to export a PNG image. In this case, we used a “Medium Rectangle” and “Thick” lines.
Note that Desmos has extensive Terms of Service which include restrictions on commercial uses.
Subsection 14.3 CalcPlot3D
To use it, start at the online app version
. Create a plot and adjust the image to a viewpoint and scale if you like. Then, click the menu/hamburger icon in the upper-left and choose
File. From here you can save a PNG image for the static version, but you also want to select
Encode View in URL. Now your browser address bar is filled with a query string (all the stuff after the question-mark) that has all the information necessary to reproduce your plot (and view). Copy everything after the first question-mark to the
interactive/code element. Be sure to replace any ampersands by
& (see the Author’s Guide for more about certain characters in URLs). Examine the source for the examples below to see how they are authored. The Help Manual for CalcPlot3D is also available off the menu/hamburger icon in the upper-left.
In Figure 14.3 grab the image with your mouse and rotate it in various directions. Then while the image has focus, press the
3 key (short for “3-D”), to get a 3D view, which will require some red-blue 3D glasses to fully appreciate. Press the key again to return to a regular view.
Subsection 14.4 IFrames from Servers
iFrame versions of interactives can point to a network location, presuming the endpoint is reasonably well-behaved. If you are using this sytematically, let us know and perhpas it should become a more dedicated PreTeXt construction. See Subsection 13.9 for the local file version.
This example is from PhET Interactive Simulations
Anything that suggests you can embed an interactive widget via an iFrame is fair game for this feature. This is a Google Map of the state of California, for use in a French language document, from Julien Giol. The necessary URL is obtained by using the “Share” feature, and then the “Embed a map” option has HTML with the URL in a