staircase table

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.

enter image description here

  • 4
    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:

enter image description here

Here is the code:


%usage: \LabGrid[colour]{CAPITAL letter for last row/column}
        \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};

% usage: \ChemGrid{comma separated list of chemicals}
      header/.style={rectangle,minimum width=2cm,minimum height=1cm}]
     \foreach \row [count=\r, remember=\r] in {#1} {
       \node[header] at (1.5,0.2-2*\r){\row};
       \foreach \chem [count=\c] in {#1} {
     \foreach \row [count=\c, remember=\c] in {#1} {
       \node[header] at (2*\c+1,-0.3-2*\r) {\row};



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



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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.