I have a longtabu that spans multiple pages. I would like to be able to provide a page total that sums and/or counts the values in one or more columns.
Does anyone have an idea how this might be achieved?
I have a longtabu that spans multiple pages. I would like to be able to provide a page total that sums and/or counts the values in one or more columns.
Does anyone have an idea how this might be achieved?
You still have to know which is the last row on each page, but this should make things easier. If the column uses reals instead of integers, you can use pgfmath.
Note: the dummy column comes from Is there an incompatibility between collcell, longtable, and/or arydshln?
\documentclass{article}
\usepackage{array}
\usepackage{collcell}
\usepackage{longtable}
\newcounter{runningsum}
\newcommand{\Smacro}[1]% see column type S
{#1\addtocounter{runningsum}{#1}}%
\newcolumntype{S}{>{\collectcell\Smacro}{r}<{\endcollectcell}}
\begin{document}
\Large
\begin{longtable}{S@{}c}
1&\\
2&\\
3&\\
4&\\
5&\\
6&\\
7&\\
8&\\
9&\\
10&\\
11&\\
12&\\
13&\\
14&\\
15&\\
16&\\
17&\\
18&\\
19&\\
20&\\
21&\\
22&\\
23&\\
24&\\
25&\\
26&\\
27&\\
28&\\
29&\\
\hline
\multicolumn{1}{r@{}}{\therunningsum\setcounter{runningsum}{0}}&\\
30&\\
31&\\
32&\\
33&\\
34&\\
35&\\
36&\\
37&\\
38&\\
39&\\
40&\\
\hline
\multicolumn{1}{r@{}}{\therunningsum\setcounter{runningsum}{0}}&
\end{longtable}
\end{document}
\bgroup as argument to \Smacro. You want to look at the collcell package, but the table foot is ”frozen", so I don't think it works anyway.
– egreg
Jun 15 '16 at 07:43