3

Sorry, this has probably been tried more than once, but I ended up with the following broken code below.

Briefly, I attempted to:

  1. define a \institute and \supervisor command;
  2. redefine the \maketitle command (taking into account the provided institute/supervisor).
\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}

Would anyone tell me why it fails with:

! Undefined control sequence.
\maketitle ...} \par \par \normalsize \@institute 
                                                  \par \@date \par \end {cen...
l.58 \maketitle

?

2 Answers2

5

The first line is to use the demo option forgraphicx. You should remove it.

Also, it is preferable to avoid the use of \def in favor of \newcommand.

The main problem was in \providecommand{\institute}[1]{} , which you already have redefined by yourself.

\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}

enter image description here

1

Okay I got it. I need to get some knowledge about how to write those macros:

in the \def block, there should be no blanklines (probably no newlines as well):

So I replaced those newlines with \par%, and it works (\maketitle gets defined!).

For the record, there are good explanations about paragraphs in macros here: https://tex.stackexchange.com/a/1057/95423

Corrected preamble lines:

\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

I still need to figure out the magic behind the newcommand syntax with \@supervisor and \supervisor, but at least it works...