16

How can I undefine an environment?

This is how to undefine a command:

\newcommand\foo
\makeatletter
\let\foo\@undefined
\makeatother

I need to undefine the spacing environment from the setspace package. This does not seem to work:

\usepackage{setspace}
\makeatletter
\let\beginspacing\@undefined
\let\endspacing\@undefined    
\makeatother
0

2 Answers 2

16

The macro \newenvironment{foo} defines the two macros

\foo
\endfoo

not \beginfoo.

Rather than undefine spacing, you could simply make it a noop:

\renewenvironment{spacing}{}{}

This is preferable because it will keep track of nested environments.

8
  • What is an environment needs to be undefined, because it was predefined but conflicts with some package? Is there a better way than going through \makeatletter?
    – Alexey
    Commented Jun 4, 2020 at 14:45
  • @Alexey Where do you get to undefine the environment?
    – egreg
    Commented Jun 4, 2020 at 15:01
  • In my own class i defined an environment, and then i loaded a package that defines an environment with the same name :). I do not want to change my class, usually it is fine.
    – Alexey
    Commented Jun 4, 2020 at 15:03
  • @Alexey It mostly depends on which of the two conflicting definitions you want to keep.
    – egreg
    Commented Jun 4, 2020 at 15:04
  • I wanted to keep the one coming from a package (not mine).
    – Alexey
    Commented Jun 4, 2020 at 21:22
2

Per this answer, use

\let\spacing\@undefined
\let\endspacing\@undefined 

to undefine the spacing environment. Note that \@undefined is not a special command, it simply is, itself, undefined.

You must log in to answer this question.

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