Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to have on my draft-documents on the bottom something like compiled ch2.tex on July 21, 2011 at 18:46. My document has multiple files which I include by using \input.

I have the following preamble (I only kept the relevant part):

\documentclass[a4paper,11pt, leqno, draft]{scrbook} %draft
\usepackage{scrtime}
\usepackage{currfile}
\usepackage{fancyref}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{calc}
\fancyheadoffset[LE,RO]{\marginparsep+\marginparwidth}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhf{}
\fancyhead[LE,RO]{\bfseries\thepage} 
\fancyhead[LO]{\rightmark}
\fancyhead[RE]{\leftmark}
\fancypagestyle{plain}{%
  \fancyhead{} % get rid of headers
  \renewcommand{\headrulewidth}{10pt} % and the line
}
\lfoot{\scriptsize{\texttt{compiled \currfilename \ on \today \ at \thistime}}}
\cfoot{}
\rfoot{}

\author{Jonas Teuwen}
\title{}

\begin{document}

\input{ch1.tex}
\input{ch2.tex}

\end{document}

The line that gives problems is the following:

\lfoot{\scriptsize{\texttt{compiled \currfilename \ on \today \ at \thistime}}}

It does work, it gives me the correct result, however, at the last page of ch1.tex at the bottom LaTeX already prints the line for ch2.tex. What is wrong?

Another small question: How do I automatically disable this part if the document is set as [final] instead of [draft]?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

You need to flush the last page of the chapter with \clearpage (or \newpage), otherwise LaTeX will already have opened file ch2.tex and \currfilename then holds that name.

Chapter should be included using \include which adds \clearpage automatically, not using \input. (You can also then use e.g. \includeonly{ch1} to only compile chapter 1.)

You can use the ifdraft package to only add this line only in draft mode:

\ifdraft{%
\lfoot{\scriptsize{\texttt{compiled \currfilename \ on \today \ at \thistime}}}%
}{}

(See also Doing something only when the draft option is on?)

Note that with the filemod package you can also add the file modification date.

share|improve this answer
    
Great! This is exactly what I wanted. –  Jonas Teuwen Jul 21 '11 at 18:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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