Extension:數學
![]() 發佈狀態: 穩定版本 |
|
---|---|
![]() |
|
实现 | 标签 |
描述 | 允许生成数学公式 |
作者 |
|
最新版本 | continuous updates |
兼容性政策 | 快照跟随MediaWiki发布。 master分支不向後兼容。 |
MediaWiki | >= 1.40.0 |
数据库更改 | 是 |
表 | math mathoid mathlatexml |
许可协议 | GNU通用公眾授權條款2.0或更新版本 |
下載 | |
|
|
<math> |
|
季度下載量 | 361 (Ranked 31st) |
公開的wiki使用 | 7,934 (Ranked 18th) |
翻譯Math的扩展,若在translatewiki.net可用 | |
問題 | 尚未完成的工作 · 报告錯誤 |
数学(Math)扩展提供渲染数学公式的支持。有关当前此扩展的功能的概述,请参考m:Help:显示公式。
更多有关安装和配置此扩展(包括旧版本)的信息,可在Extension:Math/advancedSettings 中查阅。
查看数学公式
数学扩展会依次尝试输出MathML、SVG图片(将字符转换成<path>)或PNG图片(最低优先级)。 输出的结果将取决于你使用的设备的兼容性。 基本數學支持適用於所有瀏覽器。但是,為獲得最佳渲染,可能需要進行特定的調整:
- 對於Firefox或其他Gecko瀏覽器,需要安裝Native MathML擴展和數學字體。
无障碍支持由NVDA、VoiceOver或Orca提供。 而且,NVDA需要MathPlayer来读出公式。 - 对于Safari或者其他WebKit浏览器,你可能也需要安装数学字体并通过向浏览器参数设置的自定义样式表安装一些CSS规则启用本地MathML渲染。
无障碍支持由VoiceOver屏幕朗读器提供,但是还没有Orca。 - 对于Chrome,您必须像通过ChromeVox向您的浏览器的自定义样式表插入一些CSS规则以获取访问支持,或者通过MathJax扩展获取视觉渲染。
- 在一些版本的Internet Explorer中,可以使用MathPlayer作为一种辅助技术。
安裝
- 下载文件,并将其放置在您
extensions/
文件夹中的Math
目录内。 - 将下列代码放置在您的
LocalSettings.php
的底部:wfLoadExtension( 'Math' );
- 运行更新脚本,它将自动创建此扩展必须依赖的数据库表。
- 要查看純文本輸出之外的數學輸出模式,請按照以下說明啟用各種數學輸出模式。
- 如果您在尝试使用wikipedia restbase时遇到表示公式的问题,您可以尝试使用以下修复
- 完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。
Vagrant安装:
- 如果使用Vagrant ,请通过
vagrant roles enable math --provision
安装
您还应该转到页面Special:MathStatus以查看Math扩展的所有组件现在是否正常工作。 对于你遇到的任何问题,最好的办法是在https://phabricator.wikimedia.org创建一个任务。
可惜还没有经过良好测试的关于安装Mathoid 和RESTBase 以使用Math扩展的指南,但至少有个进展中的草稿。 Extension:Math/RESTBase 请贡献。
此外,GitHub上有个通过Restbase和MW 1.28的Mathoid安装并设置MediaWiki的教程。
数学输出模式
设置$wgMathValidModes包含含有可以用于渲染的输出模式的名称的数组。 如果多个模式启用,已登录的用户可以在用户参数设置页面的appearance面板中设置个人偏好。
你也可以使用$wgDefaultUserOptions设置来设置哪个模式是默认的,比如:
$wgDefaultUserOptions['math'] = 'mathml';
Mathoid
模式: 'mathml'
您可以使用Mathoid,这是一个在服务器端使用MathJax将texvc输入转换为MathML+SVG渲染的应用。 这是最推荐的选项,Mathoid是维基百科上使用的数学渲染模式。
服务器上的Mathoid
“Mathoid as a service”是Math扩展的推荐方法,也是默认方法。如果您不向LocalSettings.php添加任何其他设置,Math将使用Wikimedia Mathoid和RESTBase 服务来渲染所有数学公式。默认设置为:
// 将MathML设为默认渲染选项
$wgDefaultUserOptions['math'] = 'mathml';
$wgMathFullRestbaseURL = 'https://wikimedia.org/api/rest_';
$wgMathMathMLUrl = 'https://mathoid-beta.wmflabs.org';
您可以修改这些设置,以使用不同的Mathoid和RESTBase服务,可能包括您自己的。
Mathoid的命令行接口
您还可以在本地服务器上将Mathoid作为命令行实用程序运行。 要使用此方法,建议使用以下设置:
// 将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'
Uses the LaTeXML utility. The rendering is done via an online service (set with $wgLaTeXMLUrl, which has a default value of https://latexml.formulasearchengine.com/convert).
未渲染
模式: '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'
|
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页面 | 默认 | 描述 |
---|---|---|
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 |
不被推荐的化学标记,参见Extension:Math/Roadmap#Step 1 Part C: Manual fixing of mhchem syntax。 |
提示与技巧
- 您可以使用Firefox的MathML copy扩展以将公式复制到其他应用,例如Microsoft Word(视频)或者Google文档(带有g(Math)插件)(视频)
- 您可以在
<math>
元素添加forcemathmode
属性,以覆盖用户首选和默认渲染模式,例如强制渲染图像为<math forcemathmode="png">...</math>
。 - 渲染公式的所有图像都存储在缓存中,并且在查看或编辑页面时不会自动重新创建。 要强制重新渲染页面的所有公式,使用
?action=purge&mathpurge=true
操作来刷新。 例如,URL https://en.wikipedia.org/w/index.php?title=Integral&action=purge&mathpurge=true会强制重新渲染w:Integer文章。 然后你需要绕过浏览器缓存以便让新创建的公式图像实际上已下载。
错误报告
如果Math扩展有问题,您可以在Phabricator报告。此外,您应检查您的问题与页面CoverageTest生成的自动化单元测试有何关系。
延伸阅读
旧版本以及更多信息可参考Extension:Math/advancedSettings 。
子页面
- Math/Announcement
- Math/CoverageTest
- Math/CustomizationHook
- Math/Displaystyle
- Math/Help:Formula
- Math/Hooks/MathAfterTexvc
- Math/Hooks/MathFormulaPostRender
- Math/Hooks/MathFormulaRendered
- Math/Hooks/MathRenderingResultRetrieved
- Math/Inputtypes
- Math/MathJaxMenu
- Math/MathJax testing
- Math/Popups
- Math/RESTBase
- Math/Roadmap
- Math/T140217
- Math/T167569
- Math/T1835557
- Math/T183559
- Math/T218295
- Math/T247697
- Math/T305613
- Math/T317065
- Math/T32215
- Math/T325625
- Math/T86450
- Math/T87007
- Math/TeX-header
- Math/Unique Ids
- Math/Url2Image
- Math/Wikibooks-20160516
- Math/additionalAnnotationTypes
- Math/advancedSettings
- Math/advancedSettings/de
- Math/advancedSettings/de-formal
- Math/advancedSettings/en
- Math/advancedSettings/es
- Math/advancedSettings/fr
- Math/advancedSettings/ja
- Math/advancedSettings/pl
- Math/advancedSettings/pt-br
- Math/advancedSettings/tr
- Math/annotation.js
- Math/bug/35189
- Math/bug/38641
- Math/bug/48032
- Math/bug/49210
- Math/bug/54818
- Math/bug/69554
- Math/bug/75285
- Math/chemrm
- Math/da
- Math/de
- Math/de-formal
- Math/en
- Math/es
- Math/fr
- Math/hu
- Math/id
- Math/ja
- Math/ko
- Math/math table
- Math/mathlatexml table
- Math/mathoid table
- Math/modifyMenu.js
- Math/newFeatures
- Math/pl
- Math/pt-br
- Math/ru
- Math/tr
- Math/uk
- Math/vi
- Math/yue
- Math/zh
參見
- Extension:Math/Roadmap
- Mathoid
- 擴展:SimpleMathJax - 提供在wiki上渲染数学公式的另一种方法,无需texvc或LaTeX
- Texvc PHP替代
- Manual:Enable TeX/problems
- 手册:數學
此扩展用于一个或多个维基媒体项目。 这可能意味着扩展足够稳定、运作足够良好,可以用在这样的高流量的网站上。 请在维基媒体的CommonSettings.php和InitialiseSettings.php配置文件中查找此扩展的名称以查看哪些网站安装了该扩展。 特定wiki上的已安装的扩展的完整列表位于Special:Version页面。 |
此擴充功能包含在以下包或/和wiki農場: 這不是一份權威名單。即使一些wiki農場/託管者沒有被列在這裡,他們也可能包含這個extension。請以各wiki農場/託管者或包的狀態為準。 |