fixed latex figure handling, added latex example

I changed the way latex figure is generated given various options and added a small latex example document.