improve LaTeX support

Fixes issue #24.