开发者

forloop and table in LaTeX

Here is the LaTeX code for my table:

  \begin{table}{| c || c | c | c || c | c | c | }  
  \caption{Examples of the concepts. \label{tab:conceptsimgs}}\\   
  \hline  
  \backslashbox{Concept}{Class} &\multicolumn{3}{|c||}{Negative Class} & \multicolumn{3}{|c|}{Positive Class}  \\  
  \hline  

  \forloop{themenumber}{1}{\value{themenumber} < 4}{  
        %\hline   
        \arabic{themenumber}  
        \forloop{classnumber}{0}{\value{classnumber} < 2}{  
            \forlo开发者_如何学编程op{imagenumber}{1}{\value{imagenumber} < 4}{  
                & 0  
            }  
        }  
        \\  
        \hline  
  }  

  \end{table}

Something is wrong in the result however. There is some extra thing at the end of the table, as shown in here:

http://www. freeimagehosting. net/image.php?c702bfc838.png

How can I fix it?


That's a nasty one. I've created a minimal example that demonstrates the problem, see below. Try to compile this and take a look at the results.

The point is, you seem to be out of luck — tabular does not like the output of forloop, it cannot disregard the last \addtocounter command. Maybe you can find some other package for loops. You should be able to figure out the rest from the code below, if not, write a comment.

\documentclass{article}
\usepackage{forloop}

\newcounter{themenumber}  
\newcounter{test}

\begin{document}
% this is your table (minimal example)
\begin{tabular}{| c |}  
  \forloop{themenumber}{1}{\value{themenumber} < 2}{x\\ \hline}   
\end{tabular}
\vspace{2cm}

% this is what you wanted to have
\begin{tabular}{| c |}  
x \\ \hline
\end{tabular}
\vspace{2cm}

% this is what forloop produces
\begin{tabular}{| c |}  
x \\ \hline \addtocounter{test}{1}
\end{tabular}

\end{document}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜