I come from this question: How can I automatically calculate sums in a LaTeX table?

I want to do the same but with "timing" calculations. So my example would look like this:

  @ a    & @ xyz      & @ duration      & @ starttime & @ endtime \\
  @ a1   & 5          & 00:03           & 00:00       & add(c2, d2) \\
  @ a2   & 9          & 00:01           & (automatically value of previous endtime)       & add(c3, d3) \\
  % and so on

I have to do do dozens of These which will change from time to time, and i only want to change the Duration and every other will be calculated.

I would stronly prefere a solution without luaTeX.


1 Answer 1


Based on Time calculations:






    \advance\hours by \addhrs\relax
    \advance\minutes by \addmins\relax
    \advance\minutes by -60\relax
    \advance\hours by 1\relax
    \advance\minutes by 60\relax
    \advance\hours by -1\relax
    \advance\hours by -24\relax
    \advance\hours by 24\relax

\newcommand\newStartTime[1]{#1 h~~ & \startTime{} & \add\startTime{#1}\startTime\\}

        a  & xyz & duration & starttime & endtime\\
        a1 & 5   & \newStartTime{00:03}
        a2 & 9   & \newStartTime{00:01}

enter image description here

  • Very nice! Could you expand the example so that there is always the formittag xx:xx. If I use your example i get for the first starttime xx:xx and in the following lines: x:xx - is this fixable?
    – user69453
    Jul 26, 2016 at 18:43
  • 2
    @user69453 yes, it's fixable. See the updated code. Jul 26, 2016 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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