Check the number of declared figures in each chapter

If the number of declared figures is greater that the number of available
figures, processing errors occur while converting to html or pdf. The error
messages are not obvious, so it is safer to catch the mistake before.