CodeCogs - A iteractive open source Numerical library in C/C++, with wrappers for .NET and Excel Welcome... Login
Site Map
shopping cart
OSXWindowsLinux
Search CodeCogs
Numerical Components
References

Valid RSS

Installing the CodeCogs Equation


Example Screen Shot (Click to see Demo of Downloadable editor)

de-de en-en fr-fr it-it en-us ro-ro

Recent News
21 Mar: The editor now understands Italian, thanks to Giovanni Brescia.

Introduction

The CodeCogs Equation Editor is an online editor that facilitates the creation and formatting of LaTeX equations. Used in combination with our LaTeX rendering scripts, it creates HTML code to render an equation on any website and some email programs. The editor is open source and can be easily extended and adapted for any particular need. It is compatible with a range of WYSIWYG editors, supports multiple languages and works across all major internet browsers, including IE, FireFox, Safari and Opera.

There are really two distinct problems that we solve:

  1. First is the creation of LaTeX formulas. Few of us remember all the commands and the CodeCogs editor is there to facilitate this.
  2. Second is how to render code into graphical (nice looking) equations. We use a variety of techniques that can be use in isolation or even collectively. If you're familiar with LaTeX then very often you can create equations without ever using the editor.

We are working hard to integrate the combine system into a range of WYSIWYG editors. A FCKEditor plugin will be released shortly.

Costs

Equations generated by the CodeCogs servers can be used for any purpose, anywhere, for free subject to our Usage Policy. Our Editor is also completely free to use on personal websites. For seemless integration of the Equation Editor with your site, try including our Javascript Program - functionally the editor will behave as though it has been installed locally.

For installation on a intranet you'll have to download the complete files and setup LaTeX. This is a more complex task, requiring root access to your server (if you don't know what 'root' is, then you shouldn't consider this option!). If you have an intranet we assume you must be a company (or a fanatical individual), so we change £180 for instructions and install files. Included is 3 months technical support and a copy of future upgrades. Contact us on CodeCogs Sales.

To produce your own customised editor for installation on a public internet site, then we ask for a donation of at least £10 for individual and £100 for commercial use (i.e. by corporations, consultants etc). You must also agree to retain the 'Powered by CodeCogs' logo and a hyperlink to our website. If this is you then make a donation below and contact us on CodeCogs Donations stating how you will use the editor.

In no circumstances can the editor be re-sold.

Please help support this service and donate whatever you can.

The increasing popularity of CodeCogs and in particular the Equation Editor requires increasingly more powerfull servers. In under 6 months we will need to double server capacity, so please help us give you the service you deserve and make a small donation.

Our remit is to support open and free websites. All money raised goes directly on raw costs of the web servers and infrastructure.

And if that's too much, please tell a friend and Dig us!

Usage Policy

There is no limit on the number of equations you can render per day. However, we reserve the right to block any use that we feel is abusive. If you think you'll make more than 10,000 calls per day, then please let us know by mailing on: CodeCogs Services.

If you plan to provide many equations, then you should install the complete LaTeX rendering service on your servers. Available upon request following a donation.

Quick Installation (using JavaScript only)

The fastest way to start using the latex editor within your own website is to simply load the http://latex.codecogs.com/editor.js script, as in:

<html>
<head>
<script type="text/javascript" src="http://latex.codecogs.com/editor.js"></script>
</head>
<body>
<p><a href="javascript:OpenLatexEditor('testbox','html','')">Launch CodeCogs Equation Editor</a></p>
<textarea id="testbox" rows="3" cols="40"></textarea>
</body>
</html>

The following examples, use the above approach with varying values of type (more details below):

->Launch CodeCogs Equation Editor with type=latex (default)
->Launch CodeCogs Equation Editor with type=html
->Launch CodeCogs Equation Editor with type=phpBB (for php Bulletin Board)
->Launch CodeCogs Equation Editor with type=tw (for TiddlyWiki)
->Launch CodeCogs Equation Editor with type=pre

As shown in the example, to launch the editor you use the javascript command OpenLatexEditor(target, type, language,inline, latex), where

If no language is specified the system will try to guess the users language based on browser settings.

The type can be any of the follow (see also HTML Equation Rendering below):

type Example Output
latex $1+sin(x)$ or \[1+sin(x)\]
doxygen \f$1+sin(x)\f$ or \f[1+sin(x)\f]
phpBB [tex]1+sin(x)[/tex]
tw [img[http://www.codecogs.com/gif.latex?1+sin(x)]]
html <img src="http://www.codecogs.com/gif.latex?1+sin(x)" />
pre <pre xml:lang="latex">1+sin(x)</pre>

The supported language's are currently:

language  
en-usEnglish USA
en-enEnglish British
fr-frFrench
gr-grGerman
it-itItalian

[Please help us write language files for Spanish, Dutch, Chinese (both languages), Japanese, etc.]

Further Example:

The following examples are started used the command shown

->OpenLatexEditor('examplebox','latex','fr-fr',true,'1+sin(x)');
->OpenLatexEditor('examplebox','html','en-us');
->OpenLatexEditor('examplebox','html','',false,'\\frac{1}{x}');
->OpenLatexEditor('examplebox','tw','',false,'\\frac{1+sin(x^2)}{x^2}');
->OpenLatexEditor('examplebox','latex','it-it',false,'e=mc^2');

Live 3rd Parts Examples :

The following sites have implemented this system (N.B. CodeCogs is not responsible for any content on these sites):

->Tiddly Wiki Implementation at http://twmath.tiddlyspot.com/

(Please let us know about further examples to be put here)

Complete Installation (PHP required)

Download v2.5:

zipequationeditor_2_5.zip

Download Latest Version:

Available after a donation!

If you want to customise the editor, then you'll need to install the key files on your server, which must also be running PHP.

Aside from cosmetic changes, the only other modification you may wish to consider is the default language file. The system will try to use the language specified by the users browser, if this can not be found it'll revert to this default. For a list of available language files look in the 'lang/' directory.

In 'editor.php', modify line 3:

define('DEFAULT_LANGUAGE','en-us');

As all equations will be rendered using the CodeCogs servers, then please show support by adding the following small banner to your website acknowledgements:

CodeCogs - An Open Source Numerical Library

This logo is created using this code:

Integration Details

Once you've installed the editor, you'll find it can be launched in a variety of different ways:

  1. In it simplest form, you can launch the equation editor simply by loading 'equationeditor.php' within your browser, e.g. The following line
    <a href="http://{your website}/eqneditor/editor.php" target="_blank">
    Launch CodeCogs Equation Editor</a>
    
    which creates: Launch CodeCogs Equation Editor
  2. Usually however, you want the result from the equation editor to be entered into a 'input' or 'textarea', for this purpose you need to install the editor on your website and would then call it in the following way:
  3. <a href="http://{your website}/eqneditor/editor.php?target=testbox" target="_blank">
    Launch CodeCogs Equation Editor</a>
    <textarea id="testbox" rows="3" cols="40">
    </textarea>
    which creates:
  4. In these past two examples, the editor is launched in its own completely new browser window. While acceptable, it is usually nicer if it is opened within a popup window of an appropriate size. To achieve this, you first need the following piece of JavaScript, which you should add to the head section of your main HTML document (that open the editor),
    <script type="text/javascript">
    var popupwindows = new Array();
    function popupnr( url, windowname, refocus, width, height )
    {
    	if(typeof(popupwindows[windowname])!='undefined')
    	  newwindow = popupwindows[windowname];
    	else newwindow=null;
    
      if (newwindow==null || newwindow.closed || !newwindow.location) 
    	{
    		newwindow=window.open(url,windowname,'width='+width+',height='+height+',status=1,scrollbars=no,resizable=1');
    		if (!newwindow.opener) newwindow.opener = self;
    		popupwindows[windowname]=newwindow;
    	}
    	if (window.focus) { newwindow.focus() }
    	return false;
    }
    </script>
    Now, when you need to launch the equation editor use:
    <a href="http://{your website}/eqneditor/editor.php" 
      onclick="return popupnr(this, 'equation', 1, 700, 450 )">
    Launch CodeCogs Equation Editor</a>
    
  5. Raw HTML. You'll notice in this last examples the equation placed in the textbox is in a LaTeX form, using \[ ...\] or $ ... $ to signify the start and end of the equation. As alternatives you can append the '&type' (see above), as in '&html'or '&phpbb' or '&tw' and the editor will return code that can be directly embedding into different editors. For example, this code create code directly for HTML, e.g.
    <a href="http://{your website}/eqneditor.php?target=testbox2&html" 
      onclick="return popupnr(this, 'equation', 1, 700, 450 )">
    Launch CodeCogs Equation Editor</a>
    <textarea id="testbox2" rows="3" cols="40">
    </textarea>

    which creates:

[N.B. Integration with other systems such as the phpBB bulletin board and FCKEditor will be covered seperated - this is still under development]

HTML Output Formats

For equations on the web, the Equation Editor is ultimately used to produce HTML code that loads an image containing your equation. To request this image, there are a variety of different approaches that can be taken which will depend largely on the capabilities of your website (or even what you're allowed to do) and personal preference and experience. You may find you use all of the following method or just one.

<IMG> Tag (Editor type="html")

At the simplest and most fundamental level, LaTeX equations can be graphically rendered using a special HTML image tag. For example, the following HTML code:

<img src="http://www.codecogs.com/gif.latex?1+sin(x)" border="0"/>
will create:

This image tag is used extensively by users who need to show equations in 3rd party forum or blog or on their websites. It allowed equations to be created without installing any additional code. If you use the CodeCogs Equation Editor to help your write your LaTeX equation, then you'll find the coresponding HTML code in the yellow box at the bottom of the equation editor.

<PRE> or <CODE> Tags (Editor type="pre")

As an alternative, Waipot Ngamsaad has developed a clever piece of javascript that parses through your HTML page and converts particular <pre> or <code> tags into our the image tags, shown previously. The main advantage of this technique is you can write cleaner, less confussing, html. For example:

<pre lang="latex">
\frac{1+sin(x)}{x}
</pre>

will create:

\frac{1+sin(x)}{x}

To enable this conversion, load the javascript code http://latex.codecog.com/render.js just before the </body> section of your html page, for example:

<html>
<body>
Here is my first formula
<pre lang="latex">1+sin(x)^2</pre> <script type="text/javascript" src="http://latex.codecogs.com/render.js"></script>
</body>
</html>

Using the <code lang="latex">...</code> instead of <pre lang="latex">...</pre> when you want your equation to appear inline, within the text, as in \frac{1+sin(x)}{x}

LaTeX Tags \[...\] and $...$ (Editor type="latex")

If you writing a lot of equations, or if like the usual LaTeX techniques for entering equations within text then you may prefer our http://latex.codecog.com/latex.js script. This script will convert \\[...\\] and \$...\$ into block and inline equations, respectively. For example:

When you add \$x^2\$ to \$y^2\$ you get \\[x^2+y^2\\]

will create:

When you add $x^2$ to $y^2$ you get \[x^2+y^2\]

There are a few necssary pre-conditions to this script. First it will only convert equations within a <p>...</p> tags - this is to help prevent this script modifying other javascript on the page. Second if you want to write dollar (\$), then you must add a backslash (\\) before the dollar, as in (\\$).

To finely control the layout of the equations (background, border, position etc) then set the styles img.latex and div.latex for inline and block equations, respectively.

The following example illustrate a complete HTML page with the variety of equations written.

<html>
<body>
<p>Dividing $x^2+1$ by $y^2$ gives \[\frac{x^2+1}{y^2}\]</p> <p>The british pound is worth 1.5 US\$</p>
<script type="text/javascript" src="http://latex.codecogs.com/latex.js"></script>
</body>
</html>

Credits

The CodeCogs equation editor is written by Will Bateman with advice and assistance from Steve Mayer. It also contains many neat Javascript enhancements by Thornahawk, which make the toolbar buttons more interactive.

Version History

Others Sites Using the Editor

If you would like a mention here then please let us know.

Page Comments

tvilot\′s Photo
23 Mar 09, 6:39PM
(1 reply)
Plugin??
I'm confused as to the status of the plugin for FCKEditor. At the top of this page, I see "A FCKEditor plugin will be released shortly" but in the comments thread, Will talks about how his instructions did not include a step. But I don't see those original instructions anywhere on the site.

So is there a plugin, or do I have to hack my own?
will\′s Photo
23 Mar 09, 7:57PM
I've been working on a new Pluging for FCKEditor, but have been side tracked. I'll get back to it, or perhaps you can help us?

The original plugin we dropped, as it only worked if you install all of LaTeX etc on your server, rather than just calling the editor through javascript.

If you send my email address (though a private email), then I can send you the current state of the FCKEditor.
dvazval\′s Photo
18 Jan 09, 8:24PM
(3 replies)
installing problems
Hi, I was searching for something like this, for an educational platform, as my research i havent found anything as good as yours, but i found some problems i want it to run from my linux base servers, i have downloaded the package, but i cant figure out how to get the latex render, http://latex.codecog.com/render.js i whant this thing to run completely from my server, and unless i have this render, what the editor do is ask for your server to do it, so any help you could tell me on this matter on installing this ecuation editor completely on my server Would be apreciated. (ps im able to create png images from terminal with this)

latex --interaction=nonstopmode my.tex dvips -E my.dvi -o my.ps convert -density 120 my.ps my.png

i could help you to the spanish laguaje translation as soon as posible

Thanks from a educational developer in Costa Rica
CodeCogs\′s Photo
22 Jan 09, 10:57PM
Hi, The set up we have on our servers is fairly complex. We've working on a cut down version, and instructions for such, that will allow you to personally install this server. Unfortunately as we make nothing from this work, its not exactly a priority, but I will find this time to do it ASAP.

Thanks for your interest, Will
dvazval\′s Photo
28 Feb 09, 6:13PM
I have figured out how it work you can call instead of an image a page on php that gets from the url the equation on the box, example_render.php?var=[tex] equation [/tex] then the function that create the image its modify so it returns the url, then i make that same page on the head to know it have an image, then it just readfile and the image url so, every time the complete src its called it goes to the server create the image, return that image, then a function delete all the dvips,ps,logs,and aux that are created on a temp folder. I have all these files and a guide of installation on spanish, i will translate it to english just in case it could be helpfull for so let me now if you could make use of it, right now i have the editor working on aolserver, and the rendering process working on apache intergrated on dotlrn platform. Thank you a lot.
will\′s Photo
1 Mar 09, 3:01PM
Sorry, I should have directed you to this before: http://www.mayer.dial.pipex.com/tex.htm

We actually use a different approach - but only for performance.

Will
mathscours\′s Photo
25 Jun 08, 2:42PM
Thanks
Great equation editor. I use it on my french site http://www.maths-cours.fr works fine!
mathson\′s Photo
28 May 08, 1:58PM
many thanks
Format Excel Equations

  You must login to leave a messge