5

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?

cgnieder
  • 66,645
expoter
  • 173
  • 1
    pgfplotstable could probably do this. – Manuel Nov 02 '16 at 09:33
  • Could you give an example? @Manuel – expoter Nov 02 '16 at 09:36
  • No, I don't know how it works, I only know of its existence. – Manuel Nov 02 '16 at 09:37
  • 3
  • @DaiBowen, please convert your comment to answer! – Zarko Nov 02 '16 at 09:56
  • @DaiBowen I didn't want to 'steal' your answer. Please post an answer (feel free to copy my code), and I will delete mine. I've just got the impression that you love terse answers and therefore wouldn't expand your comment, but thought that an example showing working code would be helpful. – gernot Nov 02 '16 at 10:12
  • I strongly feel that if you need these capabilities then your LaTeX document (or at least the table part) should be automatically generated by a separate tool, regardless of the existence of the spreadtab package. – Konrad Rudolph Nov 02 '16 at 11:49
  • @gernot not to worry I have no real experience of spreadtab just knowledge that it does Excel type functions. I was not at a computer to provide any MWE so commenting seemed the best way to give the OP the necessary information (I probably should have invited somebody else to write a proper answer in this case). I normally do follow up on request to convert comments to answers though :) – Dai Bowen Nov 02 '16 at 12:53

1 Answers1

6

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

gernot
  • 49,614