How to fold blocks of text in latex file?


Is there a way to fold blocks of text in latex file?

E.g., in a markdown file, we can fold the text at several levels of the outline by default or at the header level using markdown folder package.

Similarly, is there a way to fold texts in latex files, say under sections and subsections? This is very much required if you are writing a lengthy paper.


I haven’t found a package that does LaTeX folding, but it shouldn’t be hard to emulate the behavior of markdown-folder with different regexes. That could be a package itself, or a pull request for latextools or latex-plus.


I just need to fold environments, and this works fine out of the box, I think. custom-folds package could do the same, but won’t work for sections.

(I wrapped the section etc. commands in an environment anyway, because I restructure my text often and I’m too lazy to rename the commands every time)


Sorry for creating multiple posts but I think I don’t have edit rights right now.