% Technical Report title page style for University of Cambridge departments
% Markus Kuhn <https://www.cl.cam.ac.uk/~mgk25/>
%
% See file tr-title-demo.tex for instructions and an example of
% how to use this style file.
%
% This file defines an environment for typesetting the first two pages
% of a technical report published at the University of Cambridge.
% It follows reasonably closely the 1997 University House Style
% Guidelines on http://www.cam.ac.uk/cambuniv/style/ and in some aspects
% also ISO 5966. It expects the Adobe Sabon Type 1 fonts in OT1 encoding
% (ot1psb.fd, psb{r,b,ri}8a.{tfm,pfb}) and the 1997 University Identifier
% (CUni3.pdf) to be installed.
%
% Make sure that your page numbers and those of PDF match!
% When you produce a PDF file suitable for double-sided printing, then
% number the pages of your document starting with page 3, then prefix it with
% this title page followed by its back page. If you need for the printed
% version in addition a layout for a cover front page, use this title page
% as well.
\ProvidesPackage{tr-title}[2019/09/19]
\RequirePackage[pdfpagelabels=false,pdfborder={0 0 0}]{hyperref}
\RequirePackage{graphics}
\RequirePackage{amsfonts}
\RequirePackage{ifthen}
\RequirePackage{ragged2e}  % for better glue in centered and ragged modes
\RequirePackage{geometry}
% Call
% \begin{trtitlepage}
%   ... declaration of front-page variables ...
%   \maketrtitle
%   \begin{trbackpage}
%     ... backpage content ...
%   \end{trbackpage}
% \end{trtitlepage}
% to output the front and back side of a technical report title page
\newlength{\trbackpagewidth}
\newenvironment{trtitlepage}{%
\cleardoublepage\newgeometry{margin=20mm}%
\if@twocolumn  % from titlepage environment
\@restonecoltrue\onecolumn
\else
\@restonecolfalse\newpage
\fi
\setlength{\parindent}{0mm}%
\renewcommand{\rmdefault}{psb}\rmfamily  % use Adobe Sabon font family
\newcommand{\maketrtitle}{%
\setlength{\parskip}{\medskipamount}
\setlength{\unitlength}{1mm}
\thispagestyle{empty}
\begin{picture}(170,60)(0,-60)
\put(0,-12){\makebox(170,12)[lt]
{\fontsize{36}{44}\selectfont\itshape Technical Report}}
\put(0,-17){\makebox(170,3)[lt]{\rule{170mm}{1mm}}}
\ifthenelse{\equal{\trnumber}{}}{}
{\put(1,-27){\makebox(90,8)[lt]{\Large Number \trnumber}}}
\put(108,-45){\makebox(62,15){\includegraphics{CUni3}}}
\put(121.6,-55){\makebox(73,8)[l]{\large  % adjust this font size if necessary
\bfseries\tsdepartment}}
\ifthenelse{\equal{\tscode}{}}{}
{\put(120,-10){\makebox(50,8)[rt]
{\tscode\ifthenelse{\equal{\trnumber}{}}{}{-\trnumber}}}}
\ifthenelse{\isundefined{\tsissn}}{}
{\put(120,-10){\makebox(50,8)[rb]{ISSN \tsissn}}}
\end{picture}

\vspace{\fill}
\begin{quote}
\CenteringLeftskip 0pt plus 85mm
\CenteringRightskip 0pt plus 85mm
\begin{Center}
\huge
\trtitle\\
\strut\\
\end{Center}
\end{quote}
\begin{quote}
\begin{center}
\LARGE\trauthors
\end{center}
\end{quote}
\vspace{20mm}
\vspace{\fill}
\begin{center}
\Large \trdate
\end{center}
\vspace{\fill}
\vspace{5mm}

\parbox[b]{85mm}{\raggedright\large\trfrontnote}%
\hspace{\fill}\parbox[b]{48.4mm}{\small\tsaddress\\[2mm]%
\href{\tsdepturl}{\itshape \tsdepturl}}%
\clearpage}%
\setlength{\trbackpagewidth}{112mm}
\newenvironment{trbackpage}{\clearpage\thispagestyle{empty}\vspace*{\fill}%
  \newenvironment{backnote}{\indent % enter hmode to emit parskip
    \setlength{\parskip}{\medskipamount}\ignorespaces}{}%
  \begingroup\minipage{\trbackpagewidth}
  \setlength{\RaggedRightRightskip}{0pt plus 6em minus 2em}\RaggedRight
  \setlength{\parskip}{\bigskipamount}
}{\endminipage\endgroup\clearpage}
}{\if@restonecol\twocolumn\else\newpage\fi\restoregeometry}
