tikz 图纸覆盖或范围之间的连接

tikz 图纸覆盖或范围之间的连接

我是 tikz 新手,我的问题出在下面的图片和代码上,问题是如何连接图纸:

这是我的代码,但是箭头仍然丢失,我找不到放进去的东西。

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[align=center]
\coordinate (a) at (-1,-1);
\coordinate (b) at (1,-1);
\coordinate (c) at (1,1);
\coordinate (d) at (1,2);
\coordinate (e) at (-1,2);
\coordinate (f) at (-1,1);
\draw  (a) -- (b) -- (c) -- (d) -- (e) -- (f) -- cycle;
\draw  (c) -- (f);
\draw (a) node[blue,below left]{{1}};
\draw (b) node[blue,below right]{{2}};
\draw (c) node[blue,below right]{{4}};
\draw (f) node[blue,below left]{{3}};
\draw (c) node[red,above right]{{2}};
\draw (d) node[red,above right]{{4}};
\draw (e) node[red,above left]{{3}};
\draw (f) node[red,above left]{{1}};
\begin{scope}[xshift=100,yshift=-50]
\coordinate (a) at (-1,-1);
\coordinate (b) at (1,-1);
\coordinate (c) at (1,1);
\coordinate (f) at (-1,1);
\draw (a) -- (b) -- (c) -- (f) -- cycle;
\draw (a) node[blue,below left]{{1}};
\draw (b) node[blue,below right]{{2}};
\draw (c) node[blue,above right]{{4}};
\draw (f) node[blue,above left]{{3}};
\end{scope}
\begin{scope}[xshift=100,yshift=50]
\coordinate (c) at (1,1);
\coordinate (d) at (1,2);
\coordinate (e) at (-1,2);
\coordinate (f) at (-1,1);
\draw (c) -- (d) -- (e) -- (f) -- cycle; 
\draw (c) node[red,below right]{{2}};
\draw (d) node[red,above right]{{4}};
\draw (e) node[red,above left]{{3}};
\draw (f) node[red,below left]{{1}};
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

在此处输入图片描述

答案1

以下内容或许可以帮助你入门:

在此处输入图片描述

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning,arrows.meta,arrows}

\tikzset{
mymat/.style={
  matrix of math nodes,
  minimum width=1cm,
  minimum height=1.5cm,
  align=center,
  row sep=-\pgflinewidth, 
  nodes in empty cells
  },
}
\begin{document}

\begin{tikzpicture}[>=latex]
\matrix[mymat,anchor=west,style={nodes=draw}]
at (0,0) 
(mat1)
{
\\
\\
};
\matrix[mymat, above right =of mat1,anchor=north,style={nodes={draw}}]
(mat2)
{
\\
};
\matrix[mymat,below right=of mat1,anchor=south,style={nodes={draw}}]
(mat3)
{
\\
};
\path[->](mat1-1-1.center) edge[bend left=10] node [left] {} (mat2-1-1.west);
\path[->](mat1-2-1.center) edge[bend left=-10] node [left] {} (mat3-1-1.west);
\end{tikzpicture}

\end{document}

答案2

编辑:

\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{arrows.meta,
                positioning}

\tikzset{
box/.style args = {#1/#2}{draw, minimum width=#1mm, minimum height=#2mm, 
                          inner sep=0pt, outer sep=0pt},
box/.default = 10/15,
       }
\begin{document}
    \begin{tikzpicture}[
    node distance = 9mm and 12mm,
                > = Latex]
\node (m1) [box=9/12] {};
\node (m2) [box=9/12,below] at (m1.south) {};
\node (m3) [box, above right=of m1.east] {};
\node (m4) [box, below right=of m2.east] {};
\draw[->]   (m1.center) to [bend  left] (m3.west);
\draw[->]   (m2.center) to [bend right] (m4.west);
\foreach \i [count=\j] in {north west, north east, south west, south east}
{
\node[above right, text=red] at (m1.\i) {\j};
\node[above right, text=red] at (m3.\i) {\j};
}
\foreach \i [count=\j] in {south west, south east, north west, north east}
{
\node[below right, text=blue] at (m2.\i) {\j};
\node[below right, text=blue] at (m4.\i) {\j};
}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

笔记

  • 绘制箭头的命令是\draw[->] (<coordinate 1>) -- (<coordinate 2>);,或者在你的情况下\draw[->] (m1.center) to [bend left] (m3.west);
  • 箭头由 决定>,其种类在 TikZ & PGF 手册第章中描述16支箭,第 191 页

相关内容