updates to mathjax plugin, incl more examples #531
authorHakim El Hattab <hakim.elhattab@gmail.com>
Tue, 13 Aug 2013 02:42:14 +0000 (22:42 -0400)
committerHakim El Hattab <hakim.elhattab@gmail.com>
Tue, 13 Aug 2013 02:42:14 +0000 (22:42 -0400)
examples/math.html
plugin/math/math.js

index 49d49526ec891a145f6a5ef46af1cf68861f1ccf..67fa54621efe0435e2282c5d919ba50c5374f086 100644 (file)
@@ -15,7 +15,7 @@
                <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
 
                <link rel="stylesheet" href="../css/reveal.min.css">
-               <link rel="stylesheet" href="../css/theme/default.css" id="theme">
+               <link rel="stylesheet" href="../css/theme/night.css" id="theme">
 
                <!-- For syntax highlighting -->
                <link rel="stylesheet" href="../lib/css/zenburn.css">
                        <div class="slides">
 
                                <section>
-                                       <h1>Reveal.js Math Plugin</h1>
+                                       <h2>reveal.js Math Plugin</h2>
+                                       <p>A thin wrapper for MathJax</p>
                                </section>
 
                                <section>
-                                       <h2>The Lorenz Equations</h2>
+                                       <h3>The Lorenz Equations</h3>
                                        \[\begin{aligned}
                                        \dot{x} &amp; = \sigma(y-x) \\
                                        \dot{y} &amp; = \rho x - y - xz \\
                                </section>
 
                                <section>
-                                       <h2>The Cauchy-Schwarz Inequality</h2>
+                                       <h3>The Cauchy-Schwarz Inequality</h3>
 
                                        \[ \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right) \]
                                </section>
 
                                <section>
-                                       <h2>A Cross Product Formula</h2>
+                                       <h3>A Cross Product Formula</h3>
 
                                        \[\mathbf{V}_1 \times \mathbf{V}_2 =  \begin{vmatrix}
                                        \mathbf{i} &amp; \mathbf{j} &amp; \mathbf{k} \\
                                </section>
 
                                <section>
-                                       <h2>An Identity of Ramanujan</h2>
+                                       <h3>The probability of getting \(k\) heads when flipping \(n\) coins is</h3>
+
+                                       \[P(E)   = {n \choose k} p^k (1-p)^{ n-k} \]
+                               </section>
+
+                               <section>
+                                       <h3>An Identity of Ramanujan</h3>
 
                                        \[ \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} =
                                        1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}}
                                        {1+\frac{e^{-8\pi}} {1+\ldots} } } } \]
                                </section>
 
+                               <section>
+                                       <h3>A Rogers-Ramanujan Identity</h3>
+
+                                       \[  1 +  \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots =
+                                       \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})}\]
+                               </section>
+
+                               <section>
+                                       <h3>Maxwell&#8217;s Equations</h3>
+
+                                       \[  \begin{aligned}
+                                       \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} &amp; = \frac{4\pi}{c}\vec{\mathbf{j}} \\   \nabla \cdot \vec{\mathbf{E}} &amp; = 4 \pi \rho \\
+                                       \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} &amp; = \vec{\mathbf{0}} \\
+                                       \nabla \cdot \vec{\mathbf{B}} &amp; = 0 \end{aligned}
+                                       \]
+                               </section>
+
                        </div>
 
                </div>
                <script>
 
                        Reveal.initialize({
+                               transition: 'linear',
+
                                dependencies: [
                                        { src: '../lib/js/classList.js', condition: function() { return !document.body.classList; } },
                                        { src: '../plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
index 30dd38c6c08689b88cf54378631ba2d4b25eac0b..8ab74fad095dca78f75706ae799c20cbdf14044e 100755 (executable)
@@ -6,10 +6,13 @@
  */
 (function(){
 
+       var config = Reveal.getConfig().math || {};
+       config.mode = config.mode || 'TeX-AMS_HTML-full';
+
        var head = document.querySelector( 'head' );
        var script = document.createElement( 'script' );
        script.type = 'text/javascript';
-       script.src = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_SVG-full';
+       script.src = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=' + config.mode;
 
        // Detect when the script has loaded
        script.onload = onScriptLoad;
                        tex2jax: { inlineMath: [['$','$'],['\\(','\\)']] }
                });
 
+               // Process any math inside of the current slide when navigating,
+               // this is important since it's not possible to typeset
+               // equations within invisible elements (far future or past).
                Reveal.addEventListener( 'slidechanged', function( event ) {
+
+                       // This will only typeset equations that have not yet been
+                       // processed, as well as equations that have change since
+                       // last being processed.
                        MathJax.Hub.Update( event.currentSlide );
+
                } );
 
        }