1

Recently, I have been confronted with the task to draw three matrices using Tikz and to arrange them in a certain way.

https://imgur.com/TzxtG6qThis is what the output should look like

I have drawn the matrices using the array function but this is not really what is asked from me. Also, I cannot really arrange them to look as in the output. Nevertheless, I am sending you the code that I have used so far:

[code]

\documentclass[12pt]{article}     
\usepackage[english]{babel}     
\usepackage[utf8x]{inputenc}     
\usepackage{amsmath}     
\usepackage{tikz} 

\begin{document} 

\[     
\begin{array}{r@{\,}l@{\,}l@{\,}l@{\,}l} 
    & 
\left(\begin{array}{cccc} 
   x_{ii}&x_{22}& \ldots&x_{1j} \\ 
   x_{22}& x_{22}& \ldots & x_{2j}\\ 
    \vdots& \vdots & \ddots & \vdots\\ 
    x_{i1} &x_{i2} & \ldots&  x_{ij} \\ 
    \vdots&\vdots& &\vdots\\
    x_{n1}& x_{n2}&\ldots& x_{nj}\\
        \end{array}\right) 

& =
\left(\begin{array}{cccc} 
    \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
    \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
    \vdots&\vdots& \ddots&\vdots\\
    \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
     \vdots&\vdots& \ldots&\vdots\\
    \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
 \end{array}\right) 

& +
\left(\begin{array}{cccc} 
   r_{11}&r_{12}&\ldots&r_{1j}\\
   r_{21}&r_{22}&\ldots& r_{2j}\\
   \vdots&\vdots& \ddots& \vdots\\
   r_{i1}&r_{i2}&\ldots& r_{ij}\\
   \vdots&\vdots&\ldots&\vdots\\
   r_{n1}&r_{n2}& \ldots& r_{nj}\\
 \end{array}\right) 
\end{array} 
\] 
\end{document}

[/code]

Thank you everyone already in advance

  • Plwase add picture of desired placement of matrices to your question. Your link is not accessible to all and it is likely be dead after while. – Zarko Jun 6 at 17:16
  • 1
    Crosspost on goLaTeX and LaTeX.org – Johannes_B Jun 6 at 18:58
3

This does something of that sort.

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning,matrix}
\begin{document}
\begin{tikzpicture}
 \matrix[matrix of math nodes,draw] (mat1) {
    x_{ii}&x_{22}& \ldots&x_{1j} \\ 
    x_{22}& x_{22}& \ldots & x_{2j}\\ 
     \vdots& \vdots & \ddots & \vdots\\ 
     x_{i1} &x_{i2} & \ldots&  x_{ij} \\ 
     \vdots&\vdots& &\vdots\\
     x_{n1}& x_{n2}&\ldots& x_{nj}\\
 };
 \foreach \X/\Y in {1/1,2/2,4/i,6/k} 
 {\node[right=1pt of mat1-\X-4]{$\ifnum\X<6\ldots\fi x_{\Y k}$};}
 \matrix[matrix of math nodes,below=3em of mat1,draw,xshift=-1em] (mat2) {
     \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
     \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
     \vdots&\vdots& \ddots&\vdots\\
     \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
      \vdots&\vdots& \ldots&\vdots\\
     \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
 };
 \node[anchor=west] at (mat2.south east){$\overline{x}\ldots$};
 \matrix[matrix of math nodes,right=4em of mat2,draw] (mat3) {
    r_{11}&r_{12}&\ldots&r_{1j}\\
    r_{21}&r_{22}&\ldots& r_{2j}\\
    \vdots&\vdots& \ddots& \vdots\\
    r_{i1}&r_{i2}&\ldots& r_{ij}\\
    \vdots&\vdots&\ldots&\vdots\\
    r_{n1}&r_{n2}& \ldots& r_{nj}\\
 };
 \foreach \X/\Y in {2/{A=B},3/{C=D}}
 {\draw[-latex] (mat1) -- (mat\X);
 \draw[-latex] (mat\X.south) -- ++ (0,-2em) node[below] (G\X) 
 {$\Y$};}
 \path (mat2) -- (mat3) node[midway]{$+$} (G2) -- (G3) node[midway,below=1.5em] (F) {$F$};
 \foreach \X/\Y in {2,3}
 {\draw[-latex] (G\X) -- (F);}
\end{tikzpicture}
\end{document}

enter image description here

  • your answer has worked for me. Thank you so much! – user174854 Jun 7 at 6:47
  • Just one quick question: Is it possible to add two different formulas to G^2_zw= .... and for G^2_w=... I am asking since when I try to add a formula, the same formula appears on both sides (G^2_zw and G^2_w). Thank you! – user174854 Jun 7 at 10:14
  • @HelenaPokrivka Sure. I edited the answer to make that easier. Now you only need to replace A=B and C=D by these formulae. – user121799 Jun 7 at 13:55
  • Thank you so so much!! – user174854 Jun 10 at 11:19

Your Answer

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