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