Fixed recursive id inheritance in latex references

Signed-off-by: Tom Wright <tom@inflatablecookie.com>