# LaTeX Error: Command \c@T already defined

this is an easy question, but I couldn't find the answer just from other similar questions.

A lot of people often get an error in the form:

    LaTeX Error: Command \XYZ already defined.
Or name \end... illegal, see p.192 of the manual.


usually, the problem is that they are using something that is defined in 2 different packages, so LaTeX is confused about what to do with the command.

My symptoms are similar: after lines

88     \begin{definition}
89     The distribution of a random variable $X$ is usually described by giving its {\bf distribution function}, $f(x) = P(X \leq x)$.
90     \end{definition}


my TeXShop is saying:

   89:LaTeX Error: Command \c@T already defined.
Or name \end... illegal, see p.192 of the manual.


So, I tried to find where could command \c@T be defined. I'm only using

    \usepackage{amssymb,amsmath}
\usepackage{changepage}


and I don't really see how they could both define command c@T.

I looked at the list of all commands in LaTeX, at http://www-sop.inria.fr/marelle/tralics/doc-c.html#cmd-citetype, and I haven't even found such command, but it looked like some kind of counting is the problem. So, I admit that I also have

    \begin{document}
\newenvironment{definition}[1][Definition]
\newcounter{definition}


which might be the place where I defined something in the wrong way, but I don't see why wouldn't this problem come up in the previous definitions.

If anyone had patience to solve this old problem again and explain it to me, I would really appreciate it.

-
Welcome to TeX.SX! –  Papiro Jul 18 '13 at 11:30
Are all those <br\>s really in your document and the log? –  Loop Space Jul 18 '13 at 11:36
Ah, no, sorry about that, I added them by mistake when I was writing this post. Thanks for pointing this out! –  Lochness Monster Jul 18 '13 at 11:40
Your \newenvironment is not complete and this can lead to disaster. Add {}{} after [Definition]. –  Ulrike Fischer Jul 18 '13 at 11:55
\c@(thing) is an internal part of the counter called (thing), namely the part that stores the value. In your case, that would mean you ahve two \newcounter{T} in your code. –  Ulrich Schwarz Jul 18 '13 at 11:57

What's apparently happening is the following: as @Ulrike remarks, your \newenvironment lacks its two mandatory arguments. It will instead pick up \newcounter and definition, since that is what follows.

What this does is that when you call \begin{definition}, you inadvertently call \newcounter, so

\begin{definition} The thing


turns into, with some technicalities omitted,

\newcounter The thing


i.e.

\newcounter{T}he thing


and that's where your counters come from and that's why you get an error: you probably have to definitions that start with "T"!

(To backtrack and solve your problem: I think you really mean to look at the amsthm package and its \newtheorem command?)

-
Wow! I salute your detective work. –  Loop Space Jul 18 '13 at 12:13
@Andrew: make enough mistakes, eventually you'll have seen most of them before. ;) –  Ulrich Schwarz Jul 18 '13 at 12:15
Thank you very much, Ulrike and Ulrich! It was enough, as Ulrike suggested, to add {}{} after \newenvironment{definition}[1][Definition]{}{} Thanks to Ulrich's explanation, I see how did the \c@T appear. Also, looking at the amsthm package will be useful for the future. Vielen Dank! –  Lochness Monster Jul 18 '13 at 12:23