3

I'm creating a communication diagram. The desired effect is to have the following in a box:

Alice                                                                     Bob

                                 x
                -------------------------------------------->

                                 y
                 <-------------------------------------------

                                 z
                 -------------------------------------------->
                                  .
                                  .
                                  .

Also, I need the ability to group two of the arrows together and put curly braces around them to look like this except I want a single set of curly braces around both of them:

                      { -----> }
                      { <----- }

I figured out how to make the box and the arrows, but I'm having trouble grouping the arrows with the curly braces. I tried using the gather environment but could not figure it out. Here is what I have so far:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{center}
\begin{minipage}{6.5in}
    \setlength{\parindent}{0cm}%
    \fbox{\vbox{%
\bf Alice \hfill
\bf Bob
\begin{gather*}
\xleftarrow{\hspace*{8cm}} \\
 \xrightarrow{\hspace*{8cm}} 
\end{gather*}

\[ \xleftarrow{\hspace*{8cm}} \]

\[ \xrightarrow{\hspace*{8cm}} \]

\[ \xleftarrow{\hspace*{8cm}} \]

\[ \xrightarrow{\hspace*{8cm}} \] }}
\end{minipage}
\end{center}
\end{document}

Any help would be appreciated!

2
  • 1
    Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. Apr 18, 2013 at 19:34
  • I've changed it and I'll keep that in mind for future questions. Thanks!
    – AFS
    Apr 18, 2013 at 20:19

2 Answers 2

5

I slightly changed your code: I used \fbox to enclose the minipage; inside the minipage, the header (Bob, Alice) is placed and then a gather environment is used for the arrows; a set of arrows needing braces is placed in an array environment enclosed with \left\{...\right\} (using the optional argument for \\ you can control the vertical separation between groups). I also defined some commands for the arrows:

\documentclass{article}
\usepackage[margin=2cm,centering]{geometry}
\usepackage{amsmath}

\newcommand\MLarrow{\xleftarrow{\hspace*{8cm}}}
\newcommand\MRarrow{\xrightarrow{\hspace*{8cm}}}

\begin{document}

\noindent\fbox{\begin{minipage}{\dimexpr6.5in-2\fboxsep-2\fboxrule\relax}
{\bfseries Alice \hfill Bob}
\begin{gather*}
\left\{
\begin{array}{c}
\MLarrow \\
\MRarrow
\end{array}
\right\} 
\\
\MLarrow
\\
\MRarrow
\\
\left\{
\begin{array}{c}
\MLarrow \\
\MRarrow
\end{array}
\right\}
\end{gather*}
\end{minipage}}

\end{document}

enter image description here

2
  • Thank you! How would I get a little more space(say a skipped line) between the arrows?
    – AFS
    Apr 18, 2013 at 20:16
  • 1
    @AFS Right now I'm in the mobile, writing code is a pain. You can use the optional argument for \\ as in \\[1ex] or any other length that best suits your needs. Apr 18, 2013 at 20:22
3

(Bob and Alice temporarily removed. Only a grouping is shown.)

\documentclass{article}

\usepackage{amsmath}
\begin{document}


\begin{center}
\begin{minipage}{6.5in}
%    \setlength{\parindent}{0cm}%
%    \fbox{\vbox{%
%\bf Alice \hfill
%\bf Bob
%\item %\begin{gather*}
$
\left\{
\begin{array}{l}
\xleftarrow{\hspace*{8cm}} \\
 \xrightarrow{\hspace*{8cm}} 
\end{array}
\right\}
$
%\end{gather*}


\end{minipage}
\end{center}

\end{document}
1
  • 2
    It'd be great to have some explanation, perhaps a screenshot?
    – cmhughes
    Apr 18, 2013 at 19:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .