TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to draw a table similar to this

\begin{tabular}{ c | c | c}
$\bigcirc$ &  &  \\ \hline
   & $\bigcirc$ &  \\ \hline
   &  & $\bigcirc$ \\

for the subject of matrix ball construction, but for this I need to put more than one ball in a cell, and they cannot just be listed in a horizontal line (supposed to be in a NW to SE diagonal). Also the balls will need to be filled with numbers for later in the theory, any help with this will be very much appreciated! *edit; realised that the number filling problem can be solved with tikz

share|improve this question
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it). – Kurt Feb 21 '13 at 1:45
up vote 6 down vote accepted

This looks like a job for TikZ. I'm sure this can be improved on, but it should be enough to get you started.

% First a command to make the grid
\draw (1,1) -- (1,4);
\draw (2,1) -- (2,4);
\draw (0,2) -- (3.,2);
\draw (0,3) -- (3,3);
% now set some parameters for the nodes
\tikzset{ball node/.style={draw,circle,inner sep=.1em,minimum size=2.5ex}}

% now define two commands for a single or double node
% the placement of the nodes is based on a (0,1) .. (2,3)
% coordinate system starting at the bottom left corner.
% This could probably be made more user friendly.
% Note that this uses plain TeX delimited commands.
% Syntax is \single(x,y){<number>} or \double(x,y){<num1>}{<num2>}
% I'm assuming a maximum 2 numbers per cell always in the same orientation.

\def\single(#1,#2)#3{\node[ball node] (A) at (#1.5,#2.5) {#3};}
\def\double(#1,#2)#3#4{\node[ball node](A) at (#1.25,#2.75) {#3};
                       \node[ball node] (B) at (#1.75,#2.25) {#4};}


% now we draw a matrix with some cells filled in

% The next part is just for reference of the coordinate system
\node (A) at (1.5,0) {The grid coordinate system};
\foreach \x in {0,1,2}
    \foreach \y in {1,2,3}



output of code

share|improve this answer
This is perfect thanks for the help – rskmacdonald Feb 21 '13 at 9:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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