This question may seem very simple but I didn't find a solution!

I have a table with some values. Among these values, I want to save some of them to re-use them in a table that summarizes few tables.

How can I save the values which are in the cell to be able to re-use them later ?

Thanks a lot !

PS: With spreadtab, I cannot customize the columns as I defined them.

\documentclass[a4paper, 12pt]{report}

\begin{document}
\begin{tabular}{ccc}
  1 & 2 & 3 \\
  4 & 5 & 6 % I will re-use the values 5 and 6 later
\end{tabular}


\begin{tabular}{ccc}
  7 & 8 & 9 \\
  10 & 11 & 12 % I will re-use the values 11 and 12 later
\end{tabular}


%Summary table 
\begin{tabular}{cc}
  5 & 6 \\
  11 & 12
\end{tabular}
\end{document}
  • Welcome to TeX.SE. Could you put please your complete minimal compilable code? – Sebastiano Oct 11 at 10:45
  • Ok, it's done :-) – Flora Jonas Oct 11 at 11:33
up vote 2 down vote accepted

An approach could be to save each element to be reused in a variable. In this case, you can easily change the value only at one place.

\documentclass[a4paper, 12pt]{report}

\newcommand{\myvarA}{5}
\newcommand{\myvarB}{6}
\newcommand{\myvarC}{11}
\newcommand{\myvarD}{12}


\begin{document}
\begin{tabular}{ccc}
  1 & 2 & 3 \\
  4 & \myvarA & \myvarB % I will re-use the values 5 and 6 later
\end{tabular}


\begin{tabular}{ccc}
  7 & 8 & 9 \\
  10 & \myvarC & \myvarD % I will re-use the values 11 and 12 later
\end{tabular}


%Summary table 
\begin{tabular}{cc}
  \myvarA & \myvarB \\
  \myvarC & \myvarD
\end{tabular}
\end{document}
  • 1
    It's a good idea here. Thanks ! – Flora Jonas Oct 11 at 12:18

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.