# Fancyhdr - Is it possible to have a small table inside header?

Ok, I'm trying to create this type of formatting for each of my pages:

Now, I want to have this on every single page, in the header on the right hand side. I currently have the following:

\usepackage{fancyhdr}

\begin{table}[ht!]

\begin{tabular}{c}
safasf
\end{tabular}
\label{lable:nonlin}
\end{table}

}
\fancyfoot{}
\fancyfoot[LE, RO]{\thepage}
\fancyfoot[LO, CE]{Chapter \thechapter}

\begin{document}
\input{title}

\chapter{Introduction}
...

\chapter{Background}
...

\chapter{Conclusion}
...

\end{document}


I want to have this header, on every page even on the chapter pages. Before, using normal text.. The header does not appear to be on the chapter page.

Could anyone offer any solutions or suggestions please?

-
Your example is not compilable because missing statements and documentclass. And the table is a floating one, I am not sure whether fancyheader will do with floats. –  Christian Hupfer Apr 16 '14 at 22:48
The reason is that \chapter{} makes use of \thispagestyle{empty}. –  Sigur Apr 16 '14 at 22:48
Please complete your code to make it compile. –  cfr Apr 16 '14 at 22:52
@Sigur Chapter uses plain pagestyle. –  Harish Kumar Apr 16 '14 at 22:53
@HarishKumar, but with the option that the first page has no header. Am I right? –  Sigur Apr 16 '14 at 23:00

You can put tabular material inside the header. But if you use table (which is a float) it won't work. Also the chapter page is given plain page style by default. Hence you have to redefine the plain pagestyle to be fancy.

\documentclass[twoside]{book}
\usepackage{fancyhdr}
\begin{tabular}[b]{c}
safasf
\end{tabular}
}
\fancyfoot{}
\fancyfoot[LE, RO]{\thepage}
\fancyfoot[LO, CE]{Chapter \thechapter}

\makeatletter
\let \ps@plain\ps@fancy
\makeatother

\pagestyle{fancy}

\begin{document}
%  \input{title}

\chapter{Introduction}
...

\chapter{Background}
...

\chapter{Conclusion}
...

\end{document}


With colored line:

\documentclass[twoside,table]{book}
\usepackage{fancyhdr,xcolor}
\usepackage{xcolor}

\begin{tabular}[b]{@{}l@{}}
\arrayrulecolor{blue!75}
safasf \\
\\\hline
\end{tabular}%
}
\fancyfoot{}
\fancyfoot[LE, RO]{\thepage}
\fancyfoot[LO, CE]{Chapter \thechapter}

\makeatletter
\let \ps@plain\ps@fancy
\makeatother

\pagestyle{fancy}

\begin{document}
%  \input{title}

\chapter{Introduction}
...

\chapter{Background}
...

\chapter{Conclusion}
...

\end{document}


With \includegraphics:

\documentclass[twoside,table]{book}
\usepackage{fancyhdr,xcolor}
\usepackage{graphicx}

\includegraphics[width=2in]{capture}%
}
\fancyfoot{}
\fancyfoot[LE, RO]{\thepage}
\fancyfoot[LO, CE]{Chapter \thechapter}

\makeatletter
\let \ps@plain\ps@fancy
\makeatother

\pagestyle{fancy}

\begin{document}
%  \input{title}

\chapter{Introduction}
...

\chapter{Background}
...

\chapter{Conclusion}
...

\end{document}


You may also use a minpage wrapping around the \includegraphics for vertical position adjustment if needed.

-
Do you not get complaints about multiply defined labels? –  cfr Apr 16 '14 at 22:54
@cfr No. But that label I forgot Thanks.:) –  Harish Kumar Apr 16 '14 at 22:56
@Harish Kumar Thanks for the reply. But, how would I therefore put a boarder around the "sfsfsf" and make it right aligned even on the first page? It's kinda confusing –  Phorce Apr 16 '14 at 22:57
@user1326876 You want borders on all sides or only below as in your picture in the OP? –  Harish Kumar Apr 16 '14 at 22:58
@HarishKumar - Hey, as my graphic suggests, the idea is that it will look just like this but will be in the same location on everypage (i.e top right).. But, I could just use an image, let me try this.. Thanks –  Phorce Apr 16 '14 at 23:00

Since this is for all the pages, you could use the background package:

\documentclass{book}
\usepackage[scale=1,opacity=1,angle=0,color=black]{background}
\usepackage{tikzpagenodes}
\usepackage{fancyhdr}

\backgroundsetup{
contents={
\tikz\node[draw,text width=4cm,anchor=south east,inner sep=10pt,outer sep=0pt]
{For office use only  \\[10pt] \rule{4cm}{0.4pt}};
},
position={current page header area.south east} ,
nodeanchor=south east,
vshift=-\pgflinewidth
}
\fancyhf{}
\fancyfoot{}
\fancyfoot[LE, RO]{\thepage}
\fancyfoot[LO, CE]{Chapter \thechapter}

\pagestyle{fancy}

\begin{document}

\chapter{Test chapter}
some text\clearpage some text

\end{document}


The tikzpagenodes package was used to have easy access to the header area.

-

An alternative to Harish Kumar's approach, a third option is to define a new environment called tablehere that won't float as displayed below.

\makeatletter
\newenvironment{tablehere}
{\def\@captype{table}}
{}
\makeatother


Same idea for images

\makeatletter
\newenvironment{figuehere}
{\def\@captype{figure}}
{}
\makeatother


Code

\documentclass[twoside]{book}
\usepackage{fancyhdr}

\makeatletter
\newenvironment{tablehere}
{\def\@captype{table}}
{}
\makeatother

\begin{tablehere}
\begin{tabular}[b]{|c|}\hline
For office use only  \\[10pt] \rule{4cm}{0.4pt}
\end{tabular}
\end{tablehere}
}
\fancyfoot{}
\fancyfoot[LE, RO]{\thepage}
\fancyfoot[LO, CE]{Chapter \thechapter}

\makeatletter
\let \ps@plain\ps@fancy
\makeatother

\pagestyle{fancy}

\begin{document}
%  \input{title}

\chapter{Introduction}
...

\chapter{Background}
...

\chapter{Conclusion}
...

\end{document}

-