mardi 2 décembre 2014

How can I keep a cellcontent static?


I have defined a TeX-macro to compare date and time information. Within a single box, there is no problem, but if used in a table, in different columns or lines, as shown below, the result is 0. Obviously, the boxes are unboxed and flushed. How may I save the information of box 1 (column/line) and box 2(column/line) to be processed in column 3 without typing them again?



\documentclass[a4paper]{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{longtable}
% \time
\newcount\hour %
\newcount\hours %
\newcount\minutes %
\hour=\time \divide\hour by 60
\minutes=\time
\hours=\hour \multiply\hours by 60
\advance \minutes by -\hours
%end \time
%begin definitions of caldate
\newcount\fromcalyear %%
\newcount\fromcalmonth %%
\newcount\fromcalday %%
\newcount\fromcalhour %%
\newcount\fromcalminutes %%
\newcount\tocalyear %%
\newcount\tocalmonth %%
\newcount\tocalday %%
\newcount\tocalhour %%
\newcount\tocalminutes %%
\def\fromcaldate[#1-#2-#3 #4:#5]{%
\fromcalyear=#1 %
\fromcalmonth=#2 %
\fromcalday=#3 %
\fromcalhour=#4 %
\fromcalminutes=#5 %
\ \the\fromcalyear-\ifnum\fromcalmonth<10
0\fi\the\fromcalmonth-\ifnum\fromcalday<10
0\fi\the\fromcalday\ \ifnum\fromcalhour<10
0\fi\the\fromcalhour:\ifnum\fromcalminutes<10 0\fi\the\fromcalminutes
\vskip0.1\baselineskip}%
\def\tocaldate[#1-#2-#3 #4:#5]{%
\tocalyear=#1 %
\tocalmonth=#2 %
\tocalday=#3 %
\tocalhour=#4 %
\tocalminutes=#5\ %
\the\tocalyear-\ifnum\tocalmonth<10
0\fi\the\tocalmonth-\ifnum\tocalday<10
0\fi\the\tocalday\ \ifnum\tocalhour<10
0\fi\the\tocalhour:\ifnum\tocalminutes<10 0\fi\the\tocalminutes
\advance\fromcalyear by -\tocalyear\multiply\fromcalyear by
-1 %
\advance\fromcalmonth by -\tocalmonth\multiply \fromcalmonth
by-1 %
\advance\fromcalday by -\tocalday \multiply \fromcalday by-1 %
\advance\fromcalhour by -\tocalhour \multiply \fromcalhour by-1 %
\advance\fromcalminutes by -\tocalminutes \multiply \fromcalminutes by-1 %
\vskip0.1\baselineskip}%
\def\rescaldatetime{(\the\fromcalyear)-(\the\fromcalmonth)-(\the\fromcalday) (\the\fromcalhour):(\the\fromcalminutes)}
\def\rescaldate{(\the\fromcalyear)-(\the\fromcalmonth)-(\the\fromcalday)}
\def\rescaltime{(\the\fromcalhour):(\the\fromcalminutes)}
\begin{document}
\begin{longtable}{p{3cm}p{3cm}p{3cm}}
\fromcaldate[2013-01-01 13:00]
\tocaldate[2014-02-04 14:11]
\rescaldatetime\\
\\
\fromcaldate[2013-01-01 13:00]&
\tocaldate[2014-02-04 14:11]&
\rescaldatetime\\
&&
\rescaldatetime\\
\end{longtable}
\end{document}




Aucun commentaire:

Enregistrer un commentaire