Skip to content

Commit

Permalink
WIP \require in Markdown cell
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeier committed Mar 21, 2019
1 parent be18c28 commit 146fe8e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
5 changes: 1 addition & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@
#}

mathjax_config = {
'TeX': {
'equationNumbers': {'autoNumber': 'AMS', 'useLabelIds': True},
'extensions': ['newcommand.js', 'begingroup.js'],
},
'TeX': {'equationNumbers': {'autoNumber': 'AMS', 'useLabelIds': True}},
}

# Additional files needed for generating LaTeX/PDF output:
Expand Down
27 changes: 14 additions & 13 deletions doc/markdown-cells.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@
"```\n",
"<div hidden>\n",
"\n",
"\\def\\require#1{}\n",
"$\\require{begingroup}\\require{newcommand}$\n",
"$\\gdef\\vec#1{\\boldsymbol{#1}}$\n",
"$\\gdef\\i{\\mathrm{i}}$\n",
"\n",
"\\vskip-\\parskip\n",
"\\vskip-\\baselineskip\n",
Expand All @@ -107,7 +110,10 @@
"\n",
"<div hidden>\n",
"\n",
"\\def\\require#1{}\n",
"$\\require{begingroup}\\require{newcommand}$\n",
"$\\gdef\\vec#1{\\boldsymbol{#1}}$\n",
"$\\gdef\\i{\\mathrm{i}}$\n",
"\n",
"\\vskip-\\parskip\n",
"\\vskip-\\baselineskip\n",
Expand All @@ -123,25 +129,20 @@
"but in LaTeX, it doesn't have any effect on later math expressions.\n",
"Using `\\gdef` works in both.\n",
"Sadly, `\\gdef` isn't activated by default in MathJax,\n",
"therefore we need some additional configuration in our `conf.py` file:\n",
"so we have to use `\\require` to activate the `newcommand` and `begingroup` extensions.\n",
"Since `\\require` is a MathJax feature that's unknown to LaTeX,\n",
"we'll have to provide a dummy definition to not confuse LaTeX\n",
"\n",
"```python\n",
"mathjax_config = {\n",
" 'TeX': {\n",
" 'extensions': ['newcommand.js', 'begingroup.js'],\n",
" },\n",
"}\n",
"\n",
"```\n",
"\n",
"With the above definition and the `conf.py` setting in place,\n",
"With the above definitions,\n",
"you can use your new macro like this:\n",
"\n",
"```\n",
"$2 \\vec{a} + \\vec{b}$\n",
"```\n",
"\n",
"... which looks like this: $2 \\vec{a} + \\vec{b}$"
"... which looks like this: $2 \\vec{a} + \\vec{b}$.\n",
"\n",
"You can of course use as many `\\gdef` lines as you want."
]
},
{
Expand Down Expand Up @@ -556,7 +557,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2+"
"version": "3.7.3rc1"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 146fe8e

Please sign in to comment.