我正在尝试运行以下代码:
\documentclass{article}
\usepackage{lmodern}
\usepackage{amsthm}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lastpage}
\usepackage{indentfirst}
\usepackage{color}
\usepackage{graphicx}
\usepackage{microtype}
\usepackage{multirow}
\usepackage{multicol}
\counterwithin{figure}{chapter}
\counterwithin{table}{chapter}
\begin{document}
\chapter{CHAPTER}
I will show the Table \ref{First} and the Table \ref{Second}.
\begin{table}[h!]\begin{minipage}[b]{0.45\linewidth}
\centering
\begin{tabular}{|c|c|c|c|c|}\hline\label{First} \cline{1-5}
\multicolumn{5}{|l|}{XXXXXXXXXXXXXXXXX}\\ \hline\hline
XX & XX &XX &XX &XX \\ \hline\hline
YY & YY & YY &YY &YY \\ \hline
YY & YY & YY &YY &YY \\ \hline
YY & YY & YY &YY &YY \\ \hline
\end{tabular}
\caption{AAAAAAAAAAAAAAA}
\end{minipage}
\hspace{1 cm} \begin{minipage}[b]{0.45\linewidth}
\centering
\begin{tabular}{|c|c|c|c|c|}\hline\label{Second} \cline{1-5}
\multicolumn{5}{|l|}{XXXXXXXXXXXXXXXXX}\\ \hline\hline
XX & XX &XX &XX &XX \\ \hline\hline
YY & YY & YY &YY &YY \\ \hline
YY & YY & YY &YY &YY \\ \hline
YY & YY & YY &YY &YY \\ \hline
\end{tabular}
\caption{AAAAAAAAAAAAAAA}
\end{minipage}
\end{table}
\end{document}
但是,我在顶部看到了奇怪的几行,并且没有得到参考:
提前感谢所有明示的帮助!
答案1
\label{...}
必须位于表格中的标题或可引用计数器之后(您的表格中不存在这些内容)。- 文档类
article
未定义\chapter{...}
。为此,您需要使用report
或book
文档类(或其他类似的包,例如memoir
)
\documentclass{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\begin{document}
\section{CHAPTER ?}
I will show the Table \ref{First} and the Table \ref{Second}.
\begin{table}[ht]
\begin{minipage}[b]{0.45\linewidth}
\centering
\begin{tabular}{|c|c|c|c|c|}\hline
\multicolumn{5}{|l|}{XXXXXXXXXXXXXXXXX}\\ \hline\hline
XX & XX &XX &XX &XX \\ \hline\hline
YY & YY & YY &YY &YY \\ \hline
YY & YY & YY &YY &YY \\ \hline
YY & YY & YY &YY &YY \\ \hline
\end{tabular}
\caption{AAAAAAAAAAAAAAA}
\label{First}
\end{minipage}
\hspace{1 cm} \begin{minipage}[b]{0.45\linewidth}
\centering
\begin{tabular}{|c|c|c|c|c|}\hline
\multicolumn{5}{|l|}{XXXXXXXXXXXXXXXXX}\\ \hline\hline
XX & XX &XX &XX &XX \\ \hline\hline
YY & YY & YY &YY &YY \\ \hline
YY & YY & YY &YY &YY \\ \hline
YY & YY & YY &YY &YY \\ \hline
\end{tabular}
\caption{AAAAAAAAAAAAAAA}
\label{Second}
\end{minipage}
\end{table}
\end{document}