Auto-generate missing figure IDs to prevent duplicate numbers. Fixes #265.