Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 698037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:13:51+00:00 2026-05-14T03:13:51+00:00

I would like to use some iteration control flow to simplify the following LaTeX

  • 0

I would like to use some iteration control flow to simplify the following LaTeX code.

  \begin{sidewaystable}
  \caption{A glance of images}
  \centering
  \begin{tabular}{| c ||c| c| c |c| c|| c |c| c|c|c| }
  \hline
  \backslashbox{Theme}{Class} &\multicolumn{5}{|c|}{Class 0} & \multicolumn{5}{|c|}{Class 1}  \\
  \hline

  \hline
          1 &
          \includegraphics[scale=2]{../../results/1/0_1.eps}
          &\includegraphics[scale=2]{../../results/1/0_2.eps}
          &\includegraphics[scale=2]{../../results/1/0_3.eps}
          &\includegraphics[scale=2]{../../results/1/0_4.eps}
          &\includegraphics[scale=2]{../../results/1/0_5.eps}
          &\includegraphics[scale=2]{../../results/1/1_1.eps}
          &\includegraphics[scale=2]{../../results/1/1_2.eps}
          &\includegraphics[scale=2]{../../results/1/1_3.eps}
          &\includegraphics[scale=2]{../../results/1/1_4.eps}
          &\includegraphics[scale=2]{../../results/1/1_5.eps}      \\
  \hline

  ...  % similarly for 2, 3, ..., 22

  \hline
          23 &
          \includegraphics[scale=2]{../../results/23/0_1.eps}
          &\includegraphics[scale=2]{../../results/23/0_2.eps}
          &\includegraphics[scale=2]{../../results/23/0_3.eps}
          &\includegraphics[scale=2]{../../results/23/0_4.eps}
          &\includegraphics[scale=2]{../../results/23/0_5.eps}
          &\includegraphics[scale=2]{../../results/23/1_1.eps}
          &\includegraphics[scale=2]{../../results/23/1_2.eps}
          &\includegraphics[scale=2]{../../results/23/1_3.eps}
          &\includegraphics[scale=2]{../../results/23/1_4.eps}
          &\includegraphics[scale=2]{../../results/23/1_5.eps}      \\
  \hline

  \end{tabular}
  \end{sidewaystable}

I learn that the forloop package provides the for loop. But I am not sure how to apply it to my case? Or other methods not by forloop?


If I also want to simply another similar case, where the only difference is that the directory does not run from 1, 2, to 23, but in some arbitrary order such as 3, 2, 6, 9,…, or even a list of strings such as dira, dirc, dird, dirb,…. How do I make the LaTeX code into loops then?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:13:52+00:00Added an answer on May 14, 2026 at 3:13 am

    Something like this will take care of the body of your tabular:

    \newcounter{themenumber}
    \newcounter{classnumber}
    \newcounter{imagenumber}
    \forloop{themenumber}{1}{\value{themenumber} < 24}{
        % \hline <-- Error here
        \arabic{themenumber}
        \forloop{classnumber}{0}{\value{classnumber} < 2}{
            \forloop{imagenumber}{1}{\value{imagenumber} < 6}{
                & \includegraphics[scale=2]{
                    ../../results/\arabic{themenumber}/\arabic{classnumber}_\arabic{imagenumber}.eps
                }
            }
        }
        \\
        \hline
    }
    

    I had to comment out the first \hline because it gave me an error:

    You can't use `\hrule' here except with leaders.
    

    I’m not sure what that means; if you really cannot live without the double line, I can look into it more.

    Also note that you have to use <; for example, <= 24 will not work.


    As to your update: I would simply declare a command that takes the argument that you’re looping over. Something like this:

    \newcommand\fordir[1]{do something complex involving directory named #1}
    
    \fordir{dira}
    \fordir{dirb}
    \fordir{dirc}
    \dots
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use some code written in python (it uses built in
I would like some advice on the best approach to use in the following
I have an IFrame app, and I would like to use some Connect features
I am writing a small wxPython utility. I would like to use some event
I'm currently building a project and I would like to make use of some
I would like to use Emacs to edit some VB6 files but Emacs does
I would like to use Markov models for some architecture simulations, but don't have
I've created some custom UITableViewCells in a nib file and would like to use
I've written some applications than heavily use network, and I would like to test
I have some code like this: public void SaveImage(int Counter) { var task =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.