Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!sol.usc.edu!siemsen From: siemsen@sol.usc.edu (Pete Siemsen) Newsgroups: comp.text.tex Subject: LaTeX guru question: \timestamp macro that sometimes fails Message-ID: <32345@usc> Date: 27 Apr 91 00:48:10 GMT Sender: news@usc Distribution: comp Lines: 49 Nntp-Posting-Host: sol.usc.edu A user here asked for a way to insert the current time and date into his LaTeX files. I found a macro in "TeX for the Impatient" that does the job nicely, and the user went away happy. Then he tried using the macro in his page headings, where it only works partially. Here's a sample file the demonstrates the problem. In the heading, the date is fine but the time comes out as "0:0". I'm by no means experienced enough to understand why. Help! \documentstyle[11pt]{article} %---------------------------------------------------------------------------- \def\monthname{% \ifcase\month \or January \or February \or March \or April% \or May \or June \or July \or August% \or September\or October \or November\or December% \fi}% \def\timestring{\begingroup \count0 = \time \divide\count0 by 60 \count2 = \count0 % The hour. \count4 = \time \multiply\count0 by 60 \advance\count4 by -\count0 % The minute. \ifnum\count4<10 \toks1 = {0} % Get a leading zero. \else \toks1 = {}% \fi \ifnum\count2<12 \toks0 = {a.m.}% \else \toks0 = {p.m.}% \advance\count2 by -12 \fi \ifnum\count2=0 \count2 = 12 \fi % Make midnight '12'. \number\count2:\the\toks1 \number\count4 \thinspace \the\toks0 \endgroup}% \def\timestamp{\number\day\space\monthname\space \number\year\quad\timestring}% %---------------------------------------------------------------------------- \pagestyle{myheadings} \markright{test heading: the time is \timestamp} \begin{document} test line, page one, the time is \timestamp \pagebreak test line, page two, the time is \timestamp \pagebreak \end{document} -- Pete Siemsen Pete Siemsen siemsen@usc.edu University of Southern California 645 Ohio Ave. #302 (213) 740-7391 (w) 1020 West Jefferson Blvd. Long Beach, CA 90814 (213) 433-3059 (h) Los Angeles, CA 90089-0251