Showing posts with label MathJax. Show all posts
Showing posts with label MathJax. Show all posts

2014-01-04

Giving up Testing MathJax and Anchors on Blogger

In dynamic view, though the code for dynamic loading of MathJax contents has been pasted into the HTML code for the template, things just work in a strange way: in the class mode, MathJax works the best; in other modes, it may not work or it works partially. For example, in a mode, the dollar sign in the code tag is interpreted, and the script file for MathJax is loaded. But when you click a blog entry for a popup frame containing some MathJax code, then it simply won't load. Nonetheless, anchors don't work in a desired way in the dynamic view—after clicking an anchor, I am immediately directed to the destination, which is covered by the header. Finally, to ensure that the contents are correctly interpreted, the best way is to use the tex2jax_ignore class. [1] Anyways, if readers are also writers of HTML, $\rm \LaTeX$, etc, they'll know what I intend to write by testing the HTML code, and for the remaining readers, I just apologize for the inconvenience caused and suggest them to right click the article in the default "Sidebar" view and press <F5> to reload for the correctly rendered contents. I've forgotten about anchors since toggling between the "Compose" and "HTML" modes while writing a new post will cause some strange change in the href attribute of the a tag.

References:
[1]: http://github.com/mathjax/mathjax-docs/wiki/How-to-prevent-rendering:-use-tex2jax_ignore

Escaping '$' in MathJax

Anyone who are used to $\rm \LaTeX$'s $ character$ for switching to inline math mode would like to use the same command for the same thing on MathJax, which suggests the use of backslashed parentheses to enclose an inline math equation. As a result, in the very first part of MathJax's official documentation, it contains several lines code for that.
After pasting the code inside the head tag, the above problem is solved, but this method creates another problem.
Imagine that you want to compare the price of a product of different companies. You then typed two prices on the same line.
<p>...</p>
<p>Nowadays, it costs nearly $500. In the past, it only costs around $300. It's too expensive!</p>
<p>...</p>
Then the web browser will interpret the contents in this way:

Wrongly interpreted contents
In order to get the problem fixed, I searched "mathjax escape dollar sign" and found Stack Overflow question 8773586 very useful. Following the first answer for the question, I managed to get it right. That is, to change the it like this:
<p>...</p>
<p>Nowadays, it costs nearly <span class="tex2jax_ignore">$</span>500. In the past, it only costs around <span class="tex2jax_ignore">$</span>300. It's too expensive!</p>
<p>...</p>

Correctly interpreted contents

2013-08-16

Testing MathJax

Following the instructions here, MathJax works on Blogpost.
I typed
$\cos^2\theta-\sin^2\theta=\cos 2\theta$
and here's the result: \(\cos^2\theta-\sin^2\theta=\cos 2\theta\)
Antoher equation: \[ ax+\frac{b}{y}=1 \] This time, the equation is in display mode.
How about the inline verbatim environment? Googling "mathjax verbatim", we have \[\verb*$x^2\sqrt y$* \text{ yields } x^2\sqrt y\] on $\rm \TeX \text{ Commands available in MathJax}$ . Nevertheless, it only works in display mode.
Finally, let's get some equations numbered, just like an example on MathJax. \begin{equation} \int_{0}^{\frac{\pi}{2}} \sin x \, \mathrm d x = 1 \end{equation}