我正在并排绘制两个 tikzpictures,如下所示:
\documentclass[standalone]{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, shadows}
\usepackage{default}
\begin{document}
\begin{frame}
\begin{center}
\begin{tikzpicture}[scale=0.6]
\node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (1) at (2.5,-1.5) {1};
\node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (2) at (1,-3) {2};
\path (1) edge [->] node {} (2);
\end{tikzpicture}
\hspace{1cm}
\vspace{-1cm}
\begin{tikzpicture}[scale=0.6]
\node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (2) at (2,1) {1};
\node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (1) at (0.5, -0.5) {2};
\path (1) edge [->] node {} (2);
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
我怎样才能在两者之间画一条垂直的黑线?
答案1
我在一个tikzpicture
环境中构建了所有内容。两个图完全相同(箭头方向除外),我只需将每个图表放入一个scope
环境中,并赋予它们名称fig 1
和fig 2
。第二个向右移动。
\begin{scope}[local bounding box=fig 1]
\begin{scope}[xshift=5cm,local bounding box=fig 2]
为了在两者之间画一条线,我计算了穿过两者的线。
\draw ($(fig 1.north east)!.5!(fig 2.north west)$) --($(fig 1.south east)!.5!(fig 2.south west)$);
\documentclass[standalone]{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, shadows,calc}
%\usepackage{default}
\begin{document}
\begin{frame}
\begin{center}
\begin{tikzpicture}[scale=0.6]
\begin{scope}[local bounding box=fig 1]
\node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (1) at (2.5,-1.5) {1};
\node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (2) at (1,-3) {2};
\path (1) edge [->] node {} (2);
\end{scope}
% \end{tikzpicture}
% \hspace{1cm}
% \vspace{-1cm}
% \begin{tikzpicture}[scale=0.6]
\begin{scope}[xshift=5cm,local bounding box=fig 2]
\node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (1) at (2.5,-1.5) {1};
\node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (2) at (1,-3) {2};
\path (1) edge [<-] node {} (2);
\end{scope}
\draw ($(fig 1.north east)!.5!(fig 2.north west)$) --($(fig 1.south east)!.5!(fig 2.south west)$);
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
答案2
您可以在表格中插入两个 tikz 图片:
\documentclass[standalone]{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, shadows}
%\usepackage{default}
\begin{document}
\begin{frame}
\begin{center}
\begin{tabular}{c@{\quad}|@{\quad}c}
\begin{tikzpicture}[scale=0.6]
\node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (1) at (2.5,-1.5) {1};
\node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (2) at (1,-3) {2};
\path (1) edge [->] node {} (2);
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.6]
\node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (2) at (2,1) {1};
\node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (1) at (0.5, -0.5) {2};
\path (1) edge [->] node {} (2);
\end{tikzpicture}
\end{tabular}
\end{center}
\end{frame}
\end{document}