TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Please how do I stop at all cost in the following? Note: \leavevmode is no rescue.


enter image description here

share|improve this question
The output image you've attached appears to be produced only if \documentclass{article} is used, but not if \documentclass[crop]{standalone} is in effect. Am I missing something? – Mico Jul 7 '12 at 2:31
Could you say a little more what you mean by "stop at all costs"? It seems that the loop terminates, at least; do you mean you want to stop executing in the middle of the loop? – Ryan Reich Jul 7 '12 at 4:01
With the MWE as written, you get ! Missing } inserted. as the error: replace the crop option by preview to get ! You can't use `\end' in internal vertical mode., which relates more to the title. – Joseph Wright Jul 7 '12 at 6:36
@Mico: Joseph Wright has answered the question. I didn't look in standalone.sty to see the boxing that it does. Ditto Ryan Reich. – Ahmed Musa Jul 8 '12 at 2:10
up vote 6 down vote accepted

With the standard settings, standalone class uses an \hbox to work. You can see this if you add


before \stop: the reported values are group level 1 and group type 2 ('hbox group'). You simply cannot use the \end primitive inside a box and expect all to be well. Moreover, even if you test for a box using the e-TeX extensions, closing it does not help as the content then disappears as you get no output. So with a complex set up such as the standalone class you really do have to 'stick to the rules' in terms of interface, or write everything yourself.

share|improve this answer
Do you think the scheme at tex.stackexchange.com/questions/56294/… can help? – Ahmed Musa Jul 8 '12 at 2:15
@AhmedMusa Possibly, but if there is more than once group level then life gets extremely complicated. In that case, you'll need to insert code which will then check again on the group type, and insert \stop only when you are 'safe'. – Joseph Wright Jul 8 '12 at 8:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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