%@ -------------------------------------------------------
%@ start of file 'mycv-macros.sty'.
%@ Copyright 2012 Ghersi Andrea (ghanhawk@gmail.com).
%@
%@ This work may be distributed and/or modified under the
%@ conditions of the LaTeX Project Public License version
%@ 1.3c, available at 'http://www.latex-project.org/lppl'.
%@ -------------------------------------------------------
\ProvidesPackage{mycv-macros}[2012/04/13%
   A package providing some useful commands]

\ifdraft
   % ---------------------------------
   % rende visibili (in nero) i badbox
   % ---------------------------------
   \overfullrule=5pt
\fi


%%%%%%%%%%%%
%          %
% Hyperref %
%          %
%%%%%%%%%%%%

\hypersetup{citecolor=webgreen}
\hypersetup{pdfstartpage=1}

\hypersetup{%
   pdfstartpage = 1,
   pdfauthor    = Andrea Ghersi,
   pdftitle     = MyCV,
   pdfsubject   = MyCV class documentation,
   pdfproducer  = \LaTeX{},
   pdfkeywords  = {},
   pdfcreator   = \LaTeX{} with 'arsclassica'
}


%%%%%%%%%
%       %
% Alias %
%       %
%%%%%%%%%

%\newcommand{\mySubTitle}{a list driven cv\xspace}
\newcommand{\myTitle}{MyCV\xspace}
\newcommand{\myName}{Andrea Ghersi\xspace}
\newcommand{\myMail}{ghanhawk@gmail.com}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                       %
% Formato pagina, sezioni, capitoli,... %
%                                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% modifica la larghezza della pagine. Formato:
\areaset{412pt}{749pt}

% ---------------------------------------------------
% modifica formato section e subsection (sovrascrive
% le impostazioni definite dallo stile 'arsclassica')
% ---------------------------------------------------

% sections
\titleformat{\section}%
   {\color{red}\normalfont\Large\bfseries\bf}%
   {\color{red}\MakeTextLowercase{\thesection}}{1em}{\spacedlowsmallcaps}

% subsections
\titleformat{\subsection}%
   {\color{orange}\normalfont\bfseries\bf}
   {\textsc{\MakeTextLowercase{\thesubsection}}}{1em}{\normalsize}

% subsubsections
\titleformat{\subsubsection}%
   {\color{cyan}\normalfont\bfseries\bf}
   {\textsc{\MakeTextLowercase{\thesubsection}}}{1em}{\small}

% -------------------------------------------------
% cambia il colore dei capitoli/sezioni nell'indice
% -------------------------------------------------

\renewcommand*\cftchapfont{\color{red}\bfseries}
\renewcommand*\cftsecfont{\color{gray}\bfseries}

% -----------------------------------------------------------
% words 'chapter', 'section' and 'subsection' not capitalized
% inside a ref
% -----------------------------------------------------------

\def\chapterautorefname{chapter}       %default: Chapter
\def\sectionautorefname{section}       %default: Section
\def\subsectionautorefname{subsection} %default: Subsection


%%%%%%%%%%%%%%%%%%%%%%%%
%                      %
% Liste personalizzate %
%                      %
%%%%%%%%%%%%%%%%%%%%%%%%

% ----------------------------------------------
%\circ          — An open circle
%\cdot          — A centered dot
%\star          — A five-pointed star
%\ast           — A centered asterisk
%\rightarrow    —  A short right-pointing arrow
%\diamondsuit   — An open diamond
%\triangleright
% ----------------------------------------------

% separazione tra item
\def\myitemsep{5pt}

\newcommand{\squishlist}[1][\myitemsep]{%
   \begin{list}{$\triangleright$}%
   {  % separazione tra paragrafi: OGNI nuova
      % lista equivale ad un NUOVO paragrafo
      \setlength{\parskip}{5pt}%
      % separazione tra item
      \setlength{\itemsep}{#1}%
      \setlength{\parsep}{5pt}%
      % separazione del primo item - si aggiunge
      % all'eventuale separazione tra paragrafi
      \setlength{\topsep}{5pt}%
      \setlength{\partopsep}{0pt}%
      \setlength{\leftmargin}{2.5em}%
      \setlength{\labelwidth}{1em}%
      \setlength{\labelsep}{0.5em}%
   }}

\newcommand{\squishend}{%
   \end{list}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                          %
% Citazioni personalizzate %
%                          %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\quotes}[3][0]{%
   % ----------------------------------------------------------
   % definisce il colore dell'autore e dell'anno (verde chiaro)
   % rosso RGB {255, 0, 0}
   % ----------------------------------------------------------
   \definecolor{authorcolor}{RGB}{51, 153, 51}
   \definecolor{datecolor}  {RGB}{51, 153, 51}
   %
   \noindent\makebox[0.90\textwidth]{%
      \begin{minipage}[t]{0.50\textwidth}%
         \hfill%
      \end{minipage}%
      \begin{minipage}[t]{0.50\textwidth}%
         {\small\ignorespaces\slshape #2}\\[0.5em]%
         \medskip%
         \hfill\texttt{---} {{\color{authorcolor}{#3}}}%
         \ifnum#1>0%
            \xspace[{\color{datecolor}{#1}}]%
         \fi%
      \end{minipage}%
   }}


%%%%%%%%%%%%%%%%%%%%%%%%
%                      %
% Riferimenti a pagine %
%                      %
%%%%%%%%%%%%%%%%%%%%%%%%

% page references
\newcommand{\myref}[1]{{\color{blue}(\autoref{#1})}\xspace}
\newcommand{\myreftwo}[1]{{\color{blue}(see~\autoref{#1})}\xspace}


%%%%%%%%%%%%%%%%
%              %
% Comandi vari %
%              %
%%%%%%%%%%%%%%%%

% pensato per parole maiuscole (es CV, DPL,...)
\newcommand{\keyword}[1]{{\footnotesize\textbf{#1}}\xspace}

\newcommand{\argvsep}{\\[5pt]} % vertical sep between args list
\newcommand{\arghsep}{\;\;}    % horizontal sep between args list
\newcommand{\cmdvsep}{\\[5pt]} % vertical sep between cmds list
\newcommand{\cmdhsep}{\;\;}    % horizontal sep between cmds list
\newcommand{\cmddsep}{\par\medskip} % vertical sep between cmd and its description
\newcommand{\optvsep}{\\[5pt]} % vertical sep between opts list
\newcommand{\opthsep}{\;\;}    % horizontal sep between opts list
\newcommand{\optdsep}{\par}    % vertical sep between opt and its description
\newcommand{\sep}{\medskip}    % generic sep
\newcommand{\argname}[2][black]{{\color{#1}{$\langle$\textit{#2}$\rangle$}}}
\newcommand{\cmdname}[2][brown]{{\color{#1}{\textbf{\textbackslash#2}}}}
\newcommand{\optname}[2][brown]{{\color{#1}{\textbf{#2}}}}
\newcommand{\classname}{{\color{blue}{\textit{MyCV}}}\xspace}
\newcommand{\codeskip}{\medskip}
\newcommand{\DPL}{\keyword{DPL}} % se si usa \color bisogna anche mettere un \xspace
\newcommand{\SPL}{\keyword{SPL}} % idem
\newcommand{\CV}{\keyword{CV}}   % idem

% format '{...}' arguments: #1 is an argument
\newcommand{\marg}[1]{%
   \fbox{%
      {\color{red}\textbf{\{}}$\langle$%
      \textit{#1}%
      $\rangle${\color{red}\textbf{\}}}}%
   }

% format '[...]' arguments: #1 is an argument, #2 is the default value
\newcommand{\dargone}[2]{%
   \fbox{%
      {\color{cyan}\textbf{[}}$\langle$%
      \textit{#1}%
      $\rangle${\color{cyan}\textbf{]}}%
   }\;$\longrightarrow$\;{\color{blue}\textbf{[}\textit{#2}\textbf{]}}}

% format '<...>' arguments: #1 is an argument, #2 is the default value
\newcommand{\dargtwo}[2]{%
   \fbox{%
      {\color{cyan}\textbf{<}}$\langle$%
      \textit{#1}%
      $\rangle${\color{cyan}\textbf{>}}%
   }\;$\longrightarrow$\;{\color{blue}\textbf{<}\textit{#2}\textbf{>}}}

% indentazione
\newenvironment{myindent}[1][0.2in]%
 { \begin{list}{}{%
   \setlength{\topsep}{0pt}%
    \setlength{\leftmargin}{#1}%
    \setlength{\partopsep}{0pt}%
    \setlength{\parsep}{\parskip}}\item[]%
 }
 {\end{list}}

% colored text
\newcommand{\ctext}[2][red]{{\color{#1}{#2}}}

% omissis, nella forma: [...]
\newcommand{\omissis}{[\dots\negthinspace]}


%%%%%%%%%%%%
%          %
% Listings %
%          %
%%%%%%%%%%%%

% for backgroundcolor color
\definecolor{lightergray}{gray}{0.99}

\lstset{language=[LaTeX]Tex,
   keywordstyle=\color{RoyalBlue},
   basicstyle=\normalfont\ttfamily,
   commentstyle=\color{Emerald}\ttfamily,
   stringstyle=\rmfamily,
   numbers=none,%left,% where to put the line-numbers ('none' if no numbers are wanted)
   % to decomment for having numbers inside the listing box instead outside
   %xleftmargin=2em,frame=single,framexleftmargin=1.5em,
   numberstyle=\scriptsize\color{gray},% the style that is used for the line-numbers
   stepnumber=1, % the step between two line-numbers. If it's 1, each line will be numbered
   numbersep=8pt,% how far the line-numbers are from the code
   showstringspaces=false,
   breaklines=true,
   frameround=ftff,
   frame=lines,
   moredelim=[is][\color{orange}]{|}{|},
   moredelim=[is][\color{red}]{&}{&},
   backgroundcolor=\color{lightergray}
}

\lstset{
   morekeywords=%
   {%
      RequirePackage,newboolean,DeclareOption,setboolean,%
      ProcessOptions,PackageError,ifthenelse,boolean,%
      MakeTextLowercase,@ifpackageloaded,undefined,%
      DeclareRobustCommand,MakeTextUppercase,%
      color,titlerule,titlespacing,%
      labelitemi,hypersetup,setlength,%
      definecolor,includegraphics,ifdefined,%
      ProvidesPackage,PackageInfo,PackageWarningNoLine,%
      @ifclassloaded,ExecuteOptions,PackageWarning,textcolor%
   },%
   commentstyle=\color{Emerald}\ttfamily,%
   frame=lines%
}