我如何获取该页眉和页脚?

我如何获取该页眉和页脚?

在每个分页标题中,我希望左侧有标题、作者,右侧有章节名称,右侧有缩进和日期。我尝试了很久。这对我的论文非常重要。请有人帮我解决这个问题。以下是 MS Word 表示:

[ Title ]  - [ Subtitle ]                                            1 Introduction
[Author’s name]                                                       2012-01-04
------------------------------------------------------------------------------------

1 Introduction

   xxxxxxxxxxxxxxxxxxxxxxxxxxx
-------------------------------------------------------------------------------------
                                  1

我稍微编辑了艾伦的脚本...我需要的只是摘要、致谢和介绍页中的页眉和页脚...这是编辑后的脚本。

\documentclass{report}
\usepackage{titling}
\usepackage{fancyhdr}
\usepackage{lipsum} % for dummy text only


\makeatletter
% These commands follow the titling package format for titles
% They define user commands to format the subtitle
\newcommand\presubtitle[1]{\gdef\@presubtitle{#1}}
\newcommand\postsubtitle[1]{\gdef\@postsubtitle{#1}}
\newenvironment{alwayssingle}{%
       \@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
       \else\newpage\fi}
       {\if@restonecol\twocolumn\else\newpage\fi}
\newenvironment{acknowledgements}
{\pagestyle{empty}
\begin{alwayssingle}
\begin{center}
\vspace*{1.5cm}
 \begin{flushleft} {\Large \bfseries Acknowledgements} \end{flushleft}
\end{center}
\vspace{0.5cm}
\begin{quote}}
{\end{quote}\end{alwayssingle}}
\newenvironment{abstracts}
{\pagestyle{empty}
\begin{alwayssingle}
\begin{center}
\vspace*{1.5cm}
 \begin{flushleft} {\Large \bfseries Abstract} \end{flushleft}
\end{center}
\vspace{0.5cm}
\begin{quote}}
{\end{quote}\end{alwayssingle}}
% This command takes the subtitle as its argument, and uses the titling command
% \maketitlehookb plus the previously defined formatting commands to insert
% the subtitle into the titlepage. It also generates \thesubtitle for subsequent use
\newcommand\subtitle[1]{%
  \renewcommand{\maketitlehookb}{\@presubtitle#1\@postsubtitle}
  \newcommand\thesubtitle{#1}}
\makeatother
% Now we define the formatting for the subtitle
\presubtitle{\begin{center}\Large} % change this as needed
\postsubtitle{\end{center}}
% Now enter the regular title information, with the new \subtitle command
\title{My Thesis Title}
\author{A.M. Author}
\subtitle{My subtitle}
\date{\today}

% These commands set up the headers. They are set up for even and odd pages the same
% Check the fancyhdr documentation for information on how to set them differently
% for odd and even pages
\lhead{\begin{tabular}{@{}l}\thetitle\ -- \thesubtitle\\\theauthor\end{tabular}}
\chead{}
\rhead{\begin{tabular}{r@{}}\leftmark\\\thedate\end{tabular}}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
% Set the width of the header rule. Make 0pt to remove the rule.
\renewcommand{\headrulewidth}{.5pt}
\renewcommand{\footrulewidth}{.5pt}
% Make the head height match the size of the header
\setlength{\headheight}{24pt}
\pagestyle{fancy}
% Remove "Chapter" from the marks
\renewcommand{\chaptermark}[1]{%
  \markboth{\thechapter.\ #1}{}}

\begin{document}
\maketitle
\begin{abstracts}
\end{abstracts}
\begin{acknowledgements}
\end{acknowledgements}
\chapter{Introduction}
\lipsum\lipsum
\end{document}

答案1

这是您要使用fancyhdr和包执行的操作的一个版本。我为字幕titling创建了一个新命令(带有相关的格式化挂钩),大多数文档类都没有标准提供该命令。\subtitle

\documentclass{report}
\usepackage{titling}
\usepackage{fancyhdr}
\usepackage{lipsum} % for dummy text only

\makeatletter
% These commands follow the titling package format for titles
% They define user commands to format the subtitle
\newcommand\presubtitle[1]{\gdef\@presubtitle{#1}}
\newcommand\postsubtitle[1]{\gdef\@postsubtitle{#1}}
% This command takes the subtitle as its argument, and uses the titling command
% \maketitlehookb plus the previously defined formatting commands to insert
% the subtitle into the titlepage. It also generates \thesubtitle for subsequent use
\newcommand\subtitle[1]{%
  \renewcommand{\maketitlehookb}{\@presubtitle#1\@postsubtitle}
  \newcommand\thesubtitle{#1}}
\makeatother
% Now we define the formatting for the subtitle
\presubtitle{\begin{center}\Large} % change this as needed
\postsubtitle{\end{center}}
% Now enter the regular title information, with the new \subtitle command
\title{My Thesis Title}
\author{A.M. Author}
\subtitle{My subtitle}
\date{\today}

% These commands set up the headers. They are set up for even and odd pages the same
% Check the fancyhdr documentation for information on how to set them differently
% for odd and even pages
\lhead{\begin{tabular}{@{}l}\thetitle\ -- \thesubtitle\\\theauthor\end{tabular}}
\chead{}
\rhead{\begin{tabular}{r@{}}\leftmark\\\thedate\end{tabular}}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
% Set the width of the header rule. Make 0pt to remove the rule.
\renewcommand{\headrulewidth}{.5pt}
\renewcommand{\footrulewidth}{0pt}
% Make the head height match the size of the header
\setlength{\headheight}{24pt}
\pagestyle{fancy}
% Remove "Chapter" from the marks
\renewcommand{\chaptermark}[1]{%
  \markboth{\thechapter.\ #1}{}}

\begin{document}
\maketitle
\chapter{Introduction}
\lipsum\lipsum
\end{document}

示例标题

相关内容