表引用问题

表引用问题

如表 ~\ref{tb:3_1} 所示。

我有以下代码:

\begin{table}[]
\centering
\label{tb:3_1}
\begin{tabular}{|l|l|}
\hline
Portrait                                                                      & Einstein, Lena, woman dark hair                                                                     \\ \hline
\begin{tabular}[c]{@{}l@{}}Human,\\ animal/plants\end{tabular}                & \begin{tabular}[c]{@{}l@{}}Barbara,\\ Cameraman, living room, Mandril, peppers, pirate\end{tabular} \\ \hline
\begin{tabular}[c]{@{}l@{}}Outdoor/\\ Architecture and structure\end{tabular} & \begin{tabular}[c]{@{}l@{}}Boat,\\ lake gray, walk bridge, house\end{tabular}                       \\ \hline
Aviation                                                                      & Chemical plant, jet plane                                                                           \\ \hline
Medical                                                                       & Mri                                                                                                 \\ \hline
\end{tabular}
\caption{Grouped Images}
\end{table}

表格看起来很棒,问题出在 pdf 部分。

如表??所示。如何解决问号问题?

答案1

为了解决主要问题:正如 David Carlisle 在评论中指出的那样,声明\label必须(理想情况下:紧接着)该\caption声明。

此外,您可能希望通过设置宏来包含分割线表格材料,从而简化和精简您的 LaTeX 代码。

\documentclass{article}
\usepackage{geometry}
% custom macro to house the split-line tabular material:
\newcommand\mytab[1]{\begin{tabular}[c]{@{}l@{}} #1 \end{tabular}}
\begin{document}
\begin{table}
\centering
\begin{tabular}{|l|l|}
\hline
Portrait & Einstein, Lena, woman dark hair  \\ \hline
\mytab{Human,\\ animal/plants}
         & \mytab{Barbara,\\ Cameraman, living room, Mandril, peppers, pirate} \\ \hline
\mytab{Outdoor/\\ Architecture and structure} 
         & \mytab{Boat,\\ lake gray, walk bridge, house} \\ \hline
Aviation & Chemical plant, jet plane \\ \hline
Medical  & MRI \\ \hline
\end{tabular}
\caption{Grouped Images} \label{tb:3_1}
\end{table}

A cross-reference to Table \ref{tb:3_1}.
\end{document}

相关内容