From 169eac139e4d9e61d1d3eec93a7cad430d6db948 Mon Sep 17 00:00:00 2001
From: Christoph Groth <christoph.groth@cea.fr>
Date: Thu, 14 Feb 2013 14:45:56 +0100
Subject: [PATCH] make tutorials importable

---
 .gitignore                                    |  2 +-
 MANIFEST.in                                   |  2 +-
 doc/Makefile                                  | 38 ++++++-------
 doc/source/images/1-quantum_wire.py.diff      | 40 --------------
 doc/source/images/{defs.py => _defs.py}       |  0
 .../{2-ab_ring.py.diff => ab_ring.py.diff}    | 52 +++++++++---------
 ...-ab_ring_sketch.svg => ab_ring_sketch.svg} |  0
 ...b_ring_sketch2.svg => ab_ring_sketch2.svg} |  0
 ...ructure.py.diff => band_structure.py.diff} | 16 +++---
 ...d_system.py.diff => closed_system.py.diff} | 16 +++---
 doc/source/images/generate-diffs.sh           |  3 +-
 .../{4-graphene.py.diff => graphene.py.diff}  | 42 +++++++--------
 ...ntum_well.py.diff => quantum_well.py.diff} | 16 +++---
 doc/source/images/quantum_wire.py.diff        | 40 ++++++++++++++
 ...-spin_orbit.py.diff => spin_orbit.py.diff} | 16 +++---
 ... => superconductor_band_structure.py.diff} | 12 ++---
 ....diff => superconductor_transport.py.diff} | 12 ++---
 ...vg => superconductor_transport_sketch.svg} |  0
 .../tutorial/{2-ab_ring.py => ab_ring.py}     |  0
 ...{3-band_structure.py => band_structure.py} |  0
 .../{3-closed_system.py => closed_system.py}  |  0
 .../tutorial/{4-graphene.py => graphene.py}   |  0
 .../{2-quantum_well.py => quantum_well.py}    |  0
 .../{1-quantum_wire.py => quantum_wire.py}    |  0
 ...revisited.py => quantum_wire_revisited.py} |  0
 .../{2-spin_orbit.py => spin_orbit.py}        |  0
 ...re.py => superconductor_band_structure.py} |  0
 ...ansport.py => superconductor_transport.py} |  0
 doc/source/tutorial/tutorial1.rst             | 54 +++++++++----------
 doc/source/tutorial/tutorial2.rst             | 48 ++++++++---------
 doc/source/tutorial/tutorial3.rst             | 18 +++----
 doc/source/tutorial/tutorial4.rst             | 30 +++++------
 doc/source/tutorial/tutorial5.rst             | 24 ++++-----
 33 files changed, 241 insertions(+), 240 deletions(-)
 delete mode 100644 doc/source/images/1-quantum_wire.py.diff
 rename doc/source/images/{defs.py => _defs.py} (100%)
 rename doc/source/images/{2-ab_ring.py.diff => ab_ring.py.diff} (77%)
 rename doc/source/images/{2-ab_ring_sketch.svg => ab_ring_sketch.svg} (100%)
 rename doc/source/images/{2-ab_ring_sketch2.svg => ab_ring_sketch2.svg} (100%)
 rename doc/source/images/{3-band_structure.py.diff => band_structure.py.diff} (65%)
 rename doc/source/images/{3-closed_system.py.diff => closed_system.py.diff} (67%)
 rename doc/source/images/{4-graphene.py.diff => graphene.py.diff} (68%)
 rename doc/source/images/{2-quantum_well.py.diff => quantum_well.py.diff} (71%)
 create mode 100644 doc/source/images/quantum_wire.py.diff
 rename doc/source/images/{2-spin_orbit.py.diff => spin_orbit.py.diff} (68%)
 rename doc/source/images/{5-superconductor_band_structure.py.diff => superconductor_band_structure.py.diff} (69%)
 rename doc/source/images/{5-superconductor_transport.py.diff => superconductor_transport.py.diff} (73%)
 rename doc/source/images/{5-superconductor_transport_sketch.svg => superconductor_transport_sketch.svg} (100%)
 rename doc/source/tutorial/{2-ab_ring.py => ab_ring.py} (100%)
 rename doc/source/tutorial/{3-band_structure.py => band_structure.py} (100%)
 rename doc/source/tutorial/{3-closed_system.py => closed_system.py} (100%)
 rename doc/source/tutorial/{4-graphene.py => graphene.py} (100%)
 rename doc/source/tutorial/{2-quantum_well.py => quantum_well.py} (100%)
 rename doc/source/tutorial/{1-quantum_wire.py => quantum_wire.py} (100%)
 rename doc/source/tutorial/{1-quantum_wire_revisited.py => quantum_wire_revisited.py} (100%)
 rename doc/source/tutorial/{2-spin_orbit.py => spin_orbit.py} (100%)
 rename doc/source/tutorial/{5-superconductor_band_structure.py => superconductor_band_structure.py} (100%)
 rename doc/source/tutorial/{5-superconductor_transport.py => superconductor_transport.py} (100%)

diff --git a/.gitignore b/.gitignore
index 66870064..dac8e3bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,5 +13,5 @@ MANIFEST
 /doc/source/images/*.png
 /doc/source/images/*.pdf
 /doc/source/images/.*_flag
-/doc/source/images/[0-9]-*.py
+/doc/source/images/[a-zA-Z]*.py
 /build.conf
diff --git a/MANIFEST.in b/MANIFEST.in
index c144aabd..77a31e49 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -17,7 +17,7 @@ include doc/other/*[a-zA-Z]
 include doc/Makefile
 recursive-include doc/source *.rst *.py *.svg *.sh *.diff
 recursive-include doc/source/_static *[a-zA-Z]
-recursive-exclude doc/source/images [0-9]-*.py
+recursive-exclude doc/source/images [a-zA-Z]*.py
 recursive-include doc/templates *[a-zA-Z]
 prune doc/source/reference/generated
 recursive-include doc/sphinxext *.py *.txt *.in
diff --git a/doc/Makefile b/doc/Makefile
index 452ca2b5..29f773db 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -29,15 +29,15 @@ expand = $(foreach name, $(foreach fig, $(2), $(1)_$(fig)), \
 source/images/$(name).png source/images/$(name).pdf)
 
 # Generated images.
-1_IMAGES = $(call expand, 1-quantum_wire, result sys)
-2A_IMAGES = $(call expand, 2-spin_orbit, result)
-2B_IMAGES = $(call expand, 2-quantum_well, result)
-2C_IMAGES = $(call expand, 2-ab_ring, result sys note1 note2)
-3A_IMAGES = $(call expand, 3-band_structure, result)
-3B_IMAGES = $(call expand, 3-closed_system, result sys)
-4_IMAGES = $(call expand, 4-graphene, result sys1 sys2 bs)
-5A_IMAGES = $(call expand, 5-superconductor_band_structure, result)
-5B_IMAGES = $(call expand, 5-superconductor_transport, result)
+1_IMAGES = $(call expand, quantum_wire, result sys)
+2A_IMAGES = $(call expand, spin_orbit, result)
+2B_IMAGES = $(call expand, quantum_well, result)
+2C_IMAGES = $(call expand, ab_ring, result sys note1 note2)
+3A_IMAGES = $(call expand, band_structure, result)
+3B_IMAGES = $(call expand, closed_system, result sys)
+4_IMAGES = $(call expand, graphene, result sys1 sys2 bs)
+5A_IMAGES = $(call expand, superconductor_band_structure, result)
+5B_IMAGES = $(call expand, superconductor_transport, result)
 ALL_IMAGES = $(1_IMAGES)  $(2A_IMAGES) $(2B_IMAGES) $(2C_IMAGES) $(3A_IMAGES) \
 $(3B_IMAGES) $(4_IMAGES) $(5A_IMAGES) $(5B_IMAGES)
 
@@ -61,7 +61,7 @@ clean:
 	-rm -rf source/reference/generated
 
 realclean: clean
-	-rm -f $(ALL_IMAGES) source/images/.*_flag source/images/[0-9]-*.py
+	-rm -f $(ALL_IMAGES) source/images/.*_flag source/images/[a-zA-Z]*.py
 
 html:	$(ALL_IMAGES)
 	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@@ -138,29 +138,29 @@ doctest:
 	cd $(dir $<) && python $(notdir $<)
 	@touch $@
 
-$(1_IMAGES): source/images/.1-quantum_wire_flag
+$(1_IMAGES): source/images/.quantum_wire_flag
 	@:
 
-$(2A_IMAGES): source/images/.2-spin_orbit_flag
+$(2A_IMAGES): source/images/.spin_orbit_flag
 	@:
 
-$(2B_IMAGES): source/images/.2-quantum_well_flag
+$(2B_IMAGES): source/images/.quantum_well_flag
 	@:
 
-$(2C_IMAGES): source/images/.2-ab_ring_flag
+$(2C_IMAGES): source/images/.ab_ring_flag
 	@:
 
-$(3A_IMAGES): source/images/.3-band_structure_flag
+$(3A_IMAGES): source/images/.band_structure_flag
 	@:
 
-$(3B_IMAGES): source/images/.3-closed_system_flag
+$(3B_IMAGES): source/images/.closed_system_flag
 	@:
 
-$(4_IMAGES): source/images/.4-graphene_flag
+$(4_IMAGES): source/images/.graphene_flag
 	@:
 
-$(5A_IMAGES): source/images/.5-superconductor_band_structure_flag
+$(5A_IMAGES): source/images/.superconductor_band_structure_flag
 	@:
 
-$(5B_IMAGES): source/images/.5-superconductor_transport_flag
+$(5B_IMAGES): source/images/.superconductor_transport_flag
 	@:
diff --git a/doc/source/images/1-quantum_wire.py.diff b/doc/source/images/1-quantum_wire.py.diff
deleted file mode 100644
index d66f19aa..00000000
--- a/doc/source/images/1-quantum_wire.py.diff
+++ /dev/null
@@ -1,40 +0,0 @@
---- original
-+++ modified
-@@ -10,6 +10,7 @@
- 
- from matplotlib import pyplot
- import kwant
-+import defs
- 
- # First, define the tight-binding system
- 
-@@ -72,8 +73,9 @@
- sys.attach_lead(lead1)
- 
- # Plot it, to make sure it's OK
--
--kwant.plot(sys)
-+size = (defs.figwidth_in, 0.3 * defs.figwidth_in)
-+kwant.plot(sys, file="1-quantum_wire_sys.pdf", fig_size=size, dpi=defs.dpi)
-+kwant.plot(sys, file="1-quantum_wire_sys.png", fig_size=size, dpi=defs.dpi)
- 
- # Finalize the system
- 
-@@ -97,8 +99,13 @@
- # Use matplotlib to write output
- # We should see conductance steps
- 
--pyplot.figure()
-+fig = pyplot.figure()
- pyplot.plot(energies, data)
--pyplot.xlabel("energy [in units of t]")
--pyplot.ylabel("conductance [in units of e^2/h]")
--pyplot.show()
-+pyplot.xlabel("energy [in units of t]", fontsize=defs.mpl_label_size)
-+pyplot.ylabel("conductance [in units of e^2/h]", fontsize=defs.mpl_label_size)
-+pyplot.setp(fig.get_axes()[0].get_xticklabels(), fontsize=defs.mpl_tick_size)
-+pyplot.setp(fig.get_axes()[0].get_yticklabels(), fontsize=defs.mpl_tick_size)
-+fig.set_size_inches(defs.mpl_width_in, defs.mpl_width_in * 3. / 4.)
-+fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
-+fig.savefig("1-quantum_wire_result.pdf")
-+fig.savefig("1-quantum_wire_result.png", dpi=defs.dpi)
diff --git a/doc/source/images/defs.py b/doc/source/images/_defs.py
similarity index 100%
rename from doc/source/images/defs.py
rename to doc/source/images/_defs.py
diff --git a/doc/source/images/2-ab_ring.py.diff b/doc/source/images/ab_ring.py.diff
similarity index 77%
rename from doc/source/images/2-ab_ring.py.diff
rename to doc/source/images/ab_ring.py.diff
index 1f617d65..80d3ed99 100644
--- a/doc/source/images/2-ab_ring.py.diff
+++ b/doc/source/images/ab_ring.py.diff
@@ -1,17 +1,17 @@
 --- original
 +++ modified
 @@ -16,6 +16,7 @@
-
+ 
  # For plotting
  from matplotlib import pyplot
-+import defs
-
-
++import _defs
+ 
+ 
  def make_system(a=1, t=1.0, W=10, r1=10, r2=20):
 @@ -82,6 +83,54 @@
      return sys
-
-
+ 
+ 
 +def make_system_note1(a=1, t=1.0, W=10, r1=10, r2=20):
 +    lat = kwant.lattice.square(a)
 +    sys = kwant.Builder()
@@ -66,7 +66,7 @@
 @@ -95,18 +144,29 @@
          smatrix = kwant.solve(sys, energy)
          data.append(smatrix.transmission(1, 0))
-
+ 
 -    pyplot.figure()
 +    fig = pyplot.figure()
      pyplot.plot(normalized_fluxes, data)
@@ -74,41 +74,41 @@
 -    pyplot.ylabel("conductance [in units of e^2/h]")
 -    pyplot.show()
 +    pyplot.xlabel("flux [in units of the flux quantum]",
-+                 fontsize=defs.mpl_label_size)
++                 fontsize=_defs.mpl_label_size)
 +    pyplot.ylabel("conductance [in units of e^2/h]",
-+                 fontsize=defs.mpl_label_size)
++                 fontsize=_defs.mpl_label_size)
 +    pyplot.setp(fig.get_axes()[0].get_xticklabels(),
-+               fontsize=defs.mpl_tick_size)
++               fontsize=_defs.mpl_tick_size)
 +    pyplot.setp(fig.get_axes()[0].get_yticklabels(),
-+               fontsize=defs.mpl_tick_size)
-+    fig.set_size_inches(defs.mpl_width_in, defs.mpl_width_in * 3. / 4.)
++               fontsize=_defs.mpl_tick_size)
++    fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
 +    fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
-+    fig.savefig("2-ab_ring_result.pdf")
-+    fig.savefig("2-ab_ring_result.png", dpi=defs.dpi)
-
-
++    fig.savefig("ab_ring_result.pdf")
++    fig.savefig("ab_ring_result.png", dpi=_defs.dpi)
+ 
+ 
  def main():
      sys = make_system()
-
+ 
      # Check that the system looks as intended.
 -    kwant.plot(sys)
-+    size = (defs.figwidth_in, defs.figwidth_in)
-+    kwant.plot(sys, file="2-ab_ring_sys.pdf", fig_size=size, dpi=defs.dpi)
-+    kwant.plot(sys, file="2-ab_ring_sys.png", fig_size=size, dpi=defs.dpi)
-
++    size = (_defs.figwidth_in, _defs.figwidth_in)
++    kwant.plot(sys, file="ab_ring_sys.pdf", fig_size=size, dpi=_defs.dpi)
++    kwant.plot(sys, file="ab_ring_sys.png", fig_size=size, dpi=_defs.dpi)
+ 
      # Finalize the system.
      sys = sys.finalized()
 @@ -115,6 +175,15 @@
      plot_conductance(sys, energy=0.15, fluxes=[0.01 * i * 3 * 2 * pi
                                                  for i in xrange(100)])
-
+ 
 +    # Finally, some plots needed for the notes
 +    sys = make_system_note1()
-+    kwant.plot(sys, file="2-ab_ring_note1.pdf", fig_size=size, dpi=defs.dpi)
-+    kwant.plot(sys, file="2-ab_ring_note1.png", fig_size=size, dpi=defs.dpi)
++    kwant.plot(sys, file="ab_ring_note1.pdf", fig_size=size, dpi=_defs.dpi)
++    kwant.plot(sys, file="ab_ring_note1.png", fig_size=size, dpi=_defs.dpi)
 +    sys = make_system_note2()
-+    kwant.plot(sys, file="2-ab_ring_note2.pdf", fig_size=size, dpi=defs.dpi)
-+    kwant.plot(sys, file="2-ab_ring_note2.png", fig_size=size, dpi=defs.dpi)
++    kwant.plot(sys, file="ab_ring_note2.pdf", fig_size=size, dpi=_defs.dpi)
++    kwant.plot(sys, file="ab_ring_note2.png", fig_size=size, dpi=_defs.dpi)
 +
 +
  # Call the main function if the script gets executed (as opposed to imported).
diff --git a/doc/source/images/2-ab_ring_sketch.svg b/doc/source/images/ab_ring_sketch.svg
similarity index 100%
rename from doc/source/images/2-ab_ring_sketch.svg
rename to doc/source/images/ab_ring_sketch.svg
diff --git a/doc/source/images/2-ab_ring_sketch2.svg b/doc/source/images/ab_ring_sketch2.svg
similarity index 100%
rename from doc/source/images/2-ab_ring_sketch2.svg
rename to doc/source/images/ab_ring_sketch2.svg
diff --git a/doc/source/images/3-band_structure.py.diff b/doc/source/images/band_structure.py.diff
similarity index 65%
rename from doc/source/images/3-band_structure.py.diff
rename to doc/source/images/band_structure.py.diff
index c84cb9f2..71c2ba22 100644
--- a/doc/source/images/3-band_structure.py.diff
+++ b/doc/source/images/band_structure.py.diff
@@ -4,7 +4,7 @@
  
  # For plotting
  from matplotlib import pyplot
-+import defs
++import _defs
  
  def make_lead(a=1, t=1.0, W=10):
      # Start with an empty lead with a single square lattice
@@ -19,16 +19,16 @@
 -    pyplot.ylabel("energy [in units of t]")
 -    pyplot.show()
 +    pyplot.xlabel("momentum [in units of (lattice constant)^-1]",
-+                 fontsize=defs.mpl_label_size)
-+    pyplot.ylabel("energy [in units of t]", fontsize=defs.mpl_label_size)
++                 fontsize=_defs.mpl_label_size)
++    pyplot.ylabel("energy [in units of t]", fontsize=_defs.mpl_label_size)
 +    pyplot.setp(fig.get_axes()[0].get_xticklabels(),
-+               fontsize=defs.mpl_tick_size)
++               fontsize=_defs.mpl_tick_size)
 +    pyplot.setp(fig.get_axes()[0].get_yticklabels(),
-+               fontsize=defs.mpl_tick_size)
-+    fig.set_size_inches(defs.mpl_width_in, defs.mpl_width_in * 3. / 4.)
++               fontsize=_defs.mpl_tick_size)
++    fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
 +    fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
-+    fig.savefig("3-band_structure_result.pdf")
-+    fig.savefig("3-band_structure_result.png", dpi=defs.dpi)
++    fig.savefig("band_structure_result.pdf")
++    fig.savefig("band_structure_result.png", dpi=_defs.dpi)
  
  
  def main():
diff --git a/doc/source/images/3-closed_system.py.diff b/doc/source/images/closed_system.py.diff
similarity index 67%
rename from doc/source/images/3-closed_system.py.diff
rename to doc/source/images/closed_system.py.diff
index 80930122..7c858ecf 100644
--- a/doc/source/images/3-closed_system.py.diff
+++ b/doc/source/images/closed_system.py.diff
@@ -4,7 +4,7 @@
  
  # For plotting
  from matplotlib import pyplot
-+import defs
++import _defs
  
  
  def make_system(a=1, t=1.0, r=10):
@@ -19,16 +19,16 @@
 -    pyplot.ylabel("energy [in units of t]")
 -    pyplot.show()
 +    pyplot.xlabel("magnetic field [some arbitrary units]",
-+                 fontsize=defs.mpl_label_size)
-+    pyplot.ylabel("energy [in units of t]", fontsize=defs.mpl_label_size)
++                 fontsize=_defs.mpl_label_size)
++    pyplot.ylabel("energy [in units of t]", fontsize=_defs.mpl_label_size)
 +    pyplot.setp(fig.get_axes()[0].get_xticklabels(),
-+               fontsize=defs.mpl_tick_size)
++               fontsize=_defs.mpl_tick_size)
 +    pyplot.setp(fig.get_axes()[0].get_yticklabels(),
-+               fontsize=defs.mpl_tick_size)
-+    fig.set_size_inches(defs.mpl_width_in, defs.mpl_width_in * 3. / 4.)
++               fontsize=_defs.mpl_tick_size)
++    fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
 +    fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
-+    fig.savefig("3-closed_system_result.pdf")
-+    fig.savefig("3-closed_system_result.png", dpi=defs.dpi)
++    fig.savefig("closed_system_result.pdf")
++    fig.savefig("closed_system_result.png", dpi=_defs.dpi)
  
  
  def main():
diff --git a/doc/source/images/generate-diffs.sh b/doc/source/images/generate-diffs.sh
index aeeb479c..e83521ef 100755
--- a/doc/source/images/generate-diffs.sh
+++ b/doc/source/images/generate-diffs.sh
@@ -3,7 +3,8 @@
 # This script regenerates the .diff files in this directory.  It's these files
 # that are kept under vesion control instead of the scripts themselves.
 
-for f in [0-9]-*.py; do
+for f in [a-zA-Z]*.py; do
+    echo $f
     # We use custom labels to suppress the time stamps which are unnecessary
     # here and would only lead to noise in version control.
     grep -v '#HIDDEN' ../tutorial/$f |
diff --git a/doc/source/images/4-graphene.py.diff b/doc/source/images/graphene.py.diff
similarity index 68%
rename from doc/source/images/4-graphene.py.diff
rename to doc/source/images/graphene.py.diff
index c713f821..facca27f 100644
--- a/doc/source/images/4-graphene.py.diff
+++ b/doc/source/images/graphene.py.diff
@@ -4,7 +4,7 @@
  
  # For plotting
  from matplotlib import pyplot
-+import defs
++import _defs
  
  
  # Define the graphene lattice
@@ -28,17 +28,17 @@
 -    pyplot.ylabel("conductance [in units of e^2/h]")
 -    pyplot.show()
 +    pyplot.xlabel("energy [in units of t]",
-+                 fontsize=defs.mpl_label_size)
++                 fontsize=_defs.mpl_label_size)
 +    pyplot.ylabel("conductance [in units of e^2/h]",
-+                 fontsize=defs.mpl_label_size)
++                 fontsize=_defs.mpl_label_size)
 +    pyplot.setp(fig.get_axes()[0].get_xticklabels(),
-+               fontsize=defs.mpl_tick_size)
++               fontsize=_defs.mpl_tick_size)
 +    pyplot.setp(fig.get_axes()[0].get_yticklabels(),
-+               fontsize=defs.mpl_tick_size)
-+    fig.set_size_inches(defs.mpl_width_in, defs.mpl_width_in * 3. / 4.)
++               fontsize=_defs.mpl_tick_size)
++    fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
 +    fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
-+    fig.savefig("4-graphene_result.pdf")
-+    fig.savefig("4-graphene_result.png", dpi=defs.dpi)
++    fig.savefig("graphene_result.pdf")
++    fig.savefig("graphene_result.png", dpi=_defs.dpi)
  
  
  def plot_bandstructure(flead, momenta):
@@ -52,17 +52,17 @@
 -    pyplot.ylabel("energy [in units of t]")
 -    pyplot.show()
 +    pyplot.xlabel("momentum [in units of (lattice constant)^-1]",
-+                 fontsize=defs.mpl_label_size)
++                 fontsize=_defs.mpl_label_size)
 +    pyplot.ylabel("energy [in units of t]",
-+                 fontsize=defs.mpl_label_size)
++                 fontsize=_defs.mpl_label_size)
 +    pyplot.setp(fig.get_axes()[0].get_xticklabels(),
-+               fontsize=defs.mpl_tick_size)
++               fontsize=_defs.mpl_tick_size)
 +    pyplot.setp(fig.get_axes()[0].get_yticklabels(),
-+               fontsize=defs.mpl_tick_size)
-+    fig.set_size_inches(defs.mpl_width_in, defs.mpl_width_in * 3. / 4.)
++               fontsize=_defs.mpl_tick_size)
++    fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
 +    fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
-+    fig.savefig("4-graphene_bs.pdf")
-+    fig.savefig("4-graphene_bs.png", dpi=defs.dpi)
++    fig.savefig("graphene_bs.pdf")
++    fig.savefig("graphene_bs.png", dpi=_defs.dpi)
  
  
  def main():
@@ -74,11 +74,11 @@
 -
 -    # Compute some eigenvalues.
 -    compute_evs(sys.finalized())
-+    size = (defs.figwidth_in, defs.figwidth_in)
++    size = (_defs.figwidth_in, _defs.figwidth_in)
 +    kwant.plot(sys, site_color=group_colors, colorbar=False,
-+               file="4-graphene_sys1.pdf", fig_size=size, dpi=defs.dpi)
++               file="graphene_sys1.pdf", fig_size=size, dpi=_defs.dpi)
 +    kwant.plot(sys, site_color=group_colors, colorbar=False,
-+               file="4-graphene_sys1.png", fig_size=size, dpi=defs.dpi)
++               file="graphene_sys1.png", fig_size=size, dpi=_defs.dpi)
  
      # Attach the leads to the system.
      for lead in leads:
@@ -86,11 +86,11 @@
  
      # Then, plot the system with leads.
 -    kwant.plot(sys, site_color=group_colors, colorbar=False)
-+    size = (defs.figwidth_in, 0.9 * defs.figwidth_in)
++    size = (_defs.figwidth_in, 0.9 * _defs.figwidth_in)
 +    kwant.plot(sys, site_color=group_colors, colorbar=False,
-+               file="4-graphene_sys2.pdf", fig_size=size, dpi=defs.dpi)
++               file="graphene_sys2.pdf", fig_size=size, dpi=_defs.dpi)
 +    kwant.plot(sys, site_color=group_colors, colorbar=False,
-+               file="4-graphene_sys2.png", fig_size=size, dpi=defs.dpi)
++               file="graphene_sys2.png", fig_size=size, dpi=_defs.dpi)
  
      # Finalize the system.
      sys = sys.finalized()
diff --git a/doc/source/images/2-quantum_well.py.diff b/doc/source/images/quantum_well.py.diff
similarity index 71%
rename from doc/source/images/2-quantum_well.py.diff
rename to doc/source/images/quantum_well.py.diff
index 083f328a..c48d17e7 100644
--- a/doc/source/images/2-quantum_well.py.diff
+++ b/doc/source/images/quantum_well.py.diff
@@ -4,7 +4,7 @@
  
  # For plotting
  from matplotlib import pyplot
-+import defs
++import _defs
  
  # global variable governing the behavior of potential() in
  # make_system()
@@ -19,17 +19,17 @@
 -    pyplot.ylabel("conductance [in units of e^2/h]")
 -    pyplot.show()
 +    pyplot.xlabel("well depth [in units of t]",
-+                 fontsize=defs.mpl_label_size)
++                 fontsize=_defs.mpl_label_size)
 +    pyplot.ylabel("conductance [in units of e^2/h]",
-+                 fontsize=defs.mpl_label_size)
++                 fontsize=_defs.mpl_label_size)
 +    pyplot.setp(fig.get_axes()[0].get_xticklabels(),
-+               fontsize=defs.mpl_tick_size)
++               fontsize=_defs.mpl_tick_size)
 +    pyplot.setp(fig.get_axes()[0].get_yticklabels(),
-+               fontsize=defs.mpl_tick_size)
-+    fig.set_size_inches(defs.mpl_width_in, defs.mpl_width_in * 3. / 4.)
++               fontsize=_defs.mpl_tick_size)
++    fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
 +    fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
-+    fig.savefig("2-quantum_well_result.pdf")
-+    fig.savefig("2-quantum_well_result.png", dpi=defs.dpi)
++    fig.savefig("quantum_well_result.pdf")
++    fig.savefig("quantum_well_result.png", dpi=_defs.dpi)
  
  
  def main():
diff --git a/doc/source/images/quantum_wire.py.diff b/doc/source/images/quantum_wire.py.diff
new file mode 100644
index 00000000..4b00b7c0
--- /dev/null
+++ b/doc/source/images/quantum_wire.py.diff
@@ -0,0 +1,40 @@
+--- original
++++ modified
+@@ -10,6 +10,7 @@
+ 
+ from matplotlib import pyplot
+ import kwant
++import _defs
+ 
+ # First, define the tight-binding system
+ 
+@@ -72,8 +73,9 @@
+ sys.attach_lead(lead1)
+ 
+ # Plot it, to make sure it's OK
+-
+-kwant.plot(sys)
++size = (_defs.figwidth_in, 0.3 * _defs.figwidth_in)
++kwant.plot(sys, file="quantum_wire_sys.pdf", fig_size=size, dpi=_defs.dpi)
++kwant.plot(sys, file="quantum_wire_sys.png", fig_size=size, dpi=_defs.dpi)
+ 
+ # Finalize the system
+ 
+@@ -97,8 +99,13 @@
+ # Use matplotlib to write output
+ # We should see conductance steps
+ 
+-pyplot.figure()
++fig = pyplot.figure()
+ pyplot.plot(energies, data)
+-pyplot.xlabel("energy [in units of t]")
+-pyplot.ylabel("conductance [in units of e^2/h]")
+-pyplot.show()
++pyplot.xlabel("energy [in units of t]", fontsize=_defs.mpl_label_size)
++pyplot.ylabel("conductance [in units of e^2/h]", fontsize=_defs.mpl_label_size)
++pyplot.setp(fig.get_axes()[0].get_xticklabels(), fontsize=_defs.mpl_tick_size)
++pyplot.setp(fig.get_axes()[0].get_yticklabels(), fontsize=_defs.mpl_tick_size)
++fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
++fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
++fig.savefig("quantum_wire_result.pdf")
++fig.savefig("quantum_wire_result.png", dpi=_defs.dpi)
diff --git a/doc/source/images/2-spin_orbit.py.diff b/doc/source/images/spin_orbit.py.diff
similarity index 68%
rename from doc/source/images/2-spin_orbit.py.diff
rename to doc/source/images/spin_orbit.py.diff
index ca9661d1..299fb8e6 100644
--- a/doc/source/images/2-spin_orbit.py.diff
+++ b/doc/source/images/spin_orbit.py.diff
@@ -4,7 +4,7 @@
  
  # For matrix support
  import tinyarray
-+import defs
++import _defs
  
  # define Pauli-matrices for convenience
  sigma_0 = tinyarray.array([[1, 0], [0, 1]])
@@ -18,17 +18,17 @@
 -    pyplot.xlabel("energy [in units of t]")
 -    pyplot.ylabel("conductance [in units of e^2/h]")
 -    pyplot.show()
-+    pyplot.xlabel("energy [in units of t]", fontsize=defs.mpl_label_size)
++    pyplot.xlabel("energy [in units of t]", fontsize=_defs.mpl_label_size)
 +    pyplot.ylabel("conductance [in units of e^2/h]",
-+                 fontsize=defs.mpl_label_size)
++                 fontsize=_defs.mpl_label_size)
 +    pyplot.setp(fig.get_axes()[0].get_xticklabels(),
-+               fontsize=defs.mpl_tick_size)
++               fontsize=_defs.mpl_tick_size)
 +    pyplot.setp(fig.get_axes()[0].get_yticklabels(),
-+               fontsize=defs.mpl_tick_size)
-+    fig.set_size_inches(defs.mpl_width_in, defs.mpl_width_in * 3. / 4.)
++               fontsize=_defs.mpl_tick_size)
++    fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
 +    fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
-+    fig.savefig("2-spin_orbit_result.pdf")
-+    fig.savefig("2-spin_orbit_result.png", dpi=defs.dpi)
++    fig.savefig("spin_orbit_result.pdf")
++    fig.savefig("spin_orbit_result.png", dpi=_defs.dpi)
  
  
  def main():
diff --git a/doc/source/images/5-superconductor_band_structure.py.diff b/doc/source/images/superconductor_band_structure.py.diff
similarity index 69%
rename from doc/source/images/5-superconductor_band_structure.py.diff
rename to doc/source/images/superconductor_band_structure.py.diff
index 31f527d8..8fa888ba 100644
--- a/doc/source/images/5-superconductor_band_structure.py.diff
+++ b/doc/source/images/superconductor_band_structure.py.diff
@@ -4,7 +4,7 @@
  
  # For plotting
  from matplotlib import pyplot
-+import defs
++import _defs
  
  tau_x = tinyarray.array([[0, 1], [1, 0]])
  tau_z = tinyarray.array([[1, 0], [0, -1]])
@@ -20,13 +20,13 @@
      pyplot.ylim([-0.8, 0.8])
 -    pyplot.show()
 +    pyplot.setp(fig.get_axes()[0].get_xticklabels(),
-+               fontsize=defs.mpl_tick_size)
++               fontsize=_defs.mpl_tick_size)
 +    pyplot.setp(fig.get_axes()[0].get_yticklabels(),
-+               fontsize=defs.mpl_tick_size)
-+    fig.set_size_inches(defs.mpl_width_in, defs.mpl_width_in * 3. / 4.)
++               fontsize=_defs.mpl_tick_size)
++    fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
 +    fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
-+    fig.savefig("5-superconductor_band_structure_result.pdf")
-+    fig.savefig("5-superconductor_band_structure_result.png", dpi=defs.dpi)
++    fig.savefig("superconductor_band_structure_result.pdf")
++    fig.savefig("superconductor_band_structure_result.png", dpi=_defs.dpi)
  
  
  def main():
diff --git a/doc/source/images/5-superconductor_transport.py.diff b/doc/source/images/superconductor_transport.py.diff
similarity index 73%
rename from doc/source/images/5-superconductor_transport.py.diff
rename to doc/source/images/superconductor_transport.py.diff
index 3148a121..a33a7de6 100644
--- a/doc/source/images/5-superconductor_transport.py.diff
+++ b/doc/source/images/superconductor_transport.py.diff
@@ -4,7 +4,7 @@
  
  # For plotting
  from matplotlib import pyplot
-+import defs
++import _defs
  
  
  def make_system(a=1, W=10, L=10, barrier=1.5, barrierpos=(3, 4),
@@ -19,13 +19,13 @@
      pyplot.ylabel("conductance [in units of e^2/h]")
 -    pyplot.show()
 +    pyplot.setp(fig.get_axes()[0].get_xticklabels(),
-+               fontsize=defs.mpl_tick_size)
++               fontsize=_defs.mpl_tick_size)
 +    pyplot.setp(fig.get_axes()[0].get_yticklabels(),
-+               fontsize=defs.mpl_tick_size)
-+    fig.set_size_inches(defs.mpl_width_in, defs.mpl_width_in * 3. / 4.)
++               fontsize=_defs.mpl_tick_size)
++    fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
 +    fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
-+    fig.savefig("5-superconductor_transport_result.pdf")
-+    fig.savefig("5-superconductor_transport_result.png", dpi=defs.dpi)
++    fig.savefig("superconductor_transport_result.pdf")
++    fig.savefig("superconductor_transport_result.png", dpi=_defs.dpi)
  
  
  def main():
diff --git a/doc/source/images/5-superconductor_transport_sketch.svg b/doc/source/images/superconductor_transport_sketch.svg
similarity index 100%
rename from doc/source/images/5-superconductor_transport_sketch.svg
rename to doc/source/images/superconductor_transport_sketch.svg
diff --git a/doc/source/tutorial/2-ab_ring.py b/doc/source/tutorial/ab_ring.py
similarity index 100%
rename from doc/source/tutorial/2-ab_ring.py
rename to doc/source/tutorial/ab_ring.py
diff --git a/doc/source/tutorial/3-band_structure.py b/doc/source/tutorial/band_structure.py
similarity index 100%
rename from doc/source/tutorial/3-band_structure.py
rename to doc/source/tutorial/band_structure.py
diff --git a/doc/source/tutorial/3-closed_system.py b/doc/source/tutorial/closed_system.py
similarity index 100%
rename from doc/source/tutorial/3-closed_system.py
rename to doc/source/tutorial/closed_system.py
diff --git a/doc/source/tutorial/4-graphene.py b/doc/source/tutorial/graphene.py
similarity index 100%
rename from doc/source/tutorial/4-graphene.py
rename to doc/source/tutorial/graphene.py
diff --git a/doc/source/tutorial/2-quantum_well.py b/doc/source/tutorial/quantum_well.py
similarity index 100%
rename from doc/source/tutorial/2-quantum_well.py
rename to doc/source/tutorial/quantum_well.py
diff --git a/doc/source/tutorial/1-quantum_wire.py b/doc/source/tutorial/quantum_wire.py
similarity index 100%
rename from doc/source/tutorial/1-quantum_wire.py
rename to doc/source/tutorial/quantum_wire.py
diff --git a/doc/source/tutorial/1-quantum_wire_revisited.py b/doc/source/tutorial/quantum_wire_revisited.py
similarity index 100%
rename from doc/source/tutorial/1-quantum_wire_revisited.py
rename to doc/source/tutorial/quantum_wire_revisited.py
diff --git a/doc/source/tutorial/2-spin_orbit.py b/doc/source/tutorial/spin_orbit.py
similarity index 100%
rename from doc/source/tutorial/2-spin_orbit.py
rename to doc/source/tutorial/spin_orbit.py
diff --git a/doc/source/tutorial/5-superconductor_band_structure.py b/doc/source/tutorial/superconductor_band_structure.py
similarity index 100%
rename from doc/source/tutorial/5-superconductor_band_structure.py
rename to doc/source/tutorial/superconductor_band_structure.py
diff --git a/doc/source/tutorial/5-superconductor_transport.py b/doc/source/tutorial/superconductor_transport.py
similarity index 100%
rename from doc/source/tutorial/5-superconductor_transport.py
rename to doc/source/tutorial/superconductor_transport.py
diff --git a/doc/source/tutorial/tutorial1.rst b/doc/source/tutorial/tutorial1.rst
index 94fbe3f0..31a74dc9 100644
--- a/doc/source/tutorial/tutorial1.rst
+++ b/doc/source/tutorial/tutorial1.rst
@@ -16,7 +16,7 @@ with a hard wall confinement :math:`V(y)` in y-direction.
 
 In order to use kwant, we need to import it:
 
-.. literalinclude:: 1-quantum_wire.py
+.. literalinclude:: quantum_wire.py
     :start-after: #HIDDEN_BEGIN_dwhx
     :end-before: #HIDDEN_END_dwhx
 
@@ -26,7 +26,7 @@ The first step is now the definition of the system with scattering region and
 leads. For this we make use of the `~kwant.builder.Builder` type that allows to
 define a system in a convenient way. We need to create an instance of it:
 
-.. literalinclude:: 1-quantum_wire.py
+.. literalinclude:: quantum_wire.py
     :start-after: #HIDDEN_BEGIN_goiq
     :end-before: #HIDDEN_END_goiq
 
@@ -42,7 +42,7 @@ Apart from `~kwant.builder.Builder` we also need to specify
 what kind of sites we want to add to the system. Here we work with
 a square lattice. For simplicity, we set the lattice constant to unity:
 
-.. literalinclude:: 1-quantum_wire.py
+.. literalinclude:: quantum_wire.py
     :start-after: #HIDDEN_BEGIN_suwo
     :end-before: #HIDDEN_END_suwo
 
@@ -61,7 +61,7 @@ needed in Builder (more about that in the technical details below).
 We now build a rectangular scattering region that is `W`
 lattice points wide and `L` lattice points long:
 
-.. literalinclude:: 1-quantum_wire.py
+.. literalinclude:: quantum_wire.py
     :start-after: #HIDDEN_BEGIN_zfvr
     :end-before: #HIDDEN_END_zfvr
 
@@ -69,7 +69,7 @@ Next, we define the leads. Leads are also constructed using
 `~kwant.builder.Builder`, but in this case, the
 system must have a translational symmetry:
 
-.. literalinclude:: 1-quantum_wire.py
+.. literalinclude:: quantum_wire.py
     :start-after: #HIDDEN_BEGIN_xcmc
     :end-before: #HIDDEN_END_xcmc
 
@@ -84,7 +84,7 @@ as the hoppings inside one unit cell and to the next unit cell of the lead.
 For a square lattice, and a lead in y-direction the unit cell is
 simply a vertical line of points:
 
-.. literalinclude:: 1-quantum_wire.py
+.. literalinclude:: quantum_wire.py
     :start-after: #HIDDEN_BEGIN_ndez
     :end-before: #HIDDEN_END_ndez
 
@@ -95,7 +95,7 @@ We also want to add a lead on the right side. The only difference to
 the left lead is that the vector of the translational
 symmetry must point to the right, the remaining code is the same:
 
-.. literalinclude:: 1-quantum_wire.py
+.. literalinclude:: quantum_wire.py
     :start-after: #HIDDEN_BEGIN_xhqc
     :end-before: #HIDDEN_END_xhqc
 
@@ -107,7 +107,7 @@ you do not need to worry about that. The `~kwant.builder.Builder` with
 infinitely extended. These isolated, infinite leads can then be simply
 attached at the right position using:
 
-.. literalinclude:: 1-quantum_wire.py
+.. literalinclude:: quantum_wire.py
     :start-after: #HIDDEN_BEGIN_fskr
     :end-before: #HIDDEN_END_fskr
 
@@ -117,13 +117,13 @@ More details about attaching leads can be found in the tutorial
 Now we have finished building our system! We plot it, to make sure we didn't
 make any mistakes:
 
-.. literalinclude:: 1-quantum_wire.py
+.. literalinclude:: quantum_wire.py
     :start-after: #HIDDEN_BEGIN_wsgh
     :end-before: #HIDDEN_END_wsgh
 
 This should bring up this picture:
 
-.. image:: /images/1-quantum_wire_sys.*
+.. image:: /images/quantum_wire_sys.*
 
 The system is represented in the usual way for tight-binding systems:
 dots represent the lattice points `(i, j)`, and for every
@@ -133,14 +133,14 @@ fading color.
 
 In order to use our system for a transport calculation, we need to finalize it
 
-.. literalinclude:: 1-quantum_wire.py
+.. literalinclude:: quantum_wire.py
     :start-after: #HIDDEN_BEGIN_dngj
     :end-before: #HIDDEN_END_dngj
 
 Having successfully created a system, we now can immediately start to compute
 its conductance as a function of energy:
 
-.. literalinclude:: 1-quantum_wire.py
+.. literalinclude:: quantum_wire.py
     :start-after: #HIDDEN_BEGIN_buzn
     :end-before: #HIDDEN_END_buzn
 
@@ -154,13 +154,13 @@ Finally we can use `matplotlib` to make a plot of the computed data
 (although writing to file and using an external viewer such as
 gnuplot or xmgrace is just as viable)
 
-.. literalinclude:: 1-quantum_wire.py
+.. literalinclude:: quantum_wire.py
     :start-after: #HIDDEN_BEGIN_lliv
     :end-before: #HIDDEN_END_lliv
 
 This should yield the result
 
-.. image:: /images/1-quantum_wire_result.*
+.. image:: /images/quantum_wire_result.*
 
 We see a conductance quantized in units of :math:`e^2/h`,
 increasing in steps as the energy is increased. The
@@ -170,7 +170,7 @@ subbands that increases with energy.
 
 .. seealso::
      The full source code can be found in
-     :download:`tutorial/1-quantum_wire.py <../../../tutorial/1-quantum_wire.py>`
+     :download:`tutorial/quantum_wire.py <../../../tutorial/quantum_wire.py>`
 
 .. specialnote:: Technical details
 
@@ -278,14 +278,14 @@ We begin the program collecting all imports in the beginning of the
 file and put the build-up of the system into a separate function
 `make_system`:
 
-.. literalinclude:: 1-quantum_wire_revisited.py
+.. literalinclude:: quantum_wire_revisited.py
     :start-after: #HIDDEN_BEGIN_xkzy
     :end-before: #HIDDEN_END_xkzy
 
 Previously, the scattering region was build using two ``for``-loops.
 Instead, we now write:
 
-.. literalinclude:: 1-quantum_wire_revisited.py
+.. literalinclude:: quantum_wire_revisited.py
     :start-after: #HIDDEN_BEGIN_vvjt
     :end-before: #HIDDEN_END_vvjt
 
@@ -303,7 +303,7 @@ hoppings. In this case, an iterable like for the lattice
 points becomes a bit cumbersome, and we use instead another
 feature of kwant:
 
-.. literalinclude:: 1-quantum_wire_revisited.py
+.. literalinclude:: quantum_wire_revisited.py
     :start-after: #HIDDEN_BEGIN_nooi
     :end-before: #HIDDEN_END_nooi
 
@@ -322,7 +322,7 @@ then sets all of those hopping matrix elements at once.
 
 The leads can be constructed in an analogous way:
 
-.. literalinclude:: 1-quantum_wire_revisited.py
+.. literalinclude:: quantum_wire_revisited.py
     :start-after: #HIDDEN_BEGIN_iepx
     :end-before: #HIDDEN_END_iepx
 
@@ -335,20 +335,20 @@ lead, but with it's translational vector reversed.  This can thus be
 used to obtain a lead pointing in the opposite direction, i.e. makes a
 right lead from a left lead:
 
-.. literalinclude:: 1-quantum_wire_revisited.py
+.. literalinclude:: quantum_wire_revisited.py
     :start-after: #HIDDEN_BEGIN_xkdo
     :end-before: #HIDDEN_END_xkdo
 
 The remainder of the code is identical to the previous example
 (except for a bit of reorganization into functions):
 
-.. literalinclude:: 1-quantum_wire_revisited.py
+.. literalinclude:: quantum_wire_revisited.py
     :start-after: #HIDDEN_BEGIN_yxot
     :end-before: #HIDDEN_END_yxot
 
 and
 
-.. literalinclude:: 1-quantum_wire_revisited.py
+.. literalinclude:: quantum_wire_revisited.py
     :start-after: #HIDDEN_BEGIN_ayuk
     :end-before: #HIDDEN_END_ayuk
 
@@ -357,7 +357,7 @@ as a script, as well as allowing it to be imported as a module.
 We collect all statements that should be executed in the script
 in a ``main()``-function:
 
-.. literalinclude:: 1-quantum_wire_revisited.py
+.. literalinclude:: quantum_wire_revisited.py
     :start-after: #HIDDEN_BEGIN_cjel
     :end-before: #HIDDEN_END_cjel
 
@@ -365,7 +365,7 @@ Finally, we use the following python construct [#]_ that executes
 ``main()`` if the program is used as a script (i.e. executed as
 ``python tutorial1b.py``):
 
-.. literalinclude:: 1-quantum_wire_revisited.py
+.. literalinclude:: quantum_wire_revisited.py
     :start-after: #HIDDEN_BEGIN_ypbj
     :end-before: #HIDDEN_END_ypbj
 
@@ -379,13 +379,13 @@ The result of the example should be identical to the previous one.
 
 .. seealso::
     The full source code can be found in
-    :download:`tutorial/1-quantum_wire_revisited.py <../../../tutorial/1-quantum_wire_revisited.py>`
+    :download:`tutorial/quantum_wire_revisited.py <../../../tutorial/quantum_wire_revisited.py>`
 
 .. specialnote:: Technical details
 
    - In
 
-     .. literalinclude:: 1-quantum_wire_revisited.py
+     .. literalinclude:: quantum_wire_revisited.py
        :start-after: #HIDDEN_BEGIN_nooi
        :end-before: #HIDDEN_END_nooi
 
@@ -416,7 +416,7 @@ The result of the example should be identical to the previous one.
      using a tuple of sites. Hence it is worth noting
      a subtle detail in
 
-     .. literalinclude:: 1-quantum_wire_revisited.py
+     .. literalinclude:: quantum_wire_revisited.py
          :start-after: #HIDDEN_BEGIN_vvjt
          :end-before: #HIDDEN_END_vvjt
 
diff --git a/doc/source/tutorial/tutorial2.rst b/doc/source/tutorial/tutorial2.rst
index 7b1a5656..1c45bd3a 100644
--- a/doc/source/tutorial/tutorial2.rst
+++ b/doc/source/tutorial/tutorial2.rst
@@ -37,14 +37,14 @@ use matrices in our program, we import the tinyarray package.  (`NumPy
 <http://numpy.scipy.org/>`_ would work as well, but tinyarray is much faster
 for small arrays.)
 
-.. literalinclude:: 2-spin_orbit.py
+.. literalinclude:: spin_orbit.py
     :start-after: #HIDDEN_BEGIN_xumz
     :end-before: #HIDDEN_END_xumz
 
 For convenience, we define the Pauli-matrices first (with `sigma_0` the
 unit matrix):
 
-.. literalinclude:: 2-spin_orbit.py
+.. literalinclude:: spin_orbit.py
     :start-after: #HIDDEN_BEGIN_hwbt
     :end-before: #HIDDEN_END_hwbt
 
@@ -52,7 +52,7 @@ Previously, we used numbers as the values of our matrix elements.
 However, `~kwant.builder.Builder` also accepts matrices as values, and
 we can simply write:
 
-.. literalinclude:: 2-spin_orbit.py
+.. literalinclude:: spin_orbit.py
     :start-after: #HIDDEN_BEGIN_uxrm
     :end-before: #HIDDEN_END_uxrm
 
@@ -81,18 +81,18 @@ when specifying `(1, 0)` it is not necessary to specify `(-1, 0)`),
 
 The leads also allow for a matrix structure,
 
-.. literalinclude:: 2-spin_orbit.py
+.. literalinclude:: spin_orbit.py
     :start-after: #HIDDEN_BEGIN_yliu
     :end-before: #HIDDEN_END_yliu
 
 The remainder of the code is unchanged, and as a result we should obtain
 the following, clearly non-monotonic conductance steps:
 
-.. image:: ../images/2-spin_orbit_result.*
+.. image:: ../images/spin_orbit_result.*
 
 .. seealso::
      The full source code can be found in
-     :download:`tutorial/2-spin_orbit.py <../../../tutorial/2-spin_orbit.py>`
+     :download:`tutorial/spin_orbit.py <../../../tutorial/spin_orbit.py>`
 
 .. specialnote:: Technical details
 
@@ -144,7 +144,7 @@ changing the potential then implies the need to build up the system again.
 Instead, we use a python *function* to define the onsite energies. We
 define the potential profile of a quantum well as:
 
-.. literalinclude:: 2-quantum_well.py
+.. literalinclude:: quantum_well.py
     :start-after: #HIDDEN_BEGIN_ehso
     :end-before: #HIDDEN_END_ehso
 
@@ -161,7 +161,7 @@ the transmission as a function of well depth.
 kwant now allows us to pass a function as a value to
 `~kwant.builder.Builder`:
 
-.. literalinclude:: 2-quantum_well.py
+.. literalinclude:: quantum_well.py
     :start-after: #HIDDEN_BEGIN_coid
     :end-before: #HIDDEN_END_coid
 
@@ -177,7 +177,7 @@ of the lead -- this should be kept in mind.
 
 Finally, we compute the transmission probability:
 
-.. literalinclude:: 2-quantum_well.py
+.. literalinclude:: quantum_well.py
     :start-after: #HIDDEN_BEGIN_sqvr
     :end-before: #HIDDEN_END_sqvr
 
@@ -188,14 +188,14 @@ access to it
 Subsequent calls to :func:`kwant.solve <kwant.solvers.sparse.solve>`
 then will use the updated value of pot, and we get the result:
 
-.. image:: ../images/2-quantum_well_result.*
+.. image:: ../images/quantum_well_result.*
 
 Starting from no potential (well depth = 0), we observe the typical
 oscillatory transmission behavior through resonances in the quantum well.
 
 .. seealso::
      The full source code can be found in
-     :download:`tutorial/2-quantum_well.py <../../../tutorial/2-quantum_well.py>`
+     :download:`tutorial/quantum_well.py <../../../tutorial/quantum_well.py>`
 
 .. warning::
 
@@ -208,7 +208,7 @@ oscillatory transmission behavior through resonances in the quantum well.
   - Functions can also be used for hoppings. In this case, they take
     two `~kwant.builder.Site`'s as arguments.
 
-  - In tutorial/2-quantum_well.py, the line ::
+  - In tutorial/quantum_well.py, the line ::
 
         pot = 0
 
@@ -297,7 +297,7 @@ Up to now, we only dealt with simple wire geometries. Now we turn to the case
 of a more complex geometry, namely transport through a quantum ring
 that is pierced by a magnetic flux :math:`\Phi`:
 
-.. image:: ../images/2-ab_ring_sketch.*
+.. image:: ../images/ab_ring_sketch.*
 
 For a flux line, it is possible to choose a gauge such that a
 charged particle acquires a phase :math:`e\Phi/h` whenever it
@@ -311,7 +311,7 @@ First, define a boolean function defining the desired shape, i.e. a function
 that returns ``True`` whenever a point is inside the shape, and
 ``False`` otherwise:
 
-.. literalinclude:: 2-ab_ring.py
+.. literalinclude:: ab_ring.py
     :start-after: #HIDDEN_BEGIN_eusz
     :end-before: #HIDDEN_END_eusz
 
@@ -322,7 +322,7 @@ We can now simply add all of the lattice points inside this shape at
 once, using the function `~kwant.lattice.Square.shape`
 provided by the lattice:
 
-.. literalinclude:: 2-ab_ring.py
+.. literalinclude:: ab_ring.py
     :start-after: #HIDDEN_BEGIN_lcak
     :end-before: #HIDDEN_END_lcak
 
@@ -337,7 +337,7 @@ along the branch cut in the lower arm of the ring. For this we select
 all hoppings in x-direction that are of the form `(lat(1, j), lat(0, j))`
 with ``j<0``:
 
-.. literalinclude:: 2-ab_ring.py
+.. literalinclude:: ab_ring.py
     :start-after: #HIDDEN_BEGIN_lvkt
     :end-before: #HIDDEN_END_lvkt
 
@@ -352,7 +352,7 @@ by the global variable `phi`.
 
 For the leads, we can also use the ``lat.shape()``-functionality:
 
-.. literalinclude:: 2-ab_ring.py
+.. literalinclude:: ab_ring.py
     :start-after: #HIDDEN_BEGIN_qwgr
     :end-before: #HIDDEN_END_qwgr
 
@@ -361,7 +361,7 @@ Here, the shape must cover *at least* one unit cell of the lead
 
 Attaching the leads is done as before:
 
-.. literalinclude:: 2-ab_ring.py
+.. literalinclude:: ab_ring.py
     :start-after: #HIDDEN_BEGIN_skbz
     :end-before: #HIDDEN_END_skbz
 
@@ -376,23 +376,23 @@ back (going opposite to the direction of the translational vector)
 until it intersects the scattering region. At this intersection,
 the lead is attached:
 
-.. image:: ../images/2-ab_ring_sketch2.*
+.. image:: ../images/ab_ring_sketch2.*
 
 After the lead has been attached, the system should look like this:
 
-.. image:: ../images/2-ab_ring_sys.*
+.. image:: ../images/ab_ring_sys.*
 
 The computation of the conductance goes in the same fashion as before.
 Finally you should get the following result:
 
-.. image:: ../images/2-ab_ring_result.*
+.. image:: ../images/ab_ring_result.*
 
 where one can observe the conductance oscillations with the
 period of one flux quantum.
 
 .. seealso::
      The full source code can be found in
-     :download:`tutorial/2-ab_ring.py <../../../tutorial/2-ab_ring.py>`
+     :download:`tutorial/ab_ring.py <../../../tutorial/ab_ring.py>`
 
 .. specialnote:: Technical details
 
@@ -410,7 +410,7 @@ period of one flux quantum.
     becomes more apparent if we attach the leads a bit further away
     from the central axis o the ring, as was done in this example:
 
-    .. image:: ../images/2-ab_ring_note1.*
+    .. image:: ../images/ab_ring_note1.*
 
   - Per default, `~kwant.builder.Builder.attach_lead` attaches
     the lead to the "outside" of the structure, by tracing the
@@ -425,7 +425,7 @@ period of one flux quantum.
     starts the trace-back in the middle of the ring, resulting
     in the lead being attached to the inner circle:
 
-    .. image:: ../images/2-ab_ring_note2.*
+    .. image:: ../images/ab_ring_note2.*
 
     Note that here the lead is treated as if it would pass over
     the other arm of the ring, without intersecting it.
diff --git a/doc/source/tutorial/tutorial3.rst b/doc/source/tutorial/tutorial3.rst
index c9ac10d6..06fc4df2 100644
--- a/doc/source/tutorial/tutorial3.rst
+++ b/doc/source/tutorial/tutorial3.rst
@@ -15,7 +15,7 @@ tight-binding wire.
 Computing band structures in kwant is easy. Just define a lead in the
 usual way:
 
-.. literalinclude:: 3-band_structure.py
+.. literalinclude:: band_structure.py
     :start-after: #HIDDEN_BEGIN_zxip
     :end-before: #HIDDEN_END_zxip
 
@@ -37,13 +37,13 @@ momentum ``k`` as parameter it returns the eigenenergies of the translational
 invariant system for that momentum.  Computing these eigenenergies for a range
 of momenta then yields the bandstructure:
 
-.. literalinclude:: 3-band_structure.py
+.. literalinclude:: band_structure.py
     :start-after: #HIDDEN_BEGIN_pejz
     :end-before: #HIDDEN_END_pejz
 
 This gives the result:
 
-.. image:: ../images/3-band_structure_result.*
+.. image:: ../images/band_structure_result.*
 
 where we observe the cosine-like dispersion of the square lattice. Close
 to ``k=0`` this agrees well with the quadratic dispersion this tight-binding
@@ -51,7 +51,7 @@ Hamiltonian is approximating.
 
 .. seealso::
      The full source code can be found in
-     :download:`tutorial/3-band_structure.py <../../../tutorial/3-band_structure.py>`
+     :download:`tutorial/band_structure.py <../../../tutorial/band_structure.py>`
 
 Closed systems
 ..............
@@ -67,14 +67,14 @@ circular quantum dot as a function of magnetic field
 To compute the eigenenergies, we will make use of the linear algebra
 functionality of `scipy <www.scipy.org>`_:
 
-.. literalinclude:: 3-closed_system.py
+.. literalinclude:: closed_system.py
     :start-after: #HIDDEN_BEGIN_tibv
     :end-before: #HIDDEN_END_tibv
 
 We set up the system using the `shape`-function as in
 :ref:`tutorial-abring`, but do not add any leads:
 
-.. literalinclude:: 3-closed_system.py
+.. literalinclude:: closed_system.py
     :start-after: #HIDDEN_BEGIN_qlyd
     :end-before: #HIDDEN_END_qlyd
 
@@ -86,7 +86,7 @@ The spectrum can be obtained by diagonalizing the Hamiltonian of the
 system, which in turn can be obtained from the finalized
 system using `~kwant.system.System.hamiltonian_submatrix`:
 
-.. literalinclude:: 3-closed_system.py
+.. literalinclude:: closed_system.py
     :start-after: #HIDDEN_BEGIN_yvri
     :end-before: #HIDDEN_END_yvri
 
@@ -94,7 +94,7 @@ In this toy model we use dense matrices and dense matrix algebra since
 the system is very small. (In a real application one would probably
 want to use sparse matrix methods.) Finally, we obtain the result:
 
-.. image:: ../images/3-closed_system_result.*
+.. image:: ../images/closed_system_result.*
 
 At zero magnetic field several energy levels are degenerate (since our
 quantum dot is rather symmetric). These degeneracies are split
@@ -103,7 +103,7 @@ Landau level energies at higher magnetic fields [#]
 
 .. seealso::
     The full source code can be found in
-    :download:`tutorial/3-closed_system.py <../../../tutorial/3-closed_system.py>`
+    :download:`tutorial/closed_system.py <../../../tutorial/closed_system.py>`
 
 .. specialnote:: Technical details
 
diff --git a/doc/source/tutorial/tutorial4.rst b/doc/source/tutorial/tutorial4.rst
index 93104418..e51ad152 100644
--- a/doc/source/tutorial/tutorial4.rst
+++ b/doc/source/tutorial/tutorial4.rst
@@ -14,7 +14,7 @@ We begin by defining the honeycomb lattice of graphene. This is
 in principle already done in `kwant.lattice.Honeycomb`, but we do it
 explicitly here to show how to define a new lattice:
 
-.. literalinclude:: 4-graphene.py
+.. literalinclude:: graphene.py
     :start-after: #HIDDEN_BEGIN_hnla
     :end-before: #HIDDEN_END_hnla
 
@@ -27,7 +27,7 @@ itself forms a regular lattice of the same type as well, and those
 In the next step we define the shape of the scattering region (circle again)
 and add all lattice points using the ``shape()``-functionality:
 
-.. literalinclude:: 4-graphene.py
+.. literalinclude:: graphene.py
     :start-after: #HIDDEN_BEGIN_shzy
     :end-before: #HIDDEN_END_shzy
 
@@ -42,7 +42,7 @@ As a next step we add the hoppings, making use of
 lattice (instead of `kwant.lattice.Honeycomb`), we have to define
 the hoppings ourselves:
 
-.. literalinclude:: 4-graphene.py
+.. literalinclude:: graphene.py
     :start-after: #HIDDEN_BEGIN_hsmc
     :end-before: #HIDDEN_END_hsmc
 
@@ -60,7 +60,7 @@ respect to the two primitive vectors ``[(1, 0), (sin_30, cos_30)]``.
 
 Adding the hoppings however still works the same way:
 
-.. literalinclude:: 4-graphene.py
+.. literalinclude:: graphene.py
     :start-after: #HIDDEN_BEGIN_bfwb
     :end-before: #HIDDEN_END_bfwb
 
@@ -69,7 +69,7 @@ do something crazy, and remove an atom in sublattice A
 (which removes also the hoppings from/to this site) as well
 as add an additional link:
 
-.. literalinclude:: 4-graphene.py
+.. literalinclude:: graphene.py
     :start-after: #HIDDEN_BEGIN_efut
     :end-before: #HIDDEN_END_efut
 
@@ -78,7 +78,7 @@ is done by the sublattices `a` and `b`.
 
 The leads are defined almost as before:
 
-.. literalinclude:: 4-graphene.py
+.. literalinclude:: graphene.py
     :start-after: #HIDDEN_BEGIN_aakh
     :end-before: #HIDDEN_END_aakh
 
@@ -97,14 +97,14 @@ Later, we will compute some eigenvalues of the closed scattering region without
 leads. This is why we postpone attaching the leads to the system. Instead,
 we return the scattering region and the leads separately.
 
-.. literalinclude:: 4-graphene.py
+.. literalinclude:: graphene.py
     :start-after: #HIDDEN_BEGIN_kmmw
     :end-before: #HIDDEN_END_kmmw
 
 The computation of some eigenvalues of the closed system is done
 in the following piece of code:
 
-.. literalinclude:: 4-graphene.py
+.. literalinclude:: graphene.py
     :start-after: #HIDDEN_BEGIN_zydk
     :end-before: #HIDDEN_END_zydk
 
@@ -120,7 +120,7 @@ to the previous examples, and needs not be further explained here.
 Finally, in the `main()` function we make and
 plot the system:
 
-.. literalinclude:: 4-graphene.py
+.. literalinclude:: graphene.py
     :start-after: #HIDDEN_BEGIN_itkk
     :end-before: #HIDDEN_END_itkk
 
@@ -137,11 +137,11 @@ independent on the overall figure size.
 
 Plotting the closed system gives this result:
 
-.. image:: ../images/4-graphene_sys1.*
+.. image:: ../images/graphene_sys1.*
 
 Computing the eigenvalues of largest magnitude,
 
-.. literalinclude:: 4-graphene.py
+.. literalinclude:: graphene.py
     :start-after: #HIDDEN_BEGIN_jmbi
     :end-before: #HIDDEN_END_jmbi
 
@@ -152,11 +152,11 @@ would be equal to zero for exact arithmetics).
 The remaining code of `main()` attaches the leads to the system and plots it
 again:
 
-.. image:: ../images/4-graphene_sys2.*
+.. image:: ../images/graphene_sys2.*
 
 It computes the band structure of one of lead 0:
 
-.. image:: ../images/4-graphene_bs.*
+.. image:: ../images/graphene_bs.*
 
 showing all the features of a zigzag lead, including the flat
 edge state bands (note that the band structure is not symmetric around
@@ -164,14 +164,14 @@ zero energy, as we have a potential in the leads).
 
 Finally the transmission through the system is computed,
 
-.. image:: ../images/4-graphene_result.*
+.. image:: ../images/graphene_result.*
 
 showing the typical resonance-like transmission probability through
 an open quantum dot
 
 .. seealso::
     The full source code can be found in
-    :download:`tutorial/4-graphene.py <../../../tutorial/4-graphene.py>`
+    :download:`tutorial/graphene.py <../../../tutorial/graphene.py>`
 
 .. specialnote:: Technical details
 
diff --git a/doc/source/tutorial/tutorial5.rst b/doc/source/tutorial/tutorial5.rst
index 8215268e..bcd88b15 100644
--- a/doc/source/tutorial/tutorial5.rst
+++ b/doc/source/tutorial/tutorial5.rst
@@ -28,7 +28,7 @@ We begin by computing the band structure of a superconducting wire.
 The most natural way to implement the BdG Hamiltonian is by using a
 2x2 matrix structure for all Hamiltonian matrix elements:
 
-.. literalinclude:: 5-superconductor_band_structure.py
+.. literalinclude:: superconductor_band_structure.py
     :start-after: #HIDDEN_BEGIN_nbvn
     :end-before: #HIDDEN_END_nbvn
 
@@ -38,14 +38,14 @@ is now that the Pauli matrices act in electron-hole space.
 
 Computing the band structure then yields the result
 
-.. image:: ../images/5-superconductor_band_structure_result.*
+.. image:: ../images/superconductor_band_structure_result.*
 
 We clearly observe the superconducting gap in the spectrum. That was easy,
 he?
 
 .. seealso::
     The full source code can be found in
-    :download:`tutorial/5-superconductor_band_structure.py <../../../tutorial/5-superconductor_band_structure.py>`
+    :download:`tutorial/superconductor_band_structure.py <../../../tutorial/superconductor_band_structure.py>`
 
 
 "Lattice description": Using different lattices
@@ -76,12 +76,12 @@ separate "leads" for electrons and holes, making use of different
 lattices. The system we consider consists of a normal lead on the left,
 a superconductor on the right, and a tunnel barrier inbetween:
 
-.. image:: ../images/5-superconductor_transport_sketch.*
+.. image:: ../images/superconductor_transport_sketch.*
 
 As already mentioned above, we begin by introducing two different
 square lattices representing electron and hole degrees of freedom:
 
-.. literalinclude:: 5-superconductor_transport.py
+.. literalinclude:: superconductor_transport.py
     :start-after: #HIDDEN_BEGIN_zuuw
     :end-before: #HIDDEN_END_zuuw
 
@@ -93,7 +93,7 @@ the *same* lattice, whereas any off-diagonal entry (essentially, the
 superconducting order parameter :math:`\Delta`) corresponds
 to a hopping between *different* lattices:
 
-.. literalinclude:: 5-superconductor_transport.py
+.. literalinclude:: superconductor_transport.py
     :start-after: #HIDDEN_BEGIN_pqmp
     :end-before: #HIDDEN_END_pqmp
 
@@ -108,7 +108,7 @@ part. We use this fact to attach purely electron and hole leads
 (comprised of only electron *or* hole lattices) to the
 system:
 
-.. literalinclude:: 5-superconductor_transport.py
+.. literalinclude:: superconductor_transport.py
     :start-after: #HIDDEN_BEGIN_ttth
     :end-before: #HIDDEN_END_ttth
 
@@ -118,7 +118,7 @@ reflection probablities between electrons and holes explicitely.
 On the superconducting side, we cannot do this separation, and can
 only define a single lead coupling electrons and holes:
 
-.. literalinclude:: 5-superconductor_transport.py
+.. literalinclude:: superconductor_transport.py
     :start-after: #HIDDEN_BEGIN_mhiw
     :end-before: #HIDDEN_END_mhiw
 
@@ -126,7 +126,7 @@ We now have on the left side two leads that are sitting in the same
 spatial position, but in different lattice spaces. This ensures that
 we can still attach all leads as before:
 
-.. literalinclude:: 5-superconductor_transport.py
+.. literalinclude:: superconductor_transport.py
     :start-after: #HIDDEN_BEGIN_ozsr
     :end-before: #HIDDEN_END_ozsr
 
@@ -136,7 +136,7 @@ confused by the fact that it says ``transmission`` -- transmission
 into the same lead is reflection), and reflection from electrons to holes
 as ``smatrix.transmission(1, 0)``, by virtue of our electron and hole leads:
 
-.. literalinclude:: 5-superconductor_transport.py
+.. literalinclude:: superconductor_transport.py
     :start-after: #HIDDEN_BEGIN_jbjt
     :end-before: #HIDDEN_END_jbjt
 
@@ -146,7 +146,7 @@ within (electron) lead 0, and from its size we can extract the number of modes
 
 Finally, for the default parameters, we obtain the following result:
 
-.. image:: ../images/5-superconductor_transport_result.*
+.. image:: ../images/superconductor_transport_result.*
 
 We a see a conductance that is proportional to the square of the tunneling
 probability within the gap, and proportional to the tunneling probability
@@ -154,7 +154,7 @@ above the gap. At the gap edge, we observe a resonant Andreev reflection.
 
 .. seealso::
     The full source code can be found in
-    :download:`tutorial/5-superconductor_transport.py <../../../tutorial/5-superconductor_transport.py>`
+    :download:`tutorial/superconductor_transport.py <../../../tutorial/superconductor_transport.py>`
 
 .. specialnote:: Technical details
 
-- 
GitLab