I would like to number and label each row in my table so I can reference them later on.
But I get the flowing output:
I would like the output to look like this:
How can I fix this problem?
Code:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[danish]{babel}
\usepackage{lscape}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{color}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{float}
\usepackage[top=2.81cm, bottom=2.75cm,right=2cm, left=2cm]{geometry}
\usepackage{url}
\usepackage[hidelinks]{hyperref}
\hypersetup{breaklinks=true}
\usepackage{setspace}
\onehalfspacing
\usepackage[T1]{fontenc}
\begin{document}
\begin{table}[H]
\centering
\label{tab:Q1}
\begin{tabular}{|c|c|l|l|}
\hline
Number & Theory & Question & Explanation \\ \hline
1 \label{que:whyisit} & B & Why is it you think ... & This is a good question\\
2 \label{que:doyouthink} & A & Do you think ... & This Is also a good question\\
3 \label{que:isitcorrect} & B & is it correct that you think ... & This is question \\ \hline
\end{tabular}
\caption{Table with questions}
\end{table}
Question \ref{que:whyisit} is about ... \\
Question \ref{que:doyouthink} is about ... \\
Question \ref{que:isitcorrect} is about ...
\end{document}
Best Answer
Here is a method with a new columntype
N
which automatically increases therowcntr
, since a\label
should use a counter in the background (although writing manipulating\@currentlabel
is also possible, see gernot's answer).The
rowcntr
is reset with every newtabular
command or if a new table\caption
has been used (i.e. thetable
counter has been increased then)In my point of view, the row number should be prefixed with the table number, in order to confusion which question is meant in case of more than one table questions should occur.
Hyperlinks do work!
I also shifted the wrongly placed table label to the place where it belongs, i.e. after using
\caption
!