I'm trying to create table inside Hearder to looks like this :
but with my following
Code:
\documentclass{article}
\usepackage[margin=1in,top=0.5in,headheight=5\baselineskip,headsep=1\baselineskip,includehead]{geometry}
\usepackage{tabularx}
\usepackage{graphicx}
%create table =============================================================================================================================
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{lastpage}
\usepackage{lipsum}
\usepackage{array}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{longtable}
\definecolor{MatlabCellColour}{RGB}{252,251,220}
\newcolumntype{A}[2]{%
>{\minipage{\dimexpr#1\linewidth-2\tabcolsep-#2\arrayrulewidth\relax}\vspace\tabcolsep}%
c<{\vspace\tabcolsep\endminipage}}
\newenvironment{Table}[4]{%
\longtable{%
|A{#1}{1.5}% for figure
|>{\centering$\displaystyle}A{#2}{1}<{$}% for inline equation
|>{\correction{-1}\strut\[}A{#3}{1}<{\]\strut}% for displayed equation
|>{\centering}A{#4}{1.5}% for text
|}\hline\ignorespaces}{%
\endlongtable\ignorespacesafterend}
%% some invisible "struts" to help define the structures and row heights.
%% set up and width for the tabularx environment to expand and fit to.
\newlength{\headerwidth}
\setlength{\headerwidth}{\textwidth}
\newsavebox{\myheader}
\begin{lrbox}{\myheader}%
\begin{minipage}[b]{\headerwidth}
\noindent
\longtable{|A{0.2}{1.5}|A{0.2}{1.5}||A{0.2}{1.5}|A{0.2}{1.5}|}\arrayrulecolor{green}\hline\hline
\rowcolor{MatlabCellColour} \multicolumn{1}{|A{0.3}{1}|}{\centering Author }& \multicolumn{3}{|A{0.7}{1}|}{ \centering Universität der Mathematik Department of Mathematics }\tabularnewline\hline\hline
\multicolumn{1}{|A{0.2}{1}|}{ \textbf{Page \thepage \ of \ \pageref{LastPage} } } & \multicolumn{1}{|A{0.2}{1}|}{\centering Subject } & \multicolumn{1}{|A{0.2}{1}|}{ \centering Year } & \multicolumn{1}{|A{0.3}{1}|}{\centering Mathematics competitions }\tabularnewline\hline
\endlongtable
\vspace{-0.5ex}\par
\bfseries
Time: 120 Min \hspace*{\fill}
Date: \hspace*{\fill}
Marks:40
\bigskip
\end{minipage}
\bigskip
\end{lrbox}
%% Setting up the header
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\lhead{}
\chead{\usebox{\myheader}}
\rhead{}
\lfoot{}
\cfoot{}
\rfoot{}
\begin{document}
\noindent
\longtable{|A{0.2}{1.5}|A{0.2}{1.5}||A{0.2}{1.5}|A{0.2}{1.5}|}\arrayrulecolor{green}\hline\hline
\rowcolor{MatlabCellColour} \multicolumn{1}{|A{0.3}{1}|}{\centering Author }& \multicolumn{3}{|A{0.7}{1}|}{ \centering Universität der Mathematik Department of Mathematics }\tabularnewline\hline\hline
\multicolumn{1}{|A{0.2}{1}|}{ \textbf{Page \thepage \ of \ \pageref{LastPage} } } & \multicolumn{1}{|A{0.2}{1}|}{\centering Subject } & \multicolumn{1}{|A{0.2}{1}|}{ \centering Year } & \multicolumn{1}{|A{0.3}{1}|}{\centering Mathematics competitions }\tabularnewline\hline
\endlongtable
\vspace{-0.5ex}\par
\bfseries
Time: 120 Min \hspace*{\fill}
Date: \hspace*{\fill}
Marks:40
\bigskip
\lipsum[1]
\newpage
\lipsum[1]
\end{document}
I got this
- Could anyone offer any solutions or suggestions please?
Best Answer
Another code using
tabulary
this time, but the main idea is the same "keep it simple" principle.