Document Classes\newcommand in a style file and older documents

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
lnewton
Posts: 17
Joined: Mon Mar 31, 2008 3:01 pm

\newcommand in a style file and older documents

Post by lnewton »

Apologies if this shows up on the forum twice. I
thought I posted it before, but it did not show up.
Perhaps I forgot a subject.

By way of background, I'm a long-time user of TeX and
LaTeX (since 1988), but have only recently acquired a
need to come to grips with writing and editing class
and style files (doing it right now, in fact), and am
unaware of how some of the internal stuff works, or of
the best place to find documentation on it. (I'm
looking in "The LaTeX Companion" and am thinking it may
be the best there is.)

Meanwhile, my immediate need is as follows: We use a
command called \sanitize that gets defined in about 50%
of our documents. It makes sense to me to put it in our
main style file. However, if I do that, it will break
backward compatibility with older documents, i.e., if I
add \newcommand{\sanitize}{foo} to the style file, then
run a three-year-old document through latex that has
that same \newcommand in the preamble, it will not
build. I can't define it in the style file using
\renewcommand because it's not defined, and I'm
unwilling to go through hundreds of old documents for
instances of the declaration to change them to
\renewcommand. Does someone know a way around this?
Lynn

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

lnewton
Posts: 17
Joined: Mon Mar 31, 2008 3:01 pm

Re: \newcommand in a style file and older documents

Post by lnewton »

To reply to my own post -- the answer to some problems is
not a technical one but managerial, and often simple.

Instead of adding the \newcommand{\sanitize}{...} I added
the same identical code but called it \cleanup. That way
no legacy files have to be touched, the new name is more
obvious regarding its intent, and it's one less letter to
type as well.

Problem resolved.
Lynn
User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

\newcommand in a style file and older documents

Post by T3. »

Hi Lynn,

Perhaps this guide will be of interest to you.

Cheers,

Tomek
Post Reply