Skip to content

Commit 2fe4ebd

Browse files
committed
Improvements to extension load_tex_macros.
Compatible with 5.x. Correctly reprocess mathjax, including resetting equation numbers. Better readme.
1 parent 09024b6 commit 2fe4ebd

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/jupyter_contrib_nbextensions/nbextensions/load_tex_macros/load_tex_macros.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Description: This extension automatically loads a set of latex commands from the
44
Link: readme.md
55
Icon: icon.png
66
Main: main.js
7-
Compatibility: 4.x
7+
Compatibility: 4.x, 5.x

src/jupyter_contrib_nbextensions/nbextensions/load_tex_macros/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ define(function(require, exports, module) {
77
if ($('#latexdefs').length > 0) $('#latexdefs').remove();
88
$('body').append($('<div/>').attr('id', 'latexdefs').text(data));
99
console.log('latex_envs: loaded user LaTeX definitions latexdefs.tex');
10-
onMarkdownCellRendering();
1110
}).fail(function() {
1211
console.log('load_tex_macros: failed to load user LaTeX definitions latexdefs.tex')
1312
});
1413
}
1514

1615
function rerenderMaths() { // probably something like that
1716
MathJax.Hub.Queue(
18-
["PreProcess", MathJax.Hub], ["Reprocess", MathJax.Hub]
17+
["resetEquationNumbers",MathJax.InputJax.TeX],
18+
["PreProcess", MathJax.Hub],
19+
["Reprocess", MathJax.Hub]
1920
);
2021
}
2122

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1+
2+
Purpose
3+
=======
4+
This extension loads a tex file whenever a notebook is loaded, then re-runs
5+
mathjax. It's useful if you have several notebooks that use a common set of latex
6+
macros, so you don't have to copy the macros to each notebook.
7+
18
Usage
29
=====
310

411
Simply put your latex macros in a file named latexdefs.tex, in the same directory as your notebook.
12+
13+
14+
Credit
15+
======
16+
17+
This is derived entirely from the nbextension `jupyter_latex_envs`, with help from its author @jfbercher.

0 commit comments

Comments
 (0)