2

Working to find Latex error – Redefinition Problem

I have been trying-out the several ways of writing a vector symbol with harpoon above, - as described in several replies to an early post ref: how to set vector and tensor symbols with horizontal bars above

They all worked fine and I was simply experimenting, commenting out the various alternatives to see the effect of each - then suddenly started getting a compilation error:-

“! LaTeX Error: Command `\vec' already defined.”

Alas due to the ad hoc way I was trying out each vector symbol I am not quite sure how I managed to get this error. Simply undoing the last commented-out section should of course “fix it” – but that doesn’t seem to be the case! The strange thing is, that those different ways to draw that vector still appeared (correctly rendered) in the .pdf output. I must have added something to cause the redefinition error – but after much searching I cannot see what it is!

Resorted to looking for said symbol, \vec, in the \usepackage{} .sty files. And found, \vec it is defined in both amsmath.sty and fdsymbol.sty. The problem now is how to correct this situation?

Are such redefinitions (collisions) commonplace in a miktex build which presumably has many \usepackage{}? Or if not, how do each of the “identifiers” (excuse lack of correct terminology) maintain a unique presence in an overall .tex build? Do Tex systems have any methods in place to handle collisions of symbol names?

To summarize my questions: 1. how to correct this redefinition error 2. how should I proceed in future with regard to general TeX usage in relation to avoiding the redefinition problem in \usepackages

HERE IS THE ERROR INFORMATION

~~~~~~~~~~~~~~~~~~~~~~~~~

"C:\Program Files\MiKTeX 2.9\tex\latex\fdsymbol\fdsymbol.sty

! LaTeX Error: Command `\vec' already defined.
See the LaTeX manual or LaTeX Companion for explanation.Type H <return> for immediate help
.... ...ccent{\vec}{\mathord}{largesymbols}{"84}

~~~~~~~~~~~~~~~~~~~~~~~~~

In fdsymbol.sty, line 1799 has:-
\DeclareMathAccent{\vec}{\mathord}{largesymbols}{"84}

Thank you

4
  • I get no conflicts with \documentclass{article} \usepackage{fdsymbol} \usepackage{amsmath} \begin{document} $\vec x$ \end{document} Apr 25 '16 at 15:03
  • 1
    In general, however, to overcome a redundant symbol load, after loading the first package, \let\macroname\relax where \macroname is the redundant symbol. Then load the 2nd package, whose definition will prevail. Apr 25 '16 at 15:05
  • Also, with compilation issues such as you describe, deleting the aux file and any other auxiliary files before recompilation will frequently correct the issue. Apr 25 '16 at 15:07
  • 1
    Welcome to TeX.SX! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code. You can also highlight the code and click the "code" button (with "{}" on it). Apr 25 '16 at 15:10
2

I have been asked to summarize my comments into an answer. As it is, I have no problem compiling

\documentclass{article} 
\usepackage{fdsymbol} 
\usepackage{amsmath} 
\begin{document} 
$\vec x$ 
\end{document}

However, there is a technique to use, if two packages both wish to define the same named symbol (or macro). That is, once the first package is loaded, you can "undefine" the conflicted symbol (let us say, in this case, \vec) with the syntax

\let\vec\relax

Then, you can load the 2nd package without complaint/warning.

The other point I mentioned in comments is that the aux file that is created on one run is imported for the subsequent 2nd-pass compilation. Thus, if things went awry during any stage of the effort, remnants of the problem could remain hidden in the aux file, even if the source tex file is corrected. Thus, it is highly recommended, in such cases, to remove aux file prior to recompilation attempts. This same advice often pertains to other adjunct files associated with compilation, but most often the fault lies in the aux file.

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.