[Tex/LaTex] Matrices with cryptocode package

matrices

I am using the package cryptocode to typeset protocols in a nice way, but I have a problem with matrices. Here is a MWE which shows the problem:

\documentclass{article}

\usepackage{cryptocode}

\begin{document}

\begin{figure}%[ht]
\begin{center}
\fbox{%
\pseudocode{%
    \textbf{Sender} \<\< \textbf{Receiver} \\[][\hline]
    \<\< \text{compute } P = \begin{pmatrix}
        A \\ B + C
    \end{pmatrix} \\
    \text{compute } Q = R+S-T \<\< \\
    \< \sendmessageright*{Q} \< \\
    \< \sendmessageleft*{P} \< \\
}
}
\end{center}
\end{figure}

\end{document}

The result is

enter image description here

and, as you can see, the matrix is not typeset correctly (the alignment is wrong). How can I solve this?

Best Answer

Apparently the command \pseudocode mingles with the definition of \\ and other internals that are also relevant for \pmatrix. I can't offer a general solution. A quick hack is to save the matrix outside of \pseudocode in a box and to use this box inside of \pseudocode, like this: Before the pseudo code, add

\newsavebox\Pmatrix
\setbox\Pmatrix\hbox
 {$\begin{pmatrix}
    A \\ B + C
  \end{pmatrix}$%
 }

In the pseudo code, use \Pmatrix instead of the matrix:

\<\< \text{compute } P = \usebox\Pmatrix \\