6

I'm trying to recreate the following figure in latex:

enter image description here

Now, I dont have a lot of a problem with one of them:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,backgrounds}

\usepackage[utf8]{inputenc} %utf-8 encoding
\usepackage{amssymb} %math symbols

\begin{document}

\begin{frame}
\begin{tikzpicture}[align=center,node distance=1cm]
\tikzstyle{vertex}=[circle,draw=black]
\tikzstyle{fluct}=[dotted]

\node[vertex] (v0) {};
\node[vertex] (v1) [right of = v0] {};
\node[vertex] (v2) [right of = v1] {};
\node[vertex] (v3) [below of = v0] {};
\node[vertex] (v4) [right of = v3] {};
\node[vertex] (v5) [right of = v4] {};

\node () [above of = v1] {Una realización};

\path[every node] 
  (v0) edge [] (v1)
  (v0) edge [] (v3)
  (v1) edge [] (v4)
  (v1) edge [fluct] (v2)
  (v2) edge [] (v5)
  (v4) edge [fluct] (v5);
\end{tikzpicture}
\end{frame}
\end{document}

But not sure how to create the rest. I was thinking about copying and pasting them in a table. But multirow seems to not work giving a compilation error:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,backgrounds}

\usepackage[utf8]{inputenc} %utf-8 encoding
\usepackage{amssymb} %math symbols

\begin{document}

\begin{frame}
\begin{figure}

\begin{tabular}{cc}

\multirow{4}{*} {

\begin{tikzpicture}[align=center,node distance=1cm]
\tikzstyle{vertex}=[circle,draw=black]
\tikzstyle{fluct}=[dotted]

\node[vertex] (v0) {};
\node[vertex] (v1) [right of = v0] {};
\node[vertex] (v2) [right of = v1] {};
\node[vertex] (v3) [below of = v0] {};
\node[vertex] (v4) [right of = v3] {};
\node[vertex] (v5) [right of = v4] {};

\node () [above of = v1] {Una realización};

\path[every node] 
  (v0) edge [] (v1)
  (v0) edge [] (v3)
  (v1) edge [] (v4)
  (v1) edge [fluct] (v2)
  (v2) edge [] (v5)
  (v4) edge [fluct] (v5);
\end{tikzpicture}

}
\\
& a \\ & b \\ & c \\ & d
\end{tabular}
\end{figure}
\end{frame}
\end{document}

Doing it all in one image makes me cringe because I have to number nodes manually again. How should I solve this problem?

  • Welcome to TeX.SX!! It is better to post a full minimal working example that starts with a \documentclass command, has a minimal preamble and then \begin{document}...\end{document}. Unless the problem is a compilation error, the code should compile and be as small as possible to demonstrate your problem. This makes it much easier for people to help you --- and much ore likely that they will! – Andrew Feb 5 '16 at 7:24
  • 1
    Two comments. First, take a look at Should \tikzset or \tikzstyle be used to define TikZ styles?, and second your code doesn't works because you used a frame environment inside an article class. – Ignasi Feb 5 '16 at 10:53
  • Thanks for the link, the documentation I was reading all had that syntax, I'll read the other one. That particular document started as a presentation then I changed it to an article, that's the reason of the mixup. But it does compile over here, though. – clicea Feb 5 '16 at 18:32
  • Sorry for the double post, just to clarify, I was reading a manual for version 1! – clicea Feb 5 '16 at 19:08
4

If you want to repeat some tikzpicture or part of it, pics are a good option. Following code shows how to use them. A pic is declared to draw your original graph, and this pic is used inside several tikzpictures distributed within a tabular where fisrt column is a multirow.

As you can see, array pic only draws part of the graph which can be completed with labels or adding some more interconnection lines in each particular picture. As pic can have a name, you can later on use these names to draw some connections between them.

\documentclass{article}
\usepackage{multirow}
\usepackage{tikz}
\usetikzlibrary{arrows,backgrounds,matrix, positioning}

\usepackage[utf8]{inputenc} %utf-8 encoding
\usepackage{amssymb} %math symbols

\tikzset{
    vertex/.style={circle, fill=black},
    fluct/.style=dotted,
    array/.pic = {
        \foreach \i [count=\row] in {0,1}
            \foreach \j [count=\col] in {0,1,2,3}
                \node[vertex] (\row\col) at (\col,-\row) {};
        \draw (21)|-(13)|-(24)--(14);
        \draw (22)--(12);
    }
}
\begin{document}

\begin{tabular}{cc}

\multirow{4}{*}[-1cm]{%
\begin{tikzpicture}[remember picture]
\pic (A) {array};
\path (A11) -- (A14) node[midway,above=3mm] {Una realización};
\draw[fluct] (A13)--(A14);
\end{tikzpicture}}
&
\begin{tikzpicture}[remember picture]
\pic (B) {array};
\path (B11) -- (B21) node[midway,left=3mm] {Una realización};
\draw[fluct] (B21)--(B22);
\end{tikzpicture}
\\
&
\begin{tikzpicture}[remember picture]
\pic (C) {array};
\path (C11) -- (C21) node[midway,left=3mm] {Una realización};
\draw[fluct] (C22)--(C23);
\end{tikzpicture}
\\
&
\begin{tikzpicture}[remember picture]
\pic (D) {array};
\path (D11) -- (D21) node[midway,left=3mm] {Una realización};
\draw[fluct] (D21)--(D23);
\end{tikzpicture}
\\
&
\begin{tikzpicture}[remember picture]
\pic (E) {array};
\path (E11) -- (E21) node[midway,left=3mm] {Una realización};
\end{tikzpicture}
\end{tabular}

\tikz[remember picture, overlay] \draw[red,thick,->] (A12) to[out=30, in=60] (B13);
\end{document}

enter image description here

  • 2
    I'm not sure \multirow is necessary: just use a tabular next to the picture on the left. – egreg Feb 5 '16 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.