乳胶中的错误,我无法解决涉及多行和多列的问题

问题描述 投票:0回答:1
\begin{center}
\footnotesize
\begin{tabular}{| c | c  c  c |}
      \hline
      \multirow{3}{*}{Equipment acquired at start of year} & \multicolumn{3}{c|}{Replacement cost (\$) for given years} & &\\
      \cline{2-4}
      & 1 & 2 & 3\\
      \hline
      1 & 4000 & \multicolumn{1}{|c|}{5400} & 9800\\
      2 & 4300 & \multicolumn{1}{|c|}{6200} & 8700\\
      3 & 4800 & \multicolumn{1}{|c|}{7100} & -\\
      4 & 4900 & \multicolumn{1}{|c|}{-} & -\\
      \hline
\end{tabular}
\end{center}

出现错误:

Extra alignment tab has been changed to \cr. 

同样对于这部分代码,我不确定错误到底是什么(我得到20个放错位置的错误和缺少的括号):

\begin{table}[]
    \centering
    \begin{tabular}{c|c|c|c|c|c|c|c|c|c|c}
       \multicolumn{11}{Directed Edge Weights (Row $\rightarrow$ Col)} & & & & & & & & & & \\
       \hline
        $\rightarrow$ & A & B & C & D & E & F & G & H & I & J\\
        \hline
        A&0&4000&&&&&&&&\\
        B&&0&5400&4300&&&&&&\\
        C&&&0&&9800&6200&4800&&&\\
        D&&&&0&9800&6200&4800&&&\\
        E&&&&&0&&&8700&7100&4900\\
        F&&&&&&0&&8700&7100&4900\\
        G&&&&&&&0&8700&7100&4900\\
        H&&&&&&&&0&&\\
        I&&&&&&&&&0&\\
        J&&&&&&&&&&0\\
        \hline
    \end{tabular}
    \caption{Table of Adjacent Edges}
    \label{tab:Edges of graph}
\end{table}

请帮助:)

latex
1个回答
0
投票

在两种情况下,使用多列后似乎都添加了其他单元格。在第一种情况下,您可以在多列后删除& &,并且一切都可以正常工作:

\begin{center}
  \footnotesize
  \begin{tabular}{| c | c  c  c |}
    \hline
    \multirow{3}{*}{Equipment acquired at start of year} & \multicolumn{3}{c|}{Replacement cost (\$) for given years} \\
    \cline{2-4}
    & 1 & 2 & 3\\
    \hline
    1 & 4000 & \multicolumn{1}{|c|}{5400} & 9800\\
    2 & 4300 & \multicolumn{1}{|c|}{6200} & 8700\\
    3 & 4800 & \multicolumn{1}{|c|}{7100} & -\\
    4 & 4900 & \multicolumn{1}{|c|}{-} & -\\
    \hline
  \end{tabular}
  \end{center}

并且在第二种情况下,您需要在多列之后删除重复的&符号。同样在这种情况下,也没有显示多列间距。下表对我来说很好用,尽管我在多列中添加了{c}

\begin{table}
  \centering
  \begin{tabular}{c|c|c|c|c|c|c|c|c|c|c}
    \multicolumn{11}{c}{Directed Edge Weights (Row $\rightarrow$ Col)} \\
    \hline
    $\rightarrow$ & A & B & C & D & E & F & G & H & I & J\\
    \hline
    A&0&4000&&&&&&&&\\
    B&&0&5400&4300&&&&&&\\
    C&&&0&&9800&6200&4800&&&\\
    D&&&&0&9800&6200&4800&&&\\
    E&&&&&0&&&8700&7100&4900\\
    F&&&&&&0&&8700&7100&4900\\
    G&&&&&&&0&8700&7100&4900\\
    H&&&&&&&&0&&\\
    I&&&&&&&&&0&\\
    J&&&&&&&&&&0\\ \hline
  \end{tabular}
  \caption{Table of Adjacent Edges}
  \label{tab:Edges of graph}
\end{table}
© www.soinside.com 2019 - 2024. All rights reserved.