2

I am drawing two tikzpictures side by side as follows:

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

How can I draw a vertical black line the full height between the two?

2 Answers 2

4

I build everything in one tikzpicture environment. The two diagrams being identical (except for the direction of the arrow), I simply put each diagram in a scope environment by giving them the name of fig 1 and fig 2. The second one is shifted to the right.

\begin{scope}[local bounding box=fig 1]
\begin{scope}[xshift=5cm,local bounding box=fig 2]

To draw a line right in between, I calculate the line that passes right in between.

\draw ($(fig 1.north east)!.5!(fig 2.north west)$) --($(fig 1.south east)!.5!(fig 2.south west)$);

screenshot

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

You can insert the two tikz pictures inside a tabular:

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

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .