3

I have a table with 3 columns:

\begin{tabular}{|c|c|c|}
\textbf{C1} & \textbf{C2} & \textbf{SUM}
\hline
2 & 3 & 5
\end{tabular}

But, if I change C1 or C2, I have to change SUM manually. In excel, I can use function like =C1+C2, then SUM will update automatically when C1 or C2 changed. Can latex do that?

8
  • 1
    pgfplotstable could probably do this. – Manuel Nov 2 '16 at 9:33
  • Could you give an example? @Manuel – expoter Nov 2 '16 at 9:36
  • No, I don't know how it works, I only know of its existence. – Manuel Nov 2 '16 at 9:37
  • 3
    spreadtab – Dai Bowen Nov 2 '16 at 9:37
  • @DaiBowen, please convert your comment to answer! – Zarko Nov 2 '16 at 9:56
5

Just an advertiser for @DaiBowen's suggestion: The first example of the spreadtab Manual (page 2) addresses your question.

\documentclass{article}
\usepackage{spreadtab}
\begin{document}
\begin{spreadtab}{{tabular}{rr|r}}
   22    &    54    & a1+b1 \\
   43    &    65    & a2+b2 \\
   49    &    37    & a3+b3 \\
\hline
a1+a2+a3 & b1+b2+b3 & a4+b4
\end{spreadtab}
\end{document}

enter image description here

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