# beamerarticle breaks the msc package

For some reason beamerarticle (but not plain beamer) breaks the \action macro of the msc package (the development version using TikZ instead of PStricks) in the following way:

The figure should look like this:

The code for this MWE follows, the different results comes from commenting or uncommenting the line for beamerarticle.

\documentclass{article}
\usepackage{msc}
%\usepackage[noxcolor]{beamerarticle}

\begin{document}
\begin{figure}
\centering
\begin{msc}[msc keyword=]{}
\drawframe{no}

\declinst{A}{}{Alice}
\declinst{B}{}{Bob}

\mess*{$m$}{A}{B}
\nextlevel{}

\mess{$c, t$}{A}{B}
\action*{Record $A\to B\colon c, t$}{A}
\nextlevel[3]

\mess{$c^\prime, t^\prime$}{B}{A}
\action*{Record $B\to A\colon c^\prime, t^\prime$}{B}

\end{msc}
\caption{%
A sequence diagram illustrating the protocol.
}\label{ProtocolOverview}
\end{figure}
\end{document}


My question is thus, does anyone have any idea what might be the cause? Can anyone give me a clue to how to fix the problem?

Without beamerarticle it looks good, if the \action* lines are removed it also works well in both cases. In the slides using beamer as the document class it also works perfectly well.

The problem is that both packages define a macro called \action, as the error message you get indicates:

! LaTeX Error: Command \action already defined.


The error occurs because beamerarticle uses \newcommand to define it. msc.sty on the other hand, uses \def to define \action, and \def doesn't check if a macro of the same name already exists, it just silently overwrites it. This explains why it works in a normal beamer presentation.

As a result, if you simply swap the order of the two packages (and remove the noxcolor argument to beamerarticle), the diagram works.

An alternative would be to use the method described by David Carlisle in How to make a package play well with others?.

\documentclass{article}
\usepackage{beamerarticle}
\usepackage{msc}
\begin{document}
\begin{figure}
\centering
\begin{msc}[msc keyword=]{}
\drawframe{no}

\declinst{A}{}{Alice}
\declinst{B}{}{Bob}

\mess*{$m$}{A}{B}
\nextlevel{}

\mess{$c, t$}{A}{B}
\action*{Record $A\to B\colon c, t$}{A}
\nextlevel[3]

\mess{$c^\prime, t^\prime$}{B}{A}
\action*{Record $B\to A\colon c^\prime, t^\prime$}{B}

\end{msc}
\caption{%
A sequence diagram illustrating the protocol.
}\label{ProtocolOverview}
\end{figure}
\end{document}

• Thanks, I'd better try this again now since lots have changed since then! I never got the error message back in 2015. It compiled without any errors to the figures you see above. Did you use the development version of msc.sty or the one in CTAN? (I think the development version is still not on CTAN.) – dbosk Jan 12 '18 at 15:59
• @dbosk The development version, as that is what you said you used. The code in my answer doesn't work with the CTAN version. – Torbjørn T. Jan 12 '18 at 19:31