在枚举项目中正确引用表格

在枚举项目中正确引用表格
\documentclass[11pt,english]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[margin=1in]{geometry}
\usepackage{enumitem}
\usepackage{multirow}
\usepackage{listings}
\usepackage{rotating}
\usepackage{graphicx}
\begin{document}
\begin{enumerate}[label*=\arabic*.]

\item  \textbf{ aaaaaaa}
\item \textbf{bbbbbbb}
\begin{sidewaystable} % <-- HERE
\centering
\begin{tabular}{cccccccc}\hline
dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text \\\hline
dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text \\
dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text \\
dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text \\
dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text \\
dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text \\\hline
\end{tabular}
\caption{Some caption to the table.}
\label{table1}
\end{sidewaystable}
\end{enumerate}

now I WANT REF A TABLE \ref{table1} but it returns the item's order.not because it is the first table.
\end{document}

答案1

如果添加第二个项目,则可以看到使用了正确的引用,因为即使枚举中的顺序现在是 2(项目编号),引用仍然是 1(表编号):

\documentclass{article}
\usepackage{enumitem}
\usepackage{rotating}
\begin{document}
\begin{enumerate}[label*=\arabic*.]
  \item  aaaaaaa
  \item\label{enum:something} something
  \begin{sidewaystable} % <-- HERE
    \centering
    \begin{tabular}{cccccccc}\hline
      dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text \\\hline
      dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text \\
      dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text \\
      dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text \\
      dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text \\
      dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text & dummy text \\\hline
    \end{tabular}
    \caption{Some caption to the table.}
    \label{table1}
  \end{sidewaystable}
\end{enumerate}

Now I want to reference the table \ref{table1} and it returns the table's number and not the number of the item in the enumeration (\ref{enum:something}).
\end{document}

比较参照

相关内容