Can I refer to cells in a tabular?
You can modify \@currentlabel
to be whatever you want and then use \label
-\ref
as usual. \@currentlabel
is used as the reference component when using \ref
. The command \speciallabel{<stuff>}{<label>}
in the MWE below modifies \@currentlabel
to be <stuff>
and sets the label to <label>
:
\documentclass{article}
\makeatletter
\newcommand{\speciallabel}[2]{% \speciallabel{<stuff>}{<label>}
\edef\@currentlabel{#1}\label{#2}%
}
\makeatother
\begin{document}
\begin{table}
\centering
\begin{tabular}{lrr}\hline
This & $99^a$\speciallabel{a}{this} & $1.23$\\
That & $22$ & $3.45$\\
The Other & $69^b$\speciallabel{b}{theother} & $9.99$\\
\hline
\end{tabular}
\end{table}
I enjoyed `This' (\ref{this}) and `The Other` (\ref{theother}).
\end{document}
There was no request for hyperref
accommodation.
For an automated counter-style reference, consider the following version of \speciallabel{<label>}
:
\documentclass{article}
\newcounter{spcounter}\renewcommand{\thespcounter}{\alph{spcounter}}
\newcommand{\speciallabel}[1]{% \speciallabel{<label>}
\refstepcounter{spcounter}\textsuperscript{\thespcounter}\label{#1}%
}
\begin{document}
\begin{table}
\centering
\begin{tabular}{lrr}\hline
This & $99\speciallabel{this}$ & $1.23$\\
That & $22$ & $3.45$\\
The Other & $69\speciallabel{theother}$ & $9.99$\\
\hline
\end{tabular}
\end{table}
I enjoyed `This' (\ref{this}) and `The Other` (\ref{theother}).
\end{document}
Note that this will have the counter increment throughout the document. However, it can also be made to reset at the start of the table
(or tabular
) environment, if needed.
\documentclass{article}
\usepackage{array}
\newcounter{mycount}
\renewcommand\themycount{%
\arabic{mycount}%
\ifcase\value{mycount}%
th\or st\or nd\or rd\else th\fi}
\begin{document}
\begin{table}
\begin{tabular}{>{\refstepcounter{mycount}\themycount}lc}
\multicolumn{1}{c}{Step} & Comments \\
& a \\
\label{here} & b \\
& c \\
& d
\end{tabular}
\caption{}\label{}
\end{table}
blah blah see the \ref{here} row.
\end{document}