TeX for Gmail is a plugin which adds (La)TeX capability to Gmail and Gmail Chat. (Note: on Dec 11, 2014 the previous name GmailTeX was changed to TeX for Gmail at the request of Google Trademark Team.)

TeX for Gmail is not associated with Google in any way. It is a hobby project written by a volunteer.

TeX for Gmail uses CodeCogs for creating web-hosted images in the outgoing emails (with permission).

Sever down issues: If you consistently get the Wrong equation image or a rotaing green circle when composing an email, this may mean that the CodeCogs LaTeX server is down, and no new equations are generated. (The already generated equations are kept in a cache and continue to be served for several months.) You can verify if that is the case by going to the server's web page and entering your equation there. I have no control over that server.

June 1, 2016

## Current version: 5.19.6

• 1.0, Jun 7, 2010: The initial release.

• New in v.4.*: WYSIWYG (what you see is what you get) editing of outgoing messages. Your addressee does not have to have TeX for Gmail installed or use Gmail in order to view the math. Math is viewable in most mail readers and browsers, including mobile ones.

• New in v.5*: also works with Chat. Also adds auto mode.

v.5.10: visible actions, improvements in Simple Math.

v.5.12: better resolution for web images.

v.5.15.8: name changed from GmailTeX to TeX for Gmail at the request of Google Trademark Team.

Also, now in the outgoing emails in each $...$ the first character after $and the last character before$ must not be blank spaces. This way, you can still write something like $100 and$200, and TeX for Gmail will understand that you talk about money, not math.

v.5.16: It appears that Gmail changed its security policies and it is no longer possible to load outside scripts such as MathJax on its page using an extension. (Which is generally for the better, I am sure.) So starting with this version, MathJax has been dropped. When you receive an email with dollars in it, F8 still works. But instead of using MathJax, it replaces formulas with images, just as it did for the outgoing email.

The only downside is that when part of the formula fails (e.g due to undeclared macro), the image server at CodeCogs may silently return as image only a part of the formula that it understood. MathJax, using the extension NoErrors, would return the formula back with the offending macro highlighted. I will try to think of a workaround...

v.5.17: Multiple improvements in Simple Math Mode following suggestions from Jason Eisner. For example, \mathbb{A}, \mathcal{A}, \mathfrak{A} now produce correct unicode characters. Added macros for \dA = \mathbf{A}, \oA = \overline{A}, \wA = \widetilde{A}, \hA = \widehat{A}, etc. All LaTeX commands available in Simple Math Mode are listed here.

Warning: Mobile phones (especially Android) and some older browsers lack fonts for these Unicode characters. So it may be wise to stick to \dA = \mathbf{A}, etc.

v.5.18: Added an easy to way to turn images back into TeX: click on the image and then choose OK in the popup box. Multiple other improvements and bug fixes.

## Installation

• Google Chrome: install this extension.
• Firefox: Install Greasemonkey and then this Greasemonkey userscipt.
• Opera: enable User JavaScript and use this Greasemonkey userscipt.
• Safari: Starting June 2015, Apple began charging developers $99 per year for the privilege of building Safari extensions. (Previously, these were free.) As this is a free, not for profit extension, a Safari version will no longer be available. I suggest using Google Chrome instead. Beware of installing TeX for Gmail from any third-party sites, such as Sotpedia, crx4chrome, etc. Those sites are not authorized by me and I have no control over what they add to their binaries. ## Usage After clearing the browser cache and restarting Gmail, you should see the collapsible TeX for Gmail menu in the Gmail Navigation Bar on the left. (If you used the alternative installation, you need to click on the newly created Gmail bookmarklet first.) The menu should have the following items: • rich math (F8) • simple math (F9) • auto: off 1 2 4 8, rich / simple • help & about ### Reading email When you receive an email containing LaTeX-encoded math, hit the link simple math or rich math, or press F9, resp. F8. LaTeX in your emails will be transformed into something more readable (only temporarily, until you close the message). For rich math to work, LaTeX must be properly enclosed in$...$or $$...$$. For simple math, it does not have to be: the program will guess which part is math, and which part is not. The simple math method only supports a subset of LaTeX (subscripts, superscripts, greek letters, \sqrt, \sum, \prod, \cap, \cup, etc.) and may not work on every input (after all, it is guessing). But it is useful when you receive an email with pseudo-LaTeX which is not enclosed in proper delimiters. ### Sending email When composing an email, make sure you are NOT in "Plain text mode"! The easiest is to compose an email in Rich format. Hitting the link or rich math or pressing F8 will transform your LaTeX into images with equations. To turn an image back into LaTeX, do the following: click on the image and then choose OK in the popup box. Hitting the link simple math or pressing F9 will transform your LaTeX into simple HTML with subscripts, superscripts, greek letters etc. Ctrl-Z works for "undo". Exactly the same as for reading, for rich math to work, LaTeX must be properly enclosed in$...$or $$...$$. (In$...$the first character after$ and the last character before $must not be blank spaces. This way, you can still write something like$100 and $200, and TeX for Gmail will understand that you talk about money, not math.) For simple math, math expressions do not have to be property enclosed; the program will guess which part is math, and which part is not. \mathbb{A}, \mathcal{A}, \mathfrak{A} produce correct Unicode characters. Warning: Mobile phones and some older browsers may lack fonts to display these Unicode characters, so it may be wise to stick to \dA = \mathbf{A}, etc. iOS devices seem to correctly display \mathbb{CHNPQRZ}, \mathcal{BEFHILMRego}, \mathfrak{CHIRZ}. Android phones seem to only manage \mathcal{M} and \mathfrak{IR}. All LaTeX commands available in Simple Math Mode are listed here. Occasionally, after hitting F9 you may have trouble exiting out of subscript or superscript mode, or the font used to typeset mathematics. If it happens, use "Remove Formatting" from Gmail HTML editor's toolbar. Whichever method you use, your addressee does not need to have TeX for Gmail installed. The math should be directly viewable in most browsers, including mobile browsers. Here are some things to consider when choosing between HTML or images in the outgoing emails: • simple math is just standard HTML, which any browser or email client can read, online or offline. • rich math means links to images hosted by CodeCogs on their server, and used in this app with their explicit permission. The images are not available offline, unless they have been cached by your computer. • If a server goes down or the service is discontinued (as Google's LaTeX engine is going to do soon), the images will no longer render. • The server at CodeCogs has a daily fair usage limit, currently 3,000 equations (per IP address?) Note: 1. Color works with F8. Try writing$\color{Red}{\mathbb C^n}$and pressing F8 to get . Other available colors: Blue, Green, Yellow, Pink, Orange, Purple, Maroon, Teal. 2. TeX accents work with F9. Try writing H\'el\ene and pressing F9 to get Hélène. ### auto: off 1 2 4 8, rich / simple Turning this on produces the following effect. When composing a message, math expressions properly enclosed in$...$, $$...$$, $$...$$, or $...$ will be automatically typeset. If the rich mode is chosen, they will be replaced by (links to) images. If the simple mode is chosen, they will be replaced by simple HTML. Thus, this is roughly equivalent to pressing F8 or F9 every 1, 2, 4, or 8 seconds. But not quite. When you press F9, the whole text of the message is transformed, including math expressions and TeX accents not properly enclosed in$...$, etc. In the auto mode, only the expressions in$...$etc. are affected. A side note is that in the auto mode, when the simple mode is chosen, TeX for Gmail adds a blank space at the end of the formula. Otherwise, Gmail frequently gets stuck in the subscript or superscript mode. Once you know about this, with a little practice this should not be an inconvenience. Novice LaTeX users may also find CodeCogs' Online LaTeX Equation Editor useful. The link is available at the bottom of TeX for Gmail's window. You can compose your formula there and then paste it in the Compose window. ### Support for theorem-like environments Writing \begin{theorem}The equation $$x^n+y^n=z^n$$ has no solutions in positive integers x,y,z,n with$n\ge3$. \end{theorem} produces Theorem. The equation xn+yn=zn has no solutions in positive integers x,y,z,n with n≥3. Note that '\begin{theorem}...\end{theorem}' should not be enclosed in $$...$$. On the other hand, the usual math environments such as matrix, pmatrix, bmatrix, still work as before in Rich Math mode if they are properly enclosed in $$...$$. There is an optional argument for the theme: red, blue, green, gray, yellow (default). For example, writing \begin{theorem}{green}The equation $$x^n+y^n=z^n$$ has no solutions in positive integers x,y,z,n with$n\ge3$. \end{theorem} gives Theorem. The equation xn+yn=zn has no solutions in positive integers x,y,z,n with n≥3. The optional argument can also be used to add any legal CSS. In particular, for the color names you can use something like #FFFFF0 or rgb(248,248,248), or named colors. See also this page for a large database of colors. For example, \begin{theorem}{background: pink; border: 2px solid crimson; font-family: 'Times New Roman'; font-size: 120%; border-radius:2ex}The equation$x^n+y^n=z^n$has no solutions in positive integers x,y,z,n with$n\ge3$. \end{theorem}  gives Theorem. The equation xn+yn=zn has no solutions in positive integers x,y,z,n with n≥3. For a box without a title, use '\begin{} ... \end{}'. Works both in Simple and Rich modes. If you need to insert a line break inside an environment, do not press ENTER, since it performs a complicated function in Gmail Compose Box, with various side effects. Press SHIFT-ENTER (in Chrome) or CTRL-ENTER (in Safari) instead. There must be an equivalent in Firefox but I haven't figured it out. If things go wrong, you can use Gmail Undo (control-Z). ### More formatting options In addition, the main function of the Simple Math mode is to make any expression in$...$into an HTML span. As a byproduct, most HTML constructions inside$...$produce correctly-formatted HTML, e.g. $<b>Bold</b>, $<i>Italic</i>, <del>Strike-through</del>$
give

Bold, Italic, Strike-through

when Simple Math mode is used. $<h2>Headers</h2>$ work, too. Also, $----$ (four or more) gives a horizontal line, $--$ gives an n-dash –, and $---$ an em-dash —. And of course TeX accents work, too: $H\'el\ene$ gives Hélène.

### Using LaTeX with Chat

Just include your math in $...$ or $$...$$. It should automatically show upon entering.

## Tips

• The following method works well when reading emails with a mixed math contents, some enclosed in $...$ and some not (for example daily arXiv emails). Press F8 and then in a couple of seconds F9. Both types of math content will be typeset.
Actually, with the recent improvement in the Simple Math mode, you may get away by using F9 only.

• If you need to reformat an old email message, for example a message with math images broken by Google proxy, you can do the following:

Change to Rich Math, turn the auto mode off. Forward the message to yourself. In the Compose window, press F8 once. Now all math images are clickable. Turn them back to plain text following instructions here. They should turn back into TeX source. Now press F8 again. The formulas will be replaced with new images. Email the resulting message to yourself.

## Troubleshooting

• Sever down issues: If you consistently get the Wrong equation image when composing an email, this may mean that the CodeCogs LaTeX server is down, and no new equations are generated. (The already generated equations are kept in a cache and continue to be served for several months.) You can verify if that is the case by going to the server's web page and entering your equation there. I have no control over that server.

• Dec. 7, 2013: Starting Dec 3, Gmail rewrites the web links to images in the incoming messages to point them to a proxy server googleusercontent.com, see this official explanation for the reasons behind this move.

In any case, the Google proxy breaks the old links to math images. (For the curious: the blank spaces in the links, even encoded as '%20' are turned into '+', and latex.codecogs.com fails to understand them. Most links to math images contain blank spaces since they all start with 'inline%20' or 'display%20'.)

The links generated by TeX for Gmail version ≥5.9 should work with Google proxy, at least until they decide to break something again. To read the old emails, you can press F8 which should fix the links. An alternative is to forward the emails to an non-Gmail account or read them in another mail reader, e.g. in Mac OSX native mail reader. Google only rewrites the links shown in Gmail itself.

The SVG images do not work at all with the new Google proxy, so the option to create SVG images was removed in TeX for Gmail v.5.9; all the images are now in GIF. (Which could be for the best, since the SVG server on codecogs.com remains to be glitchy.)

• I received reports that the TeX for Gmail addon for Firefox leads to multiple error messages in the new version 22 of Firefox, such as: "Illegal Operation on Wrapped native Object".
Please note that I removed this addon from the Firefox addons store in October 2012, and it is no longer supported. The recommended way to use TeX for Gmail in Firefox is to install Greasemonkey and then this Greasemonkey userscipt.
• The new Hangouts interface for Google Chats broke the TeX for Gmail's functionality for Chats. I may try to update TeX for Gmail to address this in the future but I don't know when I will have time for this.
• If you are upgrading from a previous version of GmailTex, you need to clear the cache and restart the browser, to make sure that the new version is loading.
• If you used the alternative installation as a bookmarklet, and the control panel does not appear, try going to the http address in your bookmark manually, to make sure that it exists and that you have the necessary permissions to access it.
• To typeset multiline equations, for example with a matrix or \cases: simply remove the linebreaks. TeX for Gmail is optimized to work with each text block separately, otherwise it would work much slower and would take up more resources. So it does not look across the line breaks.
• If some formulas do not typeset correctly, switching from SVG to GIF output may fix it (The SVG engine at CodeCogs is glitchy.)

## Privacy and security

TeX for Gmail, as written by me, does nothing beyond the basic functions explained in the Usage section above. It does not collect or send out any information about its users, does not make any XMLHttpRequests, and does not load any external code other than images from CodeCogs.

And of course TeX for Gmail is an open source human-readable Javascript program, so you can examine it yourself.

Beware of installing TeX for Gmail from anywhere but the sources listed in Installation. I uploaded TeX for Gmail to those sites myself. But I do not control any of the 3rd party web sites, such as Softpedia, crx4chrome, etc. and their content.

When installing the Firefox version, the Greasemonkey script which I uploaded to http://userscripts.org/scripts/show/96444: be aware that to install the Greasemonkey script one has to click on the button Install in the upper right corner. Some of the ads on that web page have a misleading large button marked "Download". Clicking on that ad installs something else altogether. I have no control over that web site either.

## Thanks

• To CodeCogs for providing the engine for images, and for hosting them.
• To Kristi Tsukida for writing wrappers for a Chrome extension and Greasemonkey userscript.