我正在尝试为我的部门开发一个类文件。我想向命令添加两个依赖项\maketitle
。由于我们有\title
&\author
作为 的强制命令\maketitle
,因此我想要\supervisor
,并且由于我们有\date
是可选的,因此我想要\subtitle
。我尝试了以下代码。它不起作用。我犯了什么错误?
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ML}[2020/01/24 MWE class-file]
\LoadClass{book}
\newcommand{\supervisor}[1]{\textsc{supervisor : #1}}
\newcommand{\subtitle}[1]{\textsc{}}
\renewcommand{\maketitle}{
\makeatletter
\thispagestyle{empty}
\fboxsep3em
\noindent\fbox{\begin{minipage}
[c][\dimexpr\textheight-2\fboxsep-2\fboxrule]
[c]{\dimexpr\linewidth-2\fboxsep-2\fboxrule}
\begin{center}
\bigskip
\textbf{{\LARGE \textsc{\@title}}%\\
%\vspace{0.2cm}
%{\@subtitle}
}
\\
\vfill
{\large\textsc{\@author}}\\
% \vspace{0.5in}
% {\large \@supervisor}
\vspace{0.5in}
\textsc{\@date}
\end{center}
\end{minipage}}
\makeatother}
答案1
请检查下面给出的修改MWE
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ML}[2020/01/24 MWE class-file]
\LoadClass{book}
\let\@superwiser\@empty%
\def\superwiser#1{\def\@superwiser{\textsc{superwiser :#1}}}%
\let\@subtitle\@empty%
\def\subtitle#1{\def\@subtitle{\textsc{#1}}}%
\renewcommand{\maketitle}{
\makeatletter
\thispagestyle{empty}
\fboxsep3em
\noindent\fbox{\begin{minipage}
[c][\dimexpr\textheight-2\fboxsep-2\fboxrule]
[c]{\dimexpr\linewidth-2\fboxsep-2\fboxrule}
\begin{center}
\bigskip
\textbf{{\LARGE \textsc{\@title}}\\
\vspace{0.2cm}
{\@subtitle}
}
\\
\vfill
{\large\textsc{\@author}}\\
\vspace{0.5in}
{\large \@superwiser}\\
\vspace{0.5in}
\textsc{\@date}
\end{center}
\end{minipage}}
\makeatother}
\endinput
用法
\documentclass{ML}
\begin{document}
\title{Title}
\subtitle{Subtitle}
\author{Author}
\superwiser{Name}
\maketitle
\end{document}