\noalign 与 hhline 位置错误

\noalign 与 hhline 位置错误

我有下表:

\begin{table}[h!]
\caption{\textls[-15]{Results of GAN image detection tests for digital (left) and printed and scanned images (right). Best results are highlighted in yellow}}
\label{tab:resultsgan}
\tiny
\arrayrulecolor{black}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|} 
\hline
\rowcolor[rgb]{0.863,0.863,0.863} {\cellcolor[rgb]{0.863,0.863,0.863}} & {\cellcolor[rgb]{0.863,0.863,0.863}} & {\cellcolor[rgb]{0.863,0.863,0.863}} & \multicolumn{4}{c|}{\textbf{Digital images testing results}} & \multicolumn{4}{c|}{\textbf{Printed and scanned testing images results}} \\ 
\hhline{|>{\arrayrulecolor[rgb]{0.863,0.863,0.863}}--->{\arrayrulecolor{black}}--------|}
\rowcolor[rgb]{0.863,0.863,0.863} \multirow{-2}{*}{{\cellcolor[rgb]{0.863,0.863,0.863}}\textbf{Method}} & \multirow{-2}{*}{{\cellcolor[rgb]{0.863,0.863,0.863}}\textbf{Training/Validation Data}} & \multirow{-2}{*}{{\cellcolor[rgb]{0.863,0.863,0.863}}\textbf{Input Size}} & \textbf{Acc} & \textbf{F} & \textbf{Precision} & \textbf{Recall} & \textbf{Acc} & \textbf{F} & \textbf{Precision} & \textbf{Recall} \\ 
\hhline{|--->{\arrayrulecolor{black}}------->{\arrayrulecolor{black}}-|}
{\cellcolor[rgb]{0.863,0.941,0.941}}\textbf{DENSENET} ~\cite{marraetal:2018,HUANGETAL:2017} & {\cellcolor[rgb]{0.863,0.941,0.941}}Images Patches & 224x224x3 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & 0.50 & 0.00 & 0.00 & 0.00 \\ 
\hhline{|>{\arrayrulecolor{black}}-->{\arrayrulecolor{black}}---------|}
{\cellcolor[rgb]{0.863,0.941,0.941}}\textbf{INCEPTION-V3} ~\cite{marraetal:2018,Szegedyetal:2016} & {\cellcolor[rgb]{0.863,0.941,0.941}}Images Patches & 224x224x3 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & 0.50 & 0.00 & 0.00 & 0.00 \\ 
\hhline{|>{\arrayrulecolor{black}}-->{\arrayrulecolor{black}}---------|}
{\cellcolor[rgb]{0.863,0.941,0.941}}\textbf{XCEPTION}~\cite{marraetal:2018,chollet:2017}  & {\cellcolor[rgb]{0.863,0.941,0.941}}Images Patches & 299x299x3 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & 0.50 & 0.00 & 0.00 & 0.00 \\ 
\hhline{|>{\arrayrulecolor{black}}-->{\arrayrulecolor{black}}---------|}
{\cellcolor[rgb]{0.863,0.941,0.941}}\textbf{CONET} ~\cite{lakshmananetal:2019} & {\cellcolor[rgb]{0.863,0.941,0.941}}Co-occurency Matrices & 256x256x3 & 0.96 & 0.96 & 0.95 & 0.98 & 0.50 & 0.00 & 0.00 & 0.00 \\ 
\hhline{|>{\arrayrulecolor{black}}-->{\arrayrulecolor{black}}---------|}
{\cellcolor[rgb]{0.863,0.941,0.941}}\textbf{CROSSCONET}~\cite{barnietal:2020}& {\cellcolor[rgb]{0.863,0.941,0.941}}Co-occurency Matrices & 256x256x6 & 0.99 & 0.99 & 0.98 & 1.00 & {\cellcolor{yellow}}0.50 & {\cellcolor{yellow}}0.29 & {\cellcolor{yellow}}0.50 & {\cellcolor{yellow}}0.21 \\
\hline
\end{tabular}
\end{table}

但是,每当我运行 latex 编译器时,我都会收到如下错误

Misplaced \noalign. ...black}}------>{\arrayrulecolor{black}}-|}

我该如何解决这个问题?

答案1

您没有提供示例文档,如果我将您的表格不加更改地放入最小文档中,则不会出现任何错误。

在此处输入图片描述

\documentclass[landscape]{article}

\setlength\oddsidemargin{-1cm}
\usepackage{colortbl,hhline,multirow}

\begin{document}

\arrayrulecolor{black}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|} 
\hline
\rowcolor[rgb]{0.863,0.863,0.863} {\cellcolor[rgb]{0.863,0.863,0.863}} & {\cellcolor[rgb]{0.863,0.863,0.863}} & {\cellcolor[rgb]{0.863,0.863,0.863}} & \multicolumn{4}{c|}{\textbf{Digital images testing results}} & \multicolumn{4}{c|}{\textbf{Printed and scanned testing images results}} \\ 
\hhline{|>{\arrayrulecolor[rgb]{0.863,0.863,0.863}}--->{\arrayrulecolor{black}}--------|}
\rowcolor[rgb]{0.863,0.863,0.863} \multirow{-2}{*}{{\cellcolor[rgb]{0.863,0.863,0.863}}\textbf{Method}} & \multirow{-2}{*}{{\cellcolor[rgb]{0.863,0.863,0.863}}\textbf{Training/Validation Data}} & \multirow{-2}{*}{{\cellcolor[rgb]{0.863,0.863,0.863}}\textbf{Input Size}} & \textbf{Acc} & \textbf{F} & \textbf{Precision} & \textbf{Recall} & \textbf{Acc} & \textbf{F} & \textbf{Precision} & \textbf{Recall} \\ 
\hhline{|--->{\arrayrulecolor{black}}------->{\arrayrulecolor{black}}-|}
{\cellcolor[rgb]{0.863,0.941,0.941}}\textbf{DENSENET} ~\cite{marraetal:2018,HUANGETAL:2017} & {\cellcolor[rgb]{0.863,0.941,0.941}}Images Patches & 224x224x3 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & 0.50 & 0.00 & 0.00 & 0.00 \\ 
\hhline{|>{\arrayrulecolor{black}}-->{\arrayrulecolor{black}}---------|}
{\cellcolor[rgb]{0.863,0.941,0.941}}\textbf{INCEPTION-V3} ~\cite{marraetal:2018,Szegedyetal:2016} & {\cellcolor[rgb]{0.863,0.941,0.941}}Images Patches & 224x224x3 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & 0.50 & 0.00 & 0.00 & 0.00 \\ 
\hhline{|>{\arrayrulecolor{black}}-->{\arrayrulecolor{black}}---------|}
{\cellcolor[rgb]{0.863,0.941,0.941}}\textbf{XCEPTION}~\cite{marraetal:2018,chollet:2017}  & {\cellcolor[rgb]{0.863,0.941,0.941}}Images Patches & 299x299x3 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & {\cellcolor{yellow}}1.00 & 0.50 & 0.00 & 0.00 & 0.00 \\ 
\hhline{|>{\arrayrulecolor{black}}-->{\arrayrulecolor{black}}---------|}
{\cellcolor[rgb]{0.863,0.941,0.941}}\textbf{CONET} ~\cite{lakshmananetal:2019} & {\cellcolor[rgb]{0.863,0.941,0.941}}Co-occurency Matrices & 256x256x3 & 0.96 & 0.96 & 0.95 & 0.98 & 0.50 & 0.00 & 0.00 & 0.00 \\ 
\hhline{|>{\arrayrulecolor{black}}-->{\arrayrulecolor{black}}---------|}
{\cellcolor[rgb]{0.863,0.941,0.941}}\textbf{CROSSCONET}~\cite{barnietal:2020}& {\cellcolor[rgb]{0.863,0.941,0.941}}Co-occurency Matrices & 256x256x6 & 0.99 & 0.99 & 0.98 & 1.00 & {\cellcolor{yellow}}0.50 & {\cellcolor{yellow}}0.29 & {\cellcolor{yellow}}0.50 & {\cellcolor{yellow}}0.21 \\
\hline
\end{tabular}

\end{document}

答案2

在更正了您的表格代码(考虑到@David Carlisle 的评论)之后,将您的代码片段扩展为完整的可编译文档,我认识到,您的表格太大,无法适合纵向页面的文本宽度。一个可能的解决方案是将表格旋转为横向:

\documentclass{article}
\usepackage[showframe,
            margin=25mm]{geometry}
\usepackage{rotating}
\usepackage[table]{xcolor}
\definecolor{mygray}{rgb}{0.863,0.863,0.863}
\definecolor{myteal}{rgb}{0.863,0.941,0.941}
\usepackage{array, hhline, multirow}
\usepackage[skip=1ex]{caption}
\usepackage{subcaption}
\usepackage{siunitx}
%
\NewExpandableDocumentCommand\mcc{O{1}m}
    {\multicolumn{#1}{c|}{#2}}
\NewExpandableDocumentCommand\CHead{m}
    {\renewcommand\arraystretch{1}
     \begin{tabular}{@{} >{\footnotesize\bfseries}c @{}}
        #1
     \end{tabular}}

\begin{document}
    \begin{sidewaystable}[ht]
\caption{Results of GAN image detection tests for digital (left) and printed and scanned images (right). Best results are highlighted in yellow} %&\textls[-15]{
\label{tab:resultsgan}
    \renewcommand\arraystretch{1.5}
    \centering
    \small
\begin{tabular}{|l|l|c|c|c|c|c|c|c|c|c|}
    \hline
    \rowcolor{mygray}
    &   &   & \mcc[4]{\CHead{Digital images\\ testing results}}
                & \mcc[4]{\CHead{Printed and scanned\\
                                 testing images results}}    \\
\hhline{|>{\arrayrulecolor{mygray}}--->{\arrayrulecolor{black}}--------|}
    \rowcolor{mygray}
\multirow{-2}{*}{\CHead{Method}}
    & \multirow{-2}{*}{\CHead{Training/Validation\\ Data}}
        & \multirow{-2}{*}{\CHead{Input\\ Size}}
            & \CHead{Acc}
                & \CHead{F}
                    & \CHead{Precision}
                        & \CHead{Recall}
                            & \CHead{Acc}
                                & \CHead{F}
                                    & \CHead{Precision}
                                        & \CHead{Recall} \\
\hhline{|--->{\arrayrulecolor{black}}------->{\arrayrulecolor{black}}-|}
\cellcolor{myteal}{\textbf{DENSENET} ~\cite{marraetal:2018,HUANGETAL:2017}} 
    & \cellcolor{myteal}{Images Patches} 
        & \num{224x224x3} 
            & \cellcolor{yellow}{1.00} 
                & \cellcolor{yellow}{1.00} 
                    & \cellcolor{yellow}{1.00} 
                        & \cellcolor{yellow}{1.00} 
                            & 0.50 & 0.00 & 0.00 & 0.00 \\
\hhline{|>{\arrayrulecolor{black}}-->{\arrayrulecolor{black}}---------|}
\cellcolor{myteal}{\textbf{INCEPTION-V3} ~\cite{marraetal:2018,Szegedyetal:2016}} 
    & \cellcolor{myteal}{Images Patches} 
        & \num{224x224x3} 
            & \cellcolor{yellow}{1.00} 
                & \cellcolor{yellow}{1.00} 
                    & \cellcolor{yellow}{1.00} 
                        & \cellcolor{yellow}{1.00} 
                            & 0.50 & 0.00 & 0.00 & 0.00 \\
\hhline{|>{\arrayrulecolor{black}}-->{\arrayrulecolor{black}}---------|}
\cellcolor{myteal}{\textbf{XCEPTION}~\cite{marraetal:2018,chollet:2017}} 
    & \cellcolor{myteal}{Images Patches} 
        & \num{299x299x3} 
            & \cellcolor{yellow}{1.00} 
                & \cellcolor{yellow}{1.00} 
                    & \cellcolor{yellow}{1.00} 
                        & \cellcolor{yellow}{1.00} 
                            & 0.50 & 0.00 & 0.00 & 0.00 \\
\hhline{|>{\arrayrulecolor{black}}-->{\arrayrulecolor{black}}---------|}
\cellcolor{myteal}{\textbf{CONET} ~\cite{lakshmananetal:2019}} 
    & \cellcolor{myteal}{Co-occurency Matrices} 
        & \num{256x256x3} 
            & 0.96 & 0.96 & 0.95 & 0.98 & 0.50 & 0.00 & 0.00 & 0.00 \\
\hhline{|>{\arrayrulecolor{black}}-->{\arrayrulecolor{black}}---------|}
\cellcolor{myteal}{\textbf{CROSSCONET}~\cite{barnietal:2020}}
    & \cellcolor{myteal}{Co-occurency Matrices} 
        & \num{256x256x6} 
            & 0.99 & 0.99 & 0.98 & 1.00 & \cellcolor{yellow}{0.50} 
                & \cellcolor{yellow}{0.29}  
                    & \cellcolor{yellow}{0.50} 
                        & \cellcolor{yellow}{0.21} \\
    \hline
\end{tabular}
\end{sidewaystable}
\end{document}

在此处输入图片描述

答案3

这是构建表格的一种方法nicematrix(以及旋转到横向模式)。

\documentclass{article}
\usepackage[margin=25mm]{geometry}
\usepackage{rotating}
\usepackage{xcolor}
\definecolor{mygray}{rgb}{0.863,0.863,0.863}
\definecolor{myteal}{rgb}{0.863,0.941,0.941}
\usepackage[skip=1ex]{caption}
\usepackage{subcaption}
\usepackage{siunitx}
\usepackage{nicematrix}
%

\begin{document}
    \begin{sidewaystable}[ht]
\caption{Results of GAN image detection tests for digital (left) and printed and scanned images (right). Best results are highlighted in yellow}
\label{tab:resultsgan}
    \renewcommand\arraystretch{1.5}
    \centering
    \small
\begin{NiceTabular}{llccccccccc}%
  [
    hvlines,
    code-before = 
      \rowcolor{mygray}{1,2}
      \rectanglecolor{myteal}{3-1}{7-1}
      \rectanglecolor{yellow}{3-4}{5-7}
      \rectanglecolor{yellow}{7-8}{7-11}
  ]
\Block{2-1}{\bfseries Method} & \Block{2-1}<\bfseries>{Training/Validation\\ Data} & \Block{2-1}<\bfseries>{Input\\ Size}
& \Block{1-4}<\bfseries>{Digital images\\ testing results} & & & 
& \Block{1-4}<\bfseries>{Printed and scanned\\ testing images results}   \\
& & & \bfseries Acc & \bfseries F & \bfseries Precision & \bfseries Recall & \bfseries Acc 
& \bfseries F & \bfseries Precision & \bfseries Recall \\
\textbf{DENSENET} ~\cite{marraetal:2018,HUANGETAL:2017}
& Images Patches & \num{224x224x3} & 1.00 & 1.00 & 1.00 & 1.00 & 0.50 & 0.00 & 0.00 & 0.00 \\
\textbf{INCEPTION-V3} ~\cite{marraetal:2018,Szegedyetal:2016}
& Images Patches & \num{224x224x3} & 1.00 & 1.00 & 1.00 & 1.00 & 0.50 & 0.00 & 0.00 & 0.00 \\
\textbf{XCEPTION}~\cite{marraetal:2018,chollet:2017}
& Images Patches & \num{299x299x3} & 1.00 & 1.00 & 1.00 & 1.00 & 0.50 & 0.00 & 0.00 & 0.00 \\
\textbf{CONET} ~\cite{lakshmananetal:2019}
& Co-occurency Matrices & \num{256x256x3} & 0.96 & 0.96 & 0.95 & 0.98 & 0.50 & 0.00 & 0.00 & 0.00 \\
\textbf{CROSSCONET}~\cite{barnietal:2020}
& Co-occurency Matrices & \num{256x256x6} & 0.99 & 0.99 & 0.98 & 1.00 & 0.50 & 0.29 & 0.50 & 0.21 \\
\end{NiceTabular}
\end{sidewaystable}
\end{document}
  • {NiceTabular}nicematrix,您可以使用内置命令水平和垂直合并单元格\Block

  • 该密钥hvlines绘制了所有规则,但块(由\Block)除外。

  • 您可以使用中的指令为行、列和单元格着色code-before(但也可以使用类似于的语法colortbl---table的选项xcolor)。

  • 在所有缩放级别的所有 PDF 查看器中,输出都将是完美的。

  • 你不需要hhline也不需要multirow

但是,您需要多次编译(因为nicematrix使用 PGF/Tikz 节点)。

上述代码的输出

相关内容