Articles tagged with pelican:

  • Adding template pages to Pelican

    I was having a lot of trouble just getting my site to generate an authors file, even though I'm the only author here. The pelican documentation says you can add something like

    AUTHORS_URL = 'blog/authors.html'
    AUTHORS_SAVE_AS = 'blog/authors.html'
    

    To generate the authors.html file.

    It wasn't working for me. Well, after going through the source code and finding the relevant section in generators.py I found that you have to set DIRECT_TEMPLATES like so:

    DIRECT_TEMPLATES = ('index', 'tags', 'categories', 'archives', 'authors')
    AUTHORS_URL = 'blog/authors.html'
    AUTHORS_SAVE_AS = 'blog/authors.html'
    

    Now it works! And looking back at the documentation, it actually sort of hints at this. D'oh!


  • Getting LaTeX Math to work in Pelican

    Basically, you can follow this post verbatim.

    I'll just explain how I got to work on my personal setup. First of all, in order to do this you'll need to edit your template. I have a copy of the "notmyidea" template in my blog directory, so I can make changes to it. You can copy /usr/share/pyshared/pelican/themes/notmyidea to your blog directory, for example if my pelican files live in ~/blog/ I'd copy notmyidea to ~/blog/themes/notmyidea. Now you'll need to tell Pelican where to look for your theme, you can do this by editing your pelicanconf.py to include:

    THEME = "themes/notmyidea"
    THEME_STATIC_DIR = "theme"
    THEME_STATIC_PATHS = ['static']
    CSS_FILE = "main.css"
    

    Now, in blog/themes/notmyidea/templates/base.html you'll need to add

    <!-- Using MathJax, with the delimiters $ -->
    <!-- Conflict with pygments for the .mo and .mi -->
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
      "HTML-CSS": {
      styles: {
      ".MathJax .mo, .MathJax .mi": {color: "black ! important"}}
      },
      tex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']],processEscapes: true}
      });
    </script>
    
    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
    

    in the <head> section.

    Now that you have this done, you should be able to start using inline equations using \$a^{\\beta}\$ to get $a^{\\beta}$ (note the double backslash).

    I was having problems, however, getting the math directive to work with MathJax. What was happening was that instead of creating a <div class="math"> for the mathblock, RST was parsing the $\LaTeX$ as HTML. In order to fix this, you need to edit your docutils settings, as documented here. I did this by having a docutils.conf in my ~/blog folder with the following contents:

    [html4css1 writer]
    math_output: MathJax
    

    Now

    .. math::
    
       \frac{1}{\sqrt{2\pi\sigma^2}}\operatorname{exp}\left\{-\frac{\left(x-\mu\right)^2}{2\sigma^2}\right\}
    

    Outputs to:

    \begin{equation*} \frac{1}{\sqrt{2\pi\sigma^2}}\operatorname{exp}\left\{-\frac{\left(x-\mu\right)^2}{2\sigma^2}\right\} \end{equation*}

    Yay!


Page 1 / 1

Category
Tagcloud
neuro LaTeX js bad-tagging-scheme pelican R testing vim-is-okay-too emacs statistics wm sysadmin productivity
Latest posts