<?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>Dammit Jim! &#187; LaTeX</title>
	<atom:link href="http://scott.sherrillmix.com/blog/category/programmer/latex/feed/" rel="self" type="application/rss+xml" />
	<link>http://scott.sherrillmix.com/blog</link>
	<description>I'm a biologist not a...</description>
	<lastBuildDate>Mon, 06 Feb 2012 05:19:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Displaying Code in LaTeX</title>
		<link>http://scott.sherrillmix.com/blog/programmer/displaying-code-in-latex/</link>
		<comments>http://scott.sherrillmix.com/blog/programmer/displaying-code-in-latex/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 06:28:37 +0000</pubDate>
		<dc:creator>ScottS-M</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Programmer]]></category>
		<category><![CDATA[#]]></category>
		<category><![CDATA[anglesign]]></category>
		<category><![CDATA[appendix]]></category>
		<category><![CDATA[bnb]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[equation box]]></category>
		<category><![CDATA[hfill]]></category>
		<category><![CDATA[M^2]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[syntax highlighting]]></category>
		<category><![CDATA[verbatim]]></category>
		<category><![CDATA[\alpha_i]]></category>

		<guid isPermaLink="false">http://scott.sherrillmix.com/blog/?p=437</guid>
		<description><![CDATA[gioby of Bioinfo Blog! (an interesting read by the way) left a comment asking about displaying code in LaTeX documents. I&#8217;ve sort of been cludging around using \hspace&#8216;s and \textcolor but I&#8217;ve always meant to figure out the right way to do things so this seemed like a good chance to figure out how to [...]]]></description>
			<content:encoded><![CDATA[<p>gioby of <a href='http://bioinfoblog.it/'>Bioinfo Blog!</a> (an interesting read by the way) left a comment asking about displaying code in LaTeX documents. I&#8217;ve sort of been cludging around using <code>\hspace</code>&#8216;s and <code>\textcolor</code> but I&#8217;ve always meant to figure out the right way to do things so this seemed like a good chance to figure out how to do it right.</p>

<p>LaTeX tends to ignore white space. This is good when you&#8217;re writing papers but not so good when you&#8217;re trying to show code where white space is an essential part (e.g. Python). Luckily there&#8217;s a builtin <code>verbatim</code> environment in LaTeX that is equivalent to html&#8217;s <code>&lt;pre&gt;</code>. So something like the following should preserve white space.</p>
<img src="/res/images/latex_verbatim.png" alt="Code in LaTeX using verbatim" class="right"/><pre><code>\begin{verbatim}
for i in range(1, 5):
  print i
else:
  print &quot;The for loop is over&quot;
\end{verbatim}</code></pre>

<p>Unfortunately, you can&#8217;t use any normal LaTeX commands inside verbatim (since they&#8217;re displayed <em>verbatim</em>). But luckily there a handy package called <a href="http://www.ctan.org/tex-archive/macros/latex/contrib/fancyvrb/">fancyvrb</a> that fixes this (the <a href="http://www.ctan.org/tex-archive/help/Catalogue/entries/color.html">color</a> package is also useful for adding colors). For example, if you wanted to highlight &#8220;for&#8221; in the above code, you can use the <code>Verbatim</code> (note the capital V) environment from fancyvrb:</p>
<img src="/res/images/latex_fancyvrb.png" alt="Code in LaTeX using fancyvrb" class="right"/>
<pre><code>\newcommand\codeHighlight[1]{\textcolor[rgb]{1,0,0}{\textbf{#1}}}
\begin{Verbatim}[commandchars=\\\{\}]
\codeHighlight{for} i in range(1, 5):
  print i
else:
  print &quot;The for loop is over&quot;
\end{Verbatim}
</code></pre>

<img src="/res/images/latex_pygmentize.png" alt="Code in LaTeX using pygmentize" class="right"/>
<p>If you really want to get fancy, the <a href='http://pygments.org/docs/quickstart/'>Pygments package</a> in Python will output syntax highlighted latex code with a command like: <code>pygmentize -f latex -O full test.py &gt;py.tex</code> The LaTeX it outputs is a bit hard to read but it&#8217;s not too bad (it helped me figure out the fancyvrb package) and it does make nice syntax highlighted output.</p>

<p>Here&#8217;s an example LaTeX file with the three examples above and the pdf it generates if you&#8217;re curious.</p>
<ul>
<li><a href="/res/codeInLatex.tex">codeInLatex.tex</a></li>
<li><a href="/res/codeInLatex.pdf">codeInLatex.pdf</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://scott.sherrillmix.com/blog/programmer/displaying-code-in-latex/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>LaTeX: Document Creation Alternative</title>
		<link>http://scott.sherrillmix.com/blog/programmer/latex-document-creation-alternative/</link>
		<comments>http://scott.sherrillmix.com/blog/programmer/latex-document-creation-alternative/#comments</comments>
		<pubDate>Mon, 18 Dec 2006 03:20:13 +0000</pubDate>
		<dc:creator>ScottS-M</dc:creator>
				<category><![CDATA[Grad Student]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Programmer]]></category>
		<category><![CDATA[benefits]]></category>
		<category><![CDATA[recommendation]]></category>
		<category><![CDATA[start]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[WinEdt]]></category>

		<guid isPermaLink="false">http://scott.sherrillmix.com/blog/programmer/latex-document-creation-alternative/</guid>
		<description><![CDATA[I&#8217;ve been using LaTeX a lot recently and I thought I would write a quick post since I wish I would have found out about it earlier. LaTeX is a really powerful document (pdf and others) creation program. It&#8217;s sort of like HTML and CSS for paper publishing. As a first warning, LaTeX, like HTML, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <a href="http://www.latex-project.org/">LaTeX</a> a lot recently and I thought I would write a quick post since I wish I would have found out about it earlier. LaTeX is a really powerful document (pdf and others) creation program. It&#8217;s sort of like HTML and CSS for paper publishing. As a first warning, LaTeX, like HTML, is not <a href="http://en.wikipedia.org/wiki/WYSIWYG">WYSIWYG</a>. You have to code in things like <code>\textbf{This will be bold}</code>. This takes some getting used to after programs like MS Word but after using LaTeX, I really can&#8217;t stand working in Word for anything longer than a page or two.</p>

<p>So why would you want to give up the convenience of Word for the (initially) more difficult LaTeX. Well one immediate benefit is it looks better. LaTeX does <a href="http://nitens.org/taraborelli/latex">ligatures and kerning</a>. To tell the truth, I never even knew what these were until I switched but they do seem to make documents look better.</p>

<p>The main benefit to me was the easy handling of figures and references. I would often insert a figure into Word only to have to update it with new data or adjusted labels. Somehow reinserting the figure always seemed to mess up its size or spacing or the surrounding text. In LaTex, you can just type <code>\includegraphics{graph.eps}</code> and LaTeX will include the current version of <code>graph.eps</code> each time it is compiled and automatically place it in an aesthetic place. LaTeX also comes with its own bibliography and reference manager, BibTex. This makes references as simple as typing \citep{SmithJohnsonetal1999}. You just need to make a main bibliography file with the details on <code>SmithJohnsonetal1999</code> and all your other references and BibTex will select the ones referenced in your document and make a bibliography in just about any style.</p> 
<p>If you are on Windows, <a href="http://www.miktex.org/">MikTex</a> seems like best solution for implementing TeX. It&#8217;s free too. <a href="http://www.winedt.com/">WinEdt</a> (shareware) is a handy editor for LaTeX. It integrates very well with LaTeX and makes the first steps in the switch from Word <em>much</em> easier. Java-based <a href="http://jabref.sourceforge.net/">JabRef</a> (free) is handy for managing bibliography data.</p>

<p>Links:</p>
<ul>
<li><a href="http://people.ee.ethz.ch/~oetiker/lshort/lshort.pdf">The Not So Short Introduction to LaTeX2e</a></li>
<li><a href="http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/">LaTeX Tutorial</a></li>
<li><a href="http://www.winedt.com/tex.html">WinEdt and LaTeX</a></li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://scott.sherrillmix.com/blog/programmer/latex-document-creation-alternative/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

