Block Matrices – Best Ways to Create Block Matrices in LaTeX

matricestablestikz-pgf

I am interested in doing something like the following:

enter image description here

I need to show the structure of several matrices, ignoring the actual values inside of each block, but naming (some of) them, like in the image. What would be the best way to go about it? I imagine tikz may be able to do it, but I don't know enough about it.

EDIT:

I have managed to do the following:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit}
\tikzset{%
  highlight/.style={rectangle,rounded corners,fill=blue!15,draw,fill opacity=0.5,thick,inner sep=0pt}
}
\newcommand{\tikzmark}[2]{\tikz[overlay,remember picture,baseline=(#1.base)] \node (#1) {#2};}
%
\newcommand{\Highlight}[1][submatrix]{%
    \tikz[overlay,remember picture]{
    \node[highlight,fit=(left.north west) (right.south east)] (#1) {};}
}

\begin{document}

  \[
  M = \left(\begin{array}{*5{c}}
    \tikzmark{left}{} &  &  &  & \\
     &  &  &  & \tikzmark{right}{} \\
     &  &  &  &  \\
     &  &  &  & 
  \end{array}\right)
  \Highlight[first]
  \qquad
  \begin{array}{*1{c}}
    
  \end{array}
\]

\end{document}

Which produces:

enter image description here

I cannot add another highlighted block, only the second one appears.

Best Answer

A code to start your learning with TiKZ matrices.

\documentclass[tikz, border=2mm]{standalone}

\begin{document}
\begin{tikzpicture}[
    mynode/.style={draw, fill=blue!30, minimum width=2cm, minimum height=1.5cm}]
    
\matrix[row sep=-\pgflinewidth, column sep=-\pgflinewidth,] (A) {
    \node[mynode]{$D_1$}; & \node[mynode]{$D_2$}; & \node{\dots}; & \node[mynode]{$D_n$};\\
    \node[mynode]{$F_1$};\\
     & \node[mynode]{$F_2$};\\
    & & \node{$\ddots$};\\
    & & &\node[mynode]{$F_n$};\\    
    };
\end{tikzpicture}
\end{document}

enter image description here