For the following MWE, I would like to know how I can reduce the code by having two nested for loops.
\documentclass[border=10mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (A) [matrix of nodes,row sep=3mm,column sep=3mm,nodes in empty cells]
{
$a_{11}$ & $a_{12}$ & $a_{13}$ & $a_{14}$ & $a_{15}$ & $\dots$ \\
$a_{21}$ & $a_{22}$ & $a_{23}$ & $a_{24}$ & $a_{25}$ & \\
$a_{31}$ & $a_{32}$ & $a_{33}$ & $a_{34}$ & $a_{35}$ & \\
$a_{41}$ & $a_{42}$ & $a_{43}$ & $a_{44}$ & $a_{45}$ & \\
$a_{51}$ & $a_{52}$ & $a_{53}$ & $a_{54}$ & $a_{55}$ & \\
$\vdots$ & & & & & $\ddots$ \\
};
\end{tikzpicture}
\end{document}


\mytablecontentscontains? – Diaa Sep 25 '18 at 16:19&replaced by\&). – Sep 25 '18 at 16:23\show\mytablecontentswhich will tell you\mytablecontents=macro: ->$a_{11}$ \&$a_{12}$ \&$a_{13}$ \&$a_{14}$ \&$a_{15}$ \&$\cdots $\\$a_{21}$ \& $a_{22}$ \&$a_{23}$ \&$a_{24}$ \&$a_{25}$ \&\\$a_{31}$ \&$a_{32}$ \&$a_{33}$ \& $a_{34}$ \&$a_{35}$ \&\\$a_{41}$ \&$a_{42}$ \&$a_{43}$ \&$a_{44}$ \&$a_{45}$ \& \\$a_{51}$ \&$a_{52}$ \&$a_{53}$ \&$a_{54}$ \&$a_{55}$ \&\\and interrupt the compilation. Other ways to debug include\typeouts:\typeout{\mytablecontents}. – Sep 25 '18 at 17:29\newcommand*with\newcommand, the output doesn't differ. So, may I know why you chose\newcommand*? – Diaa Sep 25 '18 at 18:49*doesn't hurt either. Things will be different if you redo these tricks, in which case you may use\renewcommandin the next matrix. – Sep 25 '18 at 19:30