Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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 at 22:48
    
The reason is that \chapter{} makes use of \thispagestyle{empty}. –  Sigur Apr 16 at 22:48
    
Please complete your code to make it compile. –  cfr Apr 16 at 22:52
    
@Sigur Chapter uses plain pagestyle. –  Harish Kumar Apr 16 at 22:53
    
@HarishKumar, but with the option that the first page has no header. Am I right? –  Sigur Apr 16 at 23:00

3 Answers 3

up vote 8 down vote accepted

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.

share|improve this answer
    
Do you not get complaints about multiply defined labels? –  cfr Apr 16 at 22:54
    
@cfr No. But that label I forgot Thanks.:) –  Harish Kumar Apr 16 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 –  user1326876 Apr 16 at 22:57
    
@user1326876 You want borders on all sides or only below as in your picture in the OP? –  Harish Kumar Apr 16 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 –  user1326876 Apr 16 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}

enter image description here

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

share|improve this answer

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

enter image description here enter image description here enter image description here

Code

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

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


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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.