Is there a way to reference just plain text with the \ref{}
tag?
I have a table with two columns. Each column has content which links to a different part below.
The reference in the first column is no problem, because it refers to an item. The second column however is just plain text, but I want to refer that to the other text as well.
I want to do that, so that I only need to change the referenced text and the text in my table will automatically update (preferably a reference, which can't be clicked on).
Here is the rough outline.
Table
Col 1 | Col 2
\ref{sth:bla} & \ref{sth:text} \
The referenced part
\begin{description}
\item[Something\label{sth:bla}] The Text \hfill \\
Description!
\end{description}
So now I would want to reference "The Text" with \ref{sth:text}
, so that I wouldn't have to change the text twice. As I said, preferably I would like to reference without actually making if clickable.
The answer given by Werner does work fine to some point.
Here is an example, where it doesn't seem to work correctly anymore. How would I use regular referencing in the document now?
\documentclass{article}
\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\makeatletter
\newcommand*{\textlabel}[2]{%
\edef\@currentlabel{#1}% Set target label
\phantomsection% Correct hyper reference link
#1\label{#2}% Print and store label
}
\makeatother
\begin{document}
\section{A section}
This is a table:
\begin{center}
\begin{tabular}{l|l}
Col 1 & Col 2 \\
\ref{sth:bla} & \ref{sth:text} \\
\ref{Blub} & Text \\
\end{tabular}
\end{center}
The items:
\begin{description}
\item[\textlabel{Something}{sth:bla}] \textlabel{The Text}{sth:text} \hfill \\
Description! \\
\item[Blub\label{Blub}] Something \hfill \\
Another description!
\end{description}
\end{document}
The normal reference tag will now be replaced by the text content of the textlabel.
Best Answer
Here's one way of achieving it:
You would use
\textlabel{<text>}{<label>}
in order to mark and print the label that you can retrieve later as\ref{<label>}
. Note that\textlabel
both prints<text>
and marks the label (using\label{<label>}
internally).