扩展:数学
Math 发布状态: 稳定版 |
|
---|---|
![]() |
|
实现 | 标签 |
描述 | 允许生成数学公式 |
作者 |
|
最新版本 | continuous updates |
MediaWiki | 1.25+ |
数据庫更改 | 是 |
表 | math mathoid mathlatexml |
许可协议 | GNU通用公眾授權條款2.0或更新版本 |
下载 | |
|
|
<math> |
|
翻譯Math擴充功能如在translatewiki.net可用 | |
问题 | 尚未完成的工作 · 回報錯誤 |
数学扩展端提供渲染数学公式的支持。有关当前此扩展的功能的概述,请参考这个英语维基百科页面。
更多有关安装和配置此扩展(包括旧版本)的信息,可在Extension:Math/advancedSettings 中查阅。
查看数学公式
数学扩展会依次尝试输出MathML、SVG图片(将字符转换成<路径>)或PNG图片(最低优先级)。 输出的结果将取决于你使用的设备的兼容性。 基本數學支持適用於所有瀏覽器。但是,為了獲得最佳渲染,可能需要進行特定的調整:
- 對於Firefox或其他Gecko瀏覽器,需要安裝Native MathML擴展名和數學字體。 无障碍支持由NVDA、VoiceOver或Orca提供。 而且,NVDA需要MathPlayer来读出公式。
- 对于Safari或者其他WebKit浏览器,你可能也需要安装数学字体并通过向浏览器参数设置的自定义样式表安装一些CSS规则启用本地MathML渲染。
无障碍支持由VoiceOver屏幕朗读器提供,但是还没有Orca。
- For Chrome you must insert some CSS rules into the custom style sheet of your browser preference in order to get accessibility support via ChromeVox or visual rendering via the MathJax plugin.
- 在一些版本的Internet Explorer中,可以使用MathPlayer作为一种辅助科技。
安装
- 如果使用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 请贡献。
此外,GitHub上有个通过Restbase和MW 1.28的Mathoid安装并设置MediaWiki的教程。
数学输出模式
设置$wgMathValidModes包含含有可以用于渲染的输出模式的名称的序列。 如果多个模式启用,已登录的用户可以在用户参数设置页面的appearance面板中设置个人偏好。
你也可以使用$wgDefaultUserOptions设置来设置哪个模式是默认的,比如:
$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 will be used on Wikipedia in the future.
服务器上的Mathoid
为了使用服务器上的Mathoid以获得表现形式上的好处,推荐进行下列设置:
// 将MathML设为默认渲染选项
$wgDefaultUserOptions['math'] = 'mathml';
$wgMathFullRestbaseURL = 'https://en.wikipedia.org/api/rest_';
$wgMathMathMLUrl = 'https://mathoid-beta.wmflabs.org/';
关于自行搭建Mathoid服务器的指南在Mathoid页面 Note that as of March 2017 this is likely to also require a RESTBase server/installation (see 任务T154394).
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.
$wgMaxShellMemory = 1228800;
If you run MediaWiki under system containing SELinux and you get Mathoid cli '/path/to/mathoid/cli.js' is not executable
message from the error log, you can run
setsebool -P httpd_execmem 1 setsebool -P httpd_setrlimit 1
to make sure the Apache server allow to change system limits.
LaTeX
模式: 'png' (pre-July 2015: MW_MATH_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' (pre-July 2015: MW_MATH_LATEXML)
Uses the LaTeXML utility. The rendering is done via an online service (set with $wgLaTeXMLUrl, which has a default value).
未渲染
模式: 'source', (pre-July 2015: MW_MATH_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.
MathJax
重要的配置设置列表
设置名 | 默认值 | 描述 |
---|---|---|
$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页面 | 默认 | 描述 |
---|---|---|
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。 |
提示与技巧
- You can use the Firefox MathML copy addon to copy formulae to other applications such as Microsoft Word (video), or Google docs with the g(Math) plugin (video)
- You can override the user preferred and default rendermode by adding the
forcemathmode
attribute to the <math> element. eg.. 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.
扩展阅读
旧版本以及更多信息可参考Extension:Math/advancedSettings 。
子页面
参见
- Extension:Math/Roadmap
- Mathoid
- 擴展:SimpleMathJax - an alternative way to provide support for rendering mathematical formulas on-wiki, without texvc or LaTeX
- Texvc - 关于texvc的描述
- Texvc PHP替代
- LaTeX on a shared host
- 另外也可以使用: LaTeX with google chart
- Manual:Enable TeX/problems
- 手册:數學
此扩展被用于一个或多个维基媒体项目上。 这可能意味着扩展稳定且工作良好,足以用在同等高流量的网站上。 请在维基媒体的CommonSettings.php和InitialiseSettings.php配置文件中寻找此扩展名称以查看安装它的网站。 详细的已安装扩展的完整列表可在wiki的Special:Version页面找到。 |