Graphics, Figures & TablesReferencing a row in a table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
isharp2
Posts: 23
Joined: Fri Feb 11, 2011 2:06 am

Referencing a row in a table

Post by isharp2 »

Hi,
I would like to reference a row in a table. Where, for example, the 3rd row of table 2 would output [2.3].

Below is some code that sets up a counter and outputs the references and outputs the row of the table, but does not preface it with the table number.

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{tabularx}
\usepackage{hyperref}
\newcounter{rownumber}[figure]
\setcounter{rownumber}{1}
\begin{document}
\section{A section}
This is just some random text\dots
\subsection{A Sub-section}
\subsection{Another Sub-section}
\begin{figure}[h!]
\caption{is here}
\begin{tabular}{| c | c | c | }
\refstepcounter{rownumber}
\label{r1} 1 & my first row & some text \\
\refstepcounter{rownumber}
\label{r2} 2 & my second row & some other text \\
\refstepcounter{rownumber}
\label{r3} 3 & third row & final text \\
\end{tabular}
\end{figure}
\subsection{A Sub-Phase}
\section{YYYY}
YYYY
\section{ZZZZZZZZ}
The rownumber is \hspace{\value{rownumber}\parindent}
\subsection{A Sub-Phase}
1st Reference: \ref{r1}\\
Second Reference: \ref{r2}\\
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Referencing a row in a table

Post by Juanjo »

Perhaps it would suffice to add the following line after the corresponding \newcounter command:

Code: Select all

\renewcommand{\therownumber}{\thefigure.\arabic{rownumber}}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
isharp2
Posts: 23
Joined: Fri Feb 11, 2011 2:06 am

Re: Referencing a row in a table

Post by isharp2 »

perfect! Thanks for you reply.
Post Reply