在LaTeX forloop和表 [英] forloop and table in LaTeX

查看:573
本文介绍了在LaTeX forloop和表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的表的LaTeX代码:

  \ begin {table} {| c || c | c | c || c | c | c | } 
\ caption {概念的例子。 \标签{tab:conceptsimgs}} \\
\ hline
\backslashbox {Concept} {Class}& \multicolumn {3} {| c ||} {Negative Class }& \multicolumn {3} {| c |} {肯定分类} \\\
\ hline

\forloop {themenumber} {1} {\ value {themenumber} < 4} {
%\ hline
\ arabic {themenumber}
\forloop {classnumber} {0} {\ value {classnumber}< 2} {
\forloop {imagenumber} {1} {\ value {imagenumber}< 4} {
& 0
}
}
\\\
\ hline
}

\ end {table}

然而,结果有些不对。在表格末尾有一些额外的东西,如下所示:



HTTP:// WWW 。 freeimagehosting。 net / image.php?c702bfc838.png



我该如何解决这个问题?

解决方案

这是一个讨厌的。我已经创建了一个最小的例子来演示这个问题,见下文。试着编译一下,看看结果。

关键是,你似乎是不幸运的 - 表格不喜欢 forloop 的输出,它不能忽视最后的 \addtocounter 命令。也许你可以找到一些其他的封装循环。
你应该能够从下面的代码中找出其余的,如果没有的话,写一个评论。

  \documentclass {article} 
\usepackage {forloop}

\ newcounter {themenumber}
\ newcounter {test}

\ begin {document}
这是你的表格(最小的例子)
\ begin {tabular } {| c |}
\forloop {themenumber} {1} {\ value {themenumber}< 2} {x\\\hline}
\ end {表格}
\空间{2cm}

%这就是你想要的
\begin {表格} {| c |}
x \\\\ hline
\ end {表格}
\空间{2cm}

%这是forloop产生的
\begin {表格} {| c $}
x \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ b


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}{  
            \forloop{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}

这篇关于在LaTeX forloop和表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆