yannis assael | the blog

  • Home
  • About
  • Categories
    • Android
    • Computing
    • iOS
    • Machine Learning
    • MacOSX
  • GitHub
  • Mobile Apps
  • yannisassael.com


Posts Tagged ‘foreach’

Latex foreach multiple figures loop

Written by iassael on 28/11/2014. Posted in computing, general

800px-LaTeX_logo.svgUsing 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}

  • Continue Reading
  • 1 Comment