How can I partially re-implement an existing command in Latex?
I have a \documentclass
with:
\ProvidesClass{myclass}[My sample class]
\LoadClass{article}
When someone uses \subsection{}
, I really want to treat it as if they wrote \subsection*{}
(no section numbers). In my *.cls
I've tried:
\renewcommand{\subsection}[1]{\subsection*}
But this just causes an infinite loop in Latex and I need to kill the process.
I've also tried:
\let\subsection\subsection*
But this simply lets \subsection
equal itself and then prints a *
Best Answer
LaTeX has a built-in mechanism for this. Each sectioning command is assigned a level
A class might not have chapters, but for uniformity the levels are always the same.
You can decide up to what level sectional titles are numbered by setting the counter
secnumdepth
:will only number parts, chapters (if provided by the class) and sections.
There is a companion counter,
tocdepth
, that controls what sectioning levels are listed in the table of contents.Of course, users can override your setting, if they know about
secnumdepth
. You can't do much about that.Even if you decide to go the “redefine” way with
a user can still do
and override your decision.