My problem is that I want to have a certain footer on the first, or the last, page. The solution I've tried with is by using fancyhdr together with afterpage.
Here is a working example, without longtable, of what I want.
\documentclass[12pt,a4paper]{article}
\usepackage{fancyhdr}
\usepackage{longtable}
\usepackage{afterpage}
\pagestyle{fancy}
\begin{document}
\lfoot{
Footer page 1
}%end lhead eller lfoot
\afterpage{\clearpage
\lfoot{
Footer page 2 and forward
}%end lfoot
}%end afterpage
Test page 1
\newpage
Test page 2
\newpage
Test page 3
\end{document}
As you can see, the left footer are different on page 1 vs page 2 and 3.
But when I use a longtable which spans over these pages, the afterpage-technique don't work. Unless I force a newpage, which I really don't want to do. As you can see in the following example:
\documentclass[12pt,a4paper]{article}
\usepackage{fancyhdr}
\usepackage{longtable}
\usepackage{afterpage}
\pagestyle{fancy}
\begin{document}
\lfoot{
Footer page 1
}%end lhead eller lfoot
\afterpage{\clearpage
\lfoot{
Footer page 2 and forward
}%end lfoot
}%end afterpage
\begin{longtable}{|l| l|}
Lots of lines& like this.\\
...
Lots of lines& like this.\\
\end{longtable}
After longtable
\newpage
After newpage
\end{document}
\afterpage
is for having a different footer on page 1 than on the subsequent pages?\afterpage
for that purpose is a sledgehammer for a mosquito. Define afirstpage
style with\fancypagestyle
and issue\thispagestyle{firstpage}
just after\begin{document}
.