如何同时使用 fancyhdr 和 \maketitle

如何同时使用 fancyhdr 和 \maketitle

我试图同时使用 fancy header 和 \maketitle。这会导致问题,因为 \maketitle 显然会调用 \plainstyle,而后者会覆盖 fancyhdr 设置。有没有简单的补丁可以解决此问题?在下面的 MWE 中,注释和取消注释第 34 行会完全改变文档的布局。我想保留注释掉 \maketitle 的所有文档特征,只添加有关文本列的标题部分。有什么帮助吗?

\documentclass[a4paper,11pt]{article}

%..define packages to be used in controlling document features and layout  
\usepackage{multicol}
\usepackage[left=1.5cm,right=1.5cm,bottom=2cm,top=1cm]{geometry}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage{fancyhdr, lipsum}
\usepackage{textcomp}
\usepackage{titling}

\usepackage{etoolbox} %..http://tex.stackexchange.com/questions/199317/custom-footer-on-title-page-using-maketitle-and-book-document-class
\patchcmd{\maketitle}
  {\end{titlepage}}
  {\thispagestyle{titlepagestyle}\end{titlepage}}
  {}{}

%..This section controls the header-footer layout of the document
\setlength\headheight{25mm}
\pagestyle{fancy}

\fancyhead[L]{\parbox[b][10mm][t]{0.5\textwidth}{\large{COMPANY NAME HERE}}}
\fancyhead[R]{LOGO HERE}

\fancyfoot[C]{\textit{\textcopyright \,DRAFT: SOME COMPANY, \today}}

%..This section controls the title layout
\title{TITLE}
\author{NAME and ID}
\date{\today}

\begin{document}

%\maketitle

\begin{multicols*}{2}

\section{First Section}

Hello, here is some text without a meaning.  This text should show what  a printed text will look like at this place. If you read this text, you will get no information.  Really?  Is there no information?  Is there...

\section{Second Section}

Hello, here is some text without a meaning.  This text should show what  a printed text will look like at this place. If you read this text, you will get no information.  Really?  Is there no information?  Is there...

\end{multicols*}

\end{document}

答案1

目前,当您到达列的底部时,页面底部将消失为 Never, Never Land。这是因为您在完成其魔力headheight之后更改了值。geometry

如果您headheight=25mm在 的选项中包含geometry,则页眉会被截断,因为您没有留出足够的空间。top不能小于您想要的页眉大小。

article默认情况下不使用,titlepage因此修补无效。由于它使用未定义的页面样式,因此这可能也一样。

这是固定版本,在保证页面内容合适的前提下,尽可能保留您的布局。我用它showframe来使布局更清晰。

\thispagestyle{fancy}用于\maketitle确保页眉和页脚之后。

固定布局适合页面

\documentclass[a4paper,11pt]{article}

%..define packages to be used in controlling document features and layout
\usepackage{multicol}
\usepackage[left=1.5cm, right=1.5cm, bottom=2cm, top=25mm, marginparwidth=0pt, headheight=25mm, verbose, showframe]{geometry}% top must be at least headheight!
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage{fancyhdr, lipsum}
\usepackage{textcomp}
\usepackage{titling}

%..This section controls the header-footer layout of the document
\pagestyle{fancy}

\fancyhead[L]{\parbox[b][10mm][t]{0.5\textwidth}{\large{COMPANY NAME HERE}}}
\fancyhead[R]{LOGO HERE}

\fancyfoot[C]{\textit{\textcopyright \,DRAFT: SOME COMPANY, \today}}

%..This section controls the title layout
\title{TITLE}
\author{NAME and ID}
\date{\today}

\begin{document}

  \maketitle\thispagestyle{fancy}

  \begin{multicols*}{2}

    \section{First Section}

    \lipsum[1-10]

    \section{Second Section}

    \lipsum[11-20]

  \end{multicols*}

\end{document}

答案2

fancyhdr 文档第 7 页讨论了这个问题。只需重新定义plain页面样式:

 \fancypagestyle{plain}{INSERT YOUR DEFINITIONS}

相关内容