# Staircase table with TiKz

I would like to make a table with the following staircase pattern (preferably with TiKz). In addition for each of the cells there should be a mini-box. The minibox has further data such as a pH level while the main box has a solubility (s) or in soluable.

• Could you please show us what you've tried so far (minimal, compilable code example; MWE). – TeXnician Oct 16 '17 at 17:13

These are both fun exercises in using \foreach. The macros \LabGrid and \ChemGrid, defined below, both accept a variable number of rows/columns and \LabGrid has an optional argument for the colour. The MWE below produces:

Here is the code:

\documentclass{article}
\usepackage{tikz}

%usage: \LabGrid[colour]{CAPITAL letter for last row/column}
\newcommand\LabGrid[2][purple]{%
\begin{tikzpicture}[xscale=1]
\foreach \row [count=\r,remember=\r] in {A,...,#2} {
\draw[fill=#1!10!white](0,-\r) rectangle ++(2,1);
\node at (1,0.5-\r){$\row$};
\foreach \c in {1,...,\r} {
\draw[thick](2*\c,-\r) rectangle ++(2,1);
}
}
\draw[fill=#1!10!white](0,-1-\r) rectangle ++(2,1);
\foreach \row [count=\c] in {A,...,#2} {
\draw[fill=#1!10!white](2*\c,-1-\r) rectangle ++(2,1);
\node at (2*\c+1,-0.5-\r) {\row};
}
\end{tikzpicture}%
}

% usage: \ChemGrid{comma separated list of chemicals}
\newcommand\ChemGrid[1]{%
\begin{tikzpicture}[xscale=1.8,
\foreach \row [count=\r, remember=\r] in {#1} {
\draw(1,-2*\r)rectangle++(1,2);
\foreach \chem [count=\c] in {#1} {
\draw[thick](2*\c,-2*\r)--++(2,0)--++(0,2);
\draw(2*\c+1,2-2*\r)--++(0,-1)--++(1,0);
}
}
\foreach \row [count=\c, remember=\c] in {#1} {
\draw(2*\c,-0.5-2*\r)--++(0,0.5);
}
\draw(2*\c+2,-0.5-2*\r)--++(0,0.5);
\end{tikzpicture}
}
\begin{document}

\LabGrid{C}\bigskip

\LabGrid[green]{E}\bigskip

\ChemGrid{NH$_4$O$_2$, BACl$_2$, CuSo$_4$}

\end{document}


Edit

I realised that the nodes did not scale with xscale and yscale. I have fixed this.

As shown, the easiest way to fine-tune the sizes of the boxes is by setting xscale and yscale in the tikzpicture environment.