仅从首页删除双线页眉

仅从首页删除双线页眉

这是这个问题的延续创建一个包含图片的框。我现在尝试复制下图所示的页眉和页脚

在此处输入图片描述

我曾尝试复制这种风格,但遇到了两个问题。

在此处输入图片描述

甚至我已经为首页定义了一个纯样式,双线页眉不会消失。

第二个问题可能与第一个问题有关,即页眉也与后续页面的文本重叠。

我认为这些问题是由于标题中粗体额外行定义在规则下方而不是上方所导致的,但我尝试修复这个问题却是徒劳的。

在此处输入图片描述

\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}  

答案1

您必须\headrule在页面样式定义中重新定义plain。为避免文本与页眉重叠,请用 替换旧fullpagegeometry

在此处输入图片描述

代码:

\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}

如果确实需要,你可以改变headsep

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

上面的例子的headsep=7pt结果是

在此处输入图片描述


由于评论中的一个问题:要交换标题中的细线和粗线,您可以移到height 2pt第二个\hrule命令后面:

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

结果:

在此处输入图片描述

相关内容