Is it possible to create a macro that would close all current open environments? Or even an explicit subset of all current open environments (where the subset would be standard user environments)?

Usage would be something like

   \item blah
   \item blah


where \CloseEverything would be equivalent to

  • 3
    While that might be possible, it would not really be desirable. One of the main differences between LaTeX and plain TeX is that in LaTeX large parts of the document are presented in balanced \begin...\end pairs, whereas TeX often uses single macros, making it easier to parse the material, and giving access points for the beginning and of an element. If you are annoyed by the typing effort, it is better to use an editor that inserts these constructs as pairs for you. – Andrew Swann Oct 9 '14 at 15:15
  • Thanks Andrew, I'm not annoyed by the typing effort. Here's the application I have. I have 200 pages of lecture notes. Each day I mark where we finished in class with the following command \endclass{Wednesday, October 9} Then I set a flag and process the whole document. With the flag I would like the document to terminate at the point marked with \endclass, even if that's inside of a list, inside of my solutions, inside of an example. (You can see the result on the last page of this file evergreen.loyola.edu/educkworth/www/351_Fall_2014/master.pdf) Ethan – Ethan Duckworth Oct 9 '14 at 17:35

enter image description here



   \item blah
   \item blah

  • 5
    Note that (a) it isn't a good idea to do this and (b) it won't work for special environments eg ammath or tabularx or verbatim etc – David Carlisle Oct 9 '14 at 15:23
  • Thanks David, I'll give it a try in a little while. Even if it works for just the simplest environments that would help. Ethan – Ethan Duckworth Oct 9 '14 at 17:28
  • @EthanDuckworth honestly I would never do this. – David Carlisle Oct 9 '14 at 17:57
  • See my response to Andrew above for a scenario where it might make sense. – Ethan Duckworth Oct 9 '14 at 18:02
  • 1
    @EthanDuckworth sort of sounds almost like a justification but still, I'd never use it personally:-) If you want an emergency stop you can just use \stop latex will moan a bit if its inside an environment but it will close up the document one way or another. – David Carlisle Oct 9 '14 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.