Referencing figures by a label in mediawiki

⇠ Back to Blog:Hacks

If you want to refer to images in Mediawiki the way you would in a $\mathrm{\LaTeX}$ document, you can use this cheap trick of mine... Say you have several figures, like this one:

Figure (1): Standard deviation of the average as function of the sample size.

And this one:

Figure (2): Distribution of a thousand mean of 10 numbers: experiment vs theory.

They are labelled automaticallya and you can refer to them later, e.g., this is shown in Fig. (1) and a particular case is featured in Fig. (2).

Let me Lorem ipsum you to win some space and let you click from far away (that's two paragraphs, see you on the other side):

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras scelerisque nec ex imperdiet dapibus. Nulla elementum quis tellus eu rhoncus. Etiam et leo non ex faucibus faucibus. Donec at justo id lectus egestas posuere non at eros. Vivamus luctus lectus sed nulla bibendum blandit. Sed sagittis tempor justo eu gravida. Aenean id lorem ac felis rhoncus sollicitudin. Duis porta eu elit vel lacinia. Fusce vehicula, tellus nec maximus semper, tortor massa placerat ex, et mattis urna nisl sed purus. Nulla pretium, diam ac interdum vulputate, mi mi aliquet metus, ac mollis risus nunc tempus augue. Aliquam aliquam purus nec tristique placerat. Sed pharetra vestibulum dapibus.

Mauris luctus augue nunc, at molestie tortor congue ac. Donec sagittis aliquet ipsum non vestibulum. Cras at ligula tortor. Sed ac interdum dolor, id faucibus eros. Etiam mattis sodales tellus in ultricies. Sed porttitor augue elit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ultricies ac lorem vel sodales. Aliquam tristique varius nulla, efficitur venenatis sem vehicula sit amet. Suspendisse eget tincidunt libero, ac ultrices justo. Phasellus accumsan leo ante, a sollicitudin justo luctus nec. Praesent nec posuere nunc. Maecenas accumsan arcu eu urna molestie, at fringilla augue eleifend. Nam sapien dui, pellentesque nec imperdiet consequat, rutrum ornare arcu. Etiam rhoncus condimentum gravida.

You can then click back to the mentioned figures, e.g., Figs. (1) and (2). That's not the most powerful and flexible you would wish, but that works well enough, for within the same page! (that is a big limitation, however).

That's the code:

<small>Figure \ref{fig:1}:
Standard deviation of the average as function of the sample

And this one:

<small>Figure \ref{fig:2}:
Distribution of a thousand mean of 10 numbers: experiment vs