1

How would I draw this (Ferrers diagram) in tikz?

enter image description here

1
  • In the examples I saw, parts with different number of rows are not equalized in height.
    – egreg
    May 21, 2020 at 16:47

2 Answers 2

3

Welcome! This is one way.

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[scale=0.7]
 \fill foreach \Z [count=\Y] in {6,3,3,2,1}
  {foreach \X in {1,...,\Z} 
  {(\X,-\Y) circle[radius=3pt]}};
 \fill[xshift=8cm] foreach \Z [count=\Y] in {5,4,3,1,1}
  {foreach \X in {1,...,\Z} 
  {(\X,-\Y) circle[radius=3pt]}};
\end{tikzpicture}
\end{document}

enter image description here

2

This reproduces the diagram you show.

\documentclass{article}

\newenvironment{ferrers}[1][4em]
 {%
  \leavevmode
  \hbox\bgroup
    \def\\{\unskip\cr\noalign{\hskip#1}}%
    \valign\bgroup&##\cr
 }
 {%
  \unskip\crcr\egroup
  \egroup
 }

\newcommand{\row}[1]{%
  \hbox{$\activatem\romannumeral\number\number#1 000 \unskip$}\vskip 0.5em plus 3em
}
\newcommand{\activatem}{%
  \begingroup\lccode`~=`m \lowercase{\endgroup\def~}{\bullet\hskip1em}%
  \mathcode`m="8000
}

\begin{document}

\begin{ferrers}
\row{6}
\row{3}
\row{3}
\row{2}
\row{1}
\\
\row{5}
\row{4}
\row{3}
\row{1}
\row{1}
\row{1}
\end{ferrers}

\end{document}

New lines and spaces in the ferrers environment are irrelevant, so you can also input the same as

\begin{ferrers}
\row{6} \row{3} \row{3} \row{2} \row{1} \\
\row{5} \row{4} \row{3} \row{1} \row{1} \row{1}
\end{ferrers}

enter image description here

A version that doesn't equalize the two parts.

\documentclass{article}

\newenvironment{ferrers}[1][4em]
 {%
  \leavevmode
  %\begin{tabular}{@{}c@{}}
  \hbox\bgroup
    \def\\{\unskip\vfill\cr\noalign{\hskip#1}}%
    \valign\bgroup&##\cr
 }
 {%
  \unskip\vfill\crcr\egroup
  \egroup
  %\end{tabular}
 }

\newcommand{\row}[1]{%
  \hbox{$\activatem\romannumeral\number\number#1 000 \unskip$}\vskip 0.5em
}
\newcommand{\activatem}{%
  \begingroup\lccode`~=`m \lowercase{\endgroup\def~}{\bullet\hskip1em}%
  \mathcode`m="8000
}

\begin{document}

\begin{ferrers}
\row{6}
\row{3}
\row{3}
\row{2}
\row{1}
\\
\row{5}
\row{4}
\row{3}
\row{1}
\row{1}
\row{1}
\end{ferrers}

\end{document}

enter image description here

In both version you can use \begin{ferrers}[6em] (with whatever length) to set the space between the parts (default is 4em).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .