%************************************************
\myChapter{Il codice}
\label{cap:codice}
%************************************************
 
 
\lstset{numbers=left,
    numberstyle=\scriptsize,
    stepnumber=1,
    numbersep=8pt
}    

Annuncio del pacchetto e richiesta dei pacchetti necessari.
\begin{lstlisting}[firstnumber=1]
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{arsclassica}[2008/10/18 v2.5.3 Customizing
                              ClassicThesis (LP)]
\RequirePackage{classicthesis-ldpkg}
\RequirePackage{classicthesis}

\end{lstlisting}
Dichiarazione delle opzioni linguistiche \opzione{english} (predefinita), \opzione{french}, \opzione{german}, \opzione{spanish} e \opzione{italian}.
\begin{lstlisting}
\newboolean{english}
\newboolean{french}
\newboolean{german}
\newboolean{spanish}
\newboolean{italian}
\DeclareOption{english}{\setboolean{english}{true}}
\DeclareOption{french}{\setboolean{french}{true}}
\DeclareOption{german}{\setboolean{german}{true}}
\DeclareOption{spanish}{\setboolean{spanish}{true}}
\DeclareOption{italian}{\setboolean{italian}{true}}
\ExecuteOptions{english}
\ProcessOptions\relax

\end{lstlisting}
%
Bilanciamento delle colonne dell'indice analitico (se presente).
\begin{lstlisting}
\@ifpackageloaded{makeidx} 
{%
   \RequirePackage{multicol}
   \let\orgtheindex\theindex
   \let\orgendtheindex\endtheindex
   \def\theindex{%
      \def\twocolumn{\begin{multicols}{2}}%
      \def\onecolumn{}%
      \clearpage
      \orgtheindex}
   \def\endtheindex{%
      \end{multicols}%
      \orgendtheindex}
   \makeindex
} 
{\relax}

\end{lstlisting}
%
Riferimenti di \pacchetto{backref} in inglese, francese, tedesco, spagnolo e italiano.
\begin{lstlisting}
\ifthenelse{\boolean{english}}%
{%
   \PackageInfo{arsclassica}{Using option "english". %
              This activates english language in "backref".}
   \renewcommand*{\backreftwosep}{ and~} 
   \renewcommand*{\backreflastsep}{, and~} 
   \renewcommand*{\backrefalt}[4]{% 
      \ifcase #1 % 
         \relax% 
      \or 
         (Cited on page~#2.)% 
      \else 
         (Cited on pages~#2.) 
      \fi}
}
{\relax}

\ifthenelse{\boolean{french}}%
{%
   \PackageInfo{arsclassica}{Using option "french". %
              This activates french language in "backref".}
   \renewcommand*{\backreftwosep}{ et~} 
   \renewcommand*{\backreflastsep}{ et~} 
   \renewcommand*{\backrefalt}[4]{% 
      \ifcase #1 % 
         \relax% 
      \or 
         (Cit\'e \`a page~#2.)% 
      \else 
         (Cit\'e aux pages~#2.) 
      \fi}
}
{\relax}

\ifthenelse{\boolean{german}}%
{%
   \PackageInfo{arsclassica}{Using option "german". %
              This activates german language in "backref".}
   \renewcommand*{\backreftwosep}{ und~} 
   \renewcommand*{\backreflastsep}{ und~} 
   \renewcommand*{\backrefalt}[4]{% 
      \ifcase #1 % 
         \relax% 
      \or 
         (Zitiert auf Seite~#2.)% 
      \else 
         (Zitiert auf Seiten~#2.) 
      \fi}
}
{\relax}

\ifthenelse{\boolean{spanish}}%
{%
   \PackageInfo{arsclassica}{Using option "spanish". %
              This activates spanish language in "backref".}
   \renewcommand*{\backreftwosep}{ y~} 
   \renewcommand*{\backreflastsep}{ y~} 
   \renewcommand*{\backrefalt}[4]{% 
      \ifcase #1 % 
         \relax% 
      \or 
         (Citado en la p\'agina~#2.)% 
      \else 
         (Citado en las p\'aginas~#2.) 
      \fi}
}
{\relax}

\ifthenelse{\boolean{italian}}%
{%
   \PackageInfo{arsclassica}{Using option "italian". %
              This activates italian language in "backref".}
   \renewcommand*{\backreftwosep}{ e~} 
   \renewcommand*{\backreflastsep}{ e~} 
   \renewcommand*{\backrefalt}[4]{% 
      \ifcase #1 % 
         \relax% 
      \or 
         (Citato a pagina~#2.)% 
      \else 
         (Citato alle pagine~#2.) 
      \fi}
}
{\relax}

\end{lstlisting}
%
Impostazioni di \pacchetto{minitoc}.
\begin{lstlisting}
\@ifpackageloaded{minitoc} 
{%
   \ifthenelse{\boolean{english}}%
   {%
      \def\ptctitle{contents}
      \def\mtctitle{contents}
      \def\stctitle{contents}
      \setlength{\mtcindent}{0pt}
      \renewcommand{\mtifont}{\normalsize\sffamily%
         \scshape\lsstyle}
   }
   {%
      \setlength{\mtcindent}{0pt}
      \renewcommand{\mtifont}{\normalsize\sffamily%
         \scshape\lsstyle}
   }
}
{\relax}

\@ifpackageloaded{minitoc} 
{%
   \ifthenelse{\boolean{french}}%
   {%
      \def\ptctitle{mati\`eres}
      \def\mtctitle{mati\`eres}
      \def\stctitle{mati\`eres}
      \setlength{\mtcindent}{0pt}
      \renewcommand{\mtifont}{\normalsize\sffamily%
         \scshape\lsstyle}
   }
   {%
      \setlength{\mtcindent}{0pt}
      \renewcommand{\mtifont}{\normalsize\sffamily%
         \scshape\lsstyle}
   }
}
{\relax}

\@ifpackageloaded{minitoc} 
{%
   \ifthenelse{\boolean{german}}%
   {%
      \def\ptctitle{inhaltsverzeichnis}
      \def\mtctitle{inhaltsverzeichnis}
      \def\stctitle{inhaltsverzeichnis}
      \setlength{\mtcindent}{0pt}
      \renewcommand{\mtifont}{\normalsize\sffamily%
         \scshape\lsstyle}
   }
   {%
      \setlength{\mtcindent}{0pt}
      \renewcommand{\mtifont}{\normalsize\sffamily%
         \scshape\lsstyle}
   }
}
{\relax}

\@ifpackageloaded{minitoc} 
{%
   \ifthenelse{\boolean{spanish}}%
   {%
      \def\ptctitle{\'indice}
      \def\mtctitle{\'indice}
      \def\stctitle{\'indice}
      \setlength{\mtcindent}{0pt}
      \renewcommand{\mtifont}{\normalsize\sffamily%
         \scshape\lsstyle}
   }
   {%
      \setlength{\mtcindent}{0pt}
      \renewcommand{\mtifont}{\normalsize\sffamily%
         \scshape\lsstyle}
   }
}
{\relax}

\@ifpackageloaded{minitoc} 
{%
   \ifthenelse{\boolean{italian}}%
   {%
      \def\ptctitle{indice}
      \def\mtctitle{indice}
      \def\stctitle{indice}
      \setlength{\mtcindent}{0pt}
      \renewcommand{\mtifont}{\normalsize\sffamily%
         \scshape\lsstyle}
   }
   {%
      \setlength{\mtcindent}{0pt}
      \renewcommand{\mtifont}{\normalsize\sffamily%
         \scshape\lsstyle}
   }
}
{\relax}

\end{lstlisting}
Uso di Iwona\index{Iwona} come font sans serif.
\begin{lstlisting}
\renewcommand{\sfdefault}{iwona}

\end{lstlisting}
%
Numeri dei capitoli personalizzati.
\begin{lstlisting}
\let\chapterNumber\undefined 
\ifthenelse{\boolean{@eulerchapternumbers}}
{\newfont{\chapterNumber}{eurb10 scaled 5000}}% 
{\newfont{\chapterNumber}{pplr9d scaled 5000}}

\end{lstlisting}
%
Maiuscoletto sans serif.
\begin{lstlisting}
\ifthenelse{\boolean{@minionprospacing}}%
{%
  \DeclareRobustCommand{\spacedallcaps}[1]{\sffamily%
  \textssc{\MakeTextUppercase{#1}}}%
  \DeclareRobustCommand{\spacedlowsmallcaps}[1]%
  {\sffamily\textssc{\MakeTextLowercase{#1}}}%
}{%
  \ifthenelse{\boolean{@pdfspacing}}%
  {%
    \microtypesetup{expansion=false}%
    \DeclareRobustCommand{\spacedallcaps}[1]%
    {\sffamily\textls[160]{\MakeTextUppercase{#1}}}%
    \DeclareRobustCommand{\spacedlowsmallcaps}[1]%
    {\sffamily\textls[80]{\scshape\MakeTextLowercase{#1}}}%
  }{%
    \RequirePackage{soul} 
    \sodef\allcapsspacing{\sffamily\upshape}%
    {0.15em}{0.65em}{0.6em}%
    \sodef\lowsmallcapsspacing{\sffamily\scshape}%
    {0.075em}{0.5em}{0.6em}%   
    \DeclareRobustCommand{\spacedallcaps}[1]%
    {\MakeTextUppercase{\allcapsspacing{#1}}}%   
	\DeclareRobustCommand{\spacedlowsmallcaps}[1]%
	{\MakeTextLowercase{\textsc%
	   {\lowsmallcapsspacing{#1}}}}%
  }%
}

\end{lstlisting}
%
Testatine semitrasparenti e numeri di pagina in Iwona.
\begin{lstlisting}
\renewcommand{\sectionmark}[1]{\markright{\textsc%
{\MakeTextLowercase{\thesection}} \spacedlowsmallcaps{#1}}}
\lehead{\mbox{\llap{\small\thepage\kern1em\color{halfgray}%
\vline}%
\color{halfgray}\hspace{0.5em}\headmark\hfil}} 
\rohead{\mbox{\hfil{\color{halfgray}%
\headmark\hspace{0.5em}}%
\rlap{\small{\color{halfgray}\vline}\kern1em\thepage}}}
\renewcommand{\headfont}{\normalfont\sffamily}
\renewcommand{\pnumfont}{\small\sffamily}

\end{lstlisting}
%  
Uso del font Iwona\index{Iwona} per i titoli delle sezioni (capitoli, paragrafi, sottoparagrafi, sotto-sottoparagrafi, capoversi) e delle etichette degli elenchi descrittivi.
\begin{lstlisting}
\RequirePackage{titlesec}
		% parts
		\ifthenelse{\boolean{@parts}}%
		{%
    \titleformat{\part}[display]
        {\normalfont\centering\large}%
        {\thispagestyle{empty}\partname~\thepart}{1em}%
        {\color{Maroon}\spacedallcaps}
    }{\relax}
    % chapters
    \ifthenelse{\boolean{@linedheaders}}%
    {%
    \titleformat{\chapter}[display]%             
        {\relax}{\raggedleft{\color{halfgray}%
        \chapterNumber\thechapter} \\ }{0pt}%
        {\titlerule\vspace*{.9\baselineskip}\raggedright%
        \spacedallcaps}%
        [\normalsize\vspace*{.8\baselineskip}\titlerule]%
    }{%  
    \titleformat{\chapter}[block]%
        {\normalfont\Large\sffamily}%
        {{\color{halfgray}\chapterNumber\thechapter%
        \hspace{10pt}\vline}  }{10pt}%
        {\spacedallcaps}}
    % sections
    \titleformat{\section} 
    	  {\normalfont\Large\sffamily}{\textsc%
	  {\MakeTextLowercase{\thesection}}}%
         {1em}{\spacedlowsmallcaps}
    % subsections
    \titleformat{\subsection}
        {\normalfont\sffamily}{\textsc{\MakeTextLowercase%
        {\thesubsection}}}{1em}{\normalsize}
    % subsubsections
    \titleformat{\subsubsection}
        {\normalfont\sffamily\itshape}{\textsc%
        {\MakeTextLowercase{\thesubsubsection}}}%
        {1em}{\normalsize\itshape}        
    % paragraphs
    \titleformat{\paragraph}[runin]
        {\normalfont\normalsize\sffamily}{\textsc%
        {\MakeTextLowercase{\theparagraph}}}%
        {0pt}{\spacedlowsmallcaps}    
    % descriptionlabels
    \renewcommand{\descriptionlabel}[1]{\hspace*{\labelsep}%
    \bfseries\spacedlowsmallcaps{#1}}
    \titlespacing*{\chapter}{0pt}{1\baselineskip}%
    {2\baselineskip}
    \titlespacing*{\section}{0pt}{2\baselineskip}%
    {.8\baselineskip}[\marginparsep]
    \titlespacing*{\subsection}{0pt}{1.5\baselineskip}%
    {.8\baselineskip}[\marginparsep]
    \titlespacing*{\paragraph}{0pt}{1\baselineskip}%
    {1\baselineskip}

\end{lstlisting}
%
Elenchi puntati con etichette semitrasparenti.
\begin{lstlisting}
\renewcommand\labelitemi{\color{halfgray}$\bullet$} 

\end{lstlisting}
%
Impostazione delle didascalie.
\begin{lstlisting}
\captionsetup{format=hang,font=small,labelfont={sf,bf}}
\captionsetup[table]{skip=\medskipamount}

\end{lstlisting}
%
Note a margine simmetriche.
\begin{lstlisting}
\let\graffito\relax
\def\graffito@setup{% 
    \slshape\footnotesize% 
    \parindent=0pt \lineskip=0pt \lineskiplimit=0pt % 
    \tolerance=2000 \hyphenpenalty=300 \exhyphenpenalty=300 
    \doublehyphendemerits=100000 
    \finalhyphendemerits=\doublehyphendemerits} 
\DeclareRobustCommand{\graffito}[1]{\marginpar 
  [\graffito@setup\raggedleft\hspace{0pt}{#1}] 
  {\graffito@setup\raggedright\hspace{0pt}{#1}}} 

\end{lstlisting}
%
Interlinea.
\begin{lstlisting}
\linespread{1.00}

\end{lstlisting}
%
Corpo del testo ``a doppio quadrato'' (come nella versione~2.3 dello stile), per documenti composti in formato A4 con font Palatino.
\begin{lstlisting}
\ifthenelse{\boolean{@a5paper}}%
 {\relax}%
 {% A4
   \ifthenelse{\boolean{@minionpro}}%
     {\relax}%
     {% Palatino or other
      \PackageInfo{classicthesis}{A4 paper, Palatino or other}
      \areaset[5mm]{312pt}{699pt}
      % 624 + 33 head + 42 head \the\footskip
      \setlength{\marginparwidth}{7em}%
      \setlength{\marginparsep}{2em}%
     }%
 }

\end{lstlisting}
%
Si definisce il comando
{\ttfamily\textbackslash\color{RoyalBlue}{myincludegraphics}}, 
%\comando{myincludegraphics},
che permette di inserire un'immagine con lo sfondo di colore ``Azzurro Alice''; il suo funzionamento è analogo a quello di {\ttfamily\textbackslash\color{RoyalBlue}{includegraphics}}.
Affinché tutto funzioni, è fondamentale che l'immagine da inserire abbia lo sfondo trasparente.
Nelle versioni precedenti di \arsclassica, il comando {\ttfamily\textbackslash\color{RoyalBlue}{arsincludegraphics}} era chiamato {\ttfamily\textbackslash\color{RoyalBlue}{myincludegraphics}}: è ancora possibile usare il vecchio nome, anche se si sconsiglia di farlo. 
\begin{lstlisting}
\definecolor{aliceblue}{RGB}{240,248,255}

\let\ars@@includegraphics\includegraphics
\newcommand{\arsincludegraphics}[2][]{%
  \begingroup\setlength{\fboxsep}{0pt}%
   \colorbox{aliceblue}{\ars@@includegraphics[#1]{#2}}%
  \endgroup}
\def\myincludegraphics{\PackageWarning{classiclatex}{%
  The command \noexpand\myincludegraphics is
  obsolete;\MessageBreak use \string\arsincludegraphics}% 
  \arsincludegraphics}

\end{lstlisting}
Impostazioni di \pacchetto{hyperref}.
\begin{lstlisting}
\hypersetup{%
    colorlinks=true, linktocpage=true, pdfstartpage=3, 
    pdfstartview=FitV, breaklinks=true, pdfpagemode=UseNone, 
    pageanchor=true, pdfpagemode=UseOutlines,%
    plainpages=false, bookmarksnumbered,
    bookmarksopen=true,%
    bookmarksopenlevel=1,%
    hypertexnames=true, pdfhighlight=/O,%
    urlcolor=webbrown, linkcolor=RoyalBlue, 
    citecolor=RoyalBlue,%
    pagecolor=RoyalBlue,%
    pdfsubject={},%
    pdfkeywords={},%
    pdfcreator={pdfLaTeX},%
    pdfproducer={LaTeX con hyperref e ClassicThesis}%
}

\ifdefined\myTitle 
   \hypersetup{pdftitle={\myTitle}}
\else 
   \relax
\fi

\ifdefined\myName 
   \hypersetup{pdfauthor={\textcopyright\ \myName}}
\else 
   \relax
\fi

\end{lstlisting}
%
Definizione dei comandi
{\ttfamily\textbackslash\color{RoyalBlue}{ctLaTeX}},
{\ttfamily\textbackslash\color{RoyalBlue}{ctLaTeXe}} e
{\ttfamily\textbackslash\color{RoyalBlue}{ctTeX}}, 
per avere rispettivamente i loghi \LaTeX, \LaTeXe{} e \TeX{} composti correttamente  se scritti in Iwona.\index{Iwona}
\begin{lstlisting}
\def\@ppljLaTeX{{\upshape 
   \sbox\z@{\check@mathfonts\fontsize\sf@size\z@%
   \math@fontsfalse\selectfont A}% 
   \sbox\tw@ T% 
   L\kern-.55\wd\z@ 
   \vbox to\ht\tw@{\copy\z@\vss}% 
   \kern-.25\wd0 
        \@ctTeX}} 
\def\@ppljTeX{{\upshape T\kern -.08em \lower .3ex\hbox{E}%
\kern -.08em X}} 

\def\@ppljscLaTeX{{\upshape\scshape 
   \sbox\z@{\check@mathfonts\fontsize\sf@size\z@%
   \math@fontsfalse\selectfont a}% 
   \sbox\tw@ t% 
   l\kern-.6\wd\z@ 
   \vbox to\ht\tw@{\copy\z@\vss}% 
   \kern-.25\wd0 
        \@ctTeX}} 
\def\@ppljscTeX{{\upshape\scshape t\kern -.085em
\lower .25ex\hbox{e}\kern -.085em x}} 

\def\@iwonaLaTeX{{\upshape 
   \sbox\z@{\check@mathfonts\fontsize\sf@size\z@%
   \math@fontsfalse\selectfont A}% 
   \sbox\tw@ T% 
   L\kern-.5\wd\z@ 
   \vbox to\ht\tw@{\copy\z@\vss}% 
   \kern-.2\wd0 
        \@ctTeX}} 
\def\@iwonaTeX{{\upshape T\kern -.12em \lower .3ex\hbox{E}%
   \kern -.12em X}} 

\def\@iwonascLaTeX{{\upshape\scshape 
   \sbox\z@{\check@mathfonts\fontsize\sf@size\z@%
   \math@fontsfalse%
   \selectfont a}% 
   \sbox\tw@ t% 
   l\kern-.5\wd\z@ 
   \vbox to\ht\tw@{\copy\z@\vss}% 
   \kern-.2\wd0 
        \@ctTeX}} 
\def\@iwonascTeX{{\upshape\scshape t\kern -.1em
   \lower .25ex\hbox{e}\kern -.1em x}} 

\def\ct@sc{sc} 
\def\@ctTeX{\csname @\f@family\ifx\f@shape\ct@sc sc%
\fi TeX\endcsname} 

\DeclareRobustCommand\ctLaTeX{% 
  \texorpdfstring{\textls[1]{\csname @\f@family\ifx%
  \f@shape\ct@sc sc\fi LaTeX\endcsname}}{LaTeX}} 
\DeclareRobustCommand\ctLaTeXe{% 
  \texorpdfstring{\textls[1]{\ctLaTeX\csname @\ifx%
  \f@shape\ct@sc sc\fi twoe\endcsname}}{LaTeX2e}} 

\def\@twoe{\kern.1em$\m@th2_{\textstyle\varepsilon}$} 
\def\@sctwoe{\kern.15em$\m@th{\scriptscriptstyle2}%
_\varepsilon$}

\DeclareRobustCommand\ctTeX{% 
  \texorpdfstring{\textls[1]{\csname @\f@family\f@shape TeX%
  \endcsname}}{TeX}} 

\end{lstlisting}
%
Il codice seguente permette di avere, nell'indice generale, le testatine in maiuscoletto spaziato, anche quando l'indice occupa più di due pagine (rimediando ad un piccolo difetto di \classicthesis).
\begin{lstlisting}
\def\toc@headingbkORrp{% 
  \def\toc@heading{% 
    \chapter*{\contentsname}% 
    \@mkboth{\spacedlowsmallcaps{\contentsname}} 
      {\spacedlowsmallcaps{\contentsname}}}} 
\@ifclassloaded{scrreprt}{\toc@headingbkORrp}{} 
\@ifclassloaded{scrbook}{\toc@headingbkORrp}{}
\end{lstlisting}
