如何使用 TikZ 在流程图中绘制并排的框?

如何使用 TikZ 在流程图中绘制并排的框?

我怎样才能在以下代码中居中绘制该图形

\documentclass{exam}

\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage{txfonts}
\usepackage{url}\urlstyle{sf}
\usepackage[plain]{algorithm}
\usepackage {tikz}
\begin{document}
  \begin{parts}
    \part \begin{tikzpicture}
       \node[rectangle,minimum width=2cm,minimum height=5cm] (m) {
       \begin{minipage}{1.95cm}
          \begin{tikzpicture}
            \draw (0,5) node[minimum width=0.9cm, minimum height=0.9cm,draw] {$a$};
            \draw (0,5) -> (1,5) node[minimum width=0.9cm, minimum height=0.9cm] {$a$};
          \end{tikzpicture}
        \end{minipage}
      };
      \draw[dashed] (m.south west) rectangle (m.north east);
    \end{tikzpicture}
  \end{parts}
\end{document}

这是制作的图像

在此处输入图片描述

和这个

答案1

作为我的练习和你的起点:)

在此处输入图片描述

tikz图像,需要的库arrows.meta,,fitpositioning

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, fit, positioning}
\usepackage{amsmath}

    \begin{document}
\begin{tikzpicture}[
    node distance = 8mm and 4mm,
         F/.style = {draw, rounded corners, dash dot,
                     label=$\boldsymbol{\mathrm{E}_{#1}}$
                     }
                    ]
\node (n1) [draw]           {a};
\node (n2) [right=of n1]    {a};
\node (n3) [below=of n2]    {b};
%
\node (n4)  [below right = 2mm and 22mm of n3]  {x};
\node (n5)  [below=of n4]                       {y};
%
\node (n6)  [below left = 2mm and 22mm of n5]   {c};
\node (n7)  [below=of n6]                       {d};
%%
\node [F=3,
      fit=(n1) (n7)] {};
\node [F=4, minimum width=8mm,
      fit=(n1.north -| n4) (n7.south -| n5)] {};
%%
\draw[semithick,-Latex] (n1) edge (n2)
                        (n2) edge (n3)
                        (n4) edge (n5)
                        (n6)  to  (n7);
\draw[semithick,densely dashed,-{Latex[fill=white]}]
                        (n3) edge (n4)
                        (n5) edge (n6);
\end{tikzpicture}
    \end{document}

相关内容