这是我的第一张表:
\begin{longtable}{|p{4cm}|p{4cm}|}
\caption{Caption of the table}\\ \hline
\rowcolor{black} \textcolor{white}{\textbf{Column 1}} & \textcolor{white}{\textbf{Column 2}} \\\hline
Row 1\qquad\qquad & AAA \qquad\qquad \\\hline
Row 2 & BBB \\\hline
Row 3 & CCC \\\hline
\label{ratings}
\end{longtable}
不幸的是它看起来像这样:
这是第二张类似的表格:
\begin{longtable}[h]{|*{2}{>{\columncolor{black}\color{white}}c}*{7}{|c}|}
\caption{Caption of the table with Multirow and Multicolumn}\\
\cline{9-7}
\rowcolor{black}\multicolumn{2}{c|}{\cellcolor{white}{}}
& \textcolor{white}{\textbf{Column 1}}
& \textcolor{white}{\textbf{Column 2 }}
& \textcolor{white}{\textbf{Column 3 }}
& \textcolor{white}{\textbf{Column 4 }}
& \textcolor{white}{\textbf{Column 5 }} \\ \hline
& \textbf{$\lambda_1$} \quad \textbf{$\lambda_2$} & 0,3 \quad 0,5 & 0,1 \quad 0,2 & 0,3 \quad 0,8 & 0,4 \quad 0,7 & 0,1 \quad 0,2 \\
& \textbf{$\tau$} & 3 & 2 & 0,1 & 1 & 2 \\
\multirow{-3}{*}{\begin{minipage}{0.7in}
\begin{center}
\textbf{Row 1}
\end{center}
\end{minipage}} & \textbf{$\rho$} & 1 & 0 & -5 & -2 & 1 \\ \hline
& \textbf{$\lambda_1$} \quad \textbf{$\lambda_2$} & 0,3 \quad 0,5 & 0,1 \quad 0,2 & 4 \quad 2 & 0,1 \quad 0,2 & 0,1 \quad 0,2\\
& \textbf{$\tau$} & 3 & 2 & 0,1 & 1 & 2\\
\multirow{-3}{*}{\begin{minipage}{0.7in}
\begin{center}
\textbf{Row 2}
\end{center}
\end{minipage}} & \textbf{$\rho$} & 1 & 0 & -5 & -2 & 1 \\ \hline
\label{thisisthelabel}
\end{longtable}
这就是除了最后一条不必要的黑线之外的样子:
有人能帮我删除两个表中出现的最后一行多余的行吗?
答案1
您必须将其放在\label
标题后面。
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{longtable,multirow}
\begin{document}
\begin{longtable}{|p{4cm}|p{4cm}|}
\caption{Caption of the table}\label{ratings}\\ \hline
\rowcolor{black} \textcolor{white}{\textbf{Column 1}} & \textcolor{white}{\textbf{Column 2}} \\\hline
Row 1\qquad\qquad & AAA \qquad\qquad \\\hline
Row 2 & BBB \\\hline
Row 3 & CCC \\\hline
\end{longtable}
\begin{longtable}[h]{|*{2}{>{\columncolor{black}\color{white}}c}*{7}{|c}|}
\caption{Caption of the table with Multirow and Multicolumn}\label{thisisthelabel}\\
\cline{9-7}
\rowcolor{black}\multicolumn{2}{c|}{\cellcolor{white}{}}
& \textcolor{white}{\textbf{Column 1}}
& \textcolor{white}{\textbf{Column 2 }}
& \textcolor{white}{\textbf{Column 3 }}
& \textcolor{white}{\textbf{Column 4 }}
& \textcolor{white}{\textbf{Column 5 }} \\ \hline
& \textbf{$\lambda_1$} \quad \textbf{$\lambda_2$} & 0,3 \quad 0,5 & 0,1 \quad 0,2 & 0,3 \quad 0,8 & 0,4 \quad 0,7 & 0,1 \quad 0,2 \\
& \textbf{$\tau$} & 3 & 2 & 0,1 & 1 & 2 \\
\multirow{-3}{*}{\begin{minipage}{0.7in}
\begin{center}
\textbf{Row 1}
\end{center}
\end{minipage}} & \textbf{$\rho$} & 1 & 0 & -5 & -2 & 1 \\ \hline
& \textbf{$\lambda_1$} \quad \textbf{$\lambda_2$} & 0,3 \quad 0,5 & 0,1 \quad 0,2 & 4 \quad 2 & 0,1 \quad 0,2 & 0,1 \quad 0,2\\
& \textbf{$\tau$} & 3 & 2 & 0,1 & 1 & 2\\
\multirow{-3}{*}{\begin{minipage}{0.7in}
\begin{center}
\textbf{Row 2}
\end{center}
\end{minipage}} & \textbf{$\rho$} & 1 & 0 & -5 & -2 & 1 \\ \hline
\end{longtable}
\end{document}