# [OS X TeX] using variables in text via references or labels

Ross Moore ross at ics.mq.edu.au
Mon Mar 30 22:09:48 CEST 2009

Hello Gert,

On 31/03/2009, at 5:31 AM, Gert van Oss wrote:

> dear all,
>
> I've had some problem making up a clear subject line and stil am in
> doubt whether I've succeded. What I'm trying to achieve is the
> following.
>
> My documents have often various tables and charts embedded via the
>
>    \input{table_file}
>
> command.
>
> While explaining my tables/charts I'm mentioning actual numbers (as
> listed in the tables) in my text. Is it somehow possible to create
> a list of numbers in my latex document and have them called via a
> reference in my text? This would enable me to run a somewhat
> related scenario in my numbers and udpate both my tables with
> numbers and have all numbers changed in the text as well.

If I understand you correctly, you have tables with numbers
in (some of) the cells, but these values may change with updates
of the table data. You want your document to refer to these values
by showing the actual numbers, rather than by their location.

>
> I was thinking this should be possible while using \labels, \ref
> but for the moment can't stretch my mind to find a solution.

Not easily, as the contents of a cell is not the kind
of thing that establishes a destination for a cross-reference.

You could simply enter the values in the table as the
expansion of a macro; e.g.,

\newcommand{\specValue}{3.1415926}
\begin{tabular}{....}
...
.... & .... & \specValue & .... & .... \\
...
\end{tabular}

Then refer to the value in the main document using \specValue .

Of course updating the table is no longer as simple
as just changing the numbers within the cells.
You'll have to ensure that the \newcommand definition gets
properly updated, and its usage not clobbered.

Any other approach would require some tricky macro definitions
anyway; e.g., making table cells automatically cause their values
to be recorded as the expansion of a macro specific to the row,
column and particular table.

>
> Thanks for any reply,
>
> Gert

Hope this helps,

Ross

------------------------------------------------------------------------
Ross Moore                                       ross at maths.mq.edu.au
Mathematics Department                           office: E7A-419
Macquarie University                             tel: +61 (0)2 9850 8955
Sydney, Australia  2109                          fax: +61 (0)2 9850 8114
------------------------------------------------------------------------

-------------- next part --------------
----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: http://email.esm.psu.edu/mac-tex/
List Archive: http://tug.org/pipermail/macostex-archives/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex



More information about the macostex-archives mailing list