updates to mathjax plugin, incl more examples #531

edit
Hakim El Hattab 2013-08-12 22:42:14 -04:00
parent 9984cb1f21
commit 69f7c0c693
2 changed files with 44 additions and 7 deletions

View File

@ -15,7 +15,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <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/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 --> <!-- For syntax highlighting -->
<link rel="stylesheet" href="../lib/css/zenburn.css"> <link rel="stylesheet" href="../lib/css/zenburn.css">
@ -32,11 +32,12 @@
<div class="slides"> <div class="slides">
<section> <section>
<h1>Reveal.js Math Plugin</h1> <h2>reveal.js Math Plugin</h2>
<p>A thin wrapper for MathJax</p>
</section> </section>
<section> <section>
<h2>The Lorenz Equations</h2> <h3>The Lorenz Equations</h3>
\[\begin{aligned} \[\begin{aligned}
\dot{x} &amp; = \sigma(y-x) \\ \dot{x} &amp; = \sigma(y-x) \\
\dot{y} &amp; = \rho x - y - xz \\ \dot{y} &amp; = \rho x - y - xz \\
@ -45,13 +46,13 @@
</section> </section>
<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) \] \[ \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>
<section> <section>
<h2>A Cross Product Formula</h2> <h3>A Cross Product Formula</h3>
\[\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix} \[\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix}
\mathbf{i} &amp; \mathbf{j} &amp; \mathbf{k} \\ \mathbf{i} &amp; \mathbf{j} &amp; \mathbf{k} \\
@ -61,13 +62,36 @@
</section> </section>
<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}} = \[ \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^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}}
{1+\frac{e^{-8\pi}} {1+\ldots} } } } \] {1+\frac{e^{-8\pi}} {1+\ldots} } } } \]
</section> </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>
</div> </div>
@ -78,6 +102,8 @@
<script> <script>
Reveal.initialize({ Reveal.initialize({
transition: 'linear',
dependencies: [ dependencies: [
{ src: '../lib/js/classList.js', condition: function() { return !document.body.classList; } }, { src: '../lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: '../plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: '../plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },

View File

@ -6,10 +6,13 @@
*/ */
(function(){ (function(){
var config = Reveal.getConfig().math || {};
config.mode = config.mode || 'TeX-AMS_HTML-full';
var head = document.querySelector( 'head' ); var head = document.querySelector( 'head' );
var script = document.createElement( 'script' ); var script = document.createElement( 'script' );
script.type = 'text/javascript'; 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 // Detect when the script has loaded
script.onload = onScriptLoad; script.onload = onScriptLoad;
@ -28,8 +31,16 @@
tex2jax: { inlineMath: [['$','$'],['\\(','\\)']] } 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 ) { 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 ); MathJax.Hub.Update( event.currentSlide );
} ); } );
} }