Expressing a block matrix using Kronecker product Let $A=[a_{ij}]$ be an $m \times m$ matrix  and $B$ be a $nm \times nm$ block diagonal matrix with diagonal blocks $B_i$, $i=1, \ldots, m$, $n \times n$ matrices. I want to express
$\left[
\begin{array}[cccc]
\\a_{11} B_1 & a_{12}B_1 & \cdots & a_{1m} B_1 \\
a_{21} B_2 & a_{22}B_2 & \cdots & a_{2m} B_2 \\
\vdots & \vdots & \vdots & \vdots\\
a_{m1} B_m & a_{m2}B_m & \cdots & a_{mm} B_m \\
\end{array}\right]_{mn \times mn}$
in a compact form, possibly in one shot using Kronecker products. Is it possible?
 A: Let $e_k$ be the $k$-th column vector of the standard basis of $\mathbb{R}^m$ and $I_n$ the $n \times n$ identity matrix. Thus we can write
$$ \sum_{k=1}^{m} (e_k \otimes I_n)((e_k^T A) \otimes B_k) \tag{1} $$
Lets see how we construct this expression.
The term $(e_k^T A)$ is just the $k$ row of $A$
$$ (e_k^T A) = \left[ \begin{matrix} a_{k1} & \cdots & a_{km} \end{matrix} \right]_{1 \times m} $$
Hence
$$ (e_k^T A) \otimes B_k = \left[ \begin{matrix} a_{k1}B_k & \cdots & a_{km}B_k \end{matrix} \right]_{n \times mn} $$
Then we use
$$ (e_k \otimes I_n) = \left[ \begin{matrix} 0 \\ \vdots \\ I_n \\ \vdots \\ 0 \end{matrix} \right]_{mn \times n} $$
to "immerse" $(e_k^T A) \otimes B_k$ as the $k$-th row of a $mn \times mn$ matrix
$$ (e_k \otimes I_n)((e_k^T A) \otimes B_k) =
\left[ \begin{matrix}
0 & \cdots & 0 \\
\vdots & \vdots & \vdots \\
a_{k1} B_k & \cdots & a_{km} B_k \\
\vdots & \vdots & \vdots \\
0 & \cdots & 0 \\
\end{matrix} \right]_{mn \times mn} $$
And then finnaly we add up all these $m$ matrices.
Now we can use the Kronecker product "mixed-product" property to simplify $(1)$ as
$$ \sum_{k=1}^{m} (e_k \otimes I_n)((e_k^T A) \otimes B_k) = \sum_{k=1}^{m} ((e_k e_k^T A) \otimes (I_n B_k)) = \sum_{k=1}^{m} (e_k e_k^T A) \otimes B_k \tag{2} $$
