The following code creates the graphic below (credit to @Schrödinger's cat):

        matrix of nodes,
        nodes in empty cells,
        column sep=-\pgflinewidth,
            minimum size=1.6em,
            node contents=\the\pgfmatrixcurrentcolumn,

\draw[->, shorten > =5pt, shorten <=5pt] (a-1-3.center)--(a-1-4.center);
\draw[->, shorten > =5pt, shorten <=5pt] (a-1-4.center)--(a-1-5.center);

enter image description here

How could I use this code to create and save as PNG this kind of images in bulk, varying the numbers inside the boxes?

Within each image, the numbers inside the boxes varies from X to X+9. And for each image X is a single integer from 1 to 1000. So I would end up with 1000 different images. Thanks

  • 1
    LaTeX-related programs are not made for PNG output. You could use other conversion tools e.g. inkscape to do that
    – BambOo
    Commented May 21, 2020 at 19:42

1 Answer 1


I hope to read your question correctly. When I compile

\documentclass[tikz,border=3mm,png, convert={
        density = 300,
        convertexe = {convert},
\foreach \Y in {1,...,100}
 \path coordinate (aux) foreach \X in {1,...,10}
  {node[anchor=west,minimum size={1.2*width("1000")},draw,
  label={[name=l-\Y-\X,inner sep=0.25pt]center:{$\the\numexpr10*\Y+\X$}}] 
  (aux) at (aux.east){}}
  foreach \X in {3,4}
  {(l-\Y-\X) edge[semithick,-stealth] (l-\Y-\the\numexpr\X+1)};

with pdflatex -shell-escape on my machine, I get 100 png files. I stress my machine because this relies on the convert command that I have installed on my machine, i.e. as @BambOo is saying we need to rely on external tools at some level. Unfortunately I am not very well versed with all these external tools, so in case this does not work I would not know how to change the conversion command. Threads like this one may shed more light on this.

You must log in to answer this question.

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