Beschreibung
MathJax ermöglicht die Darstellung von LaTeX oder MathML in HTML-Seiten. Dieses Plugin fügt diese Funktion zu WordPress hinzu. Das MathJax-JavaScript wird nur in den Seiten eingebaut, die es auch verwenden. Dadurch wird ein langsamerer Seitenaufbau für alle anderen Seiten vermieden.
The MathJax JavaScript can be delivered from your own server, or you can use the jsDelivr Content Distribution Network (CDN), which is the preferred mechanism as it offers increased speed and stability over hosting the JavaScript and configuring the library yourself.
Latex kann mit einer Reihe unterschiedlicher Syntaxen verwendet werden. Dabei sollte die Shortcode-Syntax (https://codex.wordpress.org/Shortcode_API) bevorzugt werden. [latex]E=mc^2[/latex] wird einfach so funktionieren und MathJax laden.
Additionally, you can use native MathJax syntax — $$E=mc^2$$ or \(E=mc^2\). However, if this is the only syntax used, the plugin must be explicitly told to load MathJax for the current page. This can be achieved by adding a [mathjax] shortcode anywhere in the post. For posts with both [latex]x[/latex] and $$x$$ syntaxes this is unnecessary.
Zwar kann man die wp-latex-Syntax verwenden: $latex E=mc^2$, allerdings werden dabei die Parameter ignoriert! MathJax-LaTeX sollte ein direkter Ersatz für wp-latex sein. Beides zusammen steht im Konflikt, und wird daher standardmäßig blockiert. Die $latex$-Syntax kann explizit in den Einstellungen eingeschaltet werden.
You can also specify [nomathjax] — this will block mathjax on the current page, regardless of other tags.
MathJax-LaTeX wird auf GitHub entwickelt.
Copyright
Das Copyright des Plugins liegt bei Phillip Lord von der Newcastle University und ist unter GPLv2 lizenziert.
Installation
- Entpacke das heruntergeladene .zip-Archiv ins Verzeichnis
/wp-content/plugins/ - Aktiviere das Plugin über das Plugins-Menü in WordPress
FAQ
-
How do I configure MathJax?
-
Use the
mathjax_configfilter. It receives an array of MathJax 4 configuration options, which the plugin outputs aswindow.MathJaxbefore MathJax loads. Add your settings to the array you’re given and return it. Don’t return a new array, since the plugin adds its own settings to it.`phpadd_filter( ‚mathjax_config‘, function ( $config ) {
$config[‚tex‘][‚tags‘] = ‚ams‘;
return $config;
} );
`The plugin always loads MathJax’s Safe extension after the filter runs, so a filter can’t remove it.
Before 1.4, the filter took MathJax 2 configuration (
MathJax.Hub.Config). Those settings don’t work with MathJax 4; see the MathJax 4 documentation for the equivalents. -
How do I number equations?
-
Set
tex.tagstoamsto number equations in environments such asequationandalign, or toallto number every displayed equation:`phpadd_filter( ‚mathjax_config‘, function ( $config ) {
$config[‚tex‘][‚tags‘] = ‚ams‘;
return $config;
} );
`\label{…} and `\eqref{…}` then work as in LaTeX. -
Can I use single dollar signs for inline math?
-
Yes, by adding them to
tex.inlineMath:`phpadd_filter( ‚mathjax_config‘, function ( $config ) {
$config[‚tex‘][‚inlineMath‘] = [ [ ‚$‘, ‚$‘ ], [ ‚\(‚, ‚\)‘ ] ];
return $config;
} );
`A literal dollar sign then needs to be written as
\$. -
How do I use a TeX extension?
-
Many extensions load automatically when you use one of their macros, e.g.
\ce{H2O}loadsmhchem. For others,\requirethem in the post, once per page before their first use:`latex(\require{units}\nicefrac{1}{2})
`To load an extension on every page, use the
mathjax_configfilter:`phpadd_filter( ‚mathjax_config‘, function ( $config ) {
$config[‚loader‘][‚load‘][] = ‚[tex]/units‘;
$config[‚tex‘][‚packages‘][‚[+]‘][] = ‚units‘;
return $config;
} );
` -
Why do long equations wrap onto several lines?
-
MathJax-LaTeX breaks displayed equations that are wider than the column onto several lines, so they don’t run off the screen on phones. Equations that fit aren’t affected. To give wide equations their own horizontal scrollbar instead, set
output.displayOverflowtoscroll. To let them run past the edge of the column as they used to, set it tooverflow, MathJax’s own default:`phpadd_filter( ‚mathjax_config‘, function ( $config ) {
$config[‚output‘][‚displayOverflow‘] = ’scroll‘;
return $config;
} );
`MathJax also accepts
scale,truncateandelide; see the MathJax output options.
Rezensionen
Mitwirkende und Entwickler
„MathJax-LaTeX“ ist Open-Source-Software. Folgende Menschen haben an diesem Plugin mitgewirkt:
MitwirkendeÜbersetze „MathJax-LaTeX“ in deine Sprache.
Interessiert an der Entwicklung?
Durchstöbere den Code, sieh dir das SVN-Repository an oder abonniere das Entwicklungsprotokoll per RSS.
Änderungsprotokoll
1.4
- Security: load MathJax’s Safe extension wherever MathJax runs, so TeX in comments can’t create javascript: links (CVE-2026-116754). Only site code using the mathjax_config filter can loosen Safe mode’s settings.
- Use MathJax 4.1.3, loaded asynchronously from jsDelivr.
- The MathJax Configuration setting now selects a MathJax 4 component; MathJax 2 settings are mapped automatically.
- The custom location setting is now the URL of a MathJax 4 directory or component file. Self-hosted copies load fonts from the @mathjax directory next to it, as installed by npm, instead of jsDelivr.
- The mathjax_config filter now takes MathJax 4 configuration (window.MathJax); see the FAQ for examples.
- Block direct file access and fix Plugin Check issues.
1.3.13
- PHP code style fixes
1.3.12
- Use version 2.7.9 of MathJax JS
- Add code comments to all variables, functions and parameters.
1.3.11
- Verwendet Version 2.7.5 von MathJax JS
1.3.10
- Klassen-Dateien umbenannt nach PHPCS
- Null-Werte im filter_br_tags_on_math werden nun eleganter behandelt. Danke dafür an Yang Liu.
1.3.9
- Änderungen im Code-Stil nach PHPCS 3.3.0 und WPCS 0.14.1
- Verwendet die Kurz-Array-Syntax von PHP 7.
1.3.8
- Änderungen im Code-Stil nach PHPCS 3.1.1 und WPCS 0.14
1.3.7
- MathJax auf 2.7.2 aktualisiert
1.3.6
- Standort des MathJax-CDNs geändert
1.3.5
- Unterstützung zur Konfiguration von MathJax per Filter hinzugefügt
1.3.4
- PHP-Code aufgeräumt.
- Immer die https-URL für die MathJax-Bibliothek verwenden
- „Getestet bis“ auf 4.3 aktualisiert
1.3.3
- Uneinheitliche Versionsnummern zwischen Readme und PHP-Datei angepasst
1.3.2
- Code weiter aufgeräumt.
1.3.1
- Barrierefreiheit auf der Admin-Seite verbessert.
- VIP-Programmierungs-Standards
- MathML-Tags in TinyMCE aktiviert
Der gesamte Code für diese Version wurde von Benutzern dieses Plugins bereitgestellt! Danke an Jared Wenerd und Paul Schreiber.
1.3.0
- MathML-Tags und -Attribute zur Whitelist hinzufügen.
- Unerwünschte Eingaben entfernt und Ausgaben gesichert.
1.2.1
- Fehlerbehebung: Eigene Locations wurde nicht richtig angewendet.
- Fehlerbehebung: Erzwungenes Laden wurde nicht richtig angewendet.
1.2
- Die Admin-Seite war angreifbar für Dritte, deren Benutzer als Admin angemeldet waren.
- Die Admin-Infos wurden auf einer Seite zusammengefasst und umformuliert.
- Alle Optionen wurden umbenannt. Das bedeutet leider, dass das Plugin neu konfiguriert werden muss. Insbesondere ist die wp-latex-Syntax standardmäßig abgeschaltet.
1.1
- Dokumentation aktualisiert.
- Aktualisierungstest – mit Dokumentation für WordPress 3.5.1
- Getestet mit MathJax 2.1
1.0
- Kompatibilität mit MathJax 1.1. Lade eine Standard-Konfiguration von der MathJax-Distribution.
- Verwende das Content Distribution Network von MathJax, um die JavaScript-Bibliothek auszuliefern. Dies sorgt für verbesserte Leistung und Stabilität.
0.2
- Die URL, von der MathJax.js geladen wird, ist jetzt konfigurierbar. Standard ist $PLUGIN/MathJax/MathJax.js