0

I need to type only half triangular part of a chessboard with different coloring setting and label the rows and columns not by a,b,...;1,2,... but by other letters. More explicitly, I need to type something like the following figure but I couldn't find anyway to do this with any package. Are there any simple way to do this?

enter image description here

3

You can start from following code:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{matrix, positioning}

\begin{document}
\begin{tikzpicture}
\matrix (A) [matrix of nodes,
    nodes={draw, fill, minimum size=9mm}]
    {~&~&~&~&|[fill=white]|~&|[fill=white]|~&|[fill=white]|~\\
     &~&~&~&|[fill=white]|~&|[fill=white]|~&|[fill=white]|~\\
     &&~&~&|[fill=white]|~&|[fill=white]|~&|[fill=white]|~\\
     &&&~&~&~&~\\
     &&&&~&~&~\\
     &&&&&~&~\\
     &&&&&&~\\};
    \foreach \i [count=\ni from 4, count=\nj from 2] in {1,...,7}{ 
        \node[right=1mm of A-\i-7.east]{$a_{1\nj}$};
        \node[above=1mm of A-1-\i.north]{$a_{\ni(11)}$};
    }
\end{tikzpicture}
\end{document}

enter image description here

1

Just for fun, an alternative that fills the entries programmatically.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes,nodes in empty cells,column sep=-\pgflinewidth,row
sep=-3*\pgflinewidth,nodes={align=center,minimum width=4em,minimum height=4em,
/utils/exec=\ifnum\the\pgfmatrixcurrentcolumn<8
\ifnum\the\pgfmatrixcurrentrow>1 
 \ifnum\the\numexpr\pgfmatrixcurrentcolumn+1\relax>\the\numexpr\pgfmatrixcurrentrow-1\relax
  \ifnum\the\pgfmatrixcurrentcolumn>4
   \ifnum\the\pgfmatrixcurrentrow<5
    \tikzset{draw,fill=white}
   \else
    \tikzset{draw,fill}
   \fi
   \else
   \tikzset{draw,fill}
  \fi 
 \else
 \fi
\fi
\fi,
execute at begin node={\ifnum\the\pgfmatrixcurrentrow=1%
\ifnum\the\pgfmatrixcurrentcolumn<8% 
$a_{\the\numexpr\pgfmatrixcurrentcolumn+3\relax(11)}$%
\fi%
\else%
\ifnum\the\pgfmatrixcurrentcolumn=8% 
$a_{1\the\pgfmatrixcurrentrow}$%
\fi%
\fi%
}}] (mat)
 {& & & & & & &\\
 & & & & & & &\\
 & & & & & & &\\
 & & & & & & &\\
 & & & & & & &\\
 & & & & & & &\\
 & & & & & & &\\
 & & & & & & &\\
 };
\end{tikzpicture}
\end{document}

enter image description here

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.