Erweiterung:Math

From mediawiki.org
This page is a translated version of the page Extension:Math and the translation is 53% complete.
Outdated translations are marked like this.
Diese Erweiterung ist üblicherweise in MediaWiki 1.38 und darüber enthalten. Daher muss sie nicht erneut heruntergeladen werden. Allerdings müssen die folgenden Anweisungen trotzdem beachtet werden.
MediaWiki-Erweiterungen
Math
Freigabestatus: stabil
Einbindung Tag
Beschreibung Erlaubt das Rendern mathematischer Formeln
Autor(en)
  • Moritz Schubotz,
  • Tomasz Wegrzanowski,
  • Brion Vibber
  • und andere
Letzte Version continuous updates
Kompatibilitätspolitik Snapshots werden zusammen mit MediaWiki veröffentlicht. Der Master ist nicht abwärtskompatibel.
MediaWiki >= 1.42.0
Datenbankänderungen Ja
Tabellen math
mathoid
mathlatexml
Lizenz GNU General Public License 2.0 oder neuer
Herunterladen
  • $wgMathEnableWikibaseDataType
  • $wgMathDefaultLaTeXMLSetting
  • $wgMathUseInternalRestbasePath
  • $wgMathMathMLUrl
  • $wgMathFullRestbaseURL
  • $wgMathTexVCService
  • $wgMathInternalRestbaseURL
  • $wgMathConcurrentReqs
  • $wgMathEnableFormulaLinks
  • $wgMathValidModes
  • $wgMathEntitySelectorFallbackUrl
  • $wgMathWikibasePropertyIdQuantitySymbol
  • $wgMathDisableTexFilter
  • $wgMathMathMLTimeout
  • $wgMathWikibasePropertyIdSymbolRepresents
  • $wgMathWikibasePropertyIdHasPart
  • $wgMathWikibasePropertyIdInDefiningFormula
  • $wgMathWikibasePropertyIdDefiningFormula
  • $wgMathoidCli
  • $wgMathLaTeXMLUrl
  • $wgMathLaTeXMLTimeout
  • $wgMathEnableExperimentalInputFormats
‎<math>
Quarterly downloads 192 (Ranked 37th)
Public wikis using 7,934 (Ranked 18th)
Übersetze die Math-Erweiterung, wenn sie auf translatewiki.net verfügbar ist
Probleme Offene Aufgaben · Einen Fehler melden

Die Math-Erweiterung unterstützt die Darstellung mathematischer Formeln. Eine Übersicht des aktuellen Funktionsumfangs der Erweiterung ist in der Dokumentation der englischen Wikipedia verfügbar.

Mehr Informationen zur Installation und Konfiguration dieser Erweiterung, auch für ältere Versionen, sind unter Erweiterung:Math/advancedSettings zu finden.

Mathe anzeigen

The type of output depends on the software that you use to read the page. Die Math-Erweiterung versucht, eine MathML-Ausgabe mit Fallback auf Bilder in SVG (Konvertieren von Zeichen in < path>s) oder PNG (am wenigsten bevorzugt) zu liefern. Grundlegender Mathe-Support funktioniert auf allen Webbrowsern. Für optimale Darstellungsergebnisse sind jedoch spezielle Einstellungen nötig:

  • Für Firefox oder andereGecko-Browser ist es nötig, die Native MathML extension und math fonts zu installieren.
    Barrierefreiheit wird durch NVDA, VoiceOver oder Orca angeboten. Darüber hinaus erfordert NVDA das MathPlayer-Plugin, um Mathematik lesen zu können.
  • Für Safari oder andere WebKit-Browser können außerdem Mathe-Fonts installiert und das native MathML Rendering aktiviert werden, indem einige CSS-Regeln in das benutzerdefinierte Style Sheet der eigenen Browsereinstellungen eingefügt werden.
    Barrierefreiheit wird durch den VoiceOver Screenreader angeboten, aber noch nicht durch Orca.
  • Für Chrome müssen zur Unterstützung von Barrierefreiheit über ChromeVox oder visuelles Rendering per MathJax plugin einige CSS-Regeln in das benutzerdefinierte Style Sheet der eigenen Browsereinstellungen eingefügt werden.


Installation

  • Die Erweiterung herunterladen und die Datei(en) in ein Verzeichnis namens Math im Ordner extensions/ ablegen.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
  • Folgenden Code am Ende deiner LocalSettings.php -Datei einfügen:
    wfLoadExtension( 'Math' );
    
  • Führe das Aktualisierungsskript aus, welches automatisch die notwendigen Datenbanktabellen erstellt, die diese Erweiterung braucht.
  • Um Mathe jenseits eines einfachen Textoutputs zu sehen, bitte den Anweisungen unten zur Aktivierung verschiedener Mathe-Output-Modi folgen.
  • If you have problems for represent formulas when trying to use RESTBase, you can try using the following patch
  • Yes Erledigt – Zu Special:Version in dem Wiki (bei Einstellung auf deutsch nach Spezial:Version) navigieren, um die erfolgreiche Installierung der Erweiterung zu überprüfen.


Vagrant-Installation:

  • Wird Vagrant benutzt, ist mit vagrant roles enable math --provision zu installieren

You should additionally go to the page Special:MathStatus to see whether all of the components of the Math extension now work. Falls Probleme auftauchen, ist es am besten, einen Task auf https://phabricator.wikimedia.org anzulegen.

Leider gibt es keine gut getestete Anleitung zur Installation von Mathoid und RESTBase für die Math-Erweiterung, aber immerhin ist ein Arbeitsentwurf vorhanden. Extension:Math/RESTBase Bitte beitragen.

Math Output-Modi

Die Einstellung $wgMathValidModes enthält die Namen der Output-Modi, die zum Rendern verwendet werden können. Wenn mehrere Modi aktiviert sind, können angemeldete Nutzer in den persönlichen Einstellungen unter Aussehen eine Vorliebe festlegen.

Auch kann die Einstellung $wgDefaultUserOptions verwendet werden, um festzulegen, welcher dieser Modi Standard sein sollte, z. B.:

$wgDefaultUserOptions['math'] = 'mathml';

Mathoid

Modus: 'mathml'

Für MW 1.23 und höher kann ein Mathoid-Server verwendet werden, der MathJax benutzt, um texvc Input auf Serverseite in MathML+SVG Rendering zu konvertieren. This is the most recommended option; Mathoid is the Math rendering mode used on Wikipedia.

Benutzung von Mathoid

Für die Benutzung von Mathoid, was Leistungsvorteile bringt, werden folgende Einstellungen empfohlen:

// MathML als Standard-Renderoption festlegen
$wgDefaultUserOptions['math'] = 'mathml';
$wgMathUseInternalRestbasePath = false;
$wgMathFullRestbaseURL = 'https://wikimedia.org/api/rest_';
$wgMathMathMLUrl = 'https://mathoid-beta.wmflabs.org';

Siehe Mathoid für Hinweise zum Betrieb eines eigenen Mathoid-Servers.

Mathoids CLI Oberfläche

Um "Mathoid´s CLI Umgebung" nutzen zu können, was möglicherweise einfacher einzurichten ist und zu geringerem, permanentem Speicherverbrauch bei weniger Leistung führt, werden die folgenden Einstellungen empfohlen: To use this approach, the following settings are recommended:

// Setze MathML als Standard Rendering Option
$wgDefaultUserOptions['math'] = 'mathml';
// Bitte erstelle im Voraus eine config.yaml. Vorlagen befinden sich im Mathoid Verzeichnis.
$wgMathoidCli = ['/path/to/mathoid/cli.js', '-c', '/path/to/mathoid/config.yaml'];
// Erhöhe die Speichergrenze von MediaWiki auf 1,2 GB für Mathoid
$wgMaxShellMemory = 1228800;

If you run MediaWiki in a system containing SELinux and you get the message Mathoid cli '/path/to/mathoid/cli.js' is not executable in the error log, you can run the following to make sure that the Apache server allows to change system limits:

setsebool -P httpd_execmem 1
setsebool -P httpd_setrlimit 1

LaTeX

MediaWiki Version:
1.39

Modus: 'png'

Since MediaWiki 1.32, this mode will also require a Mathoid server to work. In older versions, it requires installing texvc and texvccheck, which may require the most setup work.

LaTeXML

Modus: 'latexml'

Verwendet LaTeXML. Das Rendern erfolgt über einen Onlinedienst (gesetzt per $wgLaTeXMLUrl, welche einen Standardwert von https://latexml.formulasearchengine.com/convert hat).

Native MathML

MediaWiki Version:
1.40

Mode: 'native'

This mode will generate MathML from LaTeX via PHP without Mathoid. Note this mode does not have image fallback, so formulas will only be displayed correctly if the browser supports MathML. Firefox and Safari introduced MathML support early (2006 and 2008), but support in Chromium-based browsers is a much more recent addition (Chrome 109, released in 2023).

Kein Rendern

Modus: 'source'

This mode will forward the Latex input without rendering, presenting it in a ‎<span> element, surrounded by $ :formula $.

Make sure to set $wgMathDisableTexFilter to 'always' (see below) if you only want the raw latex formula, else an error will appear due to the failed check for PNG depictions.

Liste wesentlicher Konfigurationseinstellungen

Name der Einstellung Defaultwert Beschreibung
$wgMathValidModes [ 'source', 'mathml' ] Definiert den Modus, der auf dem Server erlaubt ist.
$wgMathDisableTexFilter 'never' Option, um den Tex-Filter zu deaktivieren. Wenn dieser Wert auf true gesetzt wird, werden jegliche LaTeX-Ausdrücke geparst, was ein potentielles Sicherheitsrisiko darstellen kann. Wenn dieser Wert auf false gesetzt wird, ist nur eine Untermenge der TeX-Befehle erlaubt. Siehe die Wikipediaseite Help:Math für Details. Um dies zu deaktivieren, "always" verwenden.
$wgMathFullRestbaseURL false Die Math-Erweiterung erhält die Standard-Config vom Visual Editor, sofern verfügbar. Einzelheiten.
$wgMathPreferRestbaseURL true Whether to allow using of internal RESTBase path instead of $wgMathFullRestbaseURL and $wgVisualEditorFullRestbaseURL. Set false if you want to use external RESTBase in any case.

Tracking categories

The extension creates a number of tracking categories to detect errors and deprecated features. The exact name of the categories is determined by pages in the MediaWiki namespace.

MediaWiki-Seite Standard Beschreibung
MediaWiki:Math-tracking-category-error Category:Pages with math errors Pages where there is a syntax error in the formula causing the rendering to fail
MediaWiki:Math-tracking-category-render-error Category:Pages with math render errors Pages where there has been a temporary error in the rendering pipeline causing the rendering to fail. These normally fix themselves
MediaWiki:Math-tracking-category-texvc-deprecation Category:Pages that use a deprecated format of the math tags Pages which use deprecated texvc syntax like $ % \and \or \part \ang \C \H \bold \Bbb\ \pagecolor, which should be replaced by more standard LaTeX \$ \% \land \lor \partial \angle \Complex \mathbb{H} \mathbf \mathbb (removed) respectively. Siehe Extension:Math/Roadmap .
MediaWiki:Math-tracking-category-mhchem-deprecation Category:Pages that use a deprecated format of the chem tags

Deprecated chemical markup, see Extension:Math/Roadmap#Step 1 Part C: Manual fixing of mhchem syntax.

Tipps und Tricks

  • Um Formeln zu anderen Anwendungen wie Microsoft Word (Video) oder Google docs mit dem g(Math)-Plugin (Video) zu kopieren, kann das Firefox MathML Copy Addon verwendet werden
  • You can override the user preferred and default rendermode by adding the forcemathmode attribute to the ‎<math> element. e.g. to force an image being rendered <math forcemathmode="png">...</math>.
  • All images of rendered formula are stored in a cache and not automatically recreated if the page is viewed or edited. To force the re-rendering of all formulas of a page, purge using the ?action=purge&mathpurge=true action. For example the URL https://en.wikipedia.org/w/index.php?title=Integral&action=purge&mathpurge=true will force re-rendering of the w:Integral article. Afterwards you need to bypass your browser cache so that the new created images of the formulas are actually downloaded.

Fehler melden

Probleme mit der Math-Erweiterung können in Phabricator gemeldet werden. Zusätzlich sollte überprüft werden, wie sich das Problem zu den automatischen Unit-Tests verhält, die aus der Seite CoverageTest generiert werden.

Weitere Lektüre

Siehe Erweiterung:Math/advancedSettings für ältere Versionen und weitere Informationen.

Unterseiten

Siehe auch