Fixed bug in :chap: and :ref: directive.