5

If possible, I would like to know how to do this.

enter image description here

Thank you.

Here is my code:

\documentclass[11pt]{memoir}
\usepackage{tikz}


%%% GRAPHIQUE
\newcommand{\largeto}{\mbox{\LARGE${}\to{}$}}

\title{graphique}
\newcommand{\cellsize}{0.6}
\newcommand{\circlesize}{0.35}

\newcommand{\printwhitecell}[2][]{\node[draw=darkgray, semithick, fill=white, minimum width=\cellsize cm, minimum height=\cellsize cm] at #2 {#1};} 
\newcommand{\printblackcell}[1]{\node[draw=darkgray, semithick, fill=black, minimum width=\cellsize cm, minimum height=\cellsize cm] at #1 {};} 


\newcommand{\printcircle}[1]{\draw[gray, semithick, fill=gray] #1 circle (\circlesize cm/2);} 
\newcommand{\printcell}[2]{%
    \if#1w%
        \printwhitecell{#2}%
    \else%
        \if#1b%
            \printblackcell{#2}%
        \else%
            \if#1c%
                \printwhitecell{#2}%
                \printcircle{#2}%
            \else%
                \if#1C%
                    \printblackcell{#2}%
                    \printcircle{#2}%
                \else
                    \printwhitecell[#1]{#2}%
                \fi%
            \fi%
        \fi%
    \fi%
}

\newcommand{\printpetitvecteur}[2]{
    \begin{tikzpicture}[baseline=-1.16cm] 
    \foreach \line[count=\i] in #2 {
        \foreach \cell[count=\j] in \line {
            \printcell{\cell}{(\j*\cellsize,-\i*\cellsize)}
        }
        \xdef\width{\j}
    }
    \node at ({0.5*(\width+1)*\cellsize}, {(-\i -1)*\cellsize}) {#1};
    \end{tikzpicture}   
}

\begin{document}

\begin{center}
         $R0$ = 
        \printpetitvecteur{}{{
            {b,w,w},
            {b,b,w},
            {o,b,b}%  % 
             }} = %
            \printpetitvecteur{}{{
            {b},
            {b},
            {w}%  % 
         }}
            \printpetitvecteur{}{{
            {w},
            {b},
            {b}%  % 
         }}              
            \printpetitvecteur{}{{
            {w},
            {w},
            {b}%  % 
         }} \hspace{0.3cm}
\end{center}

\end{document}
5

I give every cell a unique label that looks like this:

<number_of_vector>x<number_of_cell_in_vector>
e.g. 1x1, 2x3, 4x1

This label can be reused in a new tikzpicture, if I add the remember picture option. Now it is possible to draw arrows.

enter image description here


\documentclass[11pt]{memoir}
\usepackage{tikz}


%%% GRAPHIQUE
\newcommand{\largeto}{\mbox{\LARGE${}\to{}$}}

% settings for tikz
\tikzstyle{every picture}+=[remember picture]
\usetikzlibrary{arrows}
\usetikzlibrary{calc}



\title{graphique}
\newcommand{\cellsize}{0.6}
\newcommand{\circlesize}{0.35}

% create counters
\newcounter{printvecteurcounter}
\newcounter{printcellcounter}

\setcounter{printvecteurcounter}{0}
\setcounter{printcellcounter}{0}
\newcommand{\nodenamesep}{x}

\newcommand{\cellname}{\theprintvecteurcounter\nodenamesep\theprintcellcounter}

\newcommand{\printwhitecell}[2][]{\node[draw=darkgray, semithick, fill=white, minimum width=\cellsize cm, minimum height=\cellsize cm](\cellname) at #2 {#1};}
\newcommand{\printblackcell}[1]{\node[draw=darkgray, semithick, fill=black, minimum width=\cellsize cm, minimum height=\cellsize cm](\cellname) at #1 {};}


\newcommand{\printcircle}[1]{\draw[gray, semithick, fill=gray] #1 circle (\circlesize cm/2);}
\newcommand{\printcell}[2]{%
    \stepcounter{printcellcounter}
    \if#1w%
        \printwhitecell{#2}%
    \else%
        \if#1b%
            \printblackcell{#2}%
        \else%
            \if#1c%
                \printwhitecell{#2}%
            \else%
                \if#1C%
                    \printblackcell{#2}%
                \else
                    \printwhitecell[#1]{#2}%
                \fi%
            \fi%
        \fi%
    \fi%
}

\newcommand{\printpetitvecteur}[2]{
    \stepcounter{printvecteurcounter}
    \setcounter{printcellcounter}{0}
    \begin{tikzpicture}[baseline=-1.16cm]
    \foreach \line[count=\i] in #2 {
        \foreach \cell[count=\j] in \line {
            \printcell{\cell}{(\j*\cellsize,-\i*\cellsize)}
        }
        \xdef\width{\j}
    }
    \node at ({0.5*(\width+1)*\cellsize}, {(-\i -1)*\cellsize}) {#1};

    \end{tikzpicture}
}

\begin{document}

\begin{center}
         $R0$ =
        \printpetitvecteur{}{{
            {b,w,w},
            {b,b,w},
            {o,b,b}%  %
             }} = %
            \printpetitvecteur{}{{
            {b},
            {b},
            {w}%  %
         }}
            \printpetitvecteur{}{{
            {w},
            {b},
            {b}%  %
         }}
            \printpetitvecteur{}{{
            {w},
            {w},
            {b}%  %
         }} \hspace{0.3cm}
\end{center}

% draw the arrows
\begin{tikzpicture}[overlay]
\draw [->, thick] ($(1x1.north) + (0, 0.1cm)$) to [out=30,in=150] ($(2x1.north) + (0, 0.1cm)$);
\draw [->, thick] ($(1x2.north) + (0, 0.1cm)$) to [out=30,in=150] ($(3x1.north) + (0, 0.1cm)$);
\draw [->, thick] ($(1x3.north) + (0, 0.1cm)$) to [out=30,in=150] ($(4x1.north) + (0, 0.1cm)$);
\end{tikzpicture}

\end{document}

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.