Was this page helpful?

Mathematical Formulae

    Vendor MindTouch
    Type Native
    Categories Misc
    Requires MindTouch 1.8.2 or later
    OS Restriction None
    Status Prototype
    License Free/Open Source
    SID (service id) sid://mindtouch.com/2007/06/math
    Assembly mindtouch.deki.services

    Install Extension

    URL of your MindTouch install (ex: http://www.mindtouch.com)
        

     

    Description

    This extension contains functions for rendering and computing mathematical expressions.

    See also How to add an extension, Using the Extension Dialog, Learn about DekiScript, Extensions Directory.

    Configuration:

    Config Key Description
    latex-path Path to latex application
    dvips-path Path to dvips application
    imagemagick-path Path to convert application

     

    If you want an alternative to getting LaTeX to work, see: MathML

     

    Fedora / Red Hat / CentOS

    Install the following before using the Math service under Debian Linux

     

    1. Execute:
      yum install tetex-latex
    2. Execute:
      mkdir /var/www/.texmf-var
      chown dekiwiki:apache /var/www/.texmf-var
      
      
      
      
      
      
      
    3. Set 'latex-path' to /usr/bin/latex
    4. Set 'dvips-path' to /usr/bin/dvips
    5. Set 'imagemagick-path' to /usr/bin/convert

     

     

     An alternative for this functionality on these environments can be achieved by invoking the ASCIIMathML JavaScript via the template here.

     

    Microsoft Windows Setup
    Install the following applications before using the Math service under Microsoft Windows XP and Windows Server 2003/2008.

    1. Install MiKTeX
    2. Install ImageMagick
    3. FIX (12-03-09) - Install Ghostscript (NEW URL, old one did not have easy link to Windows version)
    4. Set 'latex-path' to point to latex.exe installed by MiKTex (e.g. C:\Program Files\MiKTeX 2.5\miktex\bin\latex.exe)
    5. Set 'dvips-path' to ponit to dvips.exe installed by MiKTex (e.g. C:\Program Files\MiKTeX 2.5\miktex\bin\dvips.exe)
    6. Set 'imagemagick-path' to convert.exe installed by ImageMagick (e.g. C:\Program Files\ImageMagick\convert.exe)

     

    Debian Setup
    Install the following before using the Math service under Debian Linux

    1. Execute:
      apt-get install tetex-extra gs-gpl imagemagick
    2. Set 'latex-path' to /usr/bin/latex
    3. Set 'dvips-path' to /usr/bin/dvips
    4. Set 'imagemagick-path' to /usr/bin/convert

    *if any 404 errors are received in step 1., please run 'apt-get update'

     

    Gentoo Setup
    Install the following before using the Math service under Gentoo Linux

    1. Execute:
      emerge -a tetex ghostscript imagemagick
    2. Set 'latex-path' to /usr/bin/latex
    3. Set 'dvips-path' to /usr/bin/dvips
    4. Set 'imagemagick-path' to /usr/bin/convert

    Functions:

    1. math.formula
    2. math.sheet

    math.formula(formula : str) : uri

    Render math formula.

    Parameters:

    Name Type Description
    formula str Formula in Latex-AMS notation

    Remarks:   Refer here for a math guide for Latex.

    Samples:

      Output

    To embed a simple equation:

    {{ math.formula("\\alpha^2+\\beta^2*\\gamma^3=1") }} 
    ./MathFormula1.JPG

    To embed a more complicated equation:

    {{ math.formula("\\Re{z} =\\frac{n\\pi \\dfrac{\\theta +\\psi}{2} } {\\left(\\dfrac{\\theta +\\psi}{2}\\right)^2 + \\left( \\dfrac{1}{2} \\log \\left\\lvert\\dfrac{B}{A}\\right\\rvert\\right)^2}") }}
    ./MathFormula2.JPG

     


    math.sheet(sheet : uri, width : num, height : num) : xml

    Embed an InstaCalc sheet.

    Parameters:

    Name Type Description
    sheet uri URI to InstaCalc sheet.
    width num Optional.  Width of sheet (default: 425)
    height num Optional.  Height of sheet (default: 300)

    Remarks:  Refer here for more information on InstaCalc.

    Samples:

      Output

    To embed an InstaCalc sheet:

    {{ math.sheet("http://instacalc.com/?d=&c=MTAwICogNTB8MioyICsgMy80fHxzYWxlcyA9IDMwMCBtaWxsaW9uICsgMTAlfDEwIGluY2hlcyB0byBjbXwxNTAgbGJzIGluIGtnfDUgTUIvc2VjIGluIEdCL2hvdXI&s=sssssss&v=0.9") }} 
    ./MathSheet1.JPG
    Was this page helpful?
    Tag page

    Files 4

    FileVersionSizeModified 
    Viewing 10 of 10 comments: view all
    Hi there,

    unlike other wikis that have Latex rendering, the deki syntax forces you to escape the \ operator each time, so a simple equation which in dokuwiki and normal latex would look like:

    \alpha = \beta + \gamma

    in dekiwiki you'd have to write:

    \\alpha = \\beta + \\gamma

    this is a major disadvantage since it's no longer possible to simply cut and paste formulas between latex documents and dekiwiki!

    Is here a way that you could could fix the syntax to allow for "normal" latex to render properly without having to manually escape the \ characters?

    Thanks,

    YJ
    Posted 11:52, 21 Apr 2008
    YJ,
    You can already do what you desire. Instead of using the {{ math.formula() }} syntax, use the "transformations" approach as shown in http://wiki.developer.mindtouch.com/MindTouch_Deki/FAQ/Page_Management/How_do_I...Use_the_Transformations%2f%2fTransform_Content_menu_item%3f:

    1) Enter your raw latex markup (with no extra backslashes.)
    2) Select the text, change the style to "formatted"
    3) Open the transformations menu (the small gear button in the editor toolbar) and select "math.formula" edited 05:32, 3 Jul 2008
    Posted 05:31, 3 Jul 2008
    We were very careful to follow all instructions on this page for Windows Server 2003. We rebooted. This is the error on the page when we tried using the math extension:

    MindTouch.Deki.Script.DekiScriptInvokeException: function 'Formula' failed
    <?xml-stylesheet type='text/xsl' href='/@api/host/resources/error.xslt'?>
    <error>
    <status>400</status>
    <title>Bad Request</title>
    <message>latex misconfigured or missing</message>
    <uri>https://aetdwiki.gsfc.nasa.gov/@api/deki/services/default/51/Formula</uri>
    </error>
    <?xml-stylesheet type='text/xsl' href='/@api/host/resources/error.xslt'?>
    <error>
    <status>400</status>
    <title>Bad Request</title>
    <message>latex misconfigured or missing</message>
    <uri>https://aetdwiki.gsfc.nasa.gov/@api/deki/services/default/51/Formula</uri>
    </error>
    at MindTouch.Deki.Script.DekiScriptRuntime.<Invoke>d__0.MoveNext()
    at MindTouch.Dream.Coroutine.Iterate(IEnumerator`1 coroutine, TaskEnv env, Action`1 completion)
    at System.SysUtil.Rethrow(Exception exception)
    at MindTouch.Dream.ResultBase.Confirm()
    at MindTouch.Dream.Result`1.Wait()
    at MindTouch.Deki.Script.DekiScriptCall.Evaluate(DekiScriptEnv env)
    at MindTouch.Deki.Script.Dom.DekiScriptDomExpr.Evaluate(DekiScriptEvalContext context, XmlNode parent, DekiScriptEnv env)
    Posted 13:18, 3 Dec 2009
    @jonverve the error indicates that the "latex-path" config key is either not set or is not pointing to the LaTex application
    Posted 14:18, 3 Dec 2009
    Had a hard time installing this and getting it to work -- a good alternative is here: http://developer.mindtouch.com/User:SteveB/Sandbox/MathML

    Just download the .js file to your wiki and point the Template:ASCIIMathML to that, works great!
    Posted 20:11, 7 Dec 2009
    I'm testing this latex extension and it's working quite fine. Only thing is that the start and end conditions of e.g. sum and product are not shown under and above the signs but instead are placed as super and subscript right next to the sum and product signs, which makes reading rather difficult if the formula is a bit complex. Other latex implementations don't have this 'problem'. Is there a way to fix this?
    Posted 00:29, 17 Mar 2010
    @Kire this "problem" is unfortunately the desired behavior with this add-on because it is replacing what you type in between single $ in a latex document. @mindtouch: A better solution in general would be placing it between \begin{equation*} \end{equation*}. A short workaround to this is using $ in your equation yourself. so you start your equation with a $ which will end the mindtouch equation template and than you can use any latex command (well only basic ones and amslatex ones at this point), so e.g. \begin{equation} YOUR equation \end{equation} and at the end you again have to use a single $ to end the other side and get a correct latex file. This will then output a numbered equation with the desired behavior, Kire.
    Posted 03:59, 23 Mar 2010
    I'm looking for some help to get this function working. Here is the current error I get on the page:

    MindTouch.Deki.Script.DekiScriptInvokeException: function 'Formula' failed ---> System.IO.FileNotFoundException: Could not find file "/tmp/a34cfa4d-f915-0463-3319-4551474ea7bb.png".
    at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000]
    at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000]
    at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
    at System.IO.File.Open (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000]
    at System.IO.File.ReadAllBytes (System.String path) [0x00000]
    at MindTouch.Deki.Services.MathService.Formula (System.String formula) [0x00000]
    at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[])
    at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
    --- End of exception stack trace ---
    at MindTouch.Deki.Script.DekiScriptRuntime.Invoke(XUri uri, DekiScriptLiteral args, DekiScriptEnv env, Result`1 result)
    at MindTouch.Deki.DekiWikiService.GetPageContents(DreamContext context, DreamMessage request, Result`1 response)
    --- End of coroutine stack trace ---
    --- End of inner exception stack trace ---
    at MindTouch.Deki.Script.DekiScriptRuntime+<Invoke>d__0.MoveNext () [0x00000]
    at MindTouch.Tasking.Coroutine.Invoke (System.Func`1 invocation) [0x00000]
    --- End of exception stack trace ---
    at MindTouch.Deki.Script.DekiScriptRuntime.Invoke(XUri uri, DekiScriptLiteral args, DekiScriptEnv env, Result`1 result)
    at MindTouch.Deki.DekiWikiService.GetPageContents(DreamContext context, DreamMessage request, Result`1 response)
    --- End of coroutine stack trace ---

    The permissions on /tmp
    drwxrwxrwt 7 root root 4096 Apr 4 17:05 tmp

    (SE is disabled btw)
    # cat /etc/sysconfig/selinux
    SELINUX=disabled
    SELINUXTYPE=targeted
    Posted 13:15, 4 Apr 2010
    Noticed that this extension has some fixed setting for width so the pngs get a newline in them (if you know what I mean) for a long formula, even though the formula may fit on the page. How do I change this width to 100% or unlimited, etc?
    Posted 15:46, 3 Mar 2011
    Hi, I wrote an extension to call MathJax, which may be of help to you guys.

    It adds a Transformation to the editor (mathjax.formula). Optionally the Extension {{ mathjax.equation(equation: "your_equation") }} can be used. MathML an TeX is supported; the math expressions are rendered in JavaScript and can be Cut&Paste to MathML or TeX compliant aplications such as word, openoffice. FireMath on Firefox can be used to WYSIWYG edition.

    MathJax must be installed. Eventually you'll need to change the MathJax path on the script accordingly.
    Cheers.


    <extension>
    <title>MathJax</title>
    <namespace>mathjax</namespace>
    <function>
    <name>equation</name>
    <description>This will add a MathJax equation</description>
    <param name="equation" type="str">MathML or TeX equation</param>
    <return>
    <html xmlns:eval="http://mindtouch.com/2007/dekiscript">
    <head></head>
    <body>
    <script type="text/javascript" src="/var/www/dekiwiki/skins/common/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>
    <script type="text/javascript"> document.write(<eval:js>args.equation</eval:js>); </script>
    </body>
    <tail></tail>
    </html>
    </return>
    </function>
    <function transform="pre">
    <name>formula</name>
    <description>Format a MathML or Tex equation</description>
    <param name="formula" type="str">MathML or TeX equation text</param>
    <return>
    <html xmlns:eval="http://mindtouch.com/2007/dekiscript">
    <head></head>
    <body>
    <script type="text/javascript" src="/var/www/dekiwiki/skins/common/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>
    <script type="text/javascript"> document.write(<eval:js>$formula</eval:js>); </script>
    </body>
    <tail></tail>
    </html>
    </return>
    </function>
    </extension>
    Posted 06:10, 22 Dec 2011
    Viewing 10 of 10 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by