%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Instruct hacha to cut everywhere from part to subsection %%
%% Some code contributed by Gilles Gregoire                 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Inactivate cutting macros %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\let\dc@cutdef\cutdef
\let\dc@cutend\cutend
%%%%%%%%%%%%%%%%%%%
%% cut footnotes  %
%%%%%%%%%%%%%%%%%%%
\let\deepcut@thefootnotes\thefootnotes
\let\enddeepcut@thefootnotes\endthefootnotes
\renewenvironment{thefootnotes}[2][]
{\begin{cutflow}{Notes}\begin{deepcut@thefootnotes}{#2}}
{\end{deepcut@thefootnotes}\end{cutflow}}
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% sectionning commands
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif\ifcutchapter\cutchapterfalse
\let\dc@part\part\let\dc@part*\part*
\renewcommand{\part}[2][]
{\ifcutsubsection\dc@cutend\fi\cutsubsectionfalse
\ifcutsection\dc@cutend\fi\cutsectionfalse
\ifcutchapter\dc@cutend\fi
\ife#1\dc@part{#2}\else\dc@part[#1]{#2}\fi
\dc@cutdef{chapter}\cutchaptertrue}
\renewcommand{\part*}[1]
{\ifcutsubsection\dc@cutend\fi\cutsubsectionfalse
\ifcutsection\dc@cutend\fi\cutsectionfalse
\ifcutchapter\dc@cutend\fi
\dc@part*{#1}%
\dc@cutdef{chapter}\cutchaptertrue}
%%%%%%%%%%%%%%%%%%
\newif\ifcutsection\cutsectionfalse
\@ifundefined{chapter}{}
{\let\dc@chapter\chapter\let\dc@chapter*\chapter*
\renewcommand{\chapter}[2][]
{\ifcutsubsection\dc@cutend\fi\cutsubsectionfalse
\ifcutsection\dc@cutend\fi
\ife#1\dc@chapter{#2}\else\dc@chapter[#1]{#2}\fi
\dc@cutdef{section}\cutsectiontrue}
\renewcommand{\chapter*}[1]
{\ifcutsubsection\dc@cutend\fi\cutsubsectionfalse
\ifcutsection\dc@cutend\fi
\dc@chapter*{#1}%
\dc@cutdef{section}\cutsectiontrue}}
%%%%%%%%%%%%%%%%%%
\newif\ifcutsubsection\cutsubsectionfalse
\let\dc@section\section
\let\dc@section*\section*
\renewcommand{\section}[2][]
{\ifcutsubsection\dc@cutend\fi
\ife#1\dc@section{#2}\else\dc@section[#1]{#2}\fi
\dc@cutdef{subsection}\cutsubsectiontrue}
\renewcommand{\section*}[1]
{\ifcutsubsection\dc@cutend\fi
\dc@section*{#1}%
\dc@cutdef{subsection}\cutsubsectiontrue}
%%%%%Check that!
\AtEndDocument
{\ifcutsubsection\dc@cutend\fi\ifcutsection\dc@cutend\fi\ifcutchapter\dc@cutend\fi}

