Loop in latex
When exporting lots of results, it can be interesting to see them all at once, in a latex document for example.
If there are more than 3 results, it can be cumbersome to write 3 \includegraphics
commands (for example). One solution is to use the tikz
package as follow:
\foreach \x in {Australia, Austria, Belgium}
{
\begin{figure}[h]
\centering
\includegraphics[scale = .5]{rates_\x.pdf}
\caption{\x}
\label{fig:\x} \end{figure}
\clearpage
}
This code include the figures named rates_Australia
, rates_Austria
and rates_Belgium
. The \x
stands for the local variable.
Note that the \clearpage
is very important: latex cannot deal with too many floating elements (such as figures). If the loop has less than about 10 elements, it is not necessary.