-
Notifications
You must be signed in to change notification settings - Fork 107
/
toggle-steps.html
76 lines (70 loc) · 2 KB
/
toggle-steps.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>MathJax v3 dynamic equations using toggle</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script>
MathJax = {
tex: {inlineMath: [['$', '$'], ['\\(', '\\)']]},
chtml: {
displayAlign: 'left'
},
startup: {
ready: function () {
//
// Do the usual startup (which does a typeset)
//
MathJax.startup.defaultReady();
//
// When that is all done, un-hide the page
//
MathJax.startup.promise.then(function () {
document.getElementById("hidden").disabled = true;
});
}
}
};
</script>
<script src="mathjax3/tex-chtml.js" id="MathJax-script" async></script>
<style>
h1 {
background: #CCCCCC;
padding: .2em 1em;
border-top: 3px solid #666666;
border-bottom: 3px solid #999999;
}
#frame {
margin-left: 2em;
}
</style>
<style id="hidden">
body {
visibility: hidden;
}
</style>
</head>
<body>
<h1>Dynamic Equations in MathJax</h1>
<div id="frame">
<p>
Expand the following:
$$
\require{action}
\def\longest{x(x+1) + 1(x+1)}
\def\click{\rlap{\enclose{roundedbox}{\small\text{next step}}}\hphantom{\longest}}
\def\={\phantom{{}={}}}
(x+1)^2
\toggle
{\begin{aligned}[t]& = \click\end{aligned}}
{\begin{aligned}[t]& = (x+1)(x+1)\\[3px]&\=\click\end{aligned}}
{\begin{aligned}[t]& = (x+1)(x+1)\\[3px]& = x(x+1) + 1(x+1)\\&\=\click\end{aligned}}
{\begin{aligned}[t]& = (x+1)(x+1)\\[3px]& = x(x+1) + 1(x+1)\\[3px]& = (x^2+x) + (x+1)\\[3px]&\=\click\end{aligned}}
{\begin{aligned}[t]& = (x+1)(x+1)\\[3px]& = x(x+1) + 1(x+1)\\[3px]& = (x^2+x) + (x+1)\\[3px]& = x^2 + (x + x) + 1\\[3px]&\=\click\end{aligned}}
{\begin{aligned}[t]& = (x+1)(x+1)\\[3px]& = x(x+1) + 1(x+1)\\[3px]& = (x^2+x) + (x+1)\\[3px]& = x^2 + (x + x) + 1\\[3px]& = x^2 + 2x + 1\end{aligned}}
\endtoggle
$$
</p>
</frame>
</body>
</html>