1

which indicated in Table ~\ref{tb:3_1}.

I have a following code:

\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}

Table looks great, problem is in the pdf part.

which indicated in Table ??. How can fix the question mark problem?

3
  • 5
    label has to be after (or in) caption not before Jun 13, 2017 at 22:21
  • 1
    Welcome! Please post complete minimal code people can compile. (Not really necessary at this point for this question, though.)
    – cfr
    Jun 13, 2017 at 22:38
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. A suggestion: Do us a favour and change your username to something more telling than "user1234". Jun 13, 2017 at 22:43

1 Answer 1

2

To take care of the main problem: As David Carlisle has already pointed out in a comment, the \label statement must come after (ideally: immediately after) the \caption statement.

In addition, you may want to simplify and streamline your LaTeX code by setting up a macro to contain the split-line tabular material.

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .