乳胶花括号分组箭头

乳胶花括号分组箭头

我正在创建一个通信图。期望的效果是在一个框中包含以下内容:

Alice                                                                     Bob

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

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

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

另外,我需要将两个箭头组合在一起,并用花括号括起来,看起来像这样,但我希望在它们两个周围都用一组花括号括起来:

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

我搞清楚了如何制作方框和箭头,但无法用花括号将箭头组合在一起。我尝试使用环境,gather但无法弄清楚。以下是我目前所拥有的:

\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}

任何帮助,将不胜感激!

答案1

我稍微修改了你的代码:我过去常常\fboxminipage; 括在 里面minipage,放置标题(Bob、Alice),然后gather为箭头使用一个环境;一组需要括号的箭头放在array括起来的环境中\left\{...\right\}(使用可选参数\\可以控制组之间的垂直分隔)。我还为箭头定义了一些命令:

\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}

在此处输入图片描述

答案2

(Bob 和 Alice 暂时被移除。仅显示一个分组。)

\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}

相关内容