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

\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}\\
Third Reference: \ref{r3}\\

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

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