%% %% A DANTE-Edition example %% %% Example 06-00-32 on page 196. %% %% Copyright (C) 2010 Herbert Voss %% %% It may be distributed and/or modified under the conditions %% of the LaTeX Project Public License, either version 1.3 %% of this license or (at your option) any later version. %% %% See http://www.latex-project.org/lppl.txt for details. %% %% %% ==== % Show page(s) 1,2 %% \documentclass[]{article} \pagestyle{empty} \setlength\textwidth{183.78818pt} \usepackage[utf8]{inputenc}% adapt maybe \usepackage[paper=70mm:85mm,pagesize]{typearea} \usepackage[utf8]{inputenc}% adapt maybe \usepackage[english]{babel} \setlength\parindent{0pt} \usepackage{etex} % to be able to use labels \usepackage{ltxtable} \usepackage[savepos,user]{zref} % to save the current position \usepackage{fltpoint} % floating point arithmetics \usepackage{calc} % for the \widthof command \usepackage{numprint} % formatted output of numbers \usepackage{eurosym} % Euro sign % global settings for numprint \npstyleenglish % English number formatting \nprounddigits{2} % two decimal places \npreplacenull{---} % hyphen instead of decimal zeros %%%%%%%%%%%%%%commands to calculate the intermediate sums%%%%%%%%%%%%%%%%%%%% \newcommand*\intsum{0} \newcommand*\resetintsum{\global\def\intsum{0}} \newcommand*\addintsum[1]{\fpAdd{\intsum}{\intsum}{#1}% \global\let\intsum\intsum} \newcommand*\printval[1]{\numprint{#1}} %%%%%%%%PlainTeX hack for positioning of intermediate sums%%%%%%%%%%%%%%% \makeatletter % allow the at sign in variables % provide variables \newdimen\drx \newdimen\dry \newmarks\ltm@marks \def\ltm@setmarks#1{\marks\ltm@marks{#1}} \def\ltm@getmarks{\botmarks\ltm@marks} % calculate the current value of the intermediate sum and save it \newcommand*{\Val}[1]{% \printval{#1}% immediate output of the value \addintsum{#1}% add the passed value to the intermediate sum \expandafter\ltm@setmarks\expandafter{\intsum}% save intermediate sum } % save current position \newcommand*{\MarkIntSumPos}{% \leavevmode \zsavepos{zwsumpos\thepage}% \zrefused{zwsumpos\thepage}} % output intermediate sum \def\ltm@insertfoot#1{% \vbox to\z@{% \vss \hb@xt@\z@{% \color@begingroup \zsavepos{tabende\thepage}% % save current position \drx=0sp \dry=0sp % subtract current position and add saved one \advance \drx by -\zposx{tabende\thepage}sp \advance \drx by \zposx{zwsumpos\thepage}sp \advance \dry by -\zposy{tabende\thepage}sp \advance \dry by \zposy{zwsumpos\thepage}sp \smash{\kern\drx\raise\dry% \hbox{\makebox[\widthof{ \euro}][r]{% \printval{#1} \euro}}% } \color@endgroup }% }% } % output of the carry % like output of the intermediate sum, but without saved position \def\ltm@inserthead#1{% \vbox to\z@{% \vss \hb@xt@\z@{% \color@begingroup \drx=0sp \dry=0sp % subtract position of end of table \advance \drx by -\zposx{tabende\thepage}sp \advance \drx by \zposx{zwsumpos\thepage}sp \advance \dry by -\zposy{tabende\thepage}sp \advance \dry by \zposy{zwsumpos\thepage}sp \smash{\kern\drx\raise\dry% % The actual output. Right-aligned and translated by the % width of the Euro sign. \hbox{\makebox[\widthof{ \euro}][r]{% \printval{#1} \euro}}% } \color@endgroup }% }% } \def\ltm@lastfoot{\ltm@insertfoot\ltm@getmarks} \def\ltm@foot{\ltm@insertfoot{\ltm@getmarks}} \def\ltm@head{\ltm@inserthead{\ltm@getmarks}} % overwrite the output routines of longtable \def\LT@output{% \ifnum\outputpenalty <-\@Mi \ifnum\outputpenalty > -\LT@end@pen \LT@err{floats and marginpars % not allowed in a longtable}\@ehc \else \setbox\z@\vbox{\unvbox\@cclv}% \ifdim \ht\LT@lastfoot>\ht\LT@foot \dimen@\pagegoal \advance\dimen@-\ht\LT@lastfoot \ifdim\dimen@<\ht\z@ \setbox\@cclv\vbox{% \unvbox\z@\copy\LT@foot\ltm@foot\vss }% \@makecol \@outputpage \setbox\z@\vbox{\box\LT@head}% \fi \fi \global\@colroom\@colht \global\vsize\@colht \vbox{% \unvbox\z@ \box\ifvoid\LT@lastfoot \LT@foot\ltm@foot \else \LT@lastfoot\ltm@lastfoot \fi }% \fi \else \setbox\@cclv\vbox{% \unvbox\@cclv\copy\LT@foot\ltm@foot\vss }% \@makecol \@outputpage \global\vsize\@colroom \copy\LT@head\ltm@head \fi } \makeatother % disallow at sign in variables %%%%%%%%%%%%%%%%%%%%end plaintex hack%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{longtable} \begin{document} \resetintsum \begin{longtable}{p{0.7\linewidth}r} left & right \endfirsthead carry & \\ \endhead intermediate sum: & \MarkIntSumPos \\ \endfoot sum: &\MarkIntSumPos \\ \endlastfoot An arbitrary introductory text at the start of the column\ldots. & \Val{1,00} \\ b & \Val{2,1} \\ c & \Val{3,4} \\ d & \Val{4,5} \\ e & \Val{5,6} \\ f & \Val{6,7} \\ g & \Val{7,8} \\ h & \Val{8,9} \\ i & \Val{9,42} \\ j & \Val{10,88}\\ k & \Val{15,76} \end{longtable} \end{document}