\@ifundefined{@base}{\typeout{'fancysection.hva' must be loaded after base style}\endinput}{}
\usepackage{color}
%%% Color section
\newcommand{\colorsections}[1]{
\definecolor{title}{hsv}{#1,1,.7}
\definecolor{titlemain}{hsv}{#1,1,.7}
\definecolor{titlerest}{hsv}{#1,1,.7}
\definecolor{part}{hsv}{#1, 1, .8}
\ifthenelse{\equal{\@base}{article}}{%
\definecolor{section}{hsv}{#1, .8, .9}%
\definecolor{subsection}{hsv}{#1, .6, 1}%
\definecolor{subsubsection}{hsv}{#1, .4, 1}%
}{%
\definecolor{chapter}{hsv}{#1, .8, .9}%
\definecolor{section}{hsv}{#1, .6, 1}%
\definecolor{subsection}{hsv}{#1, .5, 1}%
\definecolor{subsubsection}{hsv}{#1, .4, 1}%
}%
\definecolor{paragraph}{hsv}{#1, .2, 1}}%
\colorsections{120}%
%% Define sectioning comands
\AtBeginDocument
{\newstyle{BODY}{backgroundcolor:white}%
\newstyle{.title}
	{padding:1ex;background:\@getstylecolor{title}}%
\newstyle{.titlemain}
	{padding:1ex;background:\@getstylecolor{titlemain}}%
\newstyle{.titlerest}
	{padding:1ex;background:\@getstylecolor{titlerest}}%
\newstyle{.part}
	{padding:1ex;background:\@getstylecolor{part}}%
\newstyle{.section}
	{padding:.5ex;background:\@getstylecolor{section}}%
\newstyle{.subsection}
	{padding:0.3ex;background:\@getstylecolor{subsection}}%
\newstyle{.subsubsection}
	{padding:0.5ex;background:\@getstylecolor{subsubsection}}%
\ifthenelse{\equal{\@base}{book}}
{\newstyle{.chapter}{padding:0.5ex;background:\@getstylecolor{chapter}}}
{}}
\newcounter{tocstyle}
\renewenvironment{tocenv}
  {\setenvclass{itemize}{ftoc\thetocstyle}%
   \setenvclass{li-itemize}{\getenvclass{li-toc}}%
   \stepcounter{tocstyle}%
   \begin{itemize}}
  {\end{itemize}\addtocounter{tocstyle}{-1}}
\newcommand{\newftocstyle}[2]
  {\newstyle{.ftoc#1}{list-style:none;margin:0ex 1ex;padding:0ex 1ex;border-left:1ex solid \@getstylecolor{#2};}}
\AtBeginDocument
{\newftocstyle{1}{part}%
\ifthenelse{\equal{\@base}{book}}
{\newftocstyle{2}{chapter}\newftocstyle{3}{section}%
 \newftocstyle{4}{subsection}%
 \newftocstyle{5}{subsubsection}%
 \newftocstyle{6}{paragraph}}
{\newftocstyle{2}{section}%
 \newftocstyle{3}{subsection}%
 \newftocstyle{4}{subsubsection}%
 \newftocstyle{5}{paragraph}}}

