-
Notifications
You must be signed in to change notification settings - Fork 107
/
tex-macros.html
66 lines (62 loc) · 1.68 KB
/
tex-macros.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width">
<title>Defining macros in-line in MathJax</title>
<script>
MathJax = {
tex: {
macros: {
RR: '{\\bf R}', // a simple string replacement
bold: ['\\boldsymbol{#1}',1] , // this macro has one parameter
ddx: ['\\frac{d#2}{d#1}', 2, 'x'], // this macro has an optional parameter that defaults to 'x'
abc: ['(#1)', 1, [null, '\\cba']] // equivalent to \def\abc#1\cba{(#1)}
}
}
};
</script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
</head>
<body>
<!--
|
| Here we use a math block that contains nothing but definitions in
| standard TeX format. It is enclosed in a DIV that doesn't display, so
| that there are no extra spaces generated by having the extra
| mathematics in the text.
|
| The first macro makes it easy to display vectors using \<x,y,z>
| the second uses \newcommand to create a macro
|
|-->
<div style="display:none">
\(
\def\<#1>{\left<#1\right>}
\newcommand{\CC}{\mathbf{C}}
\)
</div>
<p>
This page uses two different methods to define macros: either putting them
in JavaScript notation in the MathJax configuration, or in TeX notation in
the body of the document.
</p>
<p>Some math that uses the definitions:
\[
f\colon\RR\to\RR^3 \hbox{ by } f(t)=\< t+1,{1\over 1+t^2}, \sqrt{t^2+1} >
\]
and
\[
\{\,z\in\CC \mid z^2 = \bold{\alpha}\,\}
\]
and
\[
\ddx{f} = \ddx[u]{f} \cdot \ddx{u}
\]
and
\[
f\abc x,y \cba = x^2 + y^2
\]
</body>
</html>