6

I need to prepare several diagrams with latex and the closest match to what I need to do are these two diagrams, can anyone provide hints how to do them? I'm familiar with TikZ but these diagrams look like advance level to me. Can anyone suggest a package/plugin etc to implement something like this?

First

Second

4
  • If I had any idea where to start from to make something similar to that I would not be asking in the first place ... does it look like basic diagrams to you?
    – Giovanni Azua
    Aug 16, 2012 at 22:02
  • 2
    Use the TikZ package. Should not be too hard... two loops for the G_{x,y} entries, and afterwards some \draw[->] node_a -- node_b; for the arrows. The bottom diagrams should be even easier. Maybe you find some inspiration at texample.net/tikz/examples
    – phimuemue
    Aug 16, 2012 at 22:06
  • That's the thing, for me TikZ is a matter of finding an example that +/- closely match what I need, and if can't find it then I can't figure it just like that. TikZ is very powerful but complex too, and not very intuitive.
    – Giovanni Azua
    Aug 16, 2012 at 22:39
  • Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question.
    – Werner
    Aug 17, 2012 at 2:03

2 Answers 2

10

Here's some code for the second part:

\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage{bbding}
\usepackage{tikz}
\usetikzlibrary{calc,matrix,arrows}

\begin{document}

\newcommand\MyCross{\XSolid}

\begin{tikzpicture}[remember picture]
\begin{scope}
\matrix[matrix of nodes,column sep=-1mm] (mat1)
{
 \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 & \color{red}{\MyCross} & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 & & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 & & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
};
\draw[help lines] (mat1-4-2.north west) rectangle (mat1-5-7.south east);
\draw[-latex, shorten >=-3pt, shorten <=-3pt] (mat1-4-2) to[out=180,in=130] (mat1-5-2.160);
\node[anchor=south] at (mat1.north) {A};
\end{scope}
\begin{scope}[xshift=3.8cm]
\matrix[matrix of nodes,column sep=-1mm] (mat2)
{
 \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 &  & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 &  &  & \MyCross & \MyCross & \MyCross & \MyCross \\
 &  &  & \color{blue}{\MyCross} & \MyCross & \MyCross & \MyCross \\
 &  &  &  &  & \MyCross & \MyCross \\
 &  &  &  &  &  & \MyCross \\
};
\draw[help lines] (mat2-4-4.north west) rectangle (mat2-5-7.south east);
\node[anchor=south] at (mat2.north) {B};
\end{scope}
\begin{scope}[xshift=8cm]
\matrix[matrix of nodes,column sep=-1mm] (mat3)
{
 \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 &  & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 &  & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 &  & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
};
\draw[help lines] (mat3-1-4.north west) rectangle (mat3-7-5.south east);
\node[anchor=south] at (mat3.north) {A};
\end{scope}
\begin{scope}[xshift=11.8cm]
\matrix[matrix of nodes,column sep=-1mm] (mat4)
{
 \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 &  & \MyCross & \MyCross & \MyCross & \MyCross & \MyCross \\
 &  &  & \MyCross & \MyCross & \MyCross & \MyCross \\
 &  &  & \color{red}{\MyCross} & \MyCross & \MyCross & \MyCross \\
 &  &  &  &  & \MyCross & \MyCross \\
 &  &  &  &  &  & \MyCross \\
};
\draw[help lines] (mat4-1-4.north west) rectangle (mat4-5-5.south east);
\draw[-latex, shorten >=-3pt, shorten <=-3pt] (mat4-5-5) to[out=270,in=-40] (mat4-5-4.-80);
\node[anchor=south] at (mat4.north) {B};
\end{scope}
\draw ( $ (mat2-1-7)!.5!(mat3-1-1) + (0,0.5) $ ) -- +(0,-4.6);
\end{tikzpicture}

\end{document}

enter image description here

And here'ssome code for the first part (building on phimuemue's code):

\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[scale=1.5]
\foreach \x in {0,...,9} {
  \node at (\x-.35,-0.6) {$v_{\x}$};
}
\clip (-0.3,-1.3) rectangle (8.3,4.3);
\foreach \x in {0,...,8} {
  \foreach \y in {0,...,4} {
    \node at  (\x cm,\y cm) (g-\x-\y) {$G_{\x,\y}$};
  }
}
\foreach \y in {0,...,3} {
  \foreach \x in {0,...,8} {
    \draw[->,shorten <=2pt,shorten >=7pt] (g-\x-\y) -- +(0,20pt);
  }
}
\foreach \y in {0,...,4} {
  \foreach \x in {0,...,7} {
    \draw[->,shorten >=2pt,shorten >=7pt] (g-\x-\y) -- +(20pt,0);
  }
}
\foreach \y in {0,...,3} {
  \foreach \x in {1,...,8} {
    \draw[->] (\x-.3,\y+.3) -- (\x - .6, \y+.6);  
  }
}
\foreach \x in {0,...,11} {
  \draw[dashed,thick] (\x-4.35,5) -- (\x + .65, 0);
}
\end{tikzpicture}

\end{document}

enter image description here

4
  • Great nice! muchas gracias!
    – SkyWalker
    Aug 17, 2012 at 3:23
  • @GiovanniAzua ¡De nada! In some minutes I'll add some code for part one too ;-) Aug 17, 2012 at 3:24
  • @GiovanniAzua I've updated my answer. Aug 17, 2012 at 3:56
  • Estas escapao! un millon de gracias!
    – SkyWalker
    Aug 17, 2012 at 4:31
5

No complete working solution, but at least something to start with (for the first diagram, second ones should be simpler):

\begin{tikzpicture}[scale=1.2]
  \foreach \x in {0,...,8} {
    \foreach \y in {0,...,4} {
      \node at  (\x cm,\y cm) {$G_{\x,\y}$};
      \draw[->] (\x-.3,\y+.3) -- (\x - .6, \y+.6);
      \draw[->] (\x-.2,\y+.3) -- (\x - .2, \y+.6);
      \draw[->] (\x+.3,\y) -- (\x + .6, \y);
    }
  }
  \foreach \x in {0,...,7} {
    \draw[dashed,thick] (\x-1.35,5) -- (\x + 3.65, 0);
  }
\end{tikzpicture}

You must log in to answer this question.

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