diff --git a/doc/kwantdoctheme/static/kwantdoctheme.css b/doc/kwantdoctheme/static/kwantdoctheme.css
new file mode 100644
index 0000000000000000000000000000000000000000..8837f6ee74e9222e87c1edb10f5294864daa12d5
--- /dev/null
+++ b/doc/kwantdoctheme/static/kwantdoctheme.css
@@ -0,0 +1,198 @@
+/* This theme is based on pydoctheme by Georg Brandl. */
+
+@import url("default.css");
+
+body {
+    background-color: white;
+    margin-left: 1em;
+    margin-right: 1em;
+}
+
+/* Disable typewriter font in headings. */
+h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
+    font-family: "Bitstream Vera Sans", Verdana, sans-serif;
+    font-size: 100%;
+}
+
+div.body p, div.body dd, div.body li {
+    -webkit-hyphens: auto;
+    -moz-hyphens: auto;
+    -ms-hyphens: auto;
+    -o-hyphens: auto;
+    hyphens: auto;
+}
+
+div.related {
+    margin-bottom: 1.2em;
+    padding: 0.5em 0;
+    border-top: 1px solid #ccc;
+    margin-top: 0.5em;
+}
+
+dt:target, .highlighted {
+    background-color: #fbf1aa;
+}
+
+div.related:first-child {
+    border-top: 0;
+    border-bottom: 1px solid #ccc;
+}
+
+div.sphinxsidebar {
+    background-color: #eeeeee;
+    border-radius: 5px;
+    line-height: 130%;
+    font-size: smaller;
+    overflow: hidden;
+}
+
+div.sphinxsidebar h3, div.sphinxsidebar h4 {
+    margin-top: 1.5em;
+}
+
+div.sphinxsidebarwrapper > h3:first-child {
+    margin-top: 0.2em;
+}
+
+div.sphinxsidebarwrapper > ul > li > ul > li {
+    margin-bottom: 0.4em;
+}
+
+div.sphinxsidebar input {
+    font-family: 'Bitstream Vera Serif',  Georgia, serif
+    border: 1px solid #999999;
+    font-size: smaller;
+    border-radius: 3px;
+}
+
+div.sphinxsidebar input[type=text] {
+    max-width: 220px;
+}
+
+div.body {
+    padding: 0 0 0 1.2em;
+}
+
+div.body p {
+    line-height: 140%;
+}
+
+div.body h1, div.body h2, div.body h3, div.body h4, div.body h5, div.body h6 {
+    margin: 0;
+    border: 0;
+    padding: 0.3em 0;
+}
+
+div.body hr {
+    border: 0;
+    background-color: #ccc;
+    height: 1px;
+}
+
+div.body pre {
+    border-radius: 3px;
+    border: 1px solid #ac9;
+}
+
+div.body div.admonition, div.body div.impl-detail {
+    border-radius: 3px;
+}
+
+div.body div.impl-detail > p {
+    margin: 0;
+}
+
+div.body div.seealso {
+    border: 1px solid #dddd66;
+}
+
+tt, pre {
+    font-family: monospace, sans-serif;
+    font-size: 96.5%;
+    -webkit-hyphens: none;
+    -moz-hyphens: none;
+    -ms-hyphens: none;
+    -o-hyphens: none;
+    hyphens: none;
+}
+
+div.body tt {
+    border-radius: 3px;
+}
+
+div.body tt.descname {
+    font-size: 120%;
+}
+
+div.body tt.xref, div.body a tt {
+    font-weight: normal;
+}
+
+p.deprecated {
+    border-radius: 3px;
+}
+
+table.docutils {
+    border: 1px solid #ddd;
+    min-width: 20%;
+    border-radius: 3px;
+    margin-top: 10px;
+    margin-bottom: 10px;
+}
+
+table.docutils td, table.docutils th {
+    border: 1px solid #ddd !important;
+    border-radius: 3px;
+}
+
+table p, table li {
+    text-align: left !important;
+}
+
+table.docutils th {
+    background-color: #eee;
+    padding: 0.3em 0.5em;
+}
+
+table.docutils td {
+    background-color: white;
+    padding: 0.3em 0.5em;
+}
+
+table.footnote, table.footnote td {
+    border: 0 !important;
+}
+
+div.footer {
+    line-height: 150%;
+    margin-top: -2em;
+    text-align: right;
+    width: auto;
+    margin-right: 10px;
+}
+
+/* have arguments of functions or classes also a monospace font */
+table.longtable.docutils > tbody > tr > td:first-child,
+dl.function > dt,
+dl.class > dt,
+dl.method > dt
+{
+    font-family: "Bitstream Vera Sans Mono", monospace, serif;
+    font-size: 96.5%;
+}
+
+/* rescale font for <tt> so that it is again 96.5% with respect to body */
+table.longtable.docutils > tbody > tr > td:first-child tt,
+dl.function > dt tt,
+dl.class > dt tt,
+dl.method > dt tt
+{
+    font-family: "Bitstream Vera Sans Mono", monospace, serif;
+    font-size: 100%;
+}
+
+td.field-body strong
+{
+    font-family: "Bitstream Vera Sans Mono", monospace, serif;
+    font-size: 96.5%;
+}
diff --git a/doc/kwantdoctheme/theme.conf b/doc/kwantdoctheme/theme.conf
new file mode 100644
index 0000000000000000000000000000000000000000..1a5f002291f98f6c5a6cf73a4f1ce3624bcbc3bf
--- /dev/null
+++ b/doc/kwantdoctheme/theme.conf
@@ -0,0 +1,26 @@
+# This theme is based on pydoctheme by Georg Brandl
+
+[theme]
+inherit = default
+stylesheet = kwantdoctheme.css
+pygments_style = sphinx
+
+[options]
+bodyfont = "Bitstream Vera Serif", Georgia, serif
+headfont = "Bitstream Vera Sans", Verdana, sans-serif
+footerbgcolor = white
+footertextcolor = #555555
+relbarbgcolor = white
+relbartextcolor = #666666
+relbarlinkcolor = #444444
+sidebarbgcolor = white
+sidebartextcolor = #444444
+sidebarlinkcolor = #444444
+sidebarwidth = 300
+bgcolor = white
+textcolor = black
+linkcolor = #045e94
+visitedlinkcolor = #045e94
+headtextcolor = black
+headbgcolor = white
+headlinkcolor = #aaaaaa
diff --git a/doc/source/_static/kwant.css b/doc/source/_static/kwant.css
index 00875a2d0f364fe12f4e97a3a64fff874cc3b121..246b713baa67b4130311aa5ec1361b65080630a8 100644
--- a/doc/source/_static/kwant.css
+++ b/doc/source/_static/kwant.css
@@ -1,209 +1,27 @@
-@import "default.css";
-
-/**
- * Spacing fixes
-
-
-div.body p, div.body dd, div.body li {
-  line-height: 125%;
-}
-
-ul.simple {
-    margin-top: 0;
-    margin-bottom: 0;
-    padding-top: 0;
-    padding-bottom: 0;
-}
-*/
+@import "kwantdoctheme.css";
 
 /* spacing around blockquoted fields in parameters/attributes/returns */
-/*Essential. Otherwise there is way too much space around*/
+/* Essential. Otherwise there is way too much space around*/
 td.field-body > blockquote {
     margin-top: 0.1em;
     margin-bottom: 0.5em;
 }
 
-/* THE NEXT TWO ARE EVENTUALLY IMPORTANT I THINK */
-/* spacing around example code
-div.highlight > pre {
-    padding: 2px 5px 2px 5px;
-}
-*/
-
-/* spacing in see also definition lists
-dl.last > dd {
-    margin-top: 1px;
-    margin-bottom: 5px;
-    margin-left: 30px;
-}
-*/
-/* hide overflowing content in the sidebar
-div.sphinxsidebarwrapper p.topless {
-    overflow: hidden;
-}
-*/
-
-/**
- * Hide dummy toctrees
-
-
-ul {
-  padding-top: 0;
-  padding-bottom: 0;
-  margin-top: 0;
-  margin-bottom: 0;
-}
-ul li {
-  padding-top: 0;
-  padding-bottom: 0;
-  margin-top: 0;
-  margin-bottom: 0;
-}
-ul li a.reference {
-  padding-top: 0;
-  padding-bottom: 0;
-  margin-top: 0;
-  margin-bottom: 0;
-}
-
-*/
-
-/**
- * Make high-level subsections easier to distinguish from top-level ones
-
-div.body h3 {
-  background-color: transparent;
-}
-
-div.body h4 {
-  border: none;
-  background-color: transparent;
-}
-*/
-
-/**
- * Scipy colors
-
-body {
-  background-color: rgb(100,135,220);
-}
-
-div.document {
-  background-color: rgb(230,230,230);
-}
-
-div.sphinxsidebar {
-  background-color: rgb(230,230,230);
-}
-
-div.related {
-  background-color: rgb(100,135,220);
-}
-
-div.sphinxsidebar h3 {
-  color: rgb(0,102,204);
-}
-
-div.sphinxsidebar h3 a {
-  color: rgb(0,102,204);
-}
-
-div.sphinxsidebar h4 {
-  color: rgb(0,82,194);
-}
-
-div.sphinxsidebar p {
-  color: black;
-}
-
-div.sphinxsidebar a {
-  color: #355f7c;
-}
-
-div.sphinxsidebar ul.want-points {
-  list-style: disc;
-}
-*/
-
 .field-list th {
-  color: rgb(0,50,150);
-  background-color: #EEE8AA;
-  white-space: nowrap; /*Essential. Otherwise the colons can break
-			 into a new line*/
-}
-
-
-
-/**
- * Extra admonitions
-
-
-div.tip {
-  background-color: #ffffe4;
-  border: 1px solid #ee6;
-}
-
-div.plot-output {
-  clear-after: both;
-}
-
-div.plot-output .figure {
-  float: left;
-  text-align: center;
-  margin-bottom: 0;
-  padding-bottom: 0;
-}
-
-div.plot-output .caption {
-  margin-top: 2;
-  padding-top: 0;
-}
-
-div.plot-output p.admonition-title {
-  display: none;
-}
-
-div.plot-output:after {
-  content: "";
-  display: block;
-  height: 0;
-  clear: both;
-}
-*/
-
-
-/*
-div.admonition-example {
-    background-color: #e4ffe4;
-    border: 1px solid #ccc;
-}*/
-
-
-/**
- * Styling for field lists
- */
-
-table.field-list th {
-  border-left: 2px solid #999 !important;
-  padding-left: 5px;
+  /* color: rgb(0,50,150); */
+  /* background-color: #EEE8AA; */
+  white-space: nowrap; /* Essential. Otherwise the colons can break
+                          into a new line */
 }
 
 table.field-list {
-  border-collapse: separate; /*Essential. Otherwise Parameters and Returns
-			       are sharing one solid colored field. That looks
-			       weird.*/
+  border-collapse: separate; /* Essential. Otherwise Parameters and Returns
+                                are sharing one solid colored field. That looks
+                                weird. */
   border-spacing: 10px;
+  border-style: hidden;
 }
 
-/**
- * Styling for footnotes
-
-
-table.footnote td, table.footnote th {
-  border: none;
-}
-*/
-
 div.specialnote-title {
     font-size: 105%;
     font-weight: bold;
diff --git a/doc/source/_static/kwant_logo.png b/doc/source/_static/kwant_logo.png
index ff89b6a48c1d4be400a5ecce5ef40b2adaf69549..7e4cf313f98503cc3bccd0457e77dc5b81b73832 100644
Binary files a/doc/source/_static/kwant_logo.png and b/doc/source/_static/kwant_logo.png differ
diff --git a/doc/source/_static/sidebar.js b/doc/source/_static/sidebar.js
new file mode 100644
index 0000000000000000000000000000000000000000..5ffeb127a12ac6c5af6dd8a8e055c8c2e2932a96
--- /dev/null
+++ b/doc/source/_static/sidebar.js
@@ -0,0 +1,155 @@
+/*
+ * sidebar.js
+ * ~~~~~~~~~~
+ *
+ * This script makes the Sphinx sidebar collapsible.
+ *
+ * .sphinxsidebar contains .sphinxsidebarwrapper.  This script adds in
+ * .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton used to
+ * collapse and expand the sidebar.
+ *
+ * When the sidebar is collapsed the .sphinxsidebarwrapper is hidden and the
+ * width of the sidebar and the margin-left of the document are decreased.
+ * When the sidebar is expanded the opposite happens.  This script saves a
+ * per-browser/per-session cookie used to remember the position of the sidebar
+ * among the pages.  Once the browser is closed the cookie is deleted and the
+ * position reset to the default (expanded).
+ *
+ * :copyright: Copyright 2007-2011 by the Sphinx team.
+ * :license: BSD, see LICENSE.txt for details.
+ *
+ */
+
+$(function() {
+  // global elements used by the functions.
+  // the 'sidebarbutton' element is defined as global after its
+  // creation, in the add_sidebar_button function
+  var bodywrapper = $('.bodywrapper');
+  var sidebar = $('.sphinxsidebar');
+  var sidebarwrapper = $('.sphinxsidebarwrapper');
+
+  // original margin-left of the bodywrapper and width of the sidebar
+  // with the sidebar expanded
+  var bw_margin_expanded = bodywrapper.css('margin-left');
+  var ssb_width_expanded = sidebar.width();
+
+  // margin-left of the bodywrapper and width of the sidebar
+  // with the sidebar collapsed
+  var bw_margin_collapsed = '.8em';
+  var ssb_width_collapsed = '.8em';
+
+  // colors used by the current theme
+  var dark_color = '#AAAAAA';
+  var light_color = '#CCCCCC';
+
+  function sidebar_is_collapsed() {
+    return sidebarwrapper.is(':not(:visible)');
+  }
+
+  function toggle_sidebar() {
+    if (sidebar_is_collapsed())
+      expand_sidebar();
+    else
+      collapse_sidebar();
+  }
+
+  function collapse_sidebar() {
+    sidebarwrapper.hide();
+    sidebar.css('width', ssb_width_collapsed);
+    bodywrapper.css('margin-left', bw_margin_collapsed);
+    sidebarbutton.css({
+        'margin-left': '0',
+        'height': bodywrapper.height(),
+        'border-radius': '5px'
+    });
+    sidebarbutton.find('span').text('»');
+    sidebarbutton.attr('title', _('Expand sidebar'));
+    document.cookie = 'sidebar=collapsed';
+  }
+
+  function expand_sidebar() {
+    bodywrapper.css('margin-left', bw_margin_expanded);
+    sidebar.css('width', ssb_width_expanded);
+    sidebarwrapper.show();
+    sidebarbutton.css({
+        'margin-left': ssb_width_expanded-12,
+        'height': bodywrapper.height(),
+        'border-radius': '0 5px 5px 0'
+    });
+    sidebarbutton.find('span').text('«');
+    sidebarbutton.attr('title', _('Collapse sidebar'));
+    //sidebarwrapper.css({'padding-top':
+    //  Math.max(window.pageYOffset - sidebarwrapper.offset().top, 10)});
+    document.cookie = 'sidebar=expanded';
+  }
+
+  function add_sidebar_button() {
+    sidebarwrapper.css({
+        'float': 'left',
+        'margin-right': '0',
+        'width': ssb_width_expanded - 28
+    });
+    // create the button
+    sidebar.append(
+      '<div id="sidebarbutton"><span>&laquo;</span></div>'
+    );
+    var sidebarbutton = $('#sidebarbutton');
+    // find the height of the viewport to center the '<<' in the page
+    var viewport_height;
+    if (window.innerHeight)
+ 	  viewport_height = window.innerHeight;
+    else
+	  viewport_height = $(window).height();
+    var sidebar_offset = sidebar.offset().top;
+    var sidebar_height = Math.max(bodywrapper.height(), sidebar.height());
+    sidebarbutton.find('span').css({
+        'display': 'block',
+        'position': 'fixed',
+        'top': Math.min(viewport_height/2, sidebar_height/2 + sidebar_offset) - 10
+    });
+
+    sidebarbutton.click(toggle_sidebar);
+    sidebarbutton.attr('title', _('Collapse sidebar'));
+    sidebarbutton.css({
+        'border-radius': '0 5px 5px 0',
+        'color': '#444444',
+        'background-color': '#CCCCCC',
+        'font-size': '1.2em',
+        'cursor': 'pointer',
+        'height': sidebar_height,
+        'padding-top': '1px',
+        'padding-left': '1px',
+        'margin-left': ssb_width_expanded - 12
+    });
+
+    sidebarbutton.hover(
+      function () {
+          $(this).css('background-color', dark_color);
+      },
+      function () {
+          $(this).css('background-color', light_color);
+      }
+    );
+  }
+
+  function set_position_from_cookie() {
+    if (!document.cookie)
+      return;
+    var items = document.cookie.split(';');
+    for(var k=0; k<items.length; k++) {
+      var key_val = items[k].split('=');
+      var key = key_val[0];
+      if (key == 'sidebar') {
+        var value = key_val[1];
+        if ((value == 'collapsed') && (!sidebar_is_collapsed()))
+          collapse_sidebar();
+        else if ((value == 'expanded') && (sidebar_is_collapsed()))
+          expand_sidebar();
+      }
+    }
+  }
+
+  add_sidebar_button();
+  var sidebarbutton = $('#sidebarbutton');
+  set_position_from_cookie();
+});
diff --git a/doc/source/conf.py b/doc/source/conf.py
index 29f08e5516f3a9286f843906ce944424f80ce6c5..224e266d141dd7c3b43b046c0ecde3ae65cb0d90 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -111,7 +111,9 @@ pngmath_latex_preamble = r"""\newcommand{\bra}[1]{\left\langle#1\right|}
 
 # The theme to use for HTML and HTML Help pages.  Major themes that come with
 # Sphinx are currently 'default' and 'sphinxdoc'.
-html_theme = 'default'
+html_theme = 'kwantdoctheme'
+html_theme_path = ['..']
+html_theme_options = {'collapsiblesidebar': True}
 html_style = 'kwant.css'
 
 # Theme options are theme-specific and customize the look and feel of a theme
diff --git a/doc/templates/layout.html b/doc/templates/layout.html
index e34537c82fcff7cdd9b71ef39b73d19b5d983ce5..781a09fa641a3ab2de49ef6c7b13e38ae4c5a931 100644
--- a/doc/templates/layout.html
+++ b/doc/templates/layout.html
@@ -1,9 +1,213 @@
-{% extends "!layout.html" %}
+{#
+    This file is based on the "Master layout template for Sphinx themes".
+
+    :copyright: Copyright 2007-2011 by the Sphinx team.
+    :license: BSD, see LICENSE.txt for details.
+
+    We cannot use layout.html as provided by Sphinx because we want to set
+    the <html> lang attribute.
+#}
+
 {% set script_files = script_files + ["_static/togglediv.js"] %}
-{% block rootrellink %}
-    <li><a href="http://kwant-project.org/">
-        <img src="{{ pathto('_static/kwant_logo.png', 1) }}"
-        style="vertical-align: middle; margin-top: -4px" alt="Kwant logo"/></a>
-      {{ reldelim1 }}</li>
-    <li><a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}</li>
-{% endblock %}
+{% if theme_collapsiblesidebar|tobool %}
+{% set script_files = script_files + ['_static/sidebar.js'] %}
+{% endif %}
+
+{%- block doctype -%}
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+{%- endblock %}
+{%- set reldelim1 = reldelim1 is not defined and ' &raquo;' or reldelim1 %}
+{%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %}
+{%- set render_sidebar = (not embedded) and (not theme_nosidebar|tobool) and
+                         (sidebars != []) %}
+{%- set url_root = pathto('', 1) %}
+{# XXX necessary? #}
+{%- if url_root == '#' %}{% set url_root = '' %}{% endif %}
+{%- if not embedded and docstitle %}
+  {%- set titlesuffix = " &mdash; "|safe + docstitle|e %}
+{%- else %}
+  {%- set titlesuffix = "" %}
+{%- endif %}
+
+{%- macro relbar() %}
+    <div class="related">
+      <h3>{{ _('Navigation') }}</h3>
+      <ul>
+        {%- for rellink in rellinks %}
+        <li class="right" {% if loop.first %}style="margin-right: 10px"{% endif %}>
+          <a href="{{ pathto(rellink[0]) }}" title="{{ rellink[1]|striptags|e }}"
+             {{ accesskey(rellink[2]) }}>{{ rellink[3] }}</a>
+          {%- if not loop.first %}{{ reldelim2 }}{% endif %}</li>
+        {%- endfor %}
+        {%- block rootrellink %}
+        <li><a href="http://kwant-project.org/">
+            <img src="{{ pathto('_static/kwant_logo.png', 1) }}"
+            style="vertical-align: middle; margin-top: -4px" alt="Kwant logo"/></a>
+          {{ reldelim1 }}</li>
+        <li><a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}</li>
+        {%- endblock %}
+        {%- for parent in parents %}
+          <li><a href="{{ parent.link|e }}" {% if loop.last %}{{ accesskey("U") }}{% endif %}>{{ parent.title }}</a>{{ reldelim1 }}</li>
+        {%- endfor %}
+        {%- block relbaritems %} {% endblock %}
+      </ul>
+    </div>
+{%- endmacro %}
+
+{%- macro sidebar() %}
+      {%- if render_sidebar %}
+      <div class="sphinxsidebar">
+        <div class="sphinxsidebarwrapper">
+          {%- block sidebarlogo %}
+          {%- if logo %}
+            <p class="logo"><a href="{{ pathto(master_doc) }}">
+              <img class="logo" src="{{ pathto('_static/' + logo, 1) }}" alt="Logo"/>
+            </a></p>
+          {%- endif %}
+          {%- endblock %}
+          {%- if sidebars != None %}
+            {#- new style sidebar: explicitly include/exclude templates #}
+            {%- for sidebartemplate in sidebars %}
+            {%- include sidebartemplate %}
+            {%- endfor %}
+          {%- else %}
+            {#- old style sidebars: using blocks -- should be deprecated #}
+            {%- block sidebartoc %}
+            {%- include "localtoc.html" %}
+            {%- endblock %}
+            {%- block sidebarrel %}
+            {%- include "relations.html" %}
+            {%- endblock %}
+            {%- block sidebarsourcelink %}
+            {%- include "sourcelink.html" %}
+            {%- endblock %}
+            {%- if customsidebar %}
+            {%- include customsidebar %}
+            {%- endif %}
+            {%- block sidebarsearch %}
+            {%- include "searchbox.html" %}
+            {%- endblock %}
+          {%- endif %}
+        </div>
+      </div>
+      {%- endif %}
+{%- endmacro %}
+
+{%- macro script() %}
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    '{{ url_root }}',
+        VERSION:     '{{ release|e }}',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '{{ '' if no_search_suffix else file_suffix }}',
+        HAS_SOURCE:  {{ has_source|lower }}
+      };
+    </script>
+    {%- for scriptfile in script_files %}
+    <script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
+    {%- endfor %}
+{%- endmacro %}
+
+{%- macro css() %}
+    <link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
+    <link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
+    {%- for cssfile in css_files %}
+    <link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
+    {%- endfor %}
+{%- endmacro %}
+
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset={{ encoding }}" />
+    {{ metatags }}
+    {%- block htmltitle %}
+    <title>{{ title|striptags|e }}{{ titlesuffix }}</title>
+    {%- endblock %}
+    {{ css() }}
+    {%- if not embedded %}
+    {{ script() }}
+    {%- if use_opensearch %}
+    <link rel="search" type="application/opensearchdescription+xml"
+          title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}"
+          href="{{ pathto('_static/opensearch.xml', 1) }}"/>
+    {%- endif %}
+    {%- if favicon %}
+    <link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
+    {%- endif %}
+    {%- endif %}
+{%- block linktags %}
+    {%- if hasdoc('about') %}
+    <link rel="author" title="{{ _('About these documents') }}" href="{{ pathto('about') }}" />
+    {%- endif %}
+    {%- if hasdoc('genindex') %}
+    <link rel="index" title="{{ _('Index') }}" href="{{ pathto('genindex') }}" />
+    {%- endif %}
+    {%- if hasdoc('search') %}
+    <link rel="search" title="{{ _('Search') }}" href="{{ pathto('search') }}" />
+    {%- endif %}
+    {%- if hasdoc('copyright') %}
+    <link rel="copyright" title="{{ _('Copyright') }}" href="{{ pathto('copyright') }}" />
+    {%- endif %}
+    <link rel="top" title="{{ docstitle|e }}" href="{{ pathto('index') }}" />
+    {%- if parents %}
+    <link rel="up" title="{{ parents[-1].title|striptags|e }}" href="{{ parents[-1].link|e }}" />
+    {%- endif %}
+    {%- if next %}
+    <link rel="next" title="{{ next.title|striptags|e }}" href="{{ next.link|e }}" />
+    {%- endif %}
+    {%- if prev %}
+    <link rel="prev" title="{{ prev.title|striptags|e }}" href="{{ prev.link|e }}" />
+    {%- endif %}
+{%- endblock %}
+{%- block extrahead %} {% endblock %}
+  </head>
+  <body>
+{%- block header %}{% endblock %}
+
+{%- block relbar1 %}{{ relbar() }}{% endblock %}
+
+{%- block content %}
+  {%- block sidebar1 %} {# possible location for sidebar #} {% endblock %}
+
+    <div class="document">
+  {%- block document %}
+      <div class="documentwrapper">
+      {%- if render_sidebar %}
+        <div class="bodywrapper">
+      {%- endif %}
+          <div class="body">
+            {% block body %} {% endblock %}
+          </div>
+      {%- if render_sidebar %}
+        </div>
+      {%- endif %}
+      </div>
+  {%- endblock %}
+
+  {%- block sidebar2 %}{{ sidebar() }}{% endblock %}
+      <div class="clearer"></div>
+    </div>
+{%- endblock %}
+
+{%- block relbar2 %}{{ relbar() }}{% endblock %}
+
+{%- block footer %}
+    <div class="footer">
+    {%- if show_copyright %}
+      {%- if hasdoc('copyright') %}
+        {% trans path=pathto('copyright'), copyright=copyright|e %}&copy; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
+      {%- else %}
+        {% trans copyright=copyright|e %}&copy; Copyright {{ copyright }}.{% endtrans %}
+      {%- endif %}
+    {%- endif %}
+    {%- if last_updated %}
+      {% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
+    {%- endif %}
+    {%- if show_sphinx %}
+      {% trans sphinx_version=sphinx_version|e %}Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %}
+    {%- endif %}
+    </div>
+{%- endblock %}
+  </body>
+</html>