3

I have a class that I use for my document. This class defines the environment example. I want to use this defined environment.

I need a package that also defines an example environment. I don't want this environment.

How do I use the class definition of example and eliminate the conflict?

1 Answers1

2

When the example environment is created, LaTeX creates the macros \example and \endexample. These are used internally at the beginning and end of the environment, and their definitions can be copied using the \let command. Then, if the definitions are overwritten, we can use \let again to restore them from the copies. The following code does this with the itemize environment, but you should be able to adapt it to your own case.

\documentclass{article}
\let\olditemize\itemize %Store old itemize environment 
\let\oldenditemize\enditemize

\renewenvironment{itemize}{}{} %Destroy itemize environment 

\let\itemize\olditemize %Restore old itemize environment
\let\enditemize\oldenditemize

\begin{document}

\begin{itemize}
\item abc
\end{itemize}

\end{document}
Ian Thompson
  • 43,767