This repository has been archived by the owner on Aug 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathexample.html
227 lines (166 loc) · 5.87 KB
/
example.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>reveal.js - math-katex plugin example</title>
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
<meta name="author" content="Hakim El Hattab">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="node_modules/reveal.js/css/reveal.css">
<link rel="stylesheet" href="node_modules/reveal.js/css/theme/white.css" id="theme">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ?
'node_modules/reveal.js/css/print/pdf.css' :
'node_modules/reveal.js/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="node_modules/reveal.js/lib/js/html5shiv.js"></script>
<![endif]-->
<!-- Example styles -->
<style>
.reveal code,
.reveal .formula-source,
.reveal a {
color: #3F988E;
}
.reveal code {
padding: 0 0.25em;
}
.reveal pre.formula-source {
box-shadow: none;
font-size: 0.8em;
}
.reveal .formula,
.reveal .formula-source {
margin: 2.5rem 0;
}
.reveal li {
margin: 0.65em 0;
}
.reveal .formula.bigger {
font-size: 1.8em;
}
</style>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h2>math-katex plugin</h2>
<ul>
<li>Uses <a href="https://github.com/Khan/KaTeX">KaTeX</a> for lightweight rendering</li>
<li>Highlights errors on the slide</li>
<li>
Renders all formulas when presentation loads<br>
(no re-rendering when slide changes)
</li>
</ul>
</section>
<!-- This slide uses markdown. -->
<section data-markdown>
<script type="text/template">
## Two usage modes
- **TeX-style**, wrapped in <code>$…$</code> or <code>$$…$$</code>. Works in Markdown, too.
Elements get a class <code>formula</code> for styling
- **Wrapped in HTML elements** with class <code>formula</code> (or <code>math</code>)
</script>
</section>
<section data-math>
<!--
A `data-math` attribute is set here, as `math.enableGlobally` was set to `false`.
This allows to use `\$` characters on other slide without escaping, but you have
to enable formula replacements *per slide*.
-->
<h2>Tex style (dollars)</h2>
<!-- \$ escaping in action here: -->
<p class="formula-source"><code>\$\$\frac{1}{1 + e^{-x}}\$\$</code></p>
<p>for example yields a display formula (block):</p>
$$
\frac{1}{1 + e^{-x}}
$$
<p>
Single <code>\$…\$</code> render in-line: $-\sum_{i=1}^n p(x_i) \log p(x_i)$.
</p>
<p>
Escape literal dollars with <code>\\$</code>.
</p>
</section>
<section>
<h2>Wrapped in an element</h2>
<p>
Wrap the formula in an element with<br>
class <code>formula</code> (or <code>math</code>):<br>
</p>
<div class="formula-source"><span class="formula"> P(A \mid B) </span></div>
<p>Renders in-line by default: <span class="formula"> P(A \mid B) </span></p>
<p>Or add class <code>display</code> and use a block element (<code><div></code>):</p>
<div class="formula display">-\sum_{i=1}^n p(x_i) \log p(x_i)</div>
</section>
<section data-math>
<h2>Other Things</h2>
<p>
You can just use <code><</code> and <code>></code> for comparison operators,
<!-- oh the irony … -->
you don’t need to use HTML entities (<code>&gt;</code> or <code>&lt;</code>).
</p>
<p>
<code>\$a > b, c < d\$</code>
renders as
$a > b, c < d$. <!-- OK, there you see it -->
</p>
<p>
Ampersands (<code>&</code>) for matrices work, too:
$\begin{pmatrix} a & b \\ c & d \end{pmatrix}$
</p>
</section>
</div>
</div>
<script src="node_modules/reveal.js/lib/js/head.min.js"></script>
<script src="node_modules/reveal.js/js/reveal.js"></script>
<script>
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
// `math-katex` plugin:
// Optional configuration:
math: {
// Elements to ignore for math rendering (defaults shown):
// ignoredElements: [ 'pre', 'code' ]
// Set `enableGlobally` to `false` to avoid excessive
// escaping. You will then need to activate `$…$`-style
// replacements per slide with a `data-math` attribute
// (formulas wrapped in elements are still activated
// everywhere).
//
enableGlobally: false,
// Required for this example only, ignore --->
katexScript: 'math-katex/lib/katex-0.7.1/katex.min.js',
katexStylesheet: 'math-katex/lib/katex-0.7.1/katex.min.css'
// <---
},
// Specify the plugin as a dependency:
dependencies: [
// Change this path to 'plugin/math-katex/math-katex.js' for
// your presentation!
{ src: 'math-katex/math-katex.js', async: true },
// Also use markdown plugin:
{ src: 'node_modules/reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'node_modules/reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }
]
});
// You can also attach an event listener:
Reveal.addEventListener( 'math-rendered', function () {
console.log( 'Formulas have been rendered.' );
});
</script>
</body>
</html>