如何将两幅图像并排放置并在中心放置一些符号?

如何将两幅图像并排放置并在中心放置一些符号?

我想将两幅图像并排放置,并在它们之间放置一个比较符号。这是 tikz 代码:

\documentclass{article}

\usepackage{tikz}

\usepackage[margin=15mm]{geometry}

\usepackage{calc}

\usetikzlibrary{matrix,arrows}

\usetikzlibrary{positioning,arrows}

\usetikzlibrary{shapes,arrows,fit,calc,positioning,automata}

\begin{document}

\begin{tikzpicture}[node distance=5cm,auto,>=latex', scale = 0.75, transform shape]

      \coordinate (a1) [] {};
      \node[rectangle] (a) [draw,minimum width=2cm,minimum height=1cm, below of=a1,node distance=1.5cm] { };
      \node[rectangle] (b) [draw,minimum width=2cm,minimum height=1cm, below of=a,node distance=2cm] { };
      \coordinate[below=1cm of b] (b1)  {};
      \path[->] (a)  edge node {{$\gamma$} } (b);
      \path[->] (a1) edge node {{$\alpha.\beta$} } (a);
      \path[->] (b)  edge node {{$\delta$} } (b1);
\end{tikzpicture}

      \begin{tikzpicture}[node distance=5cm,auto,>=latex', scale = 0.75, transform shape]
      \coordinate (a1) [] {};
      \node[rectangle] (a) [draw,minimum width=4cm,minimum height=1cm, below of=a1,node distance=1.5cm] {};
      \coordinate[below=1cm of a] (b1)  {};

      \path[->] (a1) edge node {  $\alpha.\beta$ } (a);
      \path[->] (a) edge node {  $\delta$ } (b1);
      \end{tikzpicture}

\end{document} 

我想将这些图像并排放置,并在它们之间添加一个等号。我该怎么做?

答案1

您可以使用minipage它来执行此操作;根据需要调整下面给出的宽度。

请注意,每个图片\end{minipage}都有尾部,%以防止添加额外的水平空间。如果要将此图片放在环境中figure,请使用\centering而不是\begin{center}...\end{center}

截屏

\documentclass{article}

\usepackage[margin=15mm]{geometry}
\usepackage{tikz}

\usetikzlibrary{arrows,positioning}

\begin{document}

\begin{center}
\begin{minipage}{.2\textwidth}
\begin{tikzpicture}[node distance=5cm,auto,>=latex', scale = 0.75, transform shape]
      \coordinate (a1) [] {};
      \node[rectangle] (a) [draw,minimum width=2cm,minimum height=1cm, below of=a1,node distance=1.5cm] { };
      \node[rectangle] (b) [draw,minimum width=2cm,minimum height=1cm, below of=a,node distance=2cm] { };
      \coordinate[below=1cm of b] (b1)  {};
      \path[->] (a)  edge node {{$\gamma$} } (b);
      \path[->] (a1) edge node {{$\alpha.\beta$} } (a);
      \path[->] (b)  edge node {{$\delta$} } (b1);
\end{tikzpicture}
\end{minipage}%
\begin{minipage}{.2\textwidth}
your symbol here
\end{minipage}%
\begin{minipage}{.2\textwidth}
      \begin{tikzpicture}[node distance=5cm,auto,>=latex', scale = 0.75, transform shape]
      \coordinate (a1) [] {};
      \node[rectangle] (a) [draw,minimum width=4cm,minimum height=1cm, below of=a1,node distance=1.5cm] {};
      \coordinate[below=1cm of a] (b1)  {};

      \path[->] (a1) edge node {  $\alpha.\beta$ } (a);
      \path[->] (a) edge node {  $\delta$ } (b1);
      \end{tikzpicture}
\end{minipage}%
\end{center}

\end{document} 

答案2

正如 Sigur 所建议的,最好将两个部分放在同一个 tikzpicture 中。一种可能性是使用scopes。您可以将移位和特殊样式应用于每个范围。在下一个代码中,一旦我放置了两个图表,就很容易将符号放在它们之间。在这种情况下,我不得不更改第二个图片节点的名称。

\documentclass[border=3mm,tikz]{standalone}

\usetikzlibrary{matrix,arrows}

\usetikzlibrary{positioning,arrows}

\usetikzlibrary{shapes,arrows,fit,calc,positioning,automata}

\begin{document}

\begin{tikzpicture}[node distance=5cm,auto,>=latex', scale = 0.75, transform shape]

      \coordinate (a1) [] {};
      \node[rectangle] (a) [draw,minimum width=2cm,minimum height=1cm, below of=a1,node distance=1.5cm] { };
      \node[rectangle] (b) [draw,minimum width=2cm,minimum height=1cm, below of=a,node distance=2cm] { };
      \coordinate[below=1cm of b] (b1)  {};
      \path[->] (a)  edge node {{$\gamma$} } (b);
      \path[->] (a1) edge node {{$\alpha.\beta$} } (a);
      \path[->] (b)  edge node {{$\delta$} } (b1);
%\end{tikzpicture}

%      \begin{tikzpicture}[node distance=5cm,auto,>=latex', scale = 0.75, transform shape]
\begin{scope}[xshift=5cm]
      \coordinate (a1) [] {};
      \node[rectangle] (a2) [draw,minimum width=4cm,minimum height=1cm, below of=a1,node distance=1.5cm] {};
      \coordinate[below=1cm of a2] (b1)  {};

      \path[->] (a1) edge node {  $\alpha.\beta$ } (a2);
      \path[->] (a2) edge node {  $\delta$ } (b1);
\end{scope}
\path (a) -- node {$=$} (a2);
      \end{tikzpicture}

\end{document} 

在此处输入图片描述

答案3

另一个解决方案是使用 tikz

\documentclass{article}

\usepackage[margin=15mm]{geometry}
\usepackage{tikz}

\usetikzlibrary{arrows,positioning}

\begin{document}

\begin{center}
\hfill
\tikz[anchor=center,baseline] \node{
\begin{tikzpicture}[node distance=5cm,auto,>=latex', scale = 0.75, transform shape]
      \coordinate (a1) [] {};
      \node[rectangle] (a) [draw,minimum width=2cm,minimum height=1cm, below of=a1,node distance=1.5cm] { };
      \node[rectangle] (b) [draw,minimum width=2cm,minimum height=1cm, below of=a,node distance=2cm] { };
      \coordinate[below=1cm of b] (b1)  {};
      \path[->] (a)  edge node {{$\gamma$} } (b);
      \path[->] (a1) edge node {{$\alpha.\beta$} } (a);
      \path[->] (b)  edge node {{$\delta$} } (b1);
\end{tikzpicture}%
};\hfill
\begin{tikzpicture}[shift={(0.33\textwidth,0)},anchor=center,baseline]
\node{your symbol};
\end{tikzpicture}\hfill
\tikz[,anchor=center,baseline] \node{
\begin{tikzpicture}[shift={(0.66\textwidth,0)},node distance=5cm,auto,>=latex', scale = 0.75, transform shape,anchor=base,baseline]
      \coordinate (a1) [] {};
      \node[rectangle] (a) [draw,minimum width=4cm,minimum height=1cm, below of=a1,node distance=1.5cm] {};
      \coordinate[below=1cm of a] (b1)  {};

      \path[->] (a1) edge node {  $\alpha.\beta$ } (a);
      \path[->] (a) edge node {  $\delta$ } (b1);

\end{tikzpicture}%
};
\hfill ~
\end{center}

\end{document} 

这两个图形嵌入在\tikz \node 带有选项的[anchor=center,baseline]

在此处输入图片描述

相关内容