5

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?

9

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}

Result

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.