Implement figure numbering and referencing. Fixes #7.