%%
%% This is file `chapterfolder.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% chapterfolder.dtx  (with options: `package')
%% This is a generated file.
%% 
%% Copyright (C) 2003-2005 by Mathieu Boretti
%% 
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 of this license or (at your option) any later
%% version. The latest version of this license is in:
%% 
%% http://www.latex-project.org/lppl.txt
%% 
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2003/12/01 or later.
%% 
%% The current Maintainer of this work is Mathieu Boretti
%% 
%% This work consists of the file chapterfolder.ins and
%% chapterfolder.dtx and the derived file chapterfolder.sty
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{chapterfolder}[2005/11/24 v2.0 Package for dealing with folder]
\RequirePackage{ifthen}
\newcounter{@cf@currentpos}
\setcounter{@cf@currentpos}{0}
\expandafter\def\csname stackFolder0\endcsname{}
\expandafter\def\csname stackFolder1\endcsname{}
\expandafter\def\csname stackFolder2\endcsname{}
\expandafter\def\csname stackFolder3\endcsname{}
\expandafter\def\csname stackFolder4\endcsname{}
\expandafter\def\csname stackFolder5\endcsname{}
\expandafter\def\csname stackFolder6\endcsname{}
\expandafter\def\csname stackFolder7\endcsname{}
\expandafter\def\csname stackFolder8\endcsname{}
\expandafter\def\csname stackFolder9\endcsname{}
\def\@cfpush#1{%
    \expandafter%
    \def\csname stackFolder\arabic{@cf@currentpos}\endcsname{#1/}%
    \addtocounter{@cf@currentpos}{1}%
}
\def\@cfpop{%
    \addtocounter{@cf@currentpos}{-1}
    \expandafter%
    \def\csname stackFolder\arabic{@cf@currentpos}\endcsname{}%
}
\newcommand{\cfcurrentfolder}{%
\csname stackFolder0\endcsname%
\csname stackFolder1\endcsname%
\csname stackFolder2\endcsname%
\csname stackFolder3\endcsname%
\csname stackFolder4\endcsname%
\csname stackFolder5\endcsname%
\csname stackFolder6\endcsname%
\csname stackFolder7\endcsname%
\csname stackFolder8\endcsname%
\csname stackFolder9\endcsname%
}
\newcommand{\cfinput}[1]{\input{\cfcurrentfolder#1}}
\newcommand{\cffolderinput}[2]{%
    \@cfpush{#1}%
    \cfinput{#2}%
    \@cfpop%
}
\newcommand{\cfaddFolder}[2]{%
    \expandafter\def\csname cfcurrentfolder#1\endcsname{%
        \cfcurrentfolder/#2/%
    }%
    \expandafter\def\csname cfinput#1\endcsname##1{%
        \input{\csname cfcurrentfolder#1\endcsname##1}%
    }%
}
\newcommand{\@chapterfolderfigure}{figure}
\cfaddFolder{figure}{\@chapterfolderfigure}
\newcommand{\cfincludegraphics}[2][]{%
    \includegraphics[#1]{\cfcurrentfolderfigure/#2}%
}
\newcommand{\@chapterfolderlistings}{listings}
\cfaddFolder{listings}{\@chapterfolderlistings}
\newcommand{\@chapterfolderalgorithms}{algorithms}
\cfaddFolder{algorithms}{\@chapterfolderalgorithms}
\newcommand{\cfpart}{\@ifstar
  \cfpartstar%
  \cfpartstd%
}
\newcommand{\cfchapter}{\@ifstar
  \cfchapterstar%
  \cfchapterstd%
}
\newcommand{\cfsection}{\@ifstar
  \cfsectionstar%
  \cfsectionstd%
}
\newcommand{\cfsubsection}{\@ifstar
  \cfsubsectionstar%
  \cfsubsectionstd%
}
\newcommand{\cfpartstd}[4][]{%
\ifthenelse{\equal{#1}{}}{\part{#2}}{\part[#1]{#2}}%
\cffolderinput{#3}{#4}%
}
\newcommand{\cfpartstar}[4][]{%
\ifthenelse{\equal{#1}{}}{\part*{#2}}{\part[#1]{#2}}%
\cffolderinput{#3}{#4}%
}
\newcommand{\cfchapterstd}[4][]{%
\ifthenelse{\equal{#1}{}}{\chapter{#2}}{\chapter[#1]{#2}}%
\cffolderinput{#3}{#4}%
}
\newcommand{\cfchapterstar}[4][]{%
\ifthenelse{\equal{#1}{}}{\chapter*{#2}}{\chapter*[#1]{#2}}%
\cffolderinput{#3}{#4}%
}
\newcommand{\cfsectionstd}[4][]{%
\ifthenelse{\equal{#1}{}}{\section{#2}}{\section[#1]{#2}}%
\cffolderinput{#3}{#4}%
}
\newcommand{\cfsectionstar}[4][]{%
\ifthenelse{\equal{#1}{}}{\section*{#2}}{\section*[#1]{#2}}%
\cffolderinput{#3}{#4}%
}
\newcommand{\cfsubsectionstd}[4][]{%
\ifthenelse{\equal{#1}{}}{\subsection{#2}}{\subsection[#1]{#2}}%
}
\newcommand{\cfsubsectionstart}[4][]{%
\ifthenelse{\equal{#1}{}}{\subsection*{#2}}{\subsection*[#1]{#2}}%
\cffolderinput{#3}{#4}%
}
\endinput
%%
%% End of file `chapterfolder.sty'.
