TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

My daughter needs to train her eyesight in accordance to the LEA eyesight chart tests.

I have manually created a new chart for her, but it really takes a long time randomzing the four icons and manually aligning them:

The chart as I have it now

I was thinking about automating the process using LaTeX. I have all four icons as separate PDFs (also any other vector format can be derived from that, of course). Would anyone care to help me with this, as I assume it is rather more a "programming LaTeX" then "writing in LaTeX" task ;) I'd be very happy to share the result with a good friend of mine who is a pediatrician as I assume it might help others, too (they give out copies of an old copy of a fax someone received back in the 80's... - not very clean and not much help, either).

If someone could help me I'd be extremely grateful. The distance between each line and the decrease in size can be guessed but should be alterable.

share|improve this question
Welcome to TeX.sx! You don't have to sign with your name since it automatically appears in the lower right corner of your post. – Werner Feb 24 '12 at 16:47
Thanks for the note; it's something I do as a matter of habit since the dawn of electronic communication ;) – Christian Feb 24 '12 at 19:03
We'd like to keep answers separate from questions, so you should write a separate answer instead of editing your answer into the question. Self-answers are perfectly admissible, and a well-written answer may earn you additional reputation. – Joseph Wright Feb 24 '12 at 22:09
Err... clicking "Answer your Question" does - nothing?! Chrome dev, Mac OS X 10.7, Adblock. Any ideas at such an early hour? – Christian Feb 25 '12 at 7:35
up vote 9 down vote accepted

One way to accomplish this is to use pgfmathdeclarerandomlist{<list name>}{{order 1}{order 2}...{order 24}} to specify all the possible combinations of the pictures, and then use \pgfmathrandomitem to randomly pick one of these and use that as the order of the pictures.

The images are placed in a table with \TableRow{<scale>}, where the <scale> specifies the scale to be applied to the images in that row.

enter image description here


  • To increase the spacing between the rows you can include a size at the end of each row. For example: \\[0.3cm].

Further Enhancements:

  • The array of possible combinations should be auto generated.


For this to work I saved the images as 1.png, 2.png, 3.png, 4.png in the directory where I had this .tex file.


% All possible combination of pictures
% Listed here in increasing numerical order for convenience
    {1234} {2134} {3124} {4123}
    {1243} {2143} {3142} {4132}
    {1324} {2314} {3214} {4213}
    {1342} {2341} {3241} {4232}
    {1423} {2413} {3412} {4312}
    {1432} {2431} {3421} {4321}

\newcommand{\MaxWidth}{2.0}%  width in cm
\newcommand{\MaxHeight}{2.0}% height in cm

\newcommand*{\MyIncludeGraphics}[3]{% #1= scale
    \StrChar{#2}{#3}[\FigureToInclude]% Extract digit from the 4 digit random number
    \includegraphics[width=\Width cm, height=\Height cm]{\FigureToInclude}%

    \MyIncludeGraphics{#1}{\OrderOfPictures}{1} &
    \MyIncludeGraphics{#1}{\OrderOfPictures}{2} &
    \MyIncludeGraphics{#1}{\OrderOfPictures}{3} &

\begin{tabular}{c c c c}
share|improve this answer
Works like a charm - the crude table-and-hand-pasted-graphics I came up with in the meantime dig away in shame ;). I had to add a random seed though, else it came up with the "same random" set each run. THANKS! – Christian Feb 24 '12 at 21:22
@Christian: The random seed should automatically change every minute. Also, you could generate those images directly using tikz. – Peter Grill Feb 24 '12 at 21:29
see above; I will probably generate a few pages after each other, then print them so I added a "faster" random seed. – Christian Feb 24 '12 at 21:32
Are those symbols built-in into tikz? I wasn't able to find a font that had them yet so I grabbed them out of a PDF I found online... – Christian Feb 24 '12 at 21:34
I don't think they are built it (except for the square), but they can be draw fairly easily. The apple/heart may take a bit of work but not too difficult. Have a look at How to create Candle Symbol in LaTeX as that might get you started. If you get stuck you can always ask for help here. – Peter Grill Feb 24 '12 at 21:38

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.