[Tex/LaTex] cannot scale curly brace

braces

In follow up to my previous question, I wanted to align two arrows and put curly braces around them. The following works fine

\documentclass{article}
\usepackage[margin=2cm,centering]{geometry}
\usepackage{amsmath}
\usepackage{mathtools}
\newcommand*{\myrightarrow}[1]{\xrightarrow{\mathmakebox[5cm]{#1}}}
\newcommand*{\myleftarrow}[1]{\xleftarrow{\mathmakebox[5cm]{#1}}}

\begin{document}

\noindent\fbox{\begin{minipage}{\dimexpr6.5in-2\fboxsep-2\fboxrule\relax}
{\bfseries Alice \hfill Bob}
\begin{align*}
&\myleftarrow{a}
\\
&\myrightarrow{}
\\
\{&\begin{array}{c}
\myleftarrow{q} \\
\myrightarrow{k}
\end{array} 
\}
\\
&\myleftarrow{c}
\\
\end{align*}
\end{minipage}}

\end{document}

The issue is that I need to make the curly braces fit around the array. From what I read, replacing \{ with \left\{ and \} with \right\} should work. But it gives me errors when I do this:

\documentclass{article}
\usepackage[margin=2cm,centering]{geometry}
\usepackage{amsmath}
\usepackage{mathtools}
\newcommand*{\myrightarrow}[1]{\xrightarrow{\mathmakebox[5cm]{#1}}}
\newcommand*{\myleftarrow}[1]{\xleftarrow{\mathmakebox[5cm]{#1}}}


\begin{document}

\noindent\fbox{\begin{minipage}{\dimexpr6.5in-2\fboxsep-2\fboxrule\relax}
{\bfseries Alice \hfill Bob}
\begin{align*}
&\myleftarrow{a}
\\
&\myrightarrow{}
\\
\left\{&\begin{array}{c}
\myleftarrow{q} \\
\myrightarrow{k}
\end{array} 
\right\}
\\
&\myleftarrow{c}
\\
\end{align*}
\end{minipage}}
\end{document}

Any suggestions? Thanks!

Best Answer

The problem is the & after \left\{. If you just want to center the arrows, you could try the other solution (without explicit alignment characters) or another approach with

\documentclass{article}
\usepackage[margin=2cm,centering]{geometry}
\usepackage{amsmath}
\usepackage{mathtools}
\newcommand*{\myrightarrow}[1]{\xrightarrow{\mathmakebox[5cm]{#1}}}
\newcommand*{\myleftarrow}[1]{\xleftarrow{\mathmakebox[5cm]{#1}}}


\begin{document}

\fbox{\begin{minipage}{\dimexpr6.5in-2\fboxsep-2\fboxrule\relax}
\centering
{\bfseries Alice \hfill Bob}

$\myleftarrow{a}$

$\myrightarrow{}$

$\left\{\begin{array}{@{}c@{}}
\myleftarrow{q} \\
\myrightarrow{k}
\end{array} 
\right\}$

$\myleftarrow{c}$

\end{minipage}}

\end{document}

enter image description here

Related Question