Add support for on demand folding

Inspired by recent pull request for LaTeX-Box:
https://github.com/LaTeX-Box-Team/LaTeX-Box/pull/205