I am writing a command that creates a margin paragraph. This requires that this command is only used in vertical mode, which is fine. If the command is used in a float, LaTeX gives a "not in outer par mode" error, which is not very friendly. Is there a way to detect whether LaTeX is currently in vertical mode, so that I can write something helpful for the user?
See The TeXBook, Chapter 20: Definitions (also called Macros), page 209 for more details.
Note that it is sometimes required to add a
As an alternative to trying to duplicate the tests that LaTeX is doing, you could just locally redefine
which makes the "Not in outer par mode" error and then
It would be a bad idea to globally change these definitions but reasonable to change them within a specific environment.