Extension:Math/zh

From testwiki
Jump to navigation Jump to search

<languages /> Template:Extension 数学(Math)扩展提供呈現数学公式的支持。

更多有关安装和配置此扩展(包括旧版本)的信息,可在Template:Ll中查阅。

See an overview of what can currently be done with this extension at Extension:Math/Syntax.

安裝

Template:Bundled Template:ExtensionInstall

您还应该转到页面Special:MathStatus以查看Math扩展的所有组件现在是否正常工作。 对于你遇到的任何问题,最好的办法是在https://phabricator.wikimedia.org创建一个任务。

可惜还没有经过良好测试的关于安装Template:LlTemplate:Ll以使用Math扩展的指南,但至少有个进展中的草稿。 Template:Ll请贡献。

此外,GitHub上有个通过RESTBase和MW 1.28的Mathoid安装并设置MediaWiki的教程

Usage

Once installed, you write formulas using TeX markup syntax inside the Template:Tag tag. For example:

<math>E=mc^2</math>

Renders as:

E=mc2


查看数学公式

The type of output depends on the software that you use to read the page. 若是可的以話,数学扩展会依次尝试输出MathML,否則它就輸出SVG图片(将字符转换成<path> elements)或PNG图片(最低优先级)。 基本數學功能支持適用於所有瀏覽器。但是,為獲得最佳結果,你可能需要變更你的設定值:

重要的配置设置列表

设置名 Template:LC zh 描述
Template:Ll [ 'source', 'mathml' ] 定义该服务器上可用的渲染模式
Template:Ll '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. 详情.
$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.

数学输出模式

设置$wgMathValidModes包含含有可以用于渲染的输出模式的名称的数组。 如果多个模式启用,已登录的用户可以在用户参数设置页面的appearance面板中设置个人偏好。

你也可以使用$wgDefaultUserOptions设置来设置哪个模式是默认的,比如:

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

Mathoid

模式: 'mathml' Template:Warning

您可以使用Mathoid,这是一个在服务器端使用MathJax将texvc输入转换为MathML+SVG渲染的应用。 这是最推荐的选项,Mathoid是维基百科上使用的数学渲染模式。

服务器上的Mathoid

“Mathoid as a service”是Math扩展的推荐方法,也是默认方法。如果您不向LocalSettings.php添加任何其他设置,Math将使用Beta cluster的MathoidTemplate:Ll服务来渲染所有数学公式。默认设置为:

// 将MathML设为默认渲染选项
$wgDefaultUserOptions['math'] = 'mathml';
$wgMathUseInternalRestbasePath = false;
$wgMathFullRestbaseURL = 'https://wikimedia.org/api/rest_';
$wgMathMathMLUrl = 'https://mathoid-beta.wmflabs.org';

Template:Warning

您可以修改这些设置,以使用不同的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;

Template:Note

LaTeX

Template:MW 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).

Native MathML

Template:MW 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).

MathJax

Template:MW 1.42 Mode: 'mathjax'

This mode works the same as Native MathML mode (generating MathML from LaTeX via PHP), but it will use MathJax 3 to render MathML. Therefore it will work for browsers that do not have MathML support, with the overhead of loading MathJax library (bundled in Math extension) on page views. Template:Warning

未渲染

模式: 'source'

This mode will forward the Latex input without rendering, presenting it in a Template:Tag 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.

扩展会创建一系列跟踪分类,以检测错误和不被推荐的特性。 Their message keys begin with math-. Administrators may change a tracking category's name in a wiki by editing the message's value in that wiki's MediaWiki namespace. Special:TrackingCategories shows each tracking category's name, message key, and description.

MediaWiki页面 -{zh-hans:默认; zh-hant:預設;}- 描述
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. 参见Template:Ll
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

提示与技巧

错误报告

如果Math扩展有问题,您可以在Phabricator报告。此外,您应检查您的问题与页面CoverageTest生成的自动化单元测试有何关系。

延伸阅读

旧版本以及更多信息可参考Template:Ll

子页面

Template:Subpages

參見

Template:OnWikimedia Template:Used by

[[Category:TeX{{#translation:}}]] [[Category:Math display extensions{{#translation:}}]] [[Category:Extensions with VisualEditor support{{#translation:}}]]