Fix bugs in abbreviation parsing and in LaTeX output

Abbreviation substitutions failed (with a parsing error) in the presence of tables.
LaTeX output, in the presence of entities, wasn't working properly.