![自定义论文标题页,包含新字段(机构、导师)](https://linux22.com/image/412188/%E8%87%AA%E5%AE%9A%E4%B9%89%E8%AE%BA%E6%96%87%E6%A0%87%E9%A2%98%E9%A1%B5%EF%BC%8C%E5%8C%85%E5%90%AB%E6%96%B0%E5%AD%97%E6%AE%B5%EF%BC%88%E6%9C%BA%E6%9E%84%E3%80%81%E5%AF%BC%E5%B8%88%EF%BC%89.png)
抱歉,这可能已经尝试过多次,但我最终得到了下面的错误代码。
简而言之,我尝试:
- 定义一个
\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
但至少它是有效的......