Extension:Math

From mediawiki.org
This page is a translated version of the page Extension:Math and the translation is 62% complete.
Outdated translations are marked like this.
この拡張機能は MediaWiki 1.38 以降に同梱されています。 そのため再度ダウンロードする必要はありません。 しかし、提供されているその他の手順に従う必要はあります。
MediaWiki 拡張機能マニュアル
Math
リリースの状態: 安定
実装 タグ
説明 数式をレンダリングできるようにする
作者
  • Moritz Schubotz
  • Tomasz Wegrzanowski
  • Brion Vibber
最新バージョン continuous updates
互換性の方針 MediaWiki とともにリリースされるスナップショット。 master には後方互換性がありません。
MediaWiki >= 1.42.0
データベースの変更 はい
テーブル math
mathoid
mathlatexml
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
  • $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 191 (Ranked 37th)
Public wikis using 7,934 (Ranked 18th)
translatewiki.net で翻訳を利用できる場合は、Math 拡張機能の翻訳にご協力ください
問題点 未解決のタスク · バグを報告

Math拡張機能は、数式を表現するためのサポートを提供します。この拡張機能で現在できることの概要は、m:Help:数式の表示にあります。

古いバージョンを含め、この拡張機能のインストールと設定に関する詳細はExtension:Math/高度な設定 にあります。

数式の表示

The type of output depends on the software that you use to read the page. 可能な場合、Math 拡張機能が MathML を出力します。それ以外の場合は、文字を <path> 要素に変換した SVG 画像または PNG 画像を出力します。 基本的な数式のサポートはすべてのブラウザーで機能します。ただし、最良の結果を得るためには、設定を変更する必要があるかもしれません:


インストール

  • ダウンロードして、ファイルをextensions/フォルダー内のMathという名前のディレクトリ内に配置します。
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'Math' );
    
  • 更新スクリプトを実行します。このスクリプトは、この拡張機能が必要とするデータベーステーブルを自動的に作成します。
  • 平文以外の出力で数式を表示するには、以下の手順に従い、さまざまな数式の出力モードを有効にします。
  • If you have problems for represent formulas when trying to use RESTBase, you can try using the following patch
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。


Vagrant installation:

  • Vagrant を使用している場合は、vagrant roles enable math --provisionでインストールしてください。

You should additionally go to the page Special:MathStatus to see whether all of the components of the Math extension now work. 何か問題が発生した場合は、https://phabricator.wikimedia.org にタスクを作成することをお勧めします

残念ながら、Mathoid RESTBase のインストールについては、Math拡張機能を使用するための十分にテストされたガイドはありませんが、少なくとも作業用のドラフトはあります。 Extension:Math/RESTBase に貢献してください。

さらに、MW1.28にRESTBaseとMathoidをインストールしてセットアップするためのガイドがあります。

数式の出力モード

$wgMathValidModesを設定すると、レンダリングに使用できる出力モードの名前を持つ配列が保持されます。 If multiple modes are enabled, logged-in users can set a personal preference in the appearance pane of their user preferences page.

$wgDefaultUserOptions設定を使用して、これらのモードのどれをデフォルトにするかを設定することもできます。例:

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

Mathoid

モード: 'mathml'

You can use Mathoid, an application that uses MathJax on the server side to convert texvc input to MathML+SVG rendering. This is the most recommended option; Mathoid is the Math rendering mode used on Wikipedia.

Mathoid をサービスとして提供する

"Mathoid as a service" is the recommended approach for the Math extension, and the default one. If you do not add any additional settings to LocalSettings.php, Math will use the Beta cluster's Mathoid and RESTBase services to do all math formula rendering. The default settings are:

// 既定のレンダリング設定としてMathMLを設定する
$wgDefaultUserOptions['math'] = 'mathml';
$wgMathUseInternalRestbasePath = false;
$wgMathFullRestbaseURL = 'https://wikimedia.org/api/rest_';
$wgMathMathMLUrl = 'https://mathoid-beta.wmflabs.org';

You can modify these settings to use different Mathoid and RESTBase services, potentially including your own.

Mathoidの CLI インターフェース

You can instead run Mathoid as a command-line utility on the local server. To use this approach, the following settings are recommended:

// MathMLを既定の解析オプションとして設定
$wgDefaultUserOptions['math'] = 'mathml';
// まず先に、config.yamlを作成してください。テンプレートはMathoidリポジトリにあります。
$wgMathoidCli = ['/path/to/mathoid/cli.js', '-c', '/path/to/mathoid/config.yaml'];
// mathoid向けに、MediaWikiのメモリ上限を1.2Gに引き上げます。
$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 バージョン:
1.39

モード: '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

モード: 'latexml'

LaTeXML ユーティリティを使用。 The rendering is done via an online service (set with $wgLaTeXMLUrl, which has a default value of https://latexml.formulasearchengine.com/convert).

Native MathML

MediaWiki バージョン:
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).

解析処理をしない

モード: '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.

重要な構成設定のリスト

設定名 既定値 説明
$wgMathValidModes [ 'source', 'mathml' ] サーバー上で許可されるモードを定義します。
$wgMathDisableTexFilter 'never' Texフィルタを無効にするオプションについて。「true」に設定した状態でLaTeX表示があると、セキュリティ上の弱点になる可能性があります。「false」に設定すると、TeXコマンドのサブセットのみ有効になります。詳細はヘルプ:数式の書き方を参照してください。 この機能を無効にするには「always」を使用してください。
$wgMathFullRestbaseURL false 数式の拡張機能の既定の設定は、ビジュアルエディターにある場合はそこから取ってきます。 詳細.
$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.

カテゴリの追跡

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 ページ 既定値 説明
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. 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.

ヒントとトリック

  • FirefoxのアドオンMathML コピーを使うと、数式を Microsoft Wordなど他のアプリケーションに (video)、g(Math)プラグインを使うとGoogle docs (video) にそれぞれ転写できます。
  • 個人設定と既定の解析モードをオーバーライドするには、‎<math> 要素に forcemathmode 属性を追加し、例えば画像を強制的に <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.

エラーの報告

数式拡張機能でなにか問題が発生した場合は、Phabricatorに報告をお願いします。さらに、CoverageTestページから生成される自動化単体テストと、発生した問題に関連があるかどうか、点検する必要があります。

更なる情報

古いバージョンの情報ならびにその他の情報はExtension:Math/高度な設定 で確認します。

下位ページ

関連項目