Page Headers – Creating Page Header with Box Sections and Page Border in LaTeX

fancyhdrgeometrypgfplotstabletikz-pgf

So I'm currently working on converting some documents used in our university to use LaTeX, and I'm stuck on a bit of a hangup. I've been able to nail down all the basics, using plotting, etc; but I can't seem to figure out how I can re-create the headers and page look.

Here's an example of the header on the title page (the upper section will be present throughout the doc):

I've been able to create the page border with pgfpages, but I cant seem to make the coherent page table show up and work. Is this stuff even possible with LaTeX?

Best Answer

Here's one possibility using the background and tikzpagenodes packages to produce both the header and the frame; the code contains some explanatory comments:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[scale=1,angle=0,opacity=1,color=black!60]{background}
\usepackage{tikzpagenodes}
\usepackage{lastpage}
\usepackage{lmodern}
\usepackage{lipsum}

\makeatletter

% A length to control the separation of the text and the frame
\newlength\AUCFrameSep
\setlength\AUCFrameSep{2cm}

% A length to control the height of the minipages used in the header
\newlength\AUCBoxHt
\setlength\AUCBoxHt{1.5cm}

% A length to control the width of the frame
\newlength\AUCFrameWd
\setlength\AUCFrameWd{\textwidth}
\addtolength\AUCFrameWd{2\AUCFrameSep}

% Definition of the user commands to fill the header
% Initially they are empty
\newcommand\Description[1]{\gdef\@ACUdescription{\textsc{#1}}}
\newcommand\LibNum[1]{\gdef\@ACUlibnum{\textsc{#1}}}
\newcommand\Rev[1]{\gdef\@ACUrev{#1}}
\Description{}
\LibNum{}
\Rev{}

% Command to build each one of the boxes for the header
% \AUCBox{<width>}{<title>}{<contents>}
% The optional argument controls the height of the minipages;
% default value= \AUCBoxHt 
\newcommand\AUCBox[4][\AUCBoxHt]{%
\fbox{\begin{minipage}[t][#1][t]{#2}
\begin{flushleft}\footnotesize #3\end{flushleft}
\centering#4
\end{minipage}}}

% We define the background: the header and the frame
\backgroundsetup{%
contents={%
\begin{tikzpicture}[remember picture,overlay]
\draw 
  ([xshift=-\AUCFrameSep,yshift=-2cm]current page text area.north west|-current page.north west)
  rectangle
  ([xshift=\AUCFrameSep,yshift=-1.5\AUCFrameSep]current page text area.south east);
\node[anchor=north west,xshift=-\the\dimexpr\AUCFrameSep+\fboxrule\relax,yshift=-2cm,inner sep=0pt,outer sep=0pt] at (current page text area.north west|-current page.north west)
{%
  \sffamily\small%
  \setlength\fboxsep{2pt}%
  \AUCBox{\dimexpr.6\AUCFrameWd-3\fboxrule-8\fboxsep\relax}{Description}{\@ACUdescription}\kern-\fboxrule%
  \AUCBox{.175\AUCFrameWd}{Lib Num}{\@ACUlibnum}\kern-\fboxrule%
  \AUCBox{0.10\AUCFrameWd}{Rev.}{\@ACUrev}\kern-\fboxrule%
  \AUCBox{0.125\AUCFrameWd}{Page}{\scshape\thepage\ of \pageref{LastPage}}%
};%
\end{tikzpicture}%
  }
}
\makeatother

\Description{\vskip-2ex%
  Description line 1 \\
  Description line 2 \\
  Description line 3 \\
}
\LibNum{Doc 12345}
\Rev{---}

\begin{document}

\lipsum[2-20]

\end{document}

An image of the document:

enter image description here

A zoomed-in image of the header:

enter image description here