Skip to content

Commit 146fe8e

Browse files
committed
WIP \require in Markdown cell
1 parent be18c28 commit 146fe8e

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

doc/conf.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@
9797
#}
9898

9999
mathjax_config = {
100-
'TeX': {
101-
'equationNumbers': {'autoNumber': 'AMS', 'useLabelIds': True},
102-
'extensions': ['newcommand.js', 'begingroup.js'],
103-
},
100+
'TeX': {'equationNumbers': {'autoNumber': 'AMS', 'useLabelIds': True}},
104101
}
105102

106103
# Additional files needed for generating LaTeX/PDF output:

doc/markdown-cells.ipynb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@
9797
"```\n",
9898
"<div hidden>\n",
9999
"\n",
100+
"\\def\\require#1{}\n",
101+
"$\\require{begingroup}\\require{newcommand}$\n",
100102
"$\\gdef\\vec#1{\\boldsymbol{#1}}$\n",
103+
"$\\gdef\\i{\\mathrm{i}}$\n",
101104
"\n",
102105
"\\vskip-\\parskip\n",
103106
"\\vskip-\\baselineskip\n",
@@ -107,7 +110,10 @@
107110
"\n",
108111
"<div hidden>\n",
109112
"\n",
113+
"\\def\\require#1{}\n",
114+
"$\\require{begingroup}\\require{newcommand}$\n",
110115
"$\\gdef\\vec#1{\\boldsymbol{#1}}$\n",
116+
"$\\gdef\\i{\\mathrm{i}}$\n",
111117
"\n",
112118
"\\vskip-\\parskip\n",
113119
"\\vskip-\\baselineskip\n",
@@ -123,25 +129,20 @@
123129
"but in LaTeX, it doesn't have any effect on later math expressions.\n",
124130
"Using `\\gdef` works in both.\n",
125131
"Sadly, `\\gdef` isn't activated by default in MathJax,\n",
126-
"therefore we need some additional configuration in our `conf.py` file:\n",
132+
"so we have to use `\\require` to activate the `newcommand` and `begingroup` extensions.\n",
133+
"Since `\\require` is a MathJax feature that's unknown to LaTeX,\n",
134+
"we'll have to provide a dummy definition to not confuse LaTeX\n",
127135
"\n",
128-
"```python\n",
129-
"mathjax_config = {\n",
130-
" 'TeX': {\n",
131-
" 'extensions': ['newcommand.js', 'begingroup.js'],\n",
132-
" },\n",
133-
"}\n",
134-
"\n",
135-
"```\n",
136-
"\n",
137-
"With the above definition and the `conf.py` setting in place,\n",
136+
"With the above definitions,\n",
138137
"you can use your new macro like this:\n",
139138
"\n",
140139
"```\n",
141140
"$2 \\vec{a} + \\vec{b}$\n",
142141
"```\n",
143142
"\n",
144-
"... which looks like this: $2 \\vec{a} + \\vec{b}$"
143+
"... which looks like this: $2 \\vec{a} + \\vec{b}$.\n",
144+
"\n",
145+
"You can of course use as many `\\gdef` lines as you want."
145146
]
146147
},
147148
{
@@ -556,7 +557,7 @@
556557
"name": "python",
557558
"nbconvert_exporter": "python",
558559
"pygments_lexer": "ipython3",
559-
"version": "3.7.2+"
560+
"version": "3.7.3rc1"
560561
}
561562
},
562563
"nbformat": 4,

0 commit comments

Comments
 (0)