Page LayoutUsing fancyhdr and longtabu over multiple pages

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
byb3
Posts: 3
Joined: Thu May 01, 2014 6:18 pm

Using fancyhdr and longtabu over multiple pages

Post by byb3 »

Hi,

I have a clash with the fancyhdr package and the longtabu package.

I am writing an abbreviations page that spans over multiple pages. I have used the longtabu environment for this and it works well.

I am also using fancyhdr for the footers and headers which work fine on every other page apart from the first page of the multiple tables.

I was advised that for rfoot in fancyhdr you must use \\ rather than \newline otherwise it ends up centering the text on the first line.

Unfortunately longtabu tries to interpret the \\ from rfoot on this page only. I assume it thinks it is part of the table.

On the rfoot for that page, there is no newline and everything appears on one line.

I have included a MWE below, apologies it has to be large to span two pages.

Code: Select all

\documentclass[12pt,oneside]{article}
\usepackage{fancyhdr}
\usepackage{tabu}
\usepackage{longtable}

\fancypagestyle{style2}{
\renewcommand{\footrulewidth}{0.4pt}
\lhead{toptext}
\chead{}
\rhead{}
\lfoot{docref \newline Document uncontrolled when printed}
\cfoot{}
\rfoot{Version\ 1.0\\Page\ \thepage}
}

\begin{document}
\pagestyle{style2}
\begin{longtabu}{|l|l|}
\hline
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
TestA  & TestB\\
\hline
\caption[Abbreviations]{List of Abbreviations used within this document}
\end{longtabu}
\end{document}
Any suggestions for a workaround?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

byb3
Posts: 3
Joined: Thu May 01, 2014 6:18 pm

Using fancyhdr and longtabu over multiple pages

Post by byb3 »

Just for help, the horrible workaround that looks correct but is not ideal is to set up a style for just these two pages and use this in rfoot:

Code: Select all

\rfoot{\hspace{11.7cm}Version\ 1.0\newline Page\ \thepage} }
Essentially this is just a bodge. The first line moves to the centre because of the quirks of fancyhdr and the hspace just shifts it along to where it should be.

Any better suggestions?
Post Reply