<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ole Bakstad&#039;s blog &#187; plugin</title>
	<atom:link href="http://dibon.net/wordpress/tag/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://dibon.net/wordpress</link>
	<description>About stuff that happens, when it happens, if it happens.</description>
	<lastBuildDate>Mon, 15 Jun 2009 20:08:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>LaTeX in WP</title>
		<link>http://dibon.net/wordpress/testing-latex/</link>
		<comments>http://dibon.net/wordpress/testing-latex/#comments</comments>
		<pubDate>Sat, 24 May 2008 01:21:53 +0000</pubDate>
		<dc:creator>Ole Bakstad</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[codecogs]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://dibon.net/wordpress/?p=12</guid>
		<description><![CDATA[I finally got LaTeX in WP! Now I can write [ tex ] [ / tex ] and voilá! I&#8217;m now using a external site for rendering my equations, but as soon as I get the code running on my own server I will of course use my own. To get this working I had [...]]]></description>
			<content:encoded><![CDATA[<p>I finally got <a href="http://en.wikipedia.org/wiki/LaTeX" target="_blank">LaTeX</a> in WP! Now I can write [ tex ]  [ / tex ] and voilá! I&#8217;m now using a <a href="http://www.codecogs.com/" target="_blank">external site</a> for rendering my equations, but as soon as I get the code running on my own server I will of course use my own.</p>
<p>To get this working I had to write a little plugin for WP, which was easier than I thought. Here is the code I&#8217;m using:</p>
<div class="geshi no php">
<div class="head">/*</div>
<ol>
<li class="li1">
<div class="de1">Plugin Name<span class="sy0">:</span> LaTeX</div>
</li>
<li class="li1">
<div class="de1">Version<span class="sy0">:</span> <span class="nu0">0.1</span></div>
</li>
<li class="li1">
<div class="de1">Author<span class="sy0">:</span> Ole</div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">*/</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> addLatex<span class="br0">&#40;</span><span class="re1">$text</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="re1">$text</span> <span class="sy0">=</span> <span class="kw3">preg_replace</span><span class="br0">&#40;</span><span class="st0">&quot;/<span class="es0">\[</span>tex<span class="es0">\]</span>(.+)<span class="es0">\[</span><span class="es0">\/</span>tex<span class="es0">\]</span>/&quot;</span><span class="sy0">,</span><span class="st0">&#39;&lt;img src=&quot;http://www.codecogs.com/eq.latex?<span class="es0">\\</span>1&quot; alt=&quot;&quot; /&gt;&#39;</span><span class="sy0">,</span><span class="re1">$text</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">return</span> <span class="re1">$text</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">add_filter<span class="br0">&#40;</span><span class="st0">&#39;the_content&#39;</span><span class="sy0">,</span><span class="st0">&#39;addLatex&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>WP need the comment to get data about the plugin and you simply use the add_filter() to apply your own function on given data. Here I&#8217;m using addLatex() on the content.</p>
<p>Here is how it works:</p>
<p>[ tex ] V_{ind} = -\frac{d}{dt}{\int_A{\vec B d\vec A } = -\frac{d\Phi_B}{dt} =  -\frac{d}{dt}\left( \int_{a+vt}^{a+b+vt}{ \frac{\mu_oI}{2\pi x} cdx \right) = &#8230; = -\frac{\mu_0 Ic}{2\pi}\left( \frac{v}{a+b+vt} &#8211; \frac{v}{a+vt} \right) [ / tex ]</p>
<p>Gives:</p>
<p><img src="http://www.codecogs.com/eq.latex?V_{ind} = -\frac{d}{dt}{\int_A{\vec B d\vec A } = -\frac{d\Phi_B}{dt} =  -\frac{d}{dt}\left( \int_{a+vt}^{a+b+vt}{ \frac{\mu_oI}{2\pi x} cdx \right) = . . . = -\frac{\mu_0 Ic}{2\pi}\left( \frac{v}{a+b+vt} &#8211; \frac{v}{a+vt} \right)" alt="" /></p>
<p>You gotta love LaTeX, and you gotta love physics. This equation is actually the solution to a problem on an old exam.</p>
]]></content:encoded>
			<wfw:commentRss>http://dibon.net/wordpress/testing-latex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

