如何添加从矩阵到列向量的箭头?

如何添加从矩阵到列向量的箭头?

如果可能的话,我想知道该如何做到这一点。

在此处输入图片描述

谢谢。

这是我的代码:

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

答案1

我给每个单元格一个唯一的标签,如下所示:

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

tikzpicture如果我添加选项,则可以在新的中重复使用此标签remember picture。现在可以绘制箭头了。

在此处输入图片描述


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

相关内容