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

Michael Sharpe msharpe at ucsd.edu
Tue Mar 31 17:11:41 CEST 2009


On Mar 30, 2009, at 11: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.
>
> I was thinking this should be possible while using \labels, \ref but  
> for the moment can't stretch my mind to find a solution.
>
> Thanks for any reply,

Another option is to use (a modification of) the arrayjob package.  
Here's an example.

\usepackage{multido,arrayjobx}%see notes below on arrayjobx
\begin{document}
\newarray\DataA
\readarray{DataA}{%
1&2&3&%
4&5&6&%
7&8&9&%
10&11&12}
\dataheight=3% make rows of 3
% so \DataA(2,3)=6
\begin{tabular}{ccc}
\hline
\textbf{Column 1}&\textbf{Column 2}&\textbf{Column 2}\\
\hline
\let\TableData\empty
%The body of the table has to be constructed in a particular way---see  
docs.
\begingroup
\let\DataA\relax
\let\\\relax
\def\rowlength{3}
\multido{\iRow=1+1}{4}{%
   \let\RowData\empty
   \multido{\iColumn=1+1}{\rowlength}{%
   \xdef\RowData{\RowData \DataA(\iRow,\iColumn) \ifx\iColumn 
\rowlength \\ \else & \fi}}
\xdef\TableData{\TableData\RowData}}
\endgroup
\TableData
\end{tabular}
The item in row 2, column 3 is \DataA(2,3).

Note on arrayjobx. The package arrayjob conflicts with LaTeX's use of  
\array. For my own usage, I edited the file arrayjob.sty to create a  
new file arrayjobx.sty, changing the three occurrences of \array to  
\Array---lines 108, 148, 164.

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