在斯芬克斯创建方程

LaTeX

写方程的语法是 Latex 。

这里只包括一些简单的例子,因为LaTex是一个相当陡峭的学习曲线,而AMSLaTex只关心数学支持。

以下链接很有用:

  • 请参阅ftp://ftp.ams.org/pub/tex/doc/amsmash/short-math-guide.pdf,以获得一个不那么短但清晰的语法指南。

  • 完整的参考资料见http://www.ams.org/publications/authors/tex/amslatex。

  • 请参阅http://mirrors.fe.up.pt/pub/ctan/info/examples/mil/mil.pdf了解对 Latex 的不那么温和的介绍。

MathJax

在狮身人面像中,方程的渲染(显示)可以以不同的方式进行,这里不讨论。

所选选项是使用 sphinx.ext.mathjax 扩展。此扩展使用javascript包 MathJax 在浏览器中将LaTex标记转换为可读的Math Live。

缺点是Mathjax库的(大)尺寸和加载时间。

这个 mathjax_pathconf.py 文件指示Mathjax库所在的位置。默认情况下,这是Mathjax站点,但可以更改路径,不允许跨站点脚本。

公式编辑器或预览器

鉴于LaTex语法可能令人望而生畏,Wysiwyg数学编辑器可能很有用,或者至少是一个交互式预览器:

  • 如果目标只是预览结果,那么 `Interactive LaTeX Editor`_ 是非常好的选择,包括许多方程作为例子。

  • LyX_ 是一个用户友好的 Latex 处理器,包括公式编辑器。

    从长远来看,Lyx可能是最好的选择:它与EqualX(一个更大的开发和用户社区)具有相同的依赖性,并且几乎不需要任何 Latex 知识。

  • EqualX_ 是一个 Latex 公式编辑器(不是像lyx那样的文档处理器):它可以用来创建公式,然后将代码粘贴到其余的文档中。

    喜欢 LyX_, EqualX需要一个 Latex 分发(在Linux中,依赖项是自动安装的,并且 TeXLive_ 包含在所有主要发行版的官方存储库中;对于Windows系统, MiKTeX_ 是一种可能的选择)。

实例

请参阅http://sphinx-doc.org/ext/math.html上的其他示例。

代码:

If :math:`\sigma_{1}` equals :math:`\sigma_{2}` then etc, etc.

输出:

如果 \sigma_{{1}} 等于 \sigma_{{2}} 然后等等。

代码:

:math:`\underline{x}=[  x_{1}, ...,  x_{n}]^{T}`

输出:

\underline{x}=[  x_{1}, ...,  x_{n}]^{T}

代码:

\langle \alpha, \beta  \rangle
\in
\Biggl \lbrace
{
M,\text{ if }
   {
    l(\underline{x}) =
      \frac { p(\underline{x}|M ) } { p(\underline{x}|U) }
      \geq
       \frac { p(U) }{ p(M) } }
\atop
U, \text{ otherwise }
}

输出:

System Message: WARNING/2 (langle alpha beta rangle inbiggl lbrace m、biggl lbrace m、text l(und线x p(und线x 124;\124;; \125; biggl 123123; m(und线125;)

latex exited with error [stdout] This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=latex) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2017/01/01> patch level 3 Babel <3.9r> and hyphenation patterns for 12 language(s) loaded. (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2014/09/29 v1.4h Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo)) (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty (/usr/share/texlive/texmf-dist/tex/latex/base/utf8.def (/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.dfu) (/usr/share/texlive/texmf-dist/tex/latex/base/ot1enc.dfu) (/usr/share/texlive/texmf-dist/tex/latex/base/omsenc.dfu))) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amscls/amsthm.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) (/usr/share/texlive/texmf-dist/tex/latex/anyfontsize/anyfontsize.sty) (/usr/share/texlive/texmf-dist/tex/latex/tools/bm.sty) No file math.aux. (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd) ! Package inputenc Error: Unicode char 、 (U+3001) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char 、 (U+3001) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char 线 (U+7EBF) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char 线 (U+7EBF) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Undefined control sequence. <argument> ...�text l(und线x p(und线x 124;\1 24;; \125; biggl 123123; m... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Undefined control sequence. <argument> ...(und线x p(und线x 124;\124;; \1 25; biggl 123123; m(und�... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char 线 (U+7EBF) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char 、 (U+3001) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char 、 (U+3001) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char 线 (U+7EBF) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char 线 (U+7EBF) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Undefined control sequence. <argument> ...�text l(und线x p(und线x 124;\1 24;; \125; biggl 123123; m... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Undefined control sequence. <argument> ...(und线x p(und线x 124;\124;; \1 25; biggl 123123; m(und�... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} ! Package inputenc Error: Unicode char 线 (U+7EBF) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...5; biggl 123123; m(und线125;\end{split} Overfull \hbox (131.12564pt too wide) in paragraph at lines 15--15 [] [1] (./math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 416 bytes). Transcript written on math.log.