文章中有两个“maketitle”

文章中有两个“maketitle”

我正在使用该article课程撰写一份包含两部分的报告。

\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}

\usepackage[english]{babel}
\usepackage{amsmath,amsfonts,amsthm}
\usepackage[pdftex]{graphicx}   
\usepackage[top=1in,bottom=1in,left=1in,right=1in]{geometry}
\usepackage{sectsty}
\allsectionsfont{\centering \normalfont\scshape}
\usepackage{fancyhdr}

\title{\huge Title1 \\}
\author{\normalfont                 \normalsize
    Author\\                        \normalsize
    Supervisors: Prof. X}
\date{}

\begin{document}

\part{Heisenberg Picture}

\maketitle

\section{Section 1}


\clearpage

\part{Schroedinger Picture}

%\maketitle2

\section{Section 1}

\end{document}

我需要两个部分,标题分别为\part{Heisenberg Picture}\part{Schroedinger Picture}。这些部分分别对应于Title 1Supervisor XTitle 2Supervisor Y我该如何重新定义\maketitle命令来执行此操作?(如果太复杂,有没有更简单的方法?)

答案1

titling包完全满足您的要求。我还清理了您的代码,将格式化部分放入了\pretitleetc. 命令中,保留了内容\titleauthor自由格式。

\documentclass[a4paper,11pt]{article}
\usepackage{titling}
\pretitle{\begin{center}\huge}
\posttitle{\par\end{center}\vspace{\baselineskip}}
\preauthor{\normalfont\normalsize\begin{center}\begin{tabular}[t]{c}}
\postauthor{\end{tabular}\end{center}\vspace{\baselineskip}}

\title{Title 1}
\author{Author\\Supervisors: Prof. X}
\date{}

\begin{document}

\part{Heisenberg Picture}

\maketitle

\section{Section 1}

\clearpage

\part{Schroedinger Picture}
\title{Title 2}
\author{Author\\Supervisors: Prof Y}
\maketitle

\section{Section 1}

\end{document}

答案2

\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}

\usepackage[english]{babel}
\usepackage{amsmath,amsfonts,amsthm}
\usepackage[pdftex]{graphicx}   
\usepackage[top=1in,bottom=1in,left=1in,right=1in]{geometry}
\usepackage{sectsty}
\allsectionsfont{\centering \normalfont\scshape}
\usepackage{fancyhdr}

%%%Solution package%%%
\usepackage{titling}
%%%%%%%%%%%%%%%%%%%%%%

\title{\huge Title1 \\}
\author{\normalfont                 \normalsize
    Author\\                        \normalsize
    Supervisors: Prof. X}
\date{}

\begin{document}

\part{Heisenberg Picture}

\maketitle

\section{Section 1}

\clearpage

\part{Schroedinger Picture}

%still usable due to `titling`
\title{\huge Title2 \\}
\author{\normalfont                 \normalsize
    Author\\                        \normalsize
    Supervisors: Prof. Y}
\date{}

\maketitle%2

\section{Section 1}

\end{document}

相关内容