抱歉,这可能已经尝试过多次,但我最终得到了下面的错误代码。
简而言之,我尝试:
- 定义一个
\institute
和\supervisor
命令; - 重新定义
\maketitle
命令(考虑到提供的机构/主管)。
\documentclass[a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{wallpaper} % background figure on title page
% copied from Pandoc default template
\providecommand{\institute}[1]{}
\makeatletter
% copied from https://tex.stackexchange.com/a/196650/95423
\newcommand{\@supervisor}{}
\newcommand{\supervisor}[1]{\renewcommand{\@supervisor}{#1}}
\makeatother
\title{The Limits of Individual Plasticity}
\author{Edward \textsc{Prendick}}
\institute{Island of Doctor Moreau}
\supervisor{Dr. \textsc{Moreau}}
\date{1896}
\makeatletter
\def\maketitle{%
\begin{titlepage}%
\begin{center}%
\ThisULCornerWallPaper{0.2}{logo-univ}\par
\vspace*{2.5cm}
\huge\@title
\vspace{1.5cm}
\Large\@author
\vspace{1.5cm}
\normalsize
A thesis for the degree of PhD
\vfill
\normalsize
Supervised by:\\
\@supervisor\\
\vspace{0.8cm}
%\includegraphics[width=0.4\textwidth]{logo/logo-lab}
\normalsize
\@institute
\@date
\end{center}%
\end{titlepage}%
}
\makeatother
\begin{document}
\maketitle
\end{document}
有人能告诉我为什么会失败吗:
! Undefined control sequence.
\maketitle ...} \par \par \normalsize \@institute
\par \@date \par \end {cen...
l.58 \maketitle
?
答案1
第一行是使用demo
的选项graphicx
。您应该将其删除。
此外,最好避免使用\def
而采用\newcommand
。
主要问题在于\providecommand{\institute}[1]{}
,您已经自己重新定义了它。
\PassOptionsToPackage{demo}{graphicx}
\documentclass[a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{wallpaper} % background figure on title page
\makeatletter
% copied from https://tex.stackexchange.com/a/196650/95423
\newcommand{\@supervisor}{}
\newcommand{\supervisor}[1]{\renewcommand{\@supervisor}{#1}}
\newcommand{\@institute}{}
\newcommand{\institute}[1]{\renewcommand{\@institute}{#1}}
\makeatother
\title{The Limits of Individual Plasticity}
\author{Edward \textsc{Prendick}}
\institute{Island of Doctor Moreau}
\supervisor{Dr. \textsc{Moreau}}
\date{1896}
\makeatletter
\renewcommand*{\maketitle}{%
\begin{titlepage}
\begin{center}
\ThisULCornerWallPaper{0.2}{pippo}\par
\vspace*{2.5cm}
\huge\@title\\
\vspace{1.5cm}
\Large\@author
\vspace{1.5cm}
\normalsize
A thesis for the degree of PhD
\vfill
\normalsize
Supervised by:\\
\@supervisor
\vspace{0.8cm}
\includegraphics{pippo}
\normalsize
\@institute
\@date
\end{center}%
\end{titlepage}%
}
\makeatother
\begin{document}
\maketitle
\end{document}
答案2
好的,我明白了。我需要了解一些有关如何编写这些宏的知识:
在\def
块中,不应该有空行(也可能没有换行符):
因此我用 , 替换了那些换行符\par%
,并且它起作用了(\maketitle
得到定义!)。
顺便提一下,这里有关于宏中的段落的很好的解释:https://tex.stackexchange.com/a/1057/95423
修正前言部分:
\makeatletter
% copied from https://tex.stackexchange.com/a/196650/95423
\newcommand{\@institute}{}
\newcommand{\institute}[1]{\renewcommand{\@institute}{#1}}
\newcommand{\@supervisor}{}
\newcommand{\supervisor}[1]{\renewcommand{\@supervisor}{#1}}
\makeatother
\title{The Limits of Individual Plasticity}
\author{Edward \textsc{Prendick}}
\institute{Island of Doctor Moreau}
\supervisor{Dr. \textsc{Moreau}}
\date{1896}
\makeatletter
\def\maketitle{%
\begin{titlepage}%
\begin{center}%
\ThisULCornerWallPaper{0.2}{logo-univ}\par%
\vspace*{2.5cm}\par%
\huge\@title\par%
\vspace{1.5cm}\par%
\Large\@author\par%
\vspace{1.5cm}\par%
\normalsize%
A thesis for the degree of PhD\par%
\vfill\par%
\normalsize%
Supervised by:\par\@supervisor\par%
\vspace{0.8cm}\par%
%\includegraphics[width=0.4\textwidth]{logo/logo-lab}\par%
\normalsize%
\@institute\par%
\@date\par%
\end{center}%
\end{titlepage}%
}
\makeatother
我仍然需要弄清楚和的新命令语法背后的魔力\@supervisor
,\supervisor
但至少它是有效的......