Latex foreach multiple figures loop
Using Latex, many times you want to print multiple figures that have similar names like figure_1.pdf, figure_2.pdf etc…
Instead of hardcoding everything, the foreach
package saves lives!
More specifically, you can write something like this:
\begin{figure}[H]
\centering
\foreach \n in {1,3,5,10,20}{
\begin{subfigure}{.18\linewidth}
\centering
\includegraphics[width=\textwidth]{figs/question_9_\n}
\subcaption{\n Trees}
\end{subfigure}
}
\caption{RF various number of trees evaluation.}
\end{figure}