Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
\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. –  Peter Grill Mar 16 '12 at 22:12
add comment

2 Answers

up vote 8 down vote accepted
\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}
share|improve this answer
add comment

This is as simple as possible:

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

Your Answer

 
discard

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.