# standard \cup vs musixtex's \cup

I'm using the musixtex package and it contains a \cup command (command for a dotted note). Unfortunately, I need the usual \cup command (command for the union of sets).

Now, LaTeX doesn't recognize the 'normal' \cup command and gives me an error.

What could I do to solve the problem?

-
Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – egreg Mar 18 '14 at 22:12
– Werner Mar 18 '14 at 22:26

The definition of of \cup can be stored in other macros, see the example. In this case the \cup of musixtex is probably not used in math mode, thus a "switcher" macro \cup can be defined that uses the mathematical \cup in math mode and the \cup of musixtex otherwise:

\documentclass{article}

\let\mathcup\cup
\usepackage{musixtex}
\let\musixcup\cup

\DeclareRobustCommand*{\cup}{%
\ifmmode
\expandafter\mathcup
\else
\expandafter\musixcup
\fi
}

\begin{document}
\noindent
Musical note: \musixcup 0 \qquad \cup 0\\
Math: $A \mathcup B = A \cup B$
\end{document}


-