LaTeX 表格排版中遇到 Misplaced oalign

遇到该问题的根本原因是编译器认为表格没有正确换行(末尾没有添加”“)。但是,LaTeX 认为没有正确换行不代表真的没有正确换行。当表格使用了复杂的插入方式时,例如循环,LaTeX 无法正确判断。

报错示范

egin{table}
  egin{tabular}{lrrrrr}
    p & cluster distance & SE & gene & gene/SE
    DTLforeach*{at_counts}
    {
    pvalue=p value,
    cd=cluster distance,
    seCount=SE count,
    geneCount=gene count,
    
atio=ratio,
    	ored=tored
    }
    {
    	abularnewline
    ifthenelse{	ored=1}
    {
    
owcolor{green} pvalue & cd & seCount & geneCount & 
atio
    }
    {
    pvalue & cd & seCount & geneCount & 
atio
    }
    }
  end{tabular}
end{table}

在上面的例子当中,使用了 datatool 宏包来导入 csv 表格数据,使用 colortbl 宏包来修改表格底色。如果忽略错误,结果符合预期。但是由于 abularnewline没有直接和 owcolor相邻,所以会报错。进行以下修改后不会报错,同时结果符合预期。

egin{table}
  egin{tabular}{lrrrrr}
    p & cluster distance & SE & gene & gene/SE
    DTLforeach*{at_counts}
    {
    pvalue=p value,
    cd=cluster distance,
    seCount=SE count,
    geneCount=gene count,
    
atio=ratio,
    	ored=tored
    }
    {
    ifthenelse{	ored=1}
    {
    	abularnewline
    
owcolor{green} pvalue & cd & seCount & geneCount & 
atio
    }
    {
    	abularnewline
    pvalue & cd & seCount & geneCount & 
atio
    }
    }
  end{tabular}
end{table}
原文地址:https://www.cnblogs.com/flyingicedragon/p/14289493.html