| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2003-2005 by Mathieu Boretti |
| 4 |
% |
| 5 |
% This file may be distributed and/or modified under the |
| 6 |
% conditions of the LaTeX Project Public License, either |
| 7 |
% version 1.3 of this license or (at your option) any later |
| 8 |
% version. The latest version of this license is in: |
| 9 |
% |
| 10 |
% http://www.latex-project.org/lppl.txt |
| 11 |
% |
| 12 |
% and version 1.3 or later is part of all distributions of |
| 13 |
% LaTeX version 2003/12/01 or later. |
| 14 |
% |
| 15 |
% The current Maintainer of this work is Mathieu Boretti |
| 16 |
% |
| 17 |
% This work consists of the file chapterfolder.ins and |
| 18 |
% chapterfolder.dtx and the derived file chapterfolder.sty |
| 19 |
% |
| 20 |
% |
| 21 |
% \fi |
| 22 |
% \iffalse |
| 23 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 24 |
%<package>\ProvidesPackage{chapterfolder}[2005/11/24 v2.0 Package for dealing with folder] |
| 25 |
%<package>\RequirePackage{ifthen} |
| 26 |
% |
| 27 |
%<*driver> |
| 28 |
\documentclass{ltxdoc} |
| 29 |
\usepackage{chapterfolder} |
| 30 |
\EnableCrossrefs |
| 31 |
\CodelineIndex |
| 32 |
\RecordChanges |
| 33 |
\begin{document} |
| 34 |
\DocInput{chapterfolder.dtx} |
| 35 |
\end{document} |
| 36 |
%</driver> |
| 37 |
% \fi |
| 38 |
% \GetFileInfo{chapterfolder.sty} |
| 39 |
% \changes{v2.0}{2005-11-24}{First version of chapterfolder that use dtx} |
| 40 |
% \title{The \textsf{chapterfolder} package\thanks{This document corresponds to \textsf{chapterfolder}~\fileversion, dated~\filedate.}} |
| 41 |
% \author{Mathieu Boretti \\ \texttt{[email protected]}} |
| 42 |
% |
| 43 |
% \maketitle |
| 44 |
% |
| 45 |
% \begin{abstract} |
| 46 |
% This file describe the \textsf{chapterfolder} package. This package is intended for \LaTeX\ users who must deal with |
| 47 |
% complex folder structure. |
| 48 |
% \end{abstract} |
| 49 |
% |
| 50 |
% \section{Usage} |
| 51 |
% The first command that you need is the |\usepackage{chapterfolder}|. This command include the \textsf{chapterfolder}. |
| 52 |
% |
| 53 |
% \DescribeMacro{\cfpart} The |\cfpart| command define a part, change the current folder and include a main file for the part. The syntaxe of this command is |\cfpart| \oarg{short name} \marg{name} \marg{folder name} \marg{file name}. |
| 54 |
% |
| 55 |
% \DescribeMacro{\cfpart*} This command does the same think as |\cfpart| except that it use a define a part*. |
| 56 |
% |
| 57 |
% \DescribeMacro{\cfchapter} The |\cfchapter| command define a chapter, change the current folder and include a main file for the chapter. The syntaxe of this command is |\cfchapter| \oarg{short name} \marg{name} \marg{folder name} \marg{file name}. |
| 58 |
% |
| 59 |
% \DescribeMacro{\cfchapter*} This command does the same think as |\cfchapter| except that it use a define a chapter*. |
| 60 |
% |
| 61 |
% \DescribeMacro{\cfsection} The |\cfsection| command define a section, change the current folder and include a main file for the section. The syntaxe of this command is |\cfsection| \oarg{short name} \marg{name} \marg{folder name} \marg{file name}. |
| 62 |
% |
| 63 |
% \DescribeMacro{\cfsection*} This command does the same think as |\cfsection| except that it use a define a section*. |
| 64 |
% |
| 65 |
% \DescribeMacro{\cfsubsection} The |\cfsubsection| command define a subsection, change the current folder and include a main file for the subsection. The syntaxe of this command is |\cfsubsection| \oarg{short name} \marg{name} \marg{folder name} \marg{file name}. |
| 66 |
% |
| 67 |
% \DescribeMacro{\cfsubsection*} This command does the same think as |\cfsubsection| except that it use a define a subsection*. |
| 68 |
% |
| 69 |
% \DescribeMacro{\cfinput} The command |\cfinput| include a file from within the current folder. |
| 70 |
% |
| 71 |
% \DescribeMacro{\cfcurrentfolder} The command |\cfcurrentfolder| provide the path to the current folder. |
| 72 |
% |
| 73 |
% \DescribeMacro{\cfinputfigure} The command |\cfinputfigure| include a file from within the folder {\tt figure} within the current folder. |
| 74 |
% |
| 75 |
% \DescribeMacro{\cfcurrentfolderfigure} The command |\cfcurrentfolderfigure| provide the path to the current figure folder. |
| 76 |
% |
| 77 |
% \DescribeMacro{\cfinputlistings} The command |\cfinputlistings| include a file from within the folder {\tt listings} within the current folder. |
| 78 |
% |
| 79 |
% \DescribeMacro{\cfcurrentfolderlistings} The command |\cfcurrentfolderlistings| provide the path to the current listings folder. |
| 80 |
% |
| 81 |
% \DescribeMacro{\cfinputalgorithms} The command |\cfinputalgorithms| include a file from within the folder {\tt algorithms} within the current folder. |
| 82 |
% |
| 83 |
% \DescribeMacro{\cfcurrentfolderalgorithms} The command |\cfcurrentfolderalgorithms| provide the path to the current algorithms folder. |
| 84 |
% |
| 85 |
% \DescribeMacro{\cffolderfigure} The command |\cffolderfigure| change the current folder and include a main file. The syntaxe of this command is |\cffolderfigure| \marg{folder name} \marg{file name}. |
| 86 |
% |
| 87 |
% \DescribeMacro{\cfaddFolder} The command |\cfaddFolder| define two command to deal with default folder. The syntaxe of this command is |\cfaddFolder| \marg{command extension} \marg{folder name}. |
| 88 |
% |
| 89 |
% \section{Compatibility commands} |
| 90 |
% The following commands are available for backward compatibility : |
| 91 |
% |
| 92 |
% \DescribeMacro{\cfpartstar} The command |\cfpartstar| is a alias of |\cfpart*|. |
| 93 |
% |
| 94 |
% \DescribeMacro{\cfchapterstar} The command |\cfchapterstar| is a alias of |\cfchapter*|. |
| 95 |
% |
| 96 |
% \DescribeMacro{\cfsectionstar} The command |\cfsectionstar| is a alias of |\cfsection*|. |
| 97 |
% |
| 98 |
% \DescribeMacro{\cfsubsectionstar} The command |\cfsubsectionstar| is a alias of |\cfsubsection*|. |
| 99 |
% |
| 100 |
% \section{Implementation} |
| 101 |
% \begin{macro}{@cf@currentpos} |
| 102 |
% This counter define the top of the stack path |
| 103 |
% \begin{macrocode} |
| 104 |
\newcounter{@cf@currentpos} |
| 105 |
\setcounter{@cf@currentpos}{0} |
| 106 |
% \end{macrocode} |
| 107 |
% \end{macro} |
| 108 |
% \begin{macro}{\stackFolder<X>} |
| 109 |
% These macro contains, when needed the path for the stack |
| 110 |
% \begin{macrocode} |
| 111 |
\expandafter\def\csname stackFolder0\endcsname{} |
| 112 |
\expandafter\def\csname stackFolder1\endcsname{} |
| 113 |
\expandafter\def\csname stackFolder2\endcsname{} |
| 114 |
\expandafter\def\csname stackFolder3\endcsname{} |
| 115 |
\expandafter\def\csname stackFolder4\endcsname{} |
| 116 |
\expandafter\def\csname stackFolder5\endcsname{} |
| 117 |
\expandafter\def\csname stackFolder6\endcsname{} |
| 118 |
\expandafter\def\csname stackFolder7\endcsname{} |
| 119 |
\expandafter\def\csname stackFolder8\endcsname{} |
| 120 |
\expandafter\def\csname stackFolder9\endcsname{} |
| 121 |
% \end{macrocode} |
| 122 |
% \end{macro} |
| 123 |
% \begin{macro}{\@cfpush} |
| 124 |
% This macro push a path onto the stack path |
| 125 |
% \begin{macrocode} |
| 126 |
\def\@cfpush#1{% |
| 127 |
\expandafter% |
| 128 |
\def\csname stackFolder\arabic{@cf@currentpos}\endcsname{#1/}% |
| 129 |
\addtocounter{@cf@currentpos}{1}% |
| 130 |
} |
| 131 |
% \end{macrocode} |
| 132 |
% \end{macro} |
| 133 |
% \begin{macro}{\@cfpop} |
| 134 |
% This macro pop a path from the stack path |
| 135 |
% \begin{macrocode} |
| 136 |
\def\@cfpop{% |
| 137 |
\addtocounter{@cf@currentpos}{-1} |
| 138 |
\expandafter% |
| 139 |
\def\csname stackFolder\arabic{@cf@currentpos}\endcsname{}% |
| 140 |
} |
| 141 |
% \end{macrocode} |
| 142 |
% \end{macro} |
| 143 |
% \begin{macro}{\cfcurrentfolder} |
| 144 |
% This marco define the current path |
| 145 |
% \begin{macrocode} |
| 146 |
\newcommand{\cfcurrentfolder}{% |
| 147 |
\csname stackFolder0\endcsname% |
| 148 |
\csname stackFolder1\endcsname% |
| 149 |
\csname stackFolder2\endcsname% |
| 150 |
\csname stackFolder3\endcsname% |
| 151 |
\csname stackFolder4\endcsname% |
| 152 |
\csname stackFolder5\endcsname% |
| 153 |
\csname stackFolder6\endcsname% |
| 154 |
\csname stackFolder7\endcsname% |
| 155 |
\csname stackFolder8\endcsname% |
| 156 |
\csname stackFolder9\endcsname% |
| 157 |
} |
| 158 |
% \end{macrocode} |
| 159 |
% \end{macro} |
| 160 |
% \begin{macro}{\cfinput} |
| 161 |
% This macro define how to input a file from the current folder |
| 162 |
% \begin{macrocode} |
| 163 |
\newcommand{\cfinput}[1]{\input{\cfcurrentfolder#1}} |
| 164 |
% \end{macrocode} |
| 165 |
% \end{macro} |
| 166 |
% \begin{macro}{\cffolderinput} |
| 167 |
% This macro go into a folder and input a file |
| 168 |
% \begin{macrocode} |
| 169 |
\newcommand{\cffolderinput}[2]{% |
| 170 |
\@cfpush{#1}% |
| 171 |
\cfinput{#2}% |
| 172 |
\@cfpop% |
| 173 |
} |
| 174 |
% \end{macrocode} |
| 175 |
% \end{macro} |
| 176 |
% \begin{macro}{\cfaddFolder} |
| 177 |
% This macro define a new default folder for some kind of data |
| 178 |
% \begin{macrocode} |
| 179 |
\newcommand{\cfaddFolder}[2]{% |
| 180 |
\expandafter\def\csname cfcurrentfolder#1\endcsname{% |
| 181 |
\cfcurrentfolder/#2/% |
| 182 |
}% |
| 183 |
\expandafter\def\csname cfinput#1\endcsname##1{% |
| 184 |
\input{\csname cfcurrentfolder#1\endcsname##1}% |
| 185 |
}% |
| 186 |
} |
| 187 |
% \end{macrocode} |
| 188 |
% \end{macro} |
| 189 |
% \begin{macro}{\@chapterfolderfigure} |
| 190 |
% This macro define the default name of the folder for the figures |
| 191 |
% \begin{macrocode} |
| 192 |
\newcommand{\@chapterfolderfigure}{figure} |
| 193 |
% \end{macrocode} |
| 194 |
% and then define three macros that access this folder |
| 195 |
% \begin{macrocode} |
| 196 |
\cfaddFolder{figure}{\@chapterfolderfigure} |
| 197 |
\newcommand{\cfincludegraphics}[2][]{% |
| 198 |
\includegraphics[#1]{\cfcurrentfolderfigure/#2}% |
| 199 |
} |
| 200 |
% \end{macrocode} |
| 201 |
% \end{macro} |
| 202 |
% \begin{macro}{\@chapterfolderlistings} |
| 203 |
% This macro define the default name of the folder for the listings |
| 204 |
% \begin{macrocode} |
| 205 |
\newcommand{\@chapterfolderlistings}{listings} |
| 206 |
% \end{macrocode} |
| 207 |
% and then define two macros that access this folder |
| 208 |
% \begin{macrocode} |
| 209 |
\cfaddFolder{listings}{\@chapterfolderlistings} |
| 210 |
% \end{macrocode} |
| 211 |
% \end{macro} |
| 212 |
% \begin{macro}{\@chapterfolderalgorithms} |
| 213 |
% This macro define the default name of the folder for the algorithms |
| 214 |
% \begin{macrocode} |
| 215 |
\newcommand{\@chapterfolderalgorithms}{algorithms} |
| 216 |
% \end{macrocode} |
| 217 |
% and then define two macros that access this folder |
| 218 |
% \begin{macrocode} |
| 219 |
\cfaddFolder{algorithms}{\@chapterfolderalgorithms} |
| 220 |
% \end{macrocode} |
| 221 |
% \end{macro} |
| 222 |
% \begin{macro}{\cfpart} |
| 223 |
% This macro is the main macro to include a part from within a folder |
| 224 |
% \begin{macrocode} |
| 225 |
\newcommand{\cfpart}{\@ifstar |
| 226 |
\cfpartstar% |
| 227 |
\cfpartstd% |
| 228 |
} |
| 229 |
% \end{macrocode} |
| 230 |
% \end{macro} |
| 231 |
% \begin{macro}{\cfchapter} |
| 232 |
% This macro is the main macro to include a chapter from within a folder |
| 233 |
% \begin{macrocode} |
| 234 |
\newcommand{\cfchapter}{\@ifstar |
| 235 |
\cfchapterstar% |
| 236 |
\cfchapterstd% |
| 237 |
} |
| 238 |
% \end{macrocode} |
| 239 |
% \end{macro} |
| 240 |
% \begin{macro}{\cfsection} |
| 241 |
% This macro is the main macro to include a section from within a folder |
| 242 |
% \begin{macrocode} |
| 243 |
\newcommand{\cfsection}{\@ifstar |
| 244 |
\cfsectionstar% |
| 245 |
\cfsectionstd% |
| 246 |
} |
| 247 |
% \end{macrocode} |
| 248 |
% \end{macro} |
| 249 |
% \begin{macro}{\cfsubsection} |
| 250 |
% This macro is the main macro to include a subsection from within a folder |
| 251 |
% \begin{macrocode} |
| 252 |
\newcommand{\cfsubsection}{\@ifstar |
| 253 |
\cfsubsectionstar% |
| 254 |
\cfsubsectionstd% |
| 255 |
} |
| 256 |
% \end{macrocode} |
| 257 |
% \end{macro} |
| 258 |
% \begin{macro}{\cfpartstd} |
| 259 |
% This macro go in a folder, create a part, include the default file and go out of the folder |
| 260 |
% \begin{macrocode} |
| 261 |
\newcommand{\cfpartstd}[4][]{% |
| 262 |
\ifthenelse{\equal{#1}{}}{\part{#2}}{\part[#1]{#2}}% |
| 263 |
\cffolderinput{#3}{#4}% |
| 264 |
} |
| 265 |
% \end{macrocode} |
| 266 |
% \end{macro} |
| 267 |
% \begin{macro}{\cfpartstar} |
| 268 |
% This macro go in a folder, create a part*, include the default file and go out of the folder |
| 269 |
% \begin{macrocode} |
| 270 |
\newcommand{\cfpartstar}[4][]{% |
| 271 |
\ifthenelse{\equal{#1}{}}{\part*{#2}}{\part[#1]{#2}}% |
| 272 |
\cffolderinput{#3}{#4}% |
| 273 |
} |
| 274 |
% \end{macrocode} |
| 275 |
% \end{macro} |
| 276 |
% \begin{macro}{\cfchapterstd} |
| 277 |
% This macro go in a folder, create a chapter, include the default file and go out of the folder |
| 278 |
% \begin{macrocode} |
| 279 |
\newcommand{\cfchapterstd}[4][]{% |
| 280 |
\ifthenelse{\equal{#1}{}}{\chapter{#2}}{\chapter[#1]{#2}}% |
| 281 |
\cffolderinput{#3}{#4}% |
| 282 |
} |
| 283 |
% \end{macrocode} |
| 284 |
% \end{macro} |
| 285 |
% \begin{macro}{\cfchapterstar} |
| 286 |
% This macro go in a folder, create a chapter*, include the default file and go out of the folder |
| 287 |
% \begin{macrocode} |
| 288 |
\newcommand{\cfchapterstar}[4][]{% |
| 289 |
\ifthenelse{\equal{#1}{}}{\chapter*{#2}}{\chapter*[#1]{#2}}% |
| 290 |
\cffolderinput{#3}{#4}% |
| 291 |
} |
| 292 |
% \end{macrocode} |
| 293 |
% \end{macro} |
| 294 |
% \begin{macro}{\cfsectionstd} |
| 295 |
% This macro go in a folder, create a section, include the default file and go out of the folder |
| 296 |
% \begin{macrocode} |
| 297 |
\newcommand{\cfsectionstd}[4][]{% |
| 298 |
\ifthenelse{\equal{#1}{}}{\section{#2}}{\section[#1]{#2}}% |
| 299 |
\cffolderinput{#3}{#4}% |
| 300 |
} |
| 301 |
% \end{macrocode} |
| 302 |
% \end{macro} |
| 303 |
% \begin{macro}{\cfsectionstart} |
| 304 |
% This macro go in a folder, create a section*, include the default file and go out of the folder |
| 305 |
% \begin{macrocode} |
| 306 |
\newcommand{\cfsectionstar}[4][]{% |
| 307 |
\ifthenelse{\equal{#1}{}}{\section*{#2}}{\section*[#1]{#2}}% |
| 308 |
\cffolderinput{#3}{#4}% |
| 309 |
} |
| 310 |
% \end{macrocode} |
| 311 |
% \end{macro} |
| 312 |
% \begin{macro}{\cfsubsectionstd} |
| 313 |
% This macro go in a folder, create a subsection, include the default file and go out of the folder |
| 314 |
% \begin{macrocode} |
| 315 |
\newcommand{\cfsubsectionstd}[4][]{% |
| 316 |
\ifthenelse{\equal{#1}{}}{\subsection{#2}}{\subsection[#1]{#2}}% |
| 317 |
% |
| 318 |
} |
| 319 |
% \end{macrocode} |
| 320 |
% \end{macro} |
| 321 |
% \begin{macro}{\cfsubsectionstar} |
| 322 |
% This macro go in a folder, create a subsection*, include the default file and go out of the folder |
| 323 |
% \begin{macrocode} |
| 324 |
\newcommand{\cfsubsectionstart}[4][]{% |
| 325 |
\ifthenelse{\equal{#1}{}}{\subsection*{#2}}{\subsection*[#1]{#2}}% |
| 326 |
\cffolderinput{#3}{#4}% |
| 327 |
} |
| 328 |
% \end{macrocode} |
| 329 |
% \end{macro} |
| 330 |
% |
| 331 |
% \Finale |
| 332 |
\endinput |