LaTeX reader: parse math environments as inline when possible.

Closes #1821.