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'd like to be able to do the following kind of thing:

\documentclass{standalone}
\begin{document}
Foo
\begin{MyUndefinedEnv}
  Bar
\end{MyUndefinedEnv}
\end{document}

without LaTeX complaining about undefined environment. Is it possible without breaking existing environments?

share|improve this question
    
Of course, I can patch the definition of \begin to remove the \@latex@error (p.204 of source2e.pdf). As a \csname is invoked it should not be a problem if the control sequence is not defined. But I'd like to hear it is safe from gurus :). –  cjorssen Jan 10 '13 at 22:53
1  
Why do you want to use undefined environments? Just curious... –  marczellm Jan 10 '13 at 22:56
    
@marczellm Coding environments is a lot more fun than writing a whole lecture about the phase plane. So every time I need a new environment, I spend time coding it rather than doing the right thing :). –  cjorssen Jan 10 '13 at 22:59
4  
@cjorssen: Hmmm, I think you are missing the whole point of procrastinating.. :-) –  Peter Grill Jan 10 '13 at 23:02

1 Answer 1

up vote 8 down vote accepted

Yes, you can:

\documentclass{article}

\makeatletter
\let\xbegin\begin % store original \begin
\let\xifundefined\@ifundefined % store original \@ifundefined
\def\begin{%
  % "inactivate" \@ifundefined, but only once, hence reverting
  % it to original definition immediately
  \def\@ifundefined##1##2##3{\global\let\@ifundefined\xifundefined##3}%
  \xbegin}
\makeatother

\begin{document}

\begin{ttgg}
Hello!
\end{ttgg}

\begin{center}
Hello!
\end{center}

\end{document}
share|improve this answer
    
Interesting, thanks. –  cjorssen Jan 10 '13 at 23:09

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.