%%
%% This is file `frontespizio.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% frontespizio.dtx  (with options: `package')
%% 
%%  Copyright 2008-2010 Enrico Gregorio
%% 
%%  This program is provided under the terms of the
%%  LaTeX Project Public License distributed from CTAN
%%  archives in directory macros/latex/base/lppl.txt.
%% 
%%  Author: Enrico Gregorio
%%          Enrico dot Gregorio at univr dot it
%% 
%%  This work has the LPPL maintenance status "author-maintained".
%% 
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\ProvidesPackage{frontespizio}
  [2010/06/25 1.2 (Enrico Gregorio)]

\def\@not@eTeX{%
  \PackageError{frontespizio}
  {This package requires e-TeX, I'll stop right now}
  {This package is built on the e-TeX extensions which are not present.%
   \MessageBreak
   The best thing you can do is to upgrade your TeX system or try%
   \MessageBreak
   using `elatex' or `pdfelatex'.}%
    \expandafter\@@end}
\ifx\eTeXversion\@undefined
  \@not@eTeX
\else
  \let\@not@eTeX\@undefined
\fi
\newif\iffront@write
\DeclareOption{write}{\front@writetrue}
\DeclareOption{nowrite}{\front@writefalse}
\DeclareOption{infront}{\let\front@infront=T}
\DeclareOption{signatures}{\let\front@signatures=T}
\DeclareOption{noadvisor}{\let\front@noadvisor=T}
\DeclareOption{swapnames}{\let\front@swapnames=T}
\DeclareOption{normal}{\def\front@thefont{\fontoptionnormal}}
\DeclareOption{sans}{\def\front@thefont{\fontoptionsans}}
\DeclareOption{norules}{\let\front@norules=T}
\DeclareOption{nouppercase}{\let\front@nouppercase=T}
\DeclareOption{noinputenc}{\let\front@noinputenc=T}
\newif\iffront@include
\DeclareOption{onlyinclude}{\front@includetrue\ExecuteOptions{nowrite}}
\let\front@otheroptions\@empty
\DeclareOption*{\expandafter\g@addto@macro\expandafter\front@otheroptions
  \expandafter{\CurrentOption,}}
\ExecuteOptions{write,normal}
\ProcessOptions\relax
\RequirePackage{afterpage}
\RequirePackage{graphicx}
\RequirePackage{atbegshi}
\RequirePackage{environ}
\iffront@include
\newcommand{\includefront}[2][0]{%
  \titlepage\null
    \AtBeginShipoutNext{\AtBeginShipoutUpperLeft{%
      \vbox to\z@{\hbox{\includegraphics{#2}}\vss}}}
    \afterpage{\thispagestyle{empty}}%
  \endtitlepage
  \ifx0#1\else
    \null\thispagestyle{empty}\newpage\addtocounter{page}{-#1}%
  \fi}
  \newenvironment{frontespizio}{%
    \PackageWarningNoLine{frontespizio}
    {Using the `frontespizio' environment along with%
     \MessageBreak
     the `onlyinclude' option is meaningless. The%
     \MessageBreak
     environment's content will be ignored}
     \Collect@Body\@gobble}{}
\expandafter\endinput
\else
\RequirePackage{ifpdf}
\RequirePackage{ifxetex}
\fi
\iffront@write
  \ifdefined\pdfmdfivesum
    \IfFileExists{\jobname-frn.tex}{%
      \xdef\front@mdfiveold{\pdfmdfivesum file{\jobname-frn.tex}}}{}%
  \fi
  \newwrite\front@out
  \immediate\openout\front@out=\jobname-frn.tex
  \long\def\front@write#1{\immediate\write\front@out{\unexpanded{#1}}}
  \long\def\front@expwrite{\immediate\write\front@out}
\else
  \long\def\front@write#1{}
  \let\front@expwrite\front@write
\fi
\front@write{\documentclass[titlepage]{article}}
\ifdefined\front@noinputenc\else
  \ifdefined\inputencodingname
    \front@expwrite{\string\usepackage[\inputencodingname]{inputenc}}
  \fi
\fi
\front@write{\usepackage[a4paper,%
  left=1cm,bottom=1.5cm,right=1cm,top=1cm]{geometry}}
\ifx\front@otheroptions\@empty
  \front@write{\usepackage{graphicx}}
\else
  \begingroup
 \def\KV@errx#1{%
    \PackageError{frontespizio}{Key #1}
      {The only allowed key is `driver'; the given key will be ignored.%
       \MessageBreak Type \space<return> \space to proceed.}}
  \define@key{front}{driver}{\front@write{\usepackage[#1]{graphicx}}}
  \edef\front@processkeys{\noexpand\setkeys{front}{\front@otheroptions}}
  \front@processkeys
  \endgroup
\fi
\def\front@theoptions{nowrite,infront}
\ifdefined\front@signatures
  \g@addto@macro\front@theoptions{,signatures}
\fi
\ifdefined\front@noadvisor
  \g@addto@macro\front@theoptions{,noadvisor}
\fi
\ifdefined\front@swapnames
  \g@addto@macro\front@theoptions{,swapnames}
\fi
\ifdefined\front@norules
  \g@addto@macro\front@theoptions{,norules}
\fi
\ifdefined\front@nouppercase
  \g@addto@macro\front@theoptions{,nouppercase}
\fi
\front@expwrite{\string\usepackage[\front@theoptions]{frontespizio}}
\front@write{\nofiles}
\expandafter\front@write\expandafter{\front@thefont}
\ifdefined\front@infront
\def\fontoptionnormal{%
  \let\front@font\normalfont \let\front@scfont\scshape}
\def\fontoptionsans{%
  \let\front@font\sffamily \let\front@scfont\upshape}
\def\front@push{}
\def\front@thecandidate{Candidato}
\def\front@thecandidates{Candidati}
\def\front@theadvisor{Relatore}
\def\front@theadvisors{Relatori}
\def\front@thecoadvisor{Correlatore}
\def\front@thecoadvisors{Correlatori}
\def\front@punct{:}
\newif\iffront@titoletto
\newif\iffront@matr
\newif\iffront@onecand
\newif\iffront@morecand
\newif\iffront@correl
\newif\iffront@logo
\newif\iffront@inst
\newif\iffront@sottotit
\newif\iffront@multiple
\newif\iffront@division
\newif\iffront@school
\newif\iffront@foot
\newtoks\front@candtoks
\newcount\front@candcount
\newtoks\front@reltoks
\newcount\front@relcount
\newtoks\front@correltoks
\newcount\front@correlcount
\fi
\def\@front@#1{TT\fi\@nameuse{iffront@#1}}
\iffront@write
\newcommand{\Preambolo}[1]{\front@write{#1}}
\newenvironment{Preambolo*}
  {\@makeother\%\@makeother\^^M\newlinechar=`\^^M
   \Collect@Body\front@write}{}
\newcommand{\Rientro}[1]{\front@write{\Rientro{#1}}}
\newcommand{\Margini}[4]{\front@write{\Margini{#1}{#2}{#3}{#4}}}
\newcommand{\Logo}[2][1.5cm]{\front@write{\Logo[#1]{#2}}}
\newcommand{\Filigrana}[2][height=10cm]{%
  \front@write{\Filigrana[#1]{#2}}}
\newcommand{\Universita}[1]{\front@write{\Universita{#1}}}
\newcommand{\Istituzione}[1]{\front@write{\Istituzione{#1}}}
\newcommand{\Facolta}[1]{\front@write{\Facolta{#1}}}
\newcommand{\Dipartimento}[1]{\front@write{\Dipartimento{#1}}}
\newcommand{\Divisione}[1]{\front@write{\Divisione{#1}}}
\newcommand{\Interfacolta}[1]{\front@write{\Interfacolta{#1}}}
\newcommand{\Corso}[2][Laurea Magistrale]{\front@write{\Corso[#1]{#2}}}
\newcommand{\Scuola}[1]{\front@write{\Scuola{#1}}}
\newcommand{\Titolo}[1]{\front@write{\Titolo{#1}}}
\newcommand{\Sottotitolo}[1]{\front@write{\Sottotitolo{#1}}}
\newcommand{\Annoaccademico}[1]{\front@write{\Annoaccademico{#1}}}
\newcommand{\Piede}[1]{\front@write{\Piede{#1}}}
\newcommand{\Titoletto}[1]{\front@write{\Titoletto{#1}}}
\newcommand{\Candidato}[2][]{%
  \def\next{#1}%
  \ifx\next\@empty
    \front@write{\Candidato{#2}}%
  \else
    \front@write{\Candidato[#1]{#2}}%
  \fi}
\newcommand{\Relatore}[1]{\front@write{\Relatore{#1}}}
\newcommand{\Correlatore}[1]{\front@write{\Correlatore{#1}}}
\newcommand{\NCandidato}[1]{\front@write{\NCandidato{#1}}}
\newcommand{\NCandidati}[1]{\front@write{\NCandidati{#1}}}
\newcommand{\NRelatore}[2]{\front@write{\NRelatore{#1}{#2}}}
\newcommand{\NCorrelatore}[2]{\front@write{\NCorrelatore{#1}{#2}}}
\newcommand{\Punteggiatura}[1]{\front@write{\Punteggiatura{#1}}}
\def\front@oldcommand#1#2{\def#1{\PackageWarning{frontespizio}
  {Old command \string#1 found; use \string#2}#2}}
\front@oldcommand\IlCandidato\Candidato
\front@oldcommand\Package\Preambolo
\front@oldcommand\MoreMargin\Rientro
\front@oldcommand\Margins\Margini
\def\Matricola#1{\PackageError{frontespizio}
  {Old command \noexpand\Matricola found}
  {The command \noexpand\Matricola cannot be used with this package.%
   \MessageBreak Use the optional argument to \string\Candidato}}
\else\ifdefined\front@infront
\newcommand{\Rientro}[1]{\def\front@push{\hspace{#1}}}
\newcommand{\Margini}[4]{\geometry{left=#1,bottom=#2,right=#3,top=#4}}
\newcommand{\Logo}[2][1.5cm]{\def\front@logo{#2}%
  \def\front@logosize{#1}\front@logotrue}
\def\front@logobefore{1}\def\front@logoafter{1} % default values
\define@key{filigrana}{height}[10cm]{\def\front@logoheight{#1}}
\define@key{filigrana}{before}[1]{\def\front@logobefore{#1}}
\define@key{filigrana}{after}[1]{\def\front@logoafter{#1}}
\newcommand{\Filigrana}[2][height=10cm]{%
  \setkeys{filigrana}{#1}%
    \AtBeginShipoutNext{\AtBeginShipoutUpperLeft{%
      \vtop to\paperheight{\hsize=\paperwidth
        \vspace*{\stretch{\front@logobefore}}
        \centering
        \includegraphics[height=\front@logoheight]{#2}
        \vspace{\stretch{\front@logoafter}}
}}}}
\newcommand{\Universita}[1]{\def\front@univ{#1}}
\newcommand{\Istituzione}[1]{\def\front@instit{#1}\front@insttrue}
\newcommand{\Facolta}[1]{\def\front@facoldip{#1}%
  \def\front@thefacoldip{Facolt\`a}}
\newcommand{\Dipartimento}[1]{\def\front@facoldip{#1}%
  \def\front@thefacoldip{Dipartimento}}
\newcommand{\Interfacolta}[1]{%
  \def\front@multiple{#1}\front@multipletrue}
\newcommand{\Divisione}[1]{\def\front@division{#1}\front@divisiontrue}
\newcommand{\Corso}[2][Laurea Magistrale]{%
  \def\front@cl{#1\unskip\space in #2}}
\newcommand{\Scuola}[1]{\def\front@school{#1}\front@schooltrue}
\newcommand{\Titolo}[1]{\def\front@title{#1}}
\newcommand{\Sottotitolo}[1]{\def\front@subtitle{#1}\front@sottotittrue}
\newcommand{\Annoaccademico}[1]{\def\front@anno{#1}}
\newcommand{\Piede}[1]{\def\front@foot{#1}\front@foottrue}
\newcommand{\Titoletto}[1]{\def\front@titoletto{#1}\front@titolettotrue}
\newcommand{\Candidato}[2][]{\advance\front@candcount\@ne
  \front@candtoks=\expandafter{\the\front@candtoks
    \front@docand{#1}{#2}}%
  \def\front@cand{#2}%
  \def\next{#1}%
  \ifx\next\@empty\else\def\front@matr{#1}\front@matrtrue\fi
}
\newcommand{\Relatore}[1]{\advance\front@relcount\@ne
  \front@reltoks=\expandafter{\the\front@reltoks\\#1%
   \ifdefined\front@signatures\\[1cm]\fi}}
\newcommand{\Correlatore}[1]{%
  \front@correltrue\advance\front@correlcount\@ne
  \front@correltoks=\expandafter{\the\front@correltoks\\#1}}
\newcommand{\NCandidato}[1]{\def\front@thecandidate{#1}}
\newcommand{\NCandidati}[1]{\def\front@thecandidates{#1}}
\newcommand{\NRelatore}[2]{\def\front@theadvisor{#1}%
  \def\front@theadvisors{#2}}
\newcommand{\NCorrelatore}[2]{\def\front@thecoadvisor{#1}%
  \def\front@thecoadvisors{#2}}
\newcommand{\Punteggiatura}[1]{\def\front@punct{#1}}
\def\frontinstitutionfont{\fontsize{14}{17}\bfseries}
\def\frontdivisionfont{\fontsize{12}{16}\selectfont}
\def\frontpretitlefont{\fontsize{10}{12}\front@scfont}
\def\fronttitlefont{\fontsize{17}{21}\bfseries}
\def\frontsubtitlefont{\fontsize{12}{14}\selectfont}
\def\frontnamesfont{\fontsize{12}{14}\bfseries}
\def\frontsmallfont{\fontsize{9}{11}\selectfont}
\def\frontfootfont{\fontsize{12}{14}\bfseries}
\def\frontfixednamesfont{\normalfont\normalsize\front@font}
\def\frontcandidatesep{3ex}
\def\frontrelcorrelsep{1ex}
\def\frontlogosep{6pt}
\def\frontadjustforsignatures{0pt}
\def\front@docand#1#2{%
  #2\\% the candidate's name
  \def\next{#1}%
  \unless\ifx\next\@empty
    \frontsmallfont {Matricola }#1\\[\frontcandidatesep]
  \fi}
\ifdefined\front@nouppercase
  \let\front@MakeUppercase\@firstofone
\else
  \let\front@MakeUppercase\MakeUppercase
  \fi
\def\preparefrontpage{%
\titlepage\front@font
\centering
\par
\if\@front@{logo}
\includegraphics[height=\front@logosize]{\front@logo}\par
\vspace{\frontlogosep}
\fi
\par
{\frontinstitutionfont
\if\@front@{inst}
  \front@instit
\else
  Universit\`a degli Studi di \front@univ
\fi\par}
\vspace{1.5ex}
\unless\ifdefined\front@norules\hrule\fi
\vspace{1.5ex}
{\frontdivisionfont
\if\@front@{multiple}
  \front@multiple
\else
  \if\@front@{division}
    \front@MakeUppercase{\front@division}
  \else
    \front@MakeUppercase{\front@thefacoldip\space di \front@facoldip}
  \fi
\fi\\
\if\@front@{school}
  \front@school
\else
  Corso di \front@cl
\fi
\par}
\if\@front@{titoletto}
\vspace{2cm}
{\frontpretitlefont\front@titoletto\par}
\fi
\vspace{\fill}
{\fronttitlefont\front@title\par}
\if\@front@{sottotit}
\vspace{4ex}
{\frontsubtitlefont\front@subtitle\par}
\fi
\vspace{\fill}

\def\front@makecandidates{%
  \begin{tabular}[t]{@{}l@{}}
  \relax\ifnum\front@candcount<1
    \PackageWarningNoLine{frontespizio}{Missing candidate name}%
  \else
    \frontfixednamesfont
    \ifnum\front@candcount=1
      \front@thecandidate
    \else
      \front@thecandidates
    \fi
    \front@punct\\
    \the\front@candtoks
  \fi
  \end{tabular}}
\def\front@makeadvisors{%
  \unless\ifdefined\front@noadvisor
    \begin{tabular}[t]{@{}l@{}}
    \relax
    \ifcase\front@relcount
      \PackageWarningNoLine{frontespizio}{Missing advisor name}%
    \or
      \frontfixednamesfont\front@theadvisor\front@punct
    \else
      \frontfixednamesfont\front@theadvisors\front@punct
    \fi
    \the\front@reltoks
    \if\@front@{correl}
      \\[\frontrelcorrelsep]
      \ifcase\front@correlcount\or
        \frontfixednamesfont\front@thecoadvisor\front@punct
      \else
        \frontfixednamesfont\front@thecoadvisors\front@punct
      \fi
    \the\front@correltoks
    \fi
    \end{tabular}
  \fi}
\vbox to .3\textheight{\parindent\z@
\frontnamesfont
\ifdefined\front@swapnames
  \begin{tabular*}{\textwidth}
    {@{\front@push}l@{\extracolsep{\fill}}l@{\front@push}}
  \front@makeadvisors&\front@makecandidates
  \end{tabular*}
\else
  \begin{tabular*}{\textwidth}
    {@{\front@push}l@{\extracolsep{\fill}}l@{\front@push}}
  \front@makecandidates&\front@makeadvisors
  \end{tabular*}
\fi
\par
\vfill}
\ifdefined\front@signatures\vskip\frontadjustforsignatures\fi
\unless\ifdefined\front@norules\hrule\fi
\vspace{1.5ex}
{\frontfootfont
 \if\@front@{foot}
   \front@foot
 \else
   Anno Accademico \front@anno
 \fi
 \par}
\endtitlepage}
\else
\newcommand{\Preambolo}[1]{}
\newcommand{\Rientro}[1]{}
\newcommand{\Margini}[4]{}
\newcommand{\Logo}[2][]{}
\newcommand{\Filigrana}[2][]{}
\newcommand{\Universita}[1]{}
\newcommand{\Istituzione}[1]{}
\newcommand{\Facolta}[1]{}
\newcommand{\Dipartimento}[1]{}
\newcommand{\Interfacolta}[1]{}
\newcommand{\Divisione}[1]{}
\newcommand{\Corso}[2][]{}
\newcommand{\Scuola}[1]{}
\newcommand{\Titolo}[1]{}
\newcommand{\Sottotitolo}[1]{}
\newcommand{\Annoaccademico}[1]{}
\newcommand{\Piede}[1]{}
\newcommand{\Titoletto}[1]{}
\newcommand{\Candidato}[2][]{}
\newcommand{\Relatore}[1]{}
\newcommand{\Correlatore}[1]{}
\newcommand{\NCandidato}[1]{}
\newcommand{\NCandidati}[1]{}
\newcommand{\NRelatore}[2]{}
\newcommand{\NCorrelatore}[2]{}
\newcommand{\Punteggiatura}[1]{}
\fi
\fi
\ifpdf
  \def\front@ext{pdf}
\else
  \ifxetex
    \def\front@ext{pdf}
  \else
    \def\front@ext{eps}
  \fi
\fi
\@ifclassloaded{amsbook}
  {\def\front@cp{\null\thispagestyle{empty}\newpage
    \advance\c@page\m@ne}}
  {\let\front@cp\relax}
\newif\if@front@message
\def\front@message{%
  \PackageWarningNoLine{frontespizio}
    {Remember to compile \jobname-frn with\MessageBreak
    \ifpdf
      pdflatex \jobname-frn%
    \else
      \ifxetex
        xelatex \jobname-frn
      \else
        latex \jobname-frn\MessageBreak
        dvips -o \jobname-frn.eps \jobname-frn%
      \fi
    \fi\MessageBreak
    and then rerun \ifpdf pdf\fi \ifxetex xe\fi latex}}
\def\frontespizio{%
  \titlepage\null
  \IfFileExists{\jobname-frn.\front@ext}
    {\AtBeginShipoutNext{\AtBeginShipoutUpperLeft{%
     \vbox to\z@{\hbox{\includegraphics{\jobname-frn}}\vss}}}}
    {\@front@messagetrue}%
  \afterpage{\thispagestyle{empty}}%
  \endtitlepage
  \if@twoside\front@cp\fi
}
\def\endfrontespizio{%
  \front@write{\begin{document}}
  \front@write{\preparefrontpage}
  \front@write{\end{document}}
  \iffront@write\immediate\closeout\front@out\fi
  \ifdefined\front@mdfiveold
    \xdef\front@mdfivenew{\pdfmdfivesum file{\jobname-frn.tex}}%
    \ifx\front@mdfiveold\front@mdfivenew\else
      \@front@messagetrue
    \fi
  \fi
  \if@front@message
    \AtEndDocument{\front@message}
  \fi
}
\endinput
%%
%% End of file `frontespizio.sty'.
