# 扩展:数学

This page is a translated version of the page Extension:Math and the translation is 66% complete.
Outdated translations are marked like this.
Other languages:
MediaWiki擴充功能手冊
Math

• Moritz Schubotz,
• Tomasz Wegrzanowski,
• Brion Vibber
• 以及其他贡献者

MediaWiki 1.25+

math
mathoid
mathlatexml

• $wgMathEnableWikibaseDataType •$wgMathDefaultLaTeXMLSetting
• $wgMathWikibasePropertyIdHasPart •$wgMathoidCli
• $wgMathLaTeXMLTimeout •$wgMathWikibasePropertyIdQuantitySymbol
• $wgMathDisableTexFilter •$wgMathMathMLTimeout
• $wgMathLaTeXMLUrl •$wgMathEnableExperimentalInputFormats
• $wgMathValidModes •$wgMathWikibasePropertyIdDefiningFormula
• $wgMathFullRestbaseURL •$wgMathMathMLUrl
• $wgMathConcurrentReqs •$wgMathEnableFormulaLinks
‎<math>

## 安装

• 如果使用Vagrant，请通过vagrant roles enable math --provision安装

• 下载文件，并将其放置在您extensions/文件夹中的Math目录内。
• 将下列代码放置在您的LocalSettings.php的底部：
wfLoadExtension( 'Math' );
// 下面是安装和配置的设置：

• 运行更新脚本，它将自动创建此扩展必须依赖的数据库表。
• 要查看純文本輸出之外的數學輸出模式，請按照以下說明啟用各種數學輸出模式
•   完成 – 在您的wiki上导航至Special:Version，以验证扩展已成功安装。

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创建一个任务。

Unfortunately, there is no well tested guide on installing Mathoid and RESTBase to work with the Math extension, but there is at least a working draft. Extension:Math/Restbase请贡献。

## 数学输出模式

$wgDefaultUserOptions['math'] = 'mathml';  ### Mathoid 模式： 'mathml' (pre-July 2015: MW_MATH_MATHML) For MW 1.23 and higher, you can use a Mathoid server that uses MathJax to convert texvc input on the server side to MathML+SVG rendering. This is the most recommended option; Mathoid is the rendering mode that is on Wikipedia. #### 服务器上的Mathoid 为了使用服务器上的Mathoid以获得表现形式上的好处,推荐进行下列设置： // 将MathML设为默认渲染选项$wgDefaultUserOptions['math'] = 'mathml';
$wgMathFullRestbaseURL = 'https://en.wikipedia.org/api/rest_';$wgMathMathMLUrl = 'https://mathoid-beta.wmflabs.org/';


#### Mathoid的命令行接口

To use Mathoid's CLI interface, which is possibly easier to set up and resulting in less permanent memory consumption, while degrading performance, the following settings are recommended:

// 将MathML设为默认渲染选项
$wgDefaultUserOptions['math'] = 'mathml'; // Please create a config.yaml in advance. Templates are in the Mathoid repository.$wgMathoidCli = ['/path/to/mathoid/cli.js', '-c', '/path/to/mathoid/config.yaml'];
// Raise MediaWiki's memory limit to 1.2G for mathoid.

### 未渲染

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. ### MathJax  警告： The client-side MathJax rendering mode is removed in MediaWiki 1.26. 另请参阅擴展:SimpleMathJax。 ## 重要的配置设置列表 设置名 默认值 描述$wgMathValidModes array( 'png', 'source', 'mathml' ) 定义该服务器上可用的渲染模式
$wgMathDisableTexFilter 'never' Option to disable the tex filter. If set to true any LaTeX expression is parsed this can be a potential security risk. If set to false only a subset of the TeX commands is allowed. See the wikipedia page Help:Math for details. Use "always" to disable this feature.$wgMathFullRestbaseURL false The math extension gets the default config from the Visual Editor, if available. 详情.

## 跟踪分类

MediaWiki页面 默认 描述
MediaWiki:Math-tracking-category-error Category:Pages with math errors 含有导致渲染失败的公式语法错误的页面
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

## 提示与技巧

• 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:Integer article. Afterwards you need to bypass your browser cache so that the new created images of the formulas are actually downloaded.

## 错误报告

If something is wrong with the math extension you can report that at Phabricator. In addition you should check how your problem relates to the automated unit tests that are generated from the page CoverageTest.