# Two conflicting packages in one document — doable?

I have two packages I want to use in the same document. Specifically musixtex and tengwarscript.

However they do conflict. Both packages use some of the same commands, obviously for very different things. Is there a way to load both packages in the same document, but only load one of them temporarily or intermittently?

-
The mind boggles! Are you writing out the music to the Lord of the Rings?? –  Andrew Stacey May 18 '11 at 20:44
More seriously, is it just the odd command or is it a lot that are in conflict? –  Andrew Stacey May 18 '11 at 20:45
You got it Andrew! It's nothing serious, just some fun with and for friends :) As I ran into the problem, well.. i wanted to see how to fix it should something like it arise in the future. The feedback I get is: ! I can't find file nur8' ! Emergency stop. mfput.log is completely empty. This happens if I try to compile a document, empty or not, so long as both packages are called in the preamble. –  Mr. V May 18 '11 at 20:54
I just did a bit of a basic look and could only find one command in common: \Tten. tengwarscript looks pretty good at namespacing all its internal macros (with teng@). Musixtex doesn't use that for anything specific other than to define it, so I would load musixtex first, then tengwarscript and use \ttie for the musixtex version of \Tten (since \Tten is just \let to \ttie). Of course, I may be missing something else that conflicts ... –  Andrew Stacey May 18 '11 at 20:59
Could you add your code that doesn't work? It sounds like the problem is elsewhere as when I try a minimum document then I get no such errors (though I find that my suggestion in the previous comment doesn't work; you have to load tengwarscript first, save the definition of \Tten, and then restore it after loading \musixtex: \usepackage{tengwarscript}\let\origTten=\Tten\usepackage{musixtex}\let\Tten=\or‌​igTten). –  Andrew Stacey May 18 '11 at 21:02

(Basically what was in my comment, but hopefully a bit clearer here.)

The only command that I can find which is defined in both tengwarscript and musixtex is \Tten. In tengwarscript it is defined with \newcommand which checks to see if it has already been defined (and throws an error if so). In \musixtex it is defined via a \let (which doesn't check), specifically \let\Tten=\ttie. Moreover, there is no other explicit use of \Tten in musixtex. So I would keep the tengwarscript definition of \Tten. For the musixtex version, you can use \ttie itself, or define another command to be equivalent to it, say \mTten. As tengwarscript explicitly checks to see if \Tten has been defined already but musixtex doesn't, the correct order to load them in is tengwarscript first and musixtex second. The following is a way to do this:

\documentclass{article}
\usepackage{tengwarscript}
\let\tengwarTten=\Tten
\usepackage{musixtex}
\let\mTten=\Tten
\let\Tten=\tengwarTten
\begin{document}
\end{document}


(Oh, and I'd like to see the final document ...)

-
@Mr. V: I recommend using the method that Gonzalo writes (and therefore also accepting his answer) since it is a little more robust and works independently of the order of the packages. You can always rename the saved symbol yet again using, say, \let\mTtex=\origTten if you so desire. –  Andrew Stacey May 19 '11 at 8:59

As Andrew has mentioned, the general procedure to prevent symbol names clashes when two packages define the same symbol name is to load the first package, rename the conflicting symbols, and then load the second package. The \savesymbol command from the savesym package can be used to this; \savesymbol{XXX} renames a symbol from \XXX to \origXXX:

\documentclass{article}
\usepackage{savesym}
\usepackage{musixtex}
\savesymbol{Tten}
\usepackage{tengwarscript}

\begin{document}
...
\end{document}

-
Nevermind, I just looked at the code and saw that it does. –  Andrew Stacey May 19 '11 at 8:57