<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>LaTeX |</title><link>https://kristianeschenburg.netlify.app/tag/latex/</link><atom:link href="https://kristianeschenburg.netlify.app/tag/latex/index.xml" rel="self" type="application/rss+xml"/><description>LaTeX</description><generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>en-us</language><lastBuildDate>Sat, 11 Aug 2018 02:14:14 -0700</lastBuildDate><image><url>https://kristianeschenburg.netlify.app/img/Bayes.jpg</url><title>LaTeX</title><link>https://kristianeschenburg.netlify.app/tag/latex/</link></image><item><title>Rendering LaTex In Markdown Using Jekyll</title><link>https://kristianeschenburg.netlify.app/post/rendering-latex-in-markdown-using-jekyll/</link><pubDate>Sat, 11 Aug 2018 02:14:14 -0700</pubDate><guid>https://kristianeschenburg.netlify.app/post/rendering-latex-in-markdown-using-jekyll/</guid><description>&lt;p>In putting together this blog, I wanted to be able to talk about various mathematical topics that I found interesting, which inevitably lead to using LaTex in my posts.&lt;/p>
&lt;p>I&amp;rsquo;m currently using Atom as my editor (having converted from Sublime), and needed to install a bunch of packages first. First and foremost, I wanted to be able to render my markdown posts before hosting them on the blog, and consequentially needed a way to render LaTex. For this, I installed a few Atom packages:&lt;/p>
&lt;ul>
&lt;li>
&lt;a href="https://atom.io/packages/markdown-it-preview" target="_blank" rel="noopener">Markdown-Preview&lt;/a>&lt;/li>
&lt;li>
&lt;a href="https://atom.io/packages/latex" target="_blank" rel="noopener">Latex&lt;/a>&lt;/li>
&lt;li>
&lt;a href="https://atom.io/packages/language-latex" target="_blank" rel="noopener">Language-Latex&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>To preview your post in Atom, you just type &lt;code>ctrl+shift+M&lt;/code>, which will display both in-line and block math sections.&lt;/p>
&lt;p>However, if you build your site locally with the command &lt;code>bundle exec jekyll serve&lt;/code> or push it to a remote repo, the LaTex no longer renders properly. After Googling around a bit, I determined that this was due to the way markdown converters in Jekyll, like &lt;strong>kramdown&lt;/strong> and &lt;strong>redcarpet&lt;/strong>, do the conversion using MathJax &amp;ndash; specifically, in-line math segments are not properly rendered. I wanted a way to both preview the LaTex in Atom, and properly render it usng Jekyll. I found two links that solved the problem for me:&lt;/p>
&lt;ul>
&lt;li>
&lt;a href="http://www.gastonsanchez.com/visually-enforced/opinion/2014/02/16/Mathjax-with-jekyll/" target="_blank" rel="noopener">Visually Enforced&lt;/a>&lt;/li>
&lt;li>
&lt;a href="http://www.iangoodfellow.com/blog/jekyll/markdown/tex/2016/11/07/latex-in-markdown.html" target="_blank" rel="noopener">LaTeX in Jekyll&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>In short, the following steps solved the problem of LaTex not rendering for me. I&amp;rsquo;m using the &lt;strong>minima&lt;/strong> theme, so I first found the theme directory with &lt;code>bundle show minima&lt;/code>. In this directory, I copied the &lt;strong>./layouts/post.html&lt;/strong> to a local directory in my project folder called &lt;strong>./_layouts/post.html&lt;/strong>.&lt;/p>
&lt;p>Within this file, I pasted the following two sections of HTML code:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-html" data-lang="html">&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">script&lt;/span> &lt;span class="na">type&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;text/x-mathjax-config&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">MathJax&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">Hub&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">Config&lt;/span>&lt;span class="p">({&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">tex2jax&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">skipTags&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;script&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;noscript&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;style&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;textarea&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;pre&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">inlineMath&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[[&lt;/span>&lt;span class="s1">&amp;#39;$&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s1">&amp;#39;$&amp;#39;&lt;/span>&lt;span class="p">]]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">script&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">script&lt;/span> &lt;span class="na">src&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&amp;#34;&lt;/span> &lt;span class="na">type&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;text/javascript&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&amp;lt;/&lt;/span>&lt;span class="nt">script&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>And voila &amp;ndash; building the posts now correctly renders LaTex!&lt;/p></description></item></channel></rss>