[Tex/LaTex] Fancyhdr – Is it possible to have a small table inside header

fancyhdrheader-footerthesis

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

enter image description here

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}
\fancyhead{}
\fancyhead[RO, LE]{
    
    \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?

Best Answer

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}
\fancyhead{}
\fancyhead[RO, LE]{
    \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}

enter image description here

With colored line:

\documentclass[twoside,table]{book}
\usepackage{fancyhdr,xcolor}
\usepackage{xcolor}
\usepackage[margin=1in,headheight=0.5in]{geometry}

\fancyhead{}
\fancyhead[RO, LE]{%
    \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}

enter image description here

With \includegraphics:

\documentclass[twoside,table]{book}
\usepackage{fancyhdr,xcolor}
\usepackage{graphicx}
\usepackage[margin=1in,headheight=0.75in]{geometry}

\fancyhead{}
\fancyhead[RO, LE]{%
    \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}

enter image description here

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