TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How to undo a \def (i.e., Need a \undef capability)

In my template I test for chapter defined to prevent that code section only valid for a chapter class are executed. However if I load titlesec chapter is always defined regardless of the class in use.

So how can I make \chapter undefined after the execution of titlesec?

So far I tried this which did not work:

   % make chapter undefined again
share|improve this question

marked as duplicate by Werner, diabonas, clemens, lockstep, Harish Kumar Oct 15 '12 at 23:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

What happens if you \let\chapter\UnDeFiNED instead of \relax? – Marco Oct 15 '12 at 20:02
\undef\chapter seems to work with etoolbox package. Test case:Chapter is \ifcsdef{chapter}{defined}{undefined}. And @Marco's suggestion also works. – Peter Grill Oct 15 '12 at 20:05
up vote 4 down vote accepted

Instead of setting \chapter to \relax, you can set it to an undefined sequence:

share|improve this answer
I use now \undef\chapter instead, but both work. – Matthias Pospiech Oct 15 '12 at 20:14
@MatthiasPospiech \undef\chapter does a similar thing, precisely \let\chapter\etb@undefined. – egreg Oct 15 '12 at 20:25

The following should do the trick, it keeps the definition of \chapter (defined or undefined) that was active before package titlesec is loaded:

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.