%%
%% This is file `toptesi.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% toptesi.dtx  (with options: `topsty')
%%   ______________________________________________________
%%   The TOPtesi package
%%   Copyright (C) 2005-2016 Claudio Beccari
%%   All rights reserved
%% 
%%   License information appended
%% 
\NeedsTeXFormat{LaTeX2e}[2015/01/01]
\ProvidesPackage{toptesi}[%
2016/11/25 v.5.9.06
Extension for toptesi.cls]
\def\TRON{\tracingcommands \tw@ \tracingmacros \tw@}
\def\TROFF{\tracingcommands\z@ \tracingmacros \z@}
\let\TROF\TROFF
\newif\if@utoretitolo \@utoretitolofalse
\newif\if@ldstyle \@ldstylefalse
\newif\if@xivpt \@xivptfalse
\newif\ifT@Pfrontespizio \T@Pfrontespiziofalse
\newif\ifTOPfront \TOPfronttrue
\newlength\T@Pbinding\setlength\T@Pbinding{7mm}
\def\setbindingcorrection#1{\T@Pbinding=#1}
\newif\if@binding \@bindingfalse
\newif\ifchapterbibliography \chapterbibliographyfalse
\newif\ifclassica \classicafalse
\DeclareOption{cucitura}{\@bindingtrue}
\DeclareOption{14pt}{\@xivpttrue}
\DeclareOption{chapterbib}{\chapterbibliographytrue}
\DeclareOption{trieste}{\classicatrue}% Just for backwards compatibility
\DeclareOption{classica}{\classicatrue}
\DeclareOption{autoretitolo}{\ifclassica\@utoretitolotrue\fi}
\DeclareOption{oldstyle}{\ifclassica\@ldstyletrue\fi}
\DeclareOption{pdfa}{\PackageWarning{toptesi}{Option pdfa ignored.\MessageBreak
Read documentation toptesi-it-*.pdf, because package pdfx has changed}}
\DeclareOption{usefrontespizio}{\T@Pfrontespiziotrue\TOPfrontfalse}
\DeclareOption{noTOPfront}{\T@Pfrontespiziotrue\TOPfrontfalse}
\ProcessOptions\relax
\RequirePackage{graphicx}
\RequirePackage{etoolbox}
\if@xivpt\input{size14.clo}\fi
\newlength\interno
\textheight 0.7\paperheight
\setlength{\textheight}{\dimexpr\textheight*\baselineskip/\baselineskip+\topskip}
\ifx\f@size\@xivpt
    \setlength\interno{\dimexpr\paperwidth/6}
    \footskip=1,5\baselineskip
\else
    \setlength\interno{\dimexpr\paperwidth/7}
    \footskip=2\baselineskip
\fi
\textwidth=\dimexpr\paperwidth-2\interno\relax
\oddsidemargin=\dimexpr\interno-1in\relax
\evensidemargin=\oddsidemargin
\marginparwidth=\dimexpr\interno-2.5\marginparsep
\AtBeginDocument{%
\if@binding
 \PackageInfo{TOPtesi}{Margin width recalculation}
 \PackageInfo{TOPtesi}{Before:\MessageBreak
 oddsidemargin\space\space \the\oddsidemargin\MessageBreak
 evensidemargin\space \the\evensidemargin}
 \advance\oddsidemargin \T@Pbinding
 \advance\evensidemargin -\T@Pbinding
 \advance\marginparwidth -\T@Pbinding
 \PackageInfo{TOPtesi}{After:\MessageBreak
 oddsidemargin\space\space \the\oddsidemargin\MessageBreak
 evensidemargin\space \the\evensidemargin}
\fi}

\def\lapagina{\thepage}
\mark{{}{}}
\newbox\@intesta
\def\ps@plain{\let\@mkboth\@gobbletwo
\def\@oddfoot{\null\hfill {\scshape\lapagina}\hfill \null}\def\@oddhead{}
\def\@evenhead{}\let\@evenfoot\@oddfoot}
\if@twoside
   \def\ps@headings{\let\@mkboth\markboth%
   \def\@oddfoot{\null\hfill {\scshape\lapagina} \hfill\null}
   \let\@evenfoot\@oddfoot
   %
   \def\@evenhead{\setbox\@intesta\hbox{\footnotesize\slshape
        \leftmark}%
   \ifdim\wd\@intesta>\textwidth \headWarn{\chapter}\fi%
   \underline{\makebox[\textwidth]{\footnotesize\slshape
        \strut\leftmark}}}%
   \def\@oddhead{\setbox\@intesta\hbox{\footnotesize\slshape
        \rightmark}%
   \ifdim\wd\@intesta>\textwidth \headWarn{\section}\fi%
   \underline{\makebox[\textwidth]{\footnotesize\slshape
        \strut\rightmark}}}%
   \def\chaptermark##1{%
       \markboth{\thechapter\ -- ##1}{\thechapter\ -- ##1}}
   \def\sectionmark##1{\markright{\ifnum\c@secnumdepth>\z@
   \thesection\ -- \fi ##1}}}
\else
   \def\ps@headings{\let\@mkboth\markboth
   \def\@oddfoot{\null\hfill {\scshape\lapagina} \hfill\null}
   \def\@evenfoot{}
   \def\@oddhead{\setbox\@intesta\hbox{\footnotesize\slshape
        \rightmark}%
   \ifdim\wd\@intesta>\textwidth \headWarn{\chapter}\fi%
   \underline{\makebox[\textwidth]{\footnotesize\slshape
        \strut\rightmark}}}%
   \def\chaptermark##1{\markright{\thechapter\ -- ##1}}}
\fi

\def\headWarn#1{\PackageWarning{toptesi}{%
   THE HEADING IS TOO LONG\MessageBreak
   Use the optional argument of command \string#1\MessageBreak
   See the LaTeX Handbook (1994) on section C.4.1\MessageBreak}}
\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak
      \hb@xt@\@pnumwidth{\hss\ifPDFTeX\normalfont\fi\scshape{#2}}\par
      \penalty\@highpenalty
    \endgroup
  \fi}
\newif\iffigurespage
\newif\iftablespage
\newif\ifnumeriromani
\newif\iffrontmatter
\def\frontmatter{\clearpage\ps@plain\pagenumbering{roman}%
    \numeriromanitrue\frontmattertrue\@openrightfalse\c@secnumdepth=-2}
\def\mainmatter{\if@twoside\@openrighttrue\fi
    \numeriromanifalse\frontmatterfalse\c@secnumdepth=2
    \clearpage\ps@headings\pagenumbering{arabic}%
    }
\AtBeginDocument{\frontmatter}
\figurespagefalse
\tablespagefalse
\let\ps@blank\ps@plain
\newcommand*\blankpagestyle[1]{%
   \expandafter\let\expandafter\ps@blank\csname ps@#1\endcsname}
\renewcommand\cleardoublepage[1][blank]{\clearpage\ifodd\value{page}\else
   \if@twoside\if@openright
\clearpage\null\thispagestyle{#1}\clearpage\fi\fi\fi}
\def\sommario{%
 \iffrontmatter\else\frontmattertrue\fi
 \chapter*{\summaryname}}
\def\ringraziamenti{%
 \iffrontmatter\else\frontmattertrue\fi
 \chapter*{\acknowledgename}}
\def\@chapter[#1]#2{\iffrontmatter\mainmatter\fi
                    \ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#1}%
                    \else
                      \addcontentsline{toc}{chapter}{#1}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
\def\@part[#1]#2{\iffrontmatter\mainmatter\fi
    \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    \markboth{}{}%
    {\centering
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >-2\relax
       \huge\bfseries \partname\nobreakspace\thepart
       \par
       \vskip 20\p@
     \fi
     \Huge \bfseries #2\par}%
    \@endpart}
\renewcommand\tableofcontents{%
 \chapter*{\contentsname}%
 \@mkboth{\contentsname}{\contentsname}%
 \@starttoc{toc}%
 \clearpage
 \if@restonecol\twocolumn\fi
    }
\renewcommand\listoffigures{%
    \chapter*{\listfigurename}
    \@mkboth{\listfigurename}{\listfigurename}%
    \addcontentsline{toc}{chapter}{\listfigurename}
    \@starttoc{lof}%
    \clearpage
    \if@restonecol\twocolumn\fi
    }
\renewcommand\listoftables{%
    \chapter*{\listtablename}%
    \addcontentsline{toc}{chapter}{\listtablename}
    \@mkboth{\listtablename}{\listtablename}%
    \@starttoc{lot}%
    \clearpage
    \if@restonecol\twocolumn\fi
    }
\def\indici{%
 \iffrontmatter\else\frontmattertrue\fi
        \tableofcontents
        \iftablespage
                {\addvspace{10pt}
                \let\saveaddvspace=\addvspace
                \def\addvspace##1{}
                \listoftables
                \let\addvspace=\saveaddvspace}
        \fi
        \iffigurespage
                {\addvspace{10pt}
                \let\saveaddvspace=\addvspace
                \def\addvspace##1{}
                \listoffigures
                \let\addvspace=\saveaddvspace}
        \fi
\ifbool{@twoside}{\clearpage\thispagestyle{empty}\null\clearpage}{}}
\onecolumn
\if@twoside
    \flushbottom
\else
    \ifx\@xivpt\f@size
        \raggedbottom
    \else
        \flushbottom
    \fi
\fi
\brokenpenalty=10000
\def\interlinea#1{\linespread{#1}\selectfont}
\def\endinterlinea{\par}
\def\@floatboxreset{%
        \reset@font
        \linespread{1}%
        \normalsize
        \@setminipage
}
\def\fps@figure{htb} \def\fps@table{htb}
\setcounter{topnumber}{2}
\def\topfraction{1}
\setcounter{bottomnumber}{1}
\def\bottomfraction{.5}
\setcounter{totalnumber}{2}
\def\textfraction{0}
\def\floatpagefraction{0}
\setcounter{dbltopnumber}{2}
\def\dbltopfraction{1}
\def\dblfloatpagefraction{0}

\AtBeginDocument{\@ifpackageloaded{caption}{}{%
\providecommand\captionsetup{}\renewcommand\captionsetup[2][]{}%
\newdimen\captionwidth
\belowcaptionskip=\abovecaptionskip
\long\def\@makecaption#1#2{%
   \begingroup
   \small \parskip\z@ \parindent\z@
   \finalhyphendemerits 100000\relax
   \linespread{0.95}\selectfont
   \vskip \abovecaptionskip
   \captionwidth=\hsize
   \advance\captionwidth-3em
   \setbox0 \hbox{#1.\quad#2}%
   \ifdim\wd0>\hsize
      \setbox1 \vbox{\hsize=\captionwidth
      \unhbox0\par\global\setbox2\lastbox}%
      \setbox2\hbox{\unhbox2}%
      \ifdim\wd2<0.333333\captionwidth
         \count255=\ht1 \advance\count255 \dp1
         \divide\count255\baselineskip
         \advance\count255\@ne
         \@tempdima=\wd2
         \advance\@tempdima \count255\captionwidth
         \advance\@tempdima 0.5\captionwidth
         \advance \count255\@ne
         \divide \@tempdima \count255
         \captionwidth=\@tempdima
         \setbox0 \vbox{\hsize\captionwidth
         #1.\quad#2}
      \else
         \setbox2\hbox to\captionwidth{\unhbox2 \hfill}%
         \setbox0\vbox{\unvbox1\box2}%
      \fi
   \fi
   \makebox[\hsize]{\box0}%
   \vskip \belowcaptionskip
   \endgroup
}}}

\newcommand\goodpagebreak[1][4]{\ifvmode
\unless\ifdim\dimexpr\pagegoal-\pagetotal>#1\baselineskip\newpage\fi
\else\ifhmode\vadjust{\newpage}\fi\fi}
\def\redef@bibitem{\def\@bibitem##1{\item\if@filesw
       \immediate\write\@auxout
       {\string\bibcite{##1}{\thechapter.\the\c@enumi}}\fi\ignorespaces}}
\def\thebibliography#1{%
 \ifchapterbibliography\section*{\bibname}\relax
    \if@twoside\markright{\bibname}\fi
    \addcontentsline{toc}{section}{\bibname}\relax
    \redef@bibitem
    \list{[\thechapter.\arabic{enumi}]}{%
    \settowidth\labelwidth{[\thechapter.#1]}\leftmargin\labelwidth
    \advance\leftmargin\labelsep\itemsep\z@ plus 1pt\parsep\z@
    \usecounter{enumi}}
 \else
    \chapter*{\bibname}\relax
    \@mkboth{\bibname}{\bibname}\relax
    \addcontentsline{toc}{chapter}{\bibname}\relax
    \list{[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}%
    \leftmargin\labelwidth
    \advance\leftmargin\labelsep\itemsep\z@ plus 1pt\parsep\z@
    \usecounter{enumi}}
 \fi
 \def\newblock{\hskip .11em plus .33em minus -.07em}
 \sloppy
 \sfcode`\.=1000\relax}

\let\endthebibliography=\endlist
\long\def\@footnotetext#1{\insert\footins{\linespread{1}\footnotesize
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth \@parboxrestore
   \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
   \@makefntext{\rule{\z@}{\footnotesep}\ignorespaces#1\strut}}}
 \DeclareMathSymbol{\virgola}{\mathpunct}{letters}{"3B}
 \DeclareMathSymbol{\virgoladecimale}{\mathord}{letters}{"3B}
 \AtBeginDocument{\mathcode`\,=\string"8000}
 {\catcode `,=\active \gdef,{\futurelet\let@token\m@thcomma}}
\def\m@thcomma{\let\@tempB\virgola
\@tfor\@tempA:=0123456789\do{%
\expandafter\ifx\@tempA\let@token\let\@tempB\virgoladecimale
\@break@tfor\fi}\@tempB}
\catcode`\^^Z=10
\topmargin 0pt
\providecommand*\summaryname{}
\providecommand*\acknowledgename{}
\newcommand*\ExtendCaptions[3]{{%
\@ifundefined{captions#1}{%
\PackageWarning{toptesi}{Language option #1 not specified\MessageBreak
Skipping any redefinition\MessageBreak}%
}{%
\expandafter\let\expandafter\@tempA\csname captions#1\endcsname
 \toks0=\expandafter{\@tempA%
    \def\summaryname{#2}%
    \def\acknowledgename{#3}}%
 \expandafter\xdef\csname captions#1\endcsname{\the\toks0}%
 }}}%
\ExtendCaptions{italian}{Sommario}{Ringraziamenti}
\ExtendCaptions{english}{Summary}{Acknowledgements}
\def\italiano{\selectlanguage{italian}}%
\def\english{\selectlanguage{english}}%
\let\inglese\english
\AtBeginDocument{%
    \italiano
    \renewcommand\@chapapp{\chaptername}%
}
\AtBeginDocument{%
\unless\ifT@Pfrontespizio
       \RequirePackage{topfront}
    \fi
\RequirePackage{topcoman}%
}
\ifPDFTeX
\renewcommand*\not{\mathrel{\mathchoice%
{\rlap{$\displaystyle\mkern2.5mu\mathnormal{/}$}}%
{\rlap{$\textstyle\mkern2.5mu\mathnormal{/}$}}%
{\rlap{$\scriptstyle\mkern2.5mu\mathnormal{/}$}}%
{\rlap{$\scriptscriptstyle\mkern2.5mu\mathnormal{/}$}}%
}}
\renewcommand\mapstochar{\mathrel{\mathchoice
{\displaystyle\unitlength=0.0555\fontdimen6\font
   \picture(0,0)\put(1,1.5){\linethickness{0.72\unitlength}%
   \line(0,1){6}}\endpicture}
{\textstyle\unitlength=0.0555\fontdimen6\font
   \picture(0,0)\put(1,1.5){\linethickness{0.72\unitlength}%
   \line(0,1){6}}\endpicture}
{\scriptstyle\unitlength=0.0555\fontdimen6\font
   \picture(0,0)\put(1,0.55){\linethickness{0.61\unitlength}%
   \line(0,1){5}}\endpicture}
{\scriptscriptstyle\unitlength=0.0555\fontdimen6\font
   \picture(0,0)\put(1,0.2){\linethickness{0.56\unitlength}%
   \line(0,1){4}}\endpicture}
}}\fi
\newcounter{tomo}
\newcommand*{\tomo}{\clearpage\stepcounter{tomo}\boolfalse{topTPTlogos}%
   \fr@ntespizio}
\renewcommand*{\lapagina}{%
    \ifnumeriromani
        \thepage
    \else
        \if@ldstyle
            \expandafter\oldstylenums\expandafter{\thepage}%
        \else
            \thepage
        \fi
    \fi
}
\if@utoretitolo
   \if@twoside
       \renewcommand*{\ps@headings}{\let\@mkboth\markboth%
       \def\@oddfoot{\null \hfill \textbf{\lapagina} \hfill \null}%
       \let\@evenfoot\@oddfoot
       \def\@evenhead{%
           \setbox\@intesta\hbox{\ifPDFTeX\latintext\fi
           \footnotesize\strut\textsc{%
           \@author\ifx\@secondauthor\empty\else\ et al.\fi: \@stitle}%
           }%
       \ifdim\wd\@intesta>\textwidth\headwrn{\titolo}\fi
       \underline{\makebox[\textwidth]{\box\@intesta}}}%
       \def\@oddhead{\ifPDFTeX\latintext\fi
           \setbox\@intesta\hbox{%
               \footnotesize\strut\textsl{\rightmark}}%
       \ifdim\wd\@intesta>\textwidth \headWarn{\section}\fi%
       \underline{\makebox[\textwidth]{\box\@intesta}}}%
       \def\chaptermark##1{\markright{\thechapter\ -- ##1}}%
       \def\sectionmark##1{}}%
   \else
       \renewcommand*{\ps@headings}{\let\@mkboth\markboth
           \def\@oddfoot{\null \hfill \textbf{\lapagina}\hfill \null}%
           \let\@evenfoot\empty\let\@evenhead\empty
           \def\@oddhead{{\setbox\z@\hbox{\ifPDFTeX\latintext\fi\footnotesize
           \textsc{%
           \@author\ifx\@secondauthor\empty\else\ et al.\fi: \@stitle}}%
           \setbox\tw@\hbox{\ifPDFTeX\latintext\fi\footnotesize\textsl{\rightmark}}%
           \dimen@=\dimexpr2em + \wd\z@ + \wd\tw@\relax
           \ifdim\dimen@<\textwidth \relax
           \else
             \setbox\z@\vbox{\hsize.48\textwidth\parindent\z@\raggedright
             \ifPDFTeX\latintext\fi\footnotesize\textsc{%
             \@author\ifx\@secondauthor\empty\else\ et al.\fi: \@stitle
             }}%
             \setbox\tw@\vbox{\hsize.48\textwidth\parindent\z@\raggedleft
                 \ifPDFTeX\latintext\fi\footnotesize\textsl{\rightmark}}%
           \fi
           \setbox\@intesta\vbox to\z@{%
                \vss\hbox to\textwidth{\strut\box\z@\hfill\box\tw@}}%
           \underline{\box\@intesta}}}%
           \def\chaptermark##1{\markright{\thechapter\ -- ##1}}}
   \fi
\fi
\renewcommand\footnoterule{%
  \kern-6\p@
  \hrule\@width.4\columnwidth
  \kern5.6\p@}
\setlength\footnotesep{12\p@}
\setlength{\skip\footins}{24\p@ \@plus 4\p@ \@minus 2\p@}
\newcommand*\nota[1][\mathord{*}]{%
    \xdef\@thefnmark{\ensuremath{\m@th#1}}\@footnotemark\@footnotetext
}
\newcommand*{\NoteWhiteLine}{\par\vspace*{-.3\baselineskip}}
\newcommand*\paginavuota{\clearpage\thispagestyle{empty}\null\clearpage}
\newenvironment{dedica}{\clearpage
    \if@twoside
        \ifodd\c@page\else\thispagestyle{empty}\null\clearpage\fi
    \fi
    \thispagestyle{empty}%
    \list{}{\labelwidth\z@
    \leftmargin.5\textwidth
    \parindent\z@
    \raggedright\LARGE\itshape}\item[]
}{%
    \endlist\clearpage
}
\newenvironment{citazioni}{%
    \clearpage\thispagestyle{empty}
    \list{}{\labelwidth\z@
    \leftmargin.5\textwidth
    \parindent\z@
    \raggedright}\item[]
}{%
    \endlist\clearpage
}
%% 
%% Copyright 2005-2016 Claudio Beccari
%% 
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%% 
%% This work is "author-maintained"
%% 
%% This work consists of this file toptesi.dtx, a README file
%% and the derived files:
%% 
%% toptesi.cls, toptesi.sty, topfront.sty, topcoman.sty,
%% toptesi.cfg, and the English documentation toptesi.pdf.
%% 
%% Furthermore the bundle contains the documentation source
%% file toptesi-it-pdftex.tex and the derived file
%% toptesi-it-pdftex.pdf.
%% 
%% The toptesi-example.tex source file is just an example
%% that shows how to use the various commands; by commenting
%% or uncommenting certain source lines it is possible to
%% typeset different kind of theses and their front pages.
%% 
%% The topfront-example.tex source file is an example of how
%% to produce just the title page with TOPtesi and the external
%% package frontespizio.
%% 
%% The toptesi.cfg file is a sample of a local configuration
%% file that can be copied to another file and its copy freely
%% edited and customized.
%% 
%% By running pdflatex on toptesi.dtx the user gets the class,
%% sty and cfg files and the English documentation file in
%% pdf format.
%% 
%% The source file of the Italian documentation file
%% toptesi-it-pdftex.pdf is another example of how to use TOPtesi.
%% In spite of its name, toptesi-it-pdftex.tex may be typeset
%% with pdfLaTeX, XeLaTeX, and LuaLateX; see the first comment
%% lines of the file for how-to information.
%%
%% End of file `toptesi.sty'.
