[Tex/LaTex] Table name not appearing properly in ref

cross-referencingtables

Referring to the body below, I would expect ~\ref{atts} to produce Table 1, but instead, it gives just 1.

What is the issue here?

Best Answer

You have to use some package that knows what you are referring. I suggest cleveref:

\documentclass[twoside,11pt]{article}
\usepackage{cleveref}

\begin{document}

\begin{table}[ht]
\caption{Categories and example of attributes}
\label{atts}
\centering
\begin{tabular}{l p{8.0cm} l}
\hline
Variable & Items & Category \\
\hline
Built-up area  & Inside built-up area; outside built-up area & !!!CAT!!! \\
Type of road  & Highway; district or province road & !!!CAT!!! \\
Type of road lanes  & Road with one road lane; road with separated road lanes & !!!CAT!!! \\
Intersection  & Near intersection; outside intersection & !!!CAT!!! \\
Location characteristic  & Road works; bridge; tunnel; railroad; roundabout & !!!CAT!!! \\
Road factors  & Bad road surface; faulty signals; faulty lighting; road works; queue; downhill; curve; bad visibility & !!!CAT!!! \\
Miscellaneous  & Accident following accident; aquaplaning; sun blinded; school; recreation centre; bus stop; person swung out of vehicle; no safety belt; no helmet; no child seat; cargo on roadway before accident; cargo on roadway because of accident; fire after accident; comments & !!!CAT!!! \\
Total number of deaths  & 0; 1; 2; 3; 4; 5 & !!!CAT!!! \\ [1ex]
\hline
\end{tabular}
\end{table}

~\Cref{atts} is bad.

\end{document}

enter image description here

For details, refer to the documentation -- execute texdoc cleveref from command prompt.

Related Question