I found this code from Creating a fraction graph in TikZ and would like to modify it so that it fills an entire page. The goal is to create a coloured sheet handout with the fraction strips in diagram that fills the page. The truth is, I don't understand the code that was used to make the diagram so I am unsure how to modify it to fill the page.

\usepackage{amsmath, tikz}

    % #1 = optional height
    \draw (0,0) rectangle (#2,#1) node [midway] {1};

    \foreach \Size/\Options in {#3} {%
        \draw  (0,-\YCoord) rectangle (#2,-\YCoord+#1);
         \foreach \x in {1,...,\Size} {%
            \draw [fill=\Options]  ($(\Xcoord-\Xincrement,-\YCoord)$)  rectangle ($(\Xcoord,-\YCoord+#1)$);
            \node at ($(\XcoordLabel,-\YCoord+0.5*#1)$) {$\frac{1}{\Size}$};

I see how there is an optional height but not sure what it does.

The goal is to create something like the following image of fraction strips. fraction strips image

1 Answer 1


Here is a somewhat simpler approach. \fracgraph takes two arguments, one optional. The required argument is a comma-separated list of positive integers and colors. The optional argument is the height of each row (default=1cm). The spacing between each row is 25% of the height. You can change that by adjusting the 1.25 factor in -1.25*\m*#1. So in the code below, if you wanted rows of height 1.5cm instead of 1cm, just use the optional argument:


enter image description here

Here is the code:



    \foreach \n/\c[count=\m] in {#2}{
        \foreach \k in {1,...,\n}{
            \node[draw, fill=\c, minimum height=#1, minimum width=\textwidth/\n] 
                at ({\textwidth/\n*(\k-.5)},-1.25*\m*#1){$\frac{1}{\n}$};}}




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.