
저는 이 예제를 2008년에 만들었고 컴파일했습니다(texample.net).
코드를 다시 컴파일하려고 했지만 성공하지 못했으며 오류를 찾을 수 없습니다.
이제 일부 노드가 정의되지 않았습니다. 문제가 있는 줄에 댓글을 달았습니다.
\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\begin{document}
% l' unite
\newcommand{\myunit}{1 cm}
\tikzset{
node style sp/.style={draw,circle,minimum size=\myunit},
node style ge/.style={circle,minimum size=\myunit},
arrow style mul/.style={draw,sloped,midway,fill=white},
arrow style plus/.style={midway,sloped,fill=white},
}
\begin{tikzpicture}[>=latex]
% les matrices
\matrix (A) [matrix of math nodes,%
nodes = {node style ge},%
left delimiter = (,%
right delimiter = )] at (0,0)
{%
a_{11} & a_{12} & \ldots & a_{1p} \\
\node[node style sp] {a_{21}};%
& \node[node style sp] {a_{22}};%
& \ldots%
& \node[node style sp] {a_{2p}}; \\
\vdots & \vdots & \ddots & \vdots \\
a_{n1} & a_{n2} & \ldots & a_{np} \\
};
\node [draw,below=10pt] at (A.south)
{ $A$ : \textcolor{red}{$n$ rows} $p$ columns};
\matrix (B) [matrix of math nodes,%
nodes = {node style ge},%
left delimiter = (,%
right delimiter =)] at (6*\myunit,6*\myunit)
{%
b_{11} & \node[node style sp] {b_{12}};%
& \ldots & b_{1q} \\
b_{21} & \node[node style sp] {b_{22}};%
& \ldots & b_{2q} \\
\vdots & \vdots & \ddots & \vdots \\
b_{p1} & \node[node style sp] {b_{p2}};%
& \ldots & b_{pq} \\
};
\node [draw,above=10pt] at (B.north)
{ $B$ : $p$ rows \textcolor{red}{$q$ columns}};
% matrice résultat
\matrix (C) [matrix of math nodes,%
nodes = {node style ge},%
left delimiter = (,%
right delimiter = )] at (6*\myunit,0)
{%
c_{11} & c_{12} & \ldots & c_{1q} \\
c_{21} & \node[node style sp,red] {c_{22}};%
& \ldots & c_{2q} \\
\vdots & \vdots & \ddots & \vdots \\
c_{n1} & c_{n2} & \ldots & c_{nq} \\
};
% les fleches
% \draw[blue] (A-2-1.north) -- (C-2-2.north);
% \draw[blue] (A-2-1.south) -- (C-2-2.south);
% \draw[blue] (B-1-2.west) -- (C-2-2.west);
% \draw[blue] (B-1-2.east) -- (C-2-2.east);
% \draw[<->,red](A-2-1) to[in=180,out=90]
% node[arrow style mul] (x) {$a_{21}\times b_{12}$} (B-1-2);
% \draw[<->,red](A-2-2) to[in=180,out=90]
% node[arrow style mul] (y) {$a_{22}\times b_{22}$} (B-2-2);
% \draw[<->,red](A-2-4) to[in=180,out=90]
% node[arrow style mul] (z) {$a_{2p}\times b_{p2}$} (B-4-2);
% \draw[red,->] (x) to node[arrow style plus] {$+$} (y)%
% to node[arrow style plus] {$+\raisebox{.5ex}{\ldots}+$} (z)%
% to (C-2-2.north west);
\node [draw,below=10pt] at (C.south)
{$ C=A\times B$ : \textcolor{red}{$n$ rows} \textcolor{red}{$q$ columns}};
\end{tikzpicture}
\end{document}
이제 나는 얻는다
첫 번째 줄에 주석을 달았습니다.
Latex Error: ./matrix-multiplication.tex:66 Package pgf Error: No shape named `A-2-1' is known.
Latex Error: ./matrix-multiplication.tex:66 Package pgf Error: No shape named `C-2-2' is known.
2008 년에
답변1
또는 \node
에 명령을 넣는 것이 실제로 지원되는지 잘 모르겠습니다 . 어쨌든 노드에 스타일을 부여하는 데 사용하는 것 같습니다. 더 간단한 방법이 있습니다. 대신에matrix of nodes
matrix of math nodes
\node[node style sp] {a_{22}};
그냥 말해
|[node style sp]| a_{22}
이는 현재 매뉴얼(v3.1.5)에 문서화된 방법이며 작동합니다.
\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\begin{document}
% l' unite
\newcommand{\myunit}{1 cm}
\tikzset{
node style sp/.style={draw,circle,minimum size=\myunit},
node style ge/.style={circle,minimum size=\myunit},
arrow style mul/.style={draw,sloped,midway,fill=white},
arrow style plus/.style={midway,sloped,fill=white},
}
\begin{tikzpicture}[>=latex]
% les matrices
\matrix (A) [matrix of math nodes,%
nodes = {node style ge},%
left delimiter = (,%
right delimiter = )] at (0,0)
{%
a_{11} & a_{12} & \ldots & a_{1p} \\
|[node style sp]| a_{21}%
& |[node style sp]| a_{22}%
& \ldots%
& |[node style sp]| a_{2p} \\
\vdots & \vdots & \ddots & \vdots \\
a_{n1} & a_{n2} & \ldots & a_{np} \\
};
\node [draw,below=10pt] at (A.south)
{ $A$ : \textcolor{red}{$n$ rows} $p$ columns};
\matrix (B) [matrix of math nodes,%
nodes = {node style ge},%
left delimiter = (,%
right delimiter =)] at (6*\myunit,6*\myunit)
{%
b_{11} & |[node style sp]| b_{12}%
& \ldots & b_{1q} \\
b_{21} & |[node style sp]| b_{22}%
& \ldots & b_{2q} \\
\vdots & \vdots & \ddots & \vdots \\
b_{p1} & |[node style sp]| b_{p2}%
& \ldots & b_{pq} \\
};
\node [draw,above=10pt] at (B.north)
{ $B$ : $p$ rows \textcolor{red}{$q$ columns}};
% matrice résultat
\matrix (C) [matrix of math nodes,%
nodes = {node style ge},%
left delimiter = (,%
right delimiter = )] at (6*\myunit,0)
{%
c_{11} & c_{12} & \ldots & c_{1q} \\
c_{21} & |[node style sp,red]| c_{22}%
& \ldots & c_{2q} \\
\vdots & \vdots & \ddots & \vdots \\
c_{n1} & c_{n2} & \ldots & c_{nq} \\
};
% les fleches
\draw[blue] (A-2-1.north) -- (C-2-2.north);
\draw[blue] (A-2-1.south) -- (C-2-2.south);
\draw[blue] (B-1-2.west) -- (C-2-2.west);
\draw[blue] (B-1-2.east) -- (C-2-2.east);
\draw[<->,red](A-2-1) to[in=180,out=90]
node[arrow style mul] (x) {$a_{21}\times b_{12}$} (B-1-2);
\draw[<->,red](A-2-2) to[in=180,out=90]
node[arrow style mul] (y) {$a_{22}\times b_{22}$} (B-2-2);
\draw[<->,red](A-2-4) to[in=180,out=90]
node[arrow style mul] (z) {$a_{2p}\times b_{p2}$} (B-4-2);
\draw[red,->] (x) to node[arrow style plus] {$+$} (y)%
to node[arrow style plus] {$+\raisebox{.5ex}{\ldots}+$} (z)%
to (C-2-2.north west);
\node [draw,below=10pt] at (C.south)
{$ C=A\times B$ : \textcolor{red}{$n$ rows} \textcolor{red}{$q$ columns}};
\end{tikzpicture}
\end{document}