0

This is a continuation of this question Creating a box containing a picture. Where I now attempt at replicating the header and footer seen in the image below

enter image description here

I have attempted at replicating this style, but ran into two problems.

enter image description here

Even after I have defined a plainstyle for the frontpage, the double lined header will not go away.

Second problem which is probably related to the first, is that the header also overlaps with the text on the following pages.

I think these problems are caused by the bold extra line is defined below and not above the hrule in the header, however my attempts at fixing this was futile.

enter image description here

\documentclass[a4paper, norsk]{article}    

\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage{fullpage}

\usepackage{lipsum}


\usepackage{lastpage} % number of last page 
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}

\renewcommand\footrule{\begin{minipage}{1\textwidth}
\hrule width \hsize height 2pt \kern 1mm \hrule width \hsize   
\end{minipage}\par}%

\renewcommand\headrule{\begin{minipage}{1\textwidth}
\hrule width \hsize height 2pt \kern 1mm \hrule width \hsize   
\end{minipage}\par}%

\cfoot{\today}
\rfoot{Page \thepage\ of \pageref{LastPage}}

\lhead{MA1103 Flerdimensjonal analyse, vår 2018}

\fancypagestyle{plain}{% Redefine ``plain'' style for chapter boundaries  
\fancyhf{} % clear all header and footer fields  

\renewcommand\footrule{\begin{minipage}{1\textwidth}
\hrule width \hsize height 2pt \kern 1mm \hrule width \hsize   
\end{minipage}\par}%

\renewcommand{\headrulewidth}{0pt} 

\fancyfoot[C]{\today} % except the center  
\fancyfoot[R]{Side \thepage\ av \pageref{LastPage}} % except the center  
}

\definecolor{mblue}{RGB}{0,72,161}

\newcommand{\ntnulogo}{%
  \leavevmode
  \vtop{
    \hrule height 0pt
    \hbox{%
      \begin{tikzpicture}
      \fill[mblue, rounded corners=5mm] (0,2) rectangle (2,4);
      \fill[white] (0.5,2.5) rectangle (1.5,3.5);
      \fill[mblue] (1,3) circle (4mm);
      \end{tikzpicture}%
    }
  }
}
\newcommand{\course}{%
  \leavevmode
  \vtop{\LARGE
    \hrule height 0pt
    \ialign{\hfil##\cr
      MA1103\cr
      Flerdimensjonal analyse\cr
      Vår 2018\cr
    }%
  }%
}

\newcommand{\titlebox}[2]{
\thispagestyle{plain}
\begin{center}
\setlength{\fboxsep}{0pt}
\fbox{%
  \begin{minipage}{\dimexpr\textwidth-2\fboxrule}
  \vspace{1pt}
  \hrule height 1pt
  \vspace{6pt}
  \mbox{}\quad\ntnulogo\hfill\course\quad\mbox{}\\[3pt]
  \mbox{}\quad
  \begin{tabular}{@{}l@{}}
  Norges teknisk-vitenskapelige\\
  universitet\\
  Insitutt for matematiske fag
  \end{tabular}\hfill%
  \textbf{\large #1. #2}\quad\mbox{}\\
  \vspace{3pt}
  \hrule height1pt
  \vspace{1pt}
  \end{minipage}%
}
\end{center}
}

\begin{document}

\titlebox{Øving 1}{Frist: Søndag 21. januar kl 23:59}

\lipsum

\end{document}  
4

You have to redefine \headrule inside the definition of page style plain. To avoid the overlap of the text with the page header replace the old package fullpage by geometry.

enter image description here

Code:

\documentclass[a4paper, norsk]{article}    
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in,includeheadfoot]{geometry}% <- instead package fullpage
\usepackage{lipsum}
\usepackage{lastpage} % number of last page 
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand\footrule{\begin{minipage}{1\textwidth}
\hrule width \hsize height 2pt \kern 1mm \hrule width \hsize   
\end{minipage}\par}%

\renewcommand\headrule{\begin{minipage}{1\textwidth}
\hrule width \hsize height 2pt \kern 1mm \hrule width \hsize   
\end{minipage}\par}%

\cfoot{\today}
\rfoot{Page \thepage\ of \pageref{LastPage}}
\lhead{MA1103 Flerdimensjonal analyse, vår 2018}

\fancypagestyle{plain}{% Redefine ``plain'' style for chapter boundaries  
  \fancyhf{} % clear all header and footer fields  
  \renewcommand\footrule{\begin{minipage}{1\textwidth}
  \hrule width \hsize height 2pt \kern 1mm \hrule width \hsize   
  \end{minipage}\par}%
  \renewcommand{\headrulewidth}{0pt}
  %
  \renewcommand{\headrule}{}% <- added
  %
  \fancyfoot[C]{\today} % except the center  
  \fancyfoot[R]{Side \thepage\ av \pageref{LastPage}} % except the center  
}

\definecolor{mblue}{RGB}{0,72,161}
\newcommand{\ntnulogo}{%
  \leavevmode
  \vtop{
    \hrule height 0pt
    \hbox{%
      \begin{tikzpicture}
      \fill[mblue, rounded corners=5mm] (0,2) rectangle (2,4);
      \fill[white] (0.5,2.5) rectangle (1.5,3.5);
      \fill[mblue] (1,3) circle (4mm);
      \end{tikzpicture}%
    }
  }
}
\newcommand{\course}{%
  \leavevmode
  \vtop{\LARGE
    \hrule height 0pt
    \ialign{\hfil##\cr
      MA1103\cr
      Flerdimensjonal analyse\cr
      Vår 2018\cr
    }%
  }%
}
\newcommand{\titlebox}[2]{
\thispagestyle{plain}
\begin{center}
\setlength{\fboxsep}{0pt}
\fbox{%
  \begin{minipage}{\dimexpr\textwidth-2\fboxrule}
  \vspace{1pt}
  \hrule height 1pt
  \vspace{6pt}
  \mbox{}\quad\ntnulogo\hfill\course\quad\mbox{}\\[3pt]
  \mbox{}\quad
  \begin{tabular}{@{}l@{}}
  Norges teknisk-vitenskapelige\\
  universitet\\
  Insitutt for matematiske fag
  \end{tabular}\hfill%
  \textbf{\large #1. #2}\quad\mbox{}\\
  \vspace{3pt}
  \hrule height1pt
  \vspace{1pt}
  \end{minipage}%
}
\end{center}
}
\begin{document}
\titlebox{Øving 1}{Frist: Søndag 21. januar kl 23:59}

\lipsum
\end{document}

If really needed you can change headsep:

\usepackage[...,headsep=<length>]{geometry}

The example above with headsep=7pt results in

enter image description here


Because of a question in a comment: To swap the thin and the thick line in the header you can move height 2pt behind the second \hrule command:

\renewcommand\headrule{\begin{minipage}{1\textwidth}
  \hrule width \hsize \kern 1mm \hrule width \hsize height 2pt
\end{minipage}\par}%

Result:

enter image description here

|improve this answer|||||
  • This looks amazing! Thanks for telling me that fullpage is deprecated. Two quick questions though: 1. do you have any idea how to swap the thick and thin line in the header? 2. Any idea how I can place the first command in \titlepage on the right in the header? Thanks again! – N3buchadnezzar Jan 17 '18 at 12:53
  • 1
    @N3buchadnezzar For the first question see my updated answer. But note that this has nothing to do with your original question. I do not understand your second question: what should be on the right in the header of the first page? Maybe you have to ask a new question. – esdd Jan 17 '18 at 13:14

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.