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

Alain Schremmer schremmer.alain at gmail.com
Mon Mar 30 18:28:53 EDT 2009


On Mar 30, 2009, at 4:09 PM, Ross Moore wrote:

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

I don't have the time to think this through but I recently had a  
similar problem and got help from this list. Here is what I ended up  
doing using arrayjob:

In a stylesheet called RAFv3-0_CheckableItems, I enter the data, e.g.  
"alpha", "beta", "gamma", etc:


\newarray\ChapVII%381
\readarray{ChapVII}{%381
%381-1
alpha
&%381-2
beta $
&%381-3
gamma
.
.
.
.
-
&%381-49
-%this is an empty cell
&%381-50
-
}



Then, in the document I have 		
\usepackage{RAFv3-0_CheckableItems}
and then

	%Row
			
		&	
		&	1
		&	\ChapVII(1)
		&	\checkmark
		&	
		&	
		\\
	%Row
			
		&	
		&	2
		&	\ChapVII(2)
		&	\checkmark
		&	
		&	
		\\
.
.
.
.
-

which automatically shows alpha, beta, gamma, where it should. It  
makes things reasonably foolproof.

I hope this is comprehensible but, if not, I can send the complete  
files off list to anyone interested.

Regards
--schremmer







More information about the MacOSX-TeX mailing list