How to typeset a tilted matrix?

I need to typeset something like this for my homework. How to do it? I am sorry I don't have an MWE as I don't even know how to start. Also, I don't need the colorings inside. Just knowing how to typeset this would be enough.

• Is doing it in LaTeX part of the assignment? Or is the assignment the matrix and it doesn't matter how you do it? – cfr Oct 25 '15 at 16:28
• LaTeX is not the assignment. I have to typeset a similar matrix (not this one). We can type it anyway (latex, ms word, plain text whatever) but I prefer typing in LaTeX. The assignment is an algo assignment if it matters. – pratnala Oct 25 '15 at 16:32
• Thanks for clarifying. I just asked because if LaTeX was the assignment, it would be reasonable to get you started but we probably shouldn't provide a complete solution. If the assignment is the content rather than the typesetting, it is different. (Though it may be more reasonable in terms of the site's expectations to point you in the right direction - but that's a different issue.) – cfr Oct 25 '15 at 16:35
• Yes, the assignment is the content (not the one shown here, this is an example). How to get going? – pratnala Oct 25 '15 at 16:35

With a foreach would be better, but you can start with this one

\documentclass[a4paper,11pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning, shapes}

\begin{document}
\begin{tikzpicture}[mynode/.style={regular polygon, regular polygon sides=4,
minimum size=2cm, shape border rotate=45, draw}]

\node[mynode, label={135:1}, label={-90:$A_1$}] (00) {0};
\node[mynode, above right= -\pgflinewidth of 00, label={135:2}] (01)  {1500};
\node[mynode, above right= -\pgflinewidth of 01, label={135:3}, label={45:1}, label=90:$m$] (02)  {1000};

\node[mynode, below right= -\pgflinewidth of 01, fill=black!30,label={-90:$A_2$}] (10)  {1200};
\node[mynode, above right= -\pgflinewidth of 10] (10)  {1500};

\node[mynode, below right= -\pgflinewidth of 10, fill=black!20, label={-90:$A_3$}] (120)  {0};

\end{tikzpicture}
\end{document}


• Bit of a TeX noob here. I have this on the first line: \documentclass[a4paper,11pt]{article}. Should I replace that or can I just add the tikz line? – pratnala Oct 25 '15 at 17:15
• @pratnala I've updated the answer. With this code, you create a tikzpicture which will be like any other character although probably you want to include inside a figure. – Ignasi Oct 25 '15 at 17:25
• @Ignasi, is there special reason that part of some labels are enclosed with curly braces, for example label={135:1}? – Zarko Oct 25 '15 at 17:49
• @Zarko: No. I did it like this without thinking too much.But, in case you want to add options to any label you need to write like: label={[options]angle:label text} – Ignasi Oct 25 '15 at 18:15