# Are tikz and fancyheadings incompatible?

I've been using the package fancyheadings to have a footer that reads "page 2 of 3" and such, which was working fine until I added the package tikz to draw some figures. Now the footer doesn't show up at all except for the horizontal line separating it from the rest of the document. Is there a way I can enjoy both the footer and be able to draw with tikz?

Here's my code:

    \documentclass[12pt,letterpaper]{article}
\setlength{\textwidth}{6.5in}
\setlength{\textheight}{9.5in}
\setlength{\oddsidemargin}{-.25in}
\setlength{\evensidemargin}{-.25in}
\setlength{\topmargin}{-.25in}
\usepackage{fancyhdr}
\usepackage{lastpage}
\pagestyle{fancy}
\cfoot{Page \thepage\ of \pageref{LastPage}}
\renewcommand{\footrulewidth}{1pt}
%\usepackage{tikz}
\begin{document}

\begin{center}
\Huge  {\bf More Sets}\\
\end{center}
\end{document}


When I compile with \usepackage{tikz} commented out, I get what I want:

But when I uncomment \usepackage{tikz}, the bar is still there, lower, and no pages numbers are to be found:

• Welcome to TeX.SX! Please add the minimal and compilable version of your document that produces this error! – user31729 Jun 9 '16 at 19:08
• Is the horizontal line lower than it should be? You might just be running off the bottom of the page. – John Kormylo Jun 9 '16 at 22:26
• See below. Your TeX installation appears to default to A4 paper, like mine. – cfr Jun 10 '16 at 0:04

No. fancyhdr and tikz are entirely compatible. I use both in documents all the time.

However, better to load fancyhdr directly as fancyheadings just loads it anyway so it is more transparent.

You may even, should you so wish, use TikZ pictures in the arguments to fancyhdr's header- and footer-setting macros. For an example featuring TikZ cats, see below.

The problem you are experiencing is caused by the fact that, without TikZ, the document you are producing is using something like a US letter layout on A4 paper. A4 paper is taller than US letter, so there is more room. But, basically, things just end up all over the place.

When you load TikZ, this loads something (not sure what) which picks up letterpaper from the class and sets the paper accordingly. So now you have letter paper layout on letter paper. But the paper is now shorter and there is not, basically, sufficient space.

The best way of addressing this is to load geometry, but you need to then not make manual adjustments to the layout dimensions but stick to giving geometry package or configuration options.

For example:

\documentclass[12pt,letterpaper]{article}
\usepackage{geometry}
\geometry{width=6.5in,height=9.5in,left=.75in,top=.75in}
\usepackage{fancyhdr}
\usepackage{lastpage}
\pagestyle{fancy}
\cfoot{Page \thepage\ of \pageref{LastPage}}
\renewcommand{\footrulewidth}{1pt}
\usepackage{tikz}
\begin{document}
\begin{center}
\Huge\bfseries More Sets
\end{center}
\end{document}


Note that \bf was deprecated 20+ years ago and ought not be used in LaTeX documents after that date. If starts \documentclass, it shouldn't use \bf or similar.

Note also that \Huge {abc}d is just the same as \Huge abcd. \Huge doesn't take an argument. Like \bfseries, it is a switch.

Anyway, here's the result:

The cats are conspicuous by their absence, but you can't have everything and it does all now get on the page.

However, it does not really fit as fancyhdr tells us:

Package Fancyhdr Warning: \headheight is too small (12.0pt):
Make it at least 14.49998pt.
We now make it that large for the rest of the document.
This may cause the page layout to be inconsistent, however.


So we need to change our layout again, using geometry's interface:

\documentclass[12pt,letterpaper]{article}
\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{lastpage}
\pagestyle{fancy}
\cfoot{Page \thepage\ of \pageref{LastPage}}
\renewcommand{\footrulewidth}{1pt}
\usepackage{tikz}
\begin{document}
\begin{center}
\Huge\bfseries More Sets
\end{center}
\end{document}


Final result:

# Cat example

For example:

\documentclass[welsh,british]{article}
\usepackage[rgb,x11names,dvipsnames,svgnames]{xcolor}
\usepackage{kantlipsum,tikz,fancyhdr,geometry,babel}
\usetikzlibrary{cathod,trambws,positioning,decorations.footprints}
\colorlet{cath1}{blue!50!gray!75}
\colorlet{cath2}{cath1!50}
\colorlet{cath3}{DarkOrchid4}
\colorlet{cath4}{cath3!50}
\colorlet{lliw llygaid1}{Yellow1}
\colorlet{lliw llygaid2}{DarkOrange3}
\colorlet{lliw llygaid3}{Chartreuse1}
\colorlet{lliw llygaid4}{Green4}
\colorlet{lliw trwyn1}{LightPink2}
\colorlet{lliw trwyn2}{HotPink2}
\colorlet{cath5}{LavenderBlush3}
\colorlet{cath6}{LavenderBlush4}
\pagestyle{fancy}
\fancyhf{}
\fancyhf[lh]{%
\tikz{\pic [xscale=-1] {cath eistedd={stripiau=cath1, llenwi=cath2, llygaid mewnol=lliw llygaid3, llygaid allanol=lliw llygaid4, trwyn=lliw trwyn1, maint=1mm}};}%
}
\fancyhf[rh]{%
\tikz{\pic at (57.5mm,0) {cath eistedd={stripiau=cath3, llenwi=cath4, llygaid mewnol=lliw llygaid1, llygaid allanol=lliw llygaid2, trwyn=lliw trwyn2, maint=1mm}};}%
}
\fancyhf[cf]{%
\begin{tikzpicture}
\pic [xscale=-1] at (3,1.4) {cath eistedd={stripiau=cath6,llenwi=cath5,llygaid mewnol=lliw llygaid3,llygaid allanol=lliw llygaid4,trwyn=lliw trwyn2, maint=1mm}};
\draw [line width=.5pt, rounded corners=.25pt, draw=Chocolate4] (3.5,.7) rectangle (3.6,.75);
\draw [rounded corners=1pt, inner color=Chocolate3!95, outer color=Chocolate3, draw=Chocolate4, line width=.5pt] (3.35,.4) rectangle (3.75,.7);
\draw [decorate, fill=Chocolate4, draw=Chocolate4, decoration={footprints, foot of=felis silvestris, foot length=.35pt, stride length=.4pt, foot angle=-30}] (3.625,.55) -- (3.525,.6);
\draw [line width=1pt, line cap=round, draw=OliveDrab4] (4.75,1.85) -- (4.75,.25) coordinate [pos=.04] (a);
\node [double=Green2, double distance=.25pt, draw=Green4!50!black, line width=.25pt, rounded corners=1pt, text=white, inner sep=1pt, fill=Green4, font=\sffamily\tiny\bfseries, align=center, anchor=north east] at ([xshift=1pt]a) {BUS STOP\\{\selectlanguage{welsh}SAFLE BYSIAU}};
\pic [lliw y tram=Red2, lliw ffenestri=Snow3] at (-2,0) {tram=5};
\end{tikzpicture}
}
\begin{document}
\kant[1-6]
\end{document}
`