9

I know how to use \renewenvironment to redefine an environment, but instead of changing formatting, I'd like to have any use of the environment generate an error (log and abort). Is there a way to do this?

1
  • \renewenvironment{tabular}{\ABORT}{}, assuming of course that the environment `` is already defined (hence the renew, otherwise use new), and the macro \ABORT does not exit or aborts as you desire. Mar 16, 2012 at 22:12

2 Answers 2

8
\documentclass{article}
\newenvironment{die}
  {\GenericError{}{Mortal environment found}
  {I'm very unhappy, exiting}
  {What you did is highly disapproved}\endgroup\csname @@end\endcsname}
  {}

\begin{document}
\begin{die}
\end{die}
\end{document}
4

This is as simple as possible:

\def\yourenv{\GenericError{}{This is my error}{}{}}
3
  • This does not really define the environment (since you did not define \endyourenv, btu does generate an error as desired. Mar 16, 2012 at 22:15
  • the question is about re-defining, so \endyourenv should have been already defined before you do this modification.
    – yo'
    Mar 16, 2012 at 22:16
  • Duh!!! Good point. I don't have even a good excuse like too much wine!! Mar 16, 2012 at 23:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .