3

I am trying to insert a table on the header, just like the example below. The whole document where I was inspired to create this header can be found here Moshell User Guide.

Sample of desired output

On this picture this is header on every page of the document. The pages of course can vary based on the page number.

I have created a sample of code, that can reproduce the table format and also the header with the logo on the left the text in the middle and the page numbering on the right.

Sample of code provided below:

\documentclass{memoir}
\usepackage[ a4paper , centering ]{geometry}
\usepackage{graphicx} % demo option just for the example
\usepackage{lipsum} % demo option just for text
\usepackage{lastpage} % include last page numbering
\usepackage{chngpage} % allows for temporary adjustment of side margins
\usepackage{datetime}
\newdateformat{mydate}{\THEYEAR-\twodigit{\THEMONTH}-\twodigit{\THEDAY}}

\makepagestyle{mystyle}
\makeevenhead{mystyle}{\includegraphics[height=20pt]{LaTeX_logo}}{\hspace{3cm}Informational\\\hspace{3.1cm} USER GUIDE}{\thepage(\pageref{LastPage})}
\makeoddhead{mystyle}{\includegraphics[height=20pt]{LaTeX_logo}}{\hspace{3cm}Informational\\\hspace{3.1cm} USER GUIDE}{\thepage(\pageref{LastPage})}

\pagestyle{mystyle}
\begin{document}

\begin{table}
  \begin{adjustwidth}{-1in}{-1in}  
    \begin{center}
      \begin{tabular}{|l|l|l|l|l|l|} 
      \hline
      \multicolumn{3}{|l}{{\small\textbf{Prepared (subject responsible)}}} & \multicolumn{3}{|l|}{{\small\textbf{No.}}} \\
      \multicolumn{3}{|l}{Thanos 1 \& Thanos 2} & \multicolumn{3}{|l|}{1553-CXC1328930} \\ \hline
      \multicolumn{1}{|l}{{\small\textbf{Approved (Document responsible)}}} & & \multicolumn{1}{l}{{\small\textbf{Checked}}} & \multicolumn{1}{|l}{{\small\textbf{Date}}} & \multicolumn{1}{|l|}{{\small\textbf{Rev.}}} & \multicolumn{1}{l|}{{\small\textbf{Reference}}} \\
      \multicolumn{1}{|l}{ } & \multicolumn{1}{l}{ } & \multicolumn{1}{l}{ } & \multicolumn{1}{|l}{\mydate\today} & \multicolumn{1}{l}{J} & \multicolumn{1}{l|}{Thanos\_UserGuide.tex} \\ \hline
      \end{tabular}
    \end{center}
  \end{adjustwidth}
\end{table}

\tableofcontents
\listoffigures
\listoftables

\lipsum[1-20]

\end{document} 

I want the header to start from the very first page. Unfortunately on my code the header starts on the second page because of the table of contents, list of figures and list of tables. I am using the memoir class because I think it is the most correct to solve my problem but maybe it can be done also by other classes. Thanks in advance for your time and effort.

  • You need to change the plain page style which is used on the first page of chapters. (Or whatever the memoir equivalent of plain is.) – cfr Dec 5 '14 at 0:16
  • I tried this and it did work unfortunately. Thank you for your time and effort to help me though, I appreciate it. – Thanos Dec 5 '14 at 0:23
  • Do you mean that it did not work? Otherwise, I don't see why it would be unfortunate. However, if it didn't work, it would be helpful to say what happened. (And did you look at the documentation of memoir to figure out what it uses on the first page of chapters? plain is just an example from the standard classes.) – cfr Dec 5 '14 at 0:25
  • Note that using geometry rides roughshod over all the effort memoir puts into laying out your pages nicely! – cfr Dec 5 '14 at 0:27
  • OK. I'm also confused. In the code you posted, the table is just a table. It is not part of your header. You have separate headers which include the page number and graphic etc. But the table you define is just part of the document. Also, that is on the first page. So is the table not part of the header? Is it that you want that and the header on the first page and then just the header? Or...? – cfr Dec 5 '14 at 0:34
3

Here's the scheme: the table is inserted as the center field in the header, as a zero width box. For having it in all pages, use

\aliaspagestyle{plain}{mystyle}

so memoir will use mystyle also in the pages where plain is requested. The head height can be set after compiling once and looking in the .log file for a message such as

Class memoir Warning: The material used in the headers is too large
(73.19998pt) for the given head height (50.0pt), it is recommended to
either increase the head height or redesign the header
(in both cases you will find help in the memoir manual).

Here's the code. Note that the whole header is a single tabular.

\documentclass{memoir}
\usepackage[a4paper,centering,headheight=75pt]{geometry}
\usepackage[demo]{graphicx} % demo option just for the example
\usepackage{lipsum} % demo option just for text
\usepackage{lastpage} % include last page numbering
\usepackage{chngpage} % allows for temporary adjustment of side margins
\usepackage{datetime}
\newdateformat{mydate}{\THEYEAR-\twodigit{\THEMONTH}-\twodigit{\THEDAY}}

\makepagestyle{mystyle}
\makeevenhead{mystyle}{}{\thanoshead}{}
\makeoddhead{mystyle}{}{\thanoshead}{}

\newcommand{\thanoshead}{%
  \makebox[0pt]{%
    \begin{tabular}{|l|l|l|l|l|l|}
    \multicolumn{3}{@{}l}{\includegraphics[height=20pt]{LOGO}} &
      \multicolumn{2}{l}{\begin{tabular}[b]{@{}l@{}}Informational\\USER GUIDE\end{tabular}} &
      \multicolumn{1}{r@{}}{\thepage(\pageref{LastPage})} \\
    \hline
    \multicolumn{3}{|l|}{\small\textbf{Prepared (subject responsible)}} &
      \multicolumn{3}{l|}{\small\textbf{No.}} \\
    \multicolumn{3}{|l|}{Thanos 1 \& Thanos 2} &
      \multicolumn{3}{l|}{1553-CXC1328930} \\
    \hline
    \small\textbf{Approved (Document responsible)} & &
    \small\textbf{Checked} & \small\textbf{Date} &
      \small\textbf{Rev.} & \small\textbf{Reference} \\
    & & & \mydate\today & J & Thanos\_UserGuide.tex \\
    \hline
    \end{tabular}%
  }%
}

\pagestyle{mystyle}
\aliaspagestyle{plain}{mystyle}

\begin{document}

\tableofcontents
\listoffigures
\listoftables

\lipsum[1-20]

\end{document} 

enter image description here

  • Perfect is exactly what I wanted to do. Thank you for your time and effort. – Thanos Dec 5 '14 at 1:38
2

I've done this with book since you are overriding memoir's page layout anyway and it is simpler to do it without needing to define tripartite headers.

I use fancyhdr to configure the header. I read the output to figure out what the header height needed to be so that I could feed this to geometry.

Since you want the header on every page, I've just redefined the plain style and used that. I used demo mode since I don't have your logo file, and I tidied up the table a bit.

\documentclass[a4paper]{book}
\usepackage[centering, headheight=80pt]{geometry}
\usepackage[demo]{graphicx} % demo option just for the example
\usepackage{lipsum} % demo option just for text
\usepackage{lastpage} % include last page numbering
\usepackage{datetime,array,fancyhdr}
\newdateformat{mydate}{\THEYEAR-\twodigit{\THEMONTH}-\twodigit{\THEDAY}}

\newsavebox{\mytabularheader}
\newsavebox{\mytabularheadertitle}
\sbox{\mytabularheadertitle}{%
  \begin{minipage}[b]{.175\textwidth}
    Informational\\USER GUIDE
  \end{minipage}}

\renewcommand{\headrulewidth}{0pt}
\fancypagestyle{plain}{%
  \fancyhf{}%
  \fancyhf[ch]{\usebox{\mytabularheader}}}

\pagestyle{plain}
\begin{document}

\sbox{\mytabularheader}{%
  \begin{minipage}{\textwidth}
    \centering
    \begin{tabular}{|*{6}{>{\small}l|}}
      \multicolumn{3}{l}{\includegraphics[height=20pt]{example-image-a}} & \multicolumn{2}{l}{\usebox{\mytabularheadertitle}} & \multicolumn{1}{r}{\thepage(\pageref{LastPage})}\\[.25em]
      \hline
      \multicolumn{3}{|>{\small}l}{\textbf{Prepared (subject responsible)}} & \multicolumn{3}{|>{\small}l|}{\textbf{No.}} \\
      \multicolumn{3}{|>{\small}l}{Thanos 1 \& Thanos 2} & \multicolumn{3}{|>{\small}l|}{1553-CXC1328930} \\ \hline
      \multicolumn{2}{|>{\small}l|}{\textbf{Approved (Document responsible)}}  & \textbf{Checked} & \textbf{Date} & \textbf{Rev.} & \textbf{Reference} \\
      \multicolumn{2}{|>{\small}l|}{} &  & \mydate\today & J & Thanos\_UserGuide.tex \\ \hline
    \end{tabular}
  \end{minipage}}

  \tableofcontents
  \listoffigures
  \listoftables

  \lipsum[1-20]

\end{document}

tabular pages

  • Really nice answer, as a possible alternative. I will keep this in mind in case that I will use an alternative class than memoir. Again thank you for your time and effort. – Thanos Dec 5 '14 at 1:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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