Tuesday, September 9, 2008

How to Post Math Equations in Blogger Using Latex

In a previous post, I discussed how to post math equations in blogger using the ASCIIMathML script. The advantage of using this method is that you are not dependent on any external server to host your equations since they are NOT images. ASCIIMathML displays equations in ASCII format, i.e. in plain text format.

The bottleneck of this method, as I discovered later on, is its limited capability to display some complicated mathematical forms. The famous example is the limit as x goes to zero. This is how it looks using ASCIIMathML

$\lim_{x\rightarrow 0}$

I was glad to find these limitations before engaging in posting topics related mathematics. It would have been a mess to go back and forth and convert equations etc...

The method that I will discuss today is an old technique that I passed upon when I first started this blog, but had completely neglected. It uses LaTeX to display equations. Of course, this is a good sign. But how does it work? Very simple.

There is a server somewhere over the internet that has "software like" capabilities, i.e. it can process user requests dynamically. These capabilities include Perl,PhP, ASP etc...

On this server, there would be an application that takes a LaTeX syntax as input, processes it on the server, and converts it to an image on the fly.

Voila!

But where is that server? Who wrote that application? Where are the images hosted? Will the application be there, forever?

One question at a time.

Where is that server?
There are several servers out there, the ones I know of are http://www.codecogs.com/ and http://www.forkosh.com/ (which uses mimeTEX).

Who wrote that application?
One, two, or more programmers.

The CodeCogs application was written by Will Bateman and Steve Mayer and can be accessed at:
http://www.codecogs.com/gif.latex?

The mimeTEX interpreter was written by John Forkosh and can be accessed at:
http://www.forkosh.dreamhost.com/mimetex.cgi?

Where are the images hosted?
On the server, temporarily. Due to the dynamic nature of the LaTeX interpreters, they are converted to an image whenever a webpage posts a request. For example, whenever you load a page that has an equation, the server immediately interprets that equation, converts it to an image and sends back that image. I assume that there would be a cached version of the image on the server that is deleted after some time.

Will the application be there forever?
I hope so! The only alternative is to host that application yourself, on your own server. But hey! Can you make sure that you will be able to pay for that hosting for the rest of your life? This dependence on an external server is no different than our depends on google. As for the equations, I am currently hosting them on Picasa, which is basically like hosting the equation on an external server. But, remember, all you need is the application that interprets LaTeX, not the images! So, in the event that one of these applications disappears, you can very simply point to another application on some other server. It is very simple as you will see shortly.

So how does it work in blogger?

You simply create an img tag and set the source of the image as the location of the application followed by the LaTeX syntax. Here's an example. Let's say you want to write this equation


\large e^x = \sum\limits_{n = 0}^\infty {\frac{{x^n }} {{n!}}}
The LaTeX syntax is

e^x = \sum\limits_{n = 0}^\infty {\frac{{x^n }}{{n!}}}

create an img tag with the appropriate src field pointing to the online LaTeX renderer and then insert the LaTeX code, i.e.

<img src="http://www.codecogs.com/gif.latex?e^x = \sum\limits_{n = 0}^\infty {\frac{{x^n }}{{n!}}}" />
Voila!

Of course, this is a mess! If everytime you want to write an equation you have to write down the img tags and insert the path to the LaTeX renderer... that is very inefficient!

Fortunately, there are several ways to overcome this. The first one, thanks to the guys at codecogs, their online LaTeX editor prepares the img block for you. All you have to do is
  1. Go to the codecogs online LaTeX editor
  2. Type in your equations LaTeX
  3. Copy the HTML code that is generated at the bottom of the page
  4. Paste it in Blogger (either in the "Edit HTML" or "Compose views).
Voila!

After the equation is displayed, you can align it the way you want using the options provided by the blogger editor. The images generated by the codecogs LaTeX editor are transparent with a black foreground. In case your blog has a dark background, they won't look nice at all. What you have to do in this case (which is what I am doing on this blog) is create a new class for images that has a white background. Here's what you need to do
  1. Go to your blog's Layout
  2. Click on "Edit HTML"
  3. Place your class somewhere before ]]> </b:skin >
  4. Define your new class as follows:
    img.latexEquation {
    background:white;
    margin: 0px;
    padding: 5px;
    }
  5. When you paste the HTML code from codecogs, specify which class is applied to the image as follows:
    <img class="latexEquation" src="..."/>
Voila!

Now your equations will have a nice white background behind them.

Alternatively, you can use the mimetex editor which gives you the option to make an opaque background and reverse the colors for blogs with a dark background. Make sure you specify \opaque for an opaque background and \reverse for a white foreground. \reverse\opaque will set a black background and white foreground. Here's how it looks with the \reverse\opaque setting



and with the \reverse only




[To be continued...]

Cite as:
Saad, T. "How to Post Math Equations in Blogger Using Latex". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2008/09/how-to-post-math-equations-in-blogger_06.html

Wednesday, September 3, 2008

How to Rip a DVD into AVI

For future reference, I am making this post to remind myself how to backup my DVDs, especially after my hard drive crashed last week. This method is based on this excellent post.

The idea is to backup or rip a DVD into an AVI. Here's what you need first
  1. Download DVD Decrypter
  2. Download Auto Gordian Knot
As discussed in the original post, DVD Decrypter will remove any encryption that is embedded into the DVD.

Auto Gordian Knot, aka AutoGK, is a set of tools that will allow you to convert the decrypted DVD into an AVI. Don't worry, AutoGK has a single GUI where you specify the parameters for your conversion.

After installing DVD Decrypter and AutoGK, do the following
  1. Open DVD Decrypter
  2. Go to: Mode/IFO


  3. In the information files list to your right, select the item that is the longest in case of a movie. In case of TV show, select the episode of interest.


  4. Select the folder location of your decrypted DVD

  5. Finally, click on the decrypt button (with the green arrow)
Depending on the length of your DVD/episode and your platform, it usually takes less than 30 minutes to rip a 150 minutes DVD. When the decryption process in complete open up AutoGK and do the following
  1. For your input file, choose the first VOB file in the extracted directory
  2. Set the name and location of the output AVI
  3. Select the first audio track
  4. Select a subtitle (if any)
  5. Select the output size. Usually, a 120 minutes DVD converts well to 700 MB. For 30 minute TV episodes, I would choose 175 MB while for a 1 hour episode, i would choose 350 MB. Alternatively, you can set the quality percentage. I find this the fastest way as AutoGK will perform a single pass. I usually keep this setting at around 65%
  6. Click on advanced settings and choose Xvid and set the audio to VBR MP3 at 128 kbps . Note that you may need to download XviD (or DivX)
  7. Click on add job
  8. Click start
Voila!

Cite as:
Saad, T. "How to Rip a DVD into AVI". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2008/09/how-to-rip-dvd-into-avi.html

Monday, September 1, 2008

How to Post Math Equations in Blogger using ASCIIMathMIL

I know that most of us working directly with mathematics are looking for a fundamental solution to posting equations on blogger. So far, I would have my equations written in MathType, print the screen, paste, crop, and save in paint. It is a pain... a dual monitor setup would be helpful, nonethless, this is too much to go through.

I've seen several models over the net that provide different solutions, but none of them was what I was looking for, especially that I am not a LaTeX guru.

So far, the neatest model to post equations on blogger is described on Fundamental Thinking. The method uses Peter Jepsen's ASCIIMathML script.

Here's how to set it up on your blog:

  1. Download ASCIIMathML.js and host it somewhere online such as your google pages website. This will allow you to modify the script to fit your needs (like changing the forecolor of the equations). Alternatively, you can just point to the location of the script (http://www1.chapman.edu/~jipsen/mathml/ASCIIMathML.js)
  2. In Blogger, add a new HTML/Java Script widget
  3. Add the following to the new widget
    <script src="http://www1.chapman.edu/~jipsen/mathml/ASCIIMathML.js" type="text/javascript"></script>
    (In case you decided to host the script on your own website, you will need to replace src with the correct location).
Voila!

Now you're all set. All you need to to do is either learn the ASCIIMathML syntax, type in LaTeX, or copy from Mathtype as LaTeX.

To type in LaTeX, you have to wrap your equations with a dollar sign.

Alternatively, you can use some online LaTeX editors such as Thornahawk's Numerical Analysis notes or CodeCogs', and then copy and paste the code into your post.

Finally, if you use MathType, you can set it up so that it copies the equations as LaTeX. Here's how you do it
  1. In Mathtype, go to
    Preferences/Translators
  2. Select "Translation to other language"
  3. Select "TeX -- LaTeX 2.09 and later"
  4. Deselect "include MathType data in translation"
Make sure you replace the \[ and \] generated by MathType by the dollar sign.

This, I think, is by far the easiest way of getting your equations into blogger. Sometimes, the translation generated by MathType is not well interpreted by the ASCIIMathML script. For example, type the following in MathType

$\lim_{x\rightarrow 0}$

This will not be translated correctly with the ASCIIMathML.

After all this, I think we need a better solution.


UPDATE: As Bob Mathews from design science (the makers of MathType) has kindly noted, if you choose the Format/Inline Equation in MathType, the LaTeX code will exclude the \[ and \] symbols.

Cite as:
Saad, T. "How to Post Math Equations in Blogger using ASCIIMathMIL". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2008/09/how-to-post-math-equations-in-blogger.html

How to Change the Manufacturer/OEM/Computer Logo in System Properties

In Windows Vista, there's usually a logo in the system properties (right click "My Computer"/Properties) that refers to the manufacturer of your machine. The original post can be found here. This can be easily changed by modifying the registry. Here's how
  1. Create your own logo and save it as a bitmap (*.bmp) - Make sure the size is 120x120 pixels
  2. Open the registry editor (click Start/regedit)
  3. Go to:
    HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ OEMInformation
  4. Modify the "Logo" entry &/ the "Manufacturer" entry
Voila!

Note that the "&/" symbol stand for "and, or".

Cite as:
Saad, T. "How to Change the Manufacturer/OEM/Computer Logo in System Properties". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2008/09/how-to-change-manufactureroemcomputer.html

Wednesday, August 27, 2008

How to hyperlink to a specific page in a pdf file

I was working on my new website today and in one section, I needed to hyperlink to a magazine's pdf file over the internet. However, I was only interested in linking to an article in that magazine that starts on page 38. Can this be done? Yes!!! Here's how:

http://www.somewebsite.com/somePDFFile.pdf#page=page-number
Voila!

In my case, the link read something like

http://www.somewebsite.com/somePDFFile.pdf#page=38

Cite as:
Saad, T. "How to hyperlink to a specific page in a pdf file". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2008/08/how-to-hyperlink-to-specific-page-in.html