9

We often encounter multiple definitions of certain commands/macros. Then, we often get the error, e.g.: ! LaTeX Error: Command \P already defined. Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...

l.225 \newcommand{\P}{{\mathcal P}}

When we get such an error, is there anyway to know which package or file predefined that particular command/macro? I'm talking about general cases, not the particular case of '\P' listed above. It is quite cumbersome if we have to go through all possible files via 'grep' manually. I hope that there's a way to see which file already defined the command that produces the conflict/error.

Thanks a lot!

BVP

  • 1
    grep is your friend, sorry:-) – David Carlisle Jun 19 '14 at 18:34
  • For people (like me) who come here later: \P is the command to get the paragraph symbol. – dejongbrent Jan 22 '16 at 18:57
9

You can add

\show\P

to your document as in

 \show\P
\documentclass{article}
 \show\P
\usepackage{graphics}
 \show\P
\usepackage{foo}
 \show\P
\usepackage{bar}
 \show\P
\begin{document}
 \show\P

This will make the TeX stop and show the definition of \P at each step, if it is already defined in the format the first one will show the definition, otherwise it will show undefined until the package that defines it is loaded. (The definition might be delayed with \AtBeginDocument which is why I put the final \show at that point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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