| 1 |
% \iffalse |
| 2 |
%% |
| 3 |
%% Package `dirtree.dtx' |
| 4 |
%% ----------------------------------------------- |
| 5 |
%% Copyright (C) 2004-2009 Jean-C\^ome Charpentier |
| 6 |
%% ----------------------------------------------- |
| 7 |
%% |
| 8 |
%% This work may be distributed and/or modified under the |
| 9 |
%% conditions of the LaTeX Project Public License, either version 1.3 |
| 10 |
%% of this license or (at your option) any later version. |
| 11 |
%% The latest version of this license is in |
| 12 |
%% http://www.latex-project.org/lppl.txt |
| 13 |
%% and version 1.3 or later is part of all distributions of LaTeX |
| 14 |
%% version 2003/12/01 or later. |
| 15 |
%% |
| 16 |
%% See CTAN archives in directory macros/latex/base/lppl.txt. |
| 17 |
%% |
| 18 |
%% CONTENTS: |
| 19 |
%% This work consists of the files dirtree.ins and dirtree.dtx. |
| 20 |
%% Derived files are dirtree.tex and dirtree.sty. |
| 21 |
%% |
| 22 |
%% DESCRIPTION: |
| 23 |
%% dirtree is a package displaying directory trees. |
| 24 |
%% |
| 25 |
% \fi |
| 26 |
% \iffalse |
| 27 |
%<latex-wrapper|tex> \def\fileversion{0.32} |
| 28 |
%<latex-wrapper|tex> \def\filedate{2012/12/11} |
| 29 |
%<*driver> |
| 30 |
\documentclass{ltxdoc} |
| 31 |
\GetFileInfo{dirtree.dtx} |
| 32 |
\usepackage[T1]{fontenc} |
| 33 |
\usepackage[latin1]{inputenc} |
| 34 |
\usepackage{lmodern} |
| 35 |
\usepackage[english]{babel} |
| 36 |
\usepackage{hypdoc} |
| 37 |
\usepackage{xcolor} |
| 38 |
\usepackage{pstricks} |
| 39 |
\usepackage{dirtree} |
| 40 |
\newcommand*\package[1]{\textsf{#1}} |
| 41 |
\newcommand*\file[1]{\texttt{#1}} |
| 42 |
\AtBeginDocument{% |
| 43 |
\OnlyDescription % comment out for implementation details |
| 44 |
\EnableCrossrefs |
| 45 |
\RecordChanges |
| 46 |
\CodelineIndex} |
| 47 |
\AtEndDocument{% |
| 48 |
\PrintChanges |
| 49 |
\PrintIndex} |
| 50 |
\hbadness=7000 % Over and under full box warnings |
| 51 |
\hfuzz=3pt |
| 52 |
\begin{document} |
| 53 |
\DocInput{dirtree.dtx} |
| 54 |
\end{document} |
| 55 |
%</driver> |
| 56 |
% \fi |
| 57 |
% \changes{v0.01}{2004/08/10}{First realease to answer a question on |
| 58 |
% fctt.} |
| 59 |
% \changes{v0.11}{2005/12/19}{fix bug} |
| 60 |
% \changes{v0.12}{2005/12/20}{\cs{DTbaselineskip}. local \cs{parskip}, |
| 61 |
% \cs{baselineskip}, and \cs{strut} in order to fix a displaying bug.} |
| 62 |
% \changes{v0.2}{2006/01/25}{dtx for CTAN, code for both Plain \TeX{} |
| 63 |
% and \LaTeX.} |
| 64 |
% \changes{v0.3}{2009/04/08}{xkeyval syntax, breakable tree} |
| 65 |
% \changes{v0.31}{2012/11/02}{bug about some lengths} |
| 66 |
% \changes{v0.32}{2012/12/11}{bug about length (thanks to Philipp |
| 67 |
% K\"uhl). Some macro names changed in order to prevent clash with |
| 68 |
% other packages.} |
| 69 |
% |
| 70 |
% \DoNotIndex{\@,\@gobble,\@latex@error,\@nameuse} |
| 71 |
% \DoNotIndex{\@ne,\@nil,\@namedef} |
| 72 |
% \DoNotIndex{\advance} |
| 73 |
% \DoNotIndex{\baselineskip,\box} |
| 74 |
% \DoNotIndex{\catcode,\count@,\csname} |
| 75 |
% \DoNotIndex{\def,\dimen,\dotfill,\dp} |
| 76 |
% \DoNotIndex{\edef,\else,\endcsname,\endgraf,\expandafter} |
| 77 |
% \DoNotIndex{\fi,\filedate,\fileversion} |
| 78 |
% \DoNotIndex{\hbox,\hrule,\hsize,\ht} |
| 79 |
% \DoNotIndex{\ifnum,\ifx,\input,\iterate} |
| 80 |
% \DoNotIndex{\kern} |
| 81 |
% \DoNotIndex{\leavevmode,\let,\long,\loop} |
| 82 |
% \DoNotIndex{\m@ne,\message} |
| 83 |
% \DoNotIndex{\NeedsTeXFormat,\newcount,\newcommand,\newdimen,\next,\noindent} |
| 84 |
% \DoNotIndex{\par,\parindent,\parskip,\ProvidesFile,\ProvidesPackage} |
| 85 |
% \DoNotIndex{\relax,\repeat,\rm,\rmfamily} |
| 86 |
% \DoNotIndex{\setbox,\space,\strut} |
| 87 |
% \DoNotIndex{\the,\tt,\ttfamily} |
| 88 |
% \DoNotIndex{\vbox,\vrule,\vss} |
| 89 |
% \DoNotIndex{\z@} |
| 90 |
% \setcounter{IndexColumns}{2} |
| 91 |
% |
| 92 |
% \CheckSum{0} |
| 93 |
% \CharacterTable |
| 94 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 95 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 96 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 97 |
% Exclamation \! Double quote \" Hash (number) \# |
| 98 |
% Dollar \$ Percent \% Ampersand \& |
| 99 |
% Acute accent \' Left paren \( Right paren \) |
| 100 |
% Asterisk \* Plus \+ Comma \, |
| 101 |
% Minus \- Point \. Solidus \/ |
| 102 |
% Colon \: Semicolon \; Less than \< |
| 103 |
% Equals \= Greater than \> Question mark \? |
| 104 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 105 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 106 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 107 |
% Right brace \} Tilde \~} |
| 108 |
% |
| 109 |
% ................. Beginning of the documentation part ................. |
| 110 |
% |
| 111 |
% \title{The \package{dirtree} package\\Directory Tree} |
| 112 |
% \author{Jean-C\^ome |
| 113 |
% Charpentier\thanks{\texttt{[email protected]}}} |
| 114 |
% \date{Version \fileversion\ \filedate\ \\ |
| 115 |
% {\small Documentation revised \today}} |
| 116 |
% |
| 117 |
% \maketitle |
| 118 |
% |
| 119 |
% \begin{abstract} |
| 120 |
% Package \package{dirtree} allows to display directory tree, like |
| 121 |
% in the windows explorator. |
| 122 |
% \end{abstract} |
| 123 |
% |
| 124 |
% \tableofcontents |
| 125 |
% \section{Introduction} |
| 126 |
% During a discussion on fctt (\texttt{fr.comp.text.tex}) about |
| 127 |
% directory tree and how display such a structure, it appeared that |
| 128 |
% there wasn't many packages which do the job. |
| 129 |
% |
| 130 |
% One obvious solution is to use \package{PSTricks} but some people |
| 131 |
% don't like or don't know this package, so I made the first release |
| 132 |
% of \package{dirtree}. |
| 133 |
% |
| 134 |
% In fact, I didn't plan to send it in CTAN but Robin Fairbairns and |
| 135 |
% Danie was very convincing! |
| 136 |
% |
| 137 |
% \section{Usage} |
| 138 |
% Package \package{dirtree} works both on Plain \TeX{} and \LaTeX{}. |
| 139 |
% No surprise to call it: |
| 140 |
% \begin{verbatim} |
| 141 |
% \usepackage{dirtree} |
| 142 |
% \end{verbatim} |
| 143 |
% for \LaTeX{} and |
| 144 |
% \begin{verbatim} |
| 145 |
% \input dirtree |
| 146 |
% \end{verbatim} |
| 147 |
% for Plain \TeX{}. |
| 148 |
% |
| 149 |
% Since version~0.3, \package{dirtree} has some |
| 150 |
% package options. We'll see these options one by one. |
| 151 |
% |
| 152 |
% \begin{DescribeMacro}{\dirtree} |
| 153 |
% The main macro is |\dirtree| which take one argument (the tree |
| 154 |
% structure). This tree structure is a sequence of |
| 155 |
% \begin{verbatim} |
| 156 |
% .<level><space><text node>.<space> |
| 157 |
% \end{verbatim} |
| 158 |
% Note that there is a dot in the beginning and another one at the end |
| 159 |
% of each node specification. The spaces are very important: if you |
| 160 |
% forgot the space before the |level| there will be an error and if |
| 161 |
% you forgot the space after the last dot, you don't indicate the end |
| 162 |
% of the node. Since an end of line is like a space for \TeX{}, I |
| 163 |
% recommand to write a node per line in the source file: it's handy |
| 164 |
% and more readeable. |
| 165 |
% |
| 166 |
% The |level| indicates the node depth in the tree. There is two |
| 167 |
% rules you must respect: |
| 168 |
% \begin{enumerate} |
| 169 |
% \item The root must have the level one. |
| 170 |
% \item When you create a node, if the last node have the level $n$, |
| 171 |
% the created node must have a level between 2 and $n+1$. |
| 172 |
% \end{enumerate} |
| 173 |
% In fact, you can indicates a level greater than $n+1$ if one node |
| 174 |
% have a level $n$ somewhere in the tree but the result will be |
| 175 |
% strange! |
| 176 |
% |
| 177 |
% A node of level $n$ will be connected to the last node defined which |
| 178 |
% has a level lesser or equal to $n$. |
| 179 |
% |
| 180 |
% For example, the code |
| 181 |
% \begin{verbatim} |
| 182 |
% \dirtree{% |
| 183 |
% .1 /. |
| 184 |
% .2 bin. |
| 185 |
% .2 home. |
| 186 |
% .3 jeancome. |
| 187 |
% .4 texmf. |
| 188 |
% .5 tex. |
| 189 |
% .6 latex. |
| 190 |
% .7 dirtree. |
| 191 |
% .3 jeancomeson. |
| 192 |
% .3 jeancomedaughter. |
| 193 |
% .2 usr. |
| 194 |
% .3 bin. |
| 195 |
% .3 games. |
| 196 |
% .4 fortunes. |
| 197 |
% .3 include. |
| 198 |
% .3 local. |
| 199 |
% .4 bin. |
| 200 |
% .4 share. |
| 201 |
% .5 texmf. |
| 202 |
% .6 fonts. |
| 203 |
% .6 metapost. |
| 204 |
% .6 tex. |
| 205 |
% .3 share. |
| 206 |
% } |
| 207 |
% \end{verbatim} |
| 208 |
% give the result |
| 209 |
% \dirtree{%^^A |
| 210 |
% .1 /. |
| 211 |
% .2 bin. |
| 212 |
% .2 home. |
| 213 |
% .3 jeancome. |
| 214 |
% .4 texmf. |
| 215 |
% .5 tex. |
| 216 |
% .6 latex. |
| 217 |
% .7 dirtree. |
| 218 |
% .3 jeancomeson. |
| 219 |
% .3 jeancomedaughter. |
| 220 |
% .2 usr. |
| 221 |
% .3 bin. |
| 222 |
% .3 games. |
| 223 |
% .4 fortunes. |
| 224 |
% .3 include. |
| 225 |
% .3 local. |
| 226 |
% .4 bin. |
| 227 |
% .4 share. |
| 228 |
% .5 texmf. |
| 229 |
% .6 fonts. |
| 230 |
% .6 metapost. |
| 231 |
% .6 tex. |
| 232 |
% .3 share. |
| 233 |
% } |
| 234 |
% |
| 235 |
% Note the |%| after the left brace in the beginning: it's important |
| 236 |
% because the first character encountered must be a dot. |
| 237 |
% |
| 238 |
% \begin{DescribeMacro}{\DTstyle} |
| 239 |
% A text node is typeset with the command |\DTstyle|. Its default |
| 240 |
% value is |\ttfamily| when you are under \LaTeX{} and |\tt| when you |
| 241 |
% are under Plain \TeX{}. You can redefine this macro as you want, |
| 242 |
% it is used with the syntax |{\DTstyle{text node}}|, so you can use |
| 243 |
% both |\ttfamily| and |\texttt| for example. |
| 244 |
% \end{DescribeMacro} |
| 245 |
% |
| 246 |
% \begin{DescribeMacro}{\DTcomment} |
| 247 |
% The |\DTcomment| command allows to put text at the right side, with |
| 248 |
% leaders. The syntax is |
| 249 |
% \begin{verbatim} |
| 250 |
% \DTcomment{comment text} |
| 251 |
% \end{verbatim} |
| 252 |
% \begin{DescribeMacro}{\DTstylecomment} |
| 253 |
% The style of comment is defined by |\DTstylecomment|. Its default |
| 254 |
% value is |\rmfamilly| under \LaTeX{} and |\rm| under Plain \TeX{}, |
| 255 |
% and it acts like |\DTstyle|. |
| 256 |
% Here is an example: the code |
| 257 |
% \begin{verbatim} |
| 258 |
% \renewcommand*\DTstylecomment{\rmfamily\color{green}\textsc} |
| 259 |
% \renewcommand*\DTstyle{\ttfamily\textcolor{red}} |
| 260 |
% \dirtree{% |
| 261 |
% .1 /. |
| 262 |
% .2 bin. |
| 263 |
% .2 home. |
| 264 |
% .3 jeancome. |
| 265 |
% .4 texmf. |
| 266 |
% .5 tex. |
| 267 |
% .3 jeancomeson\DTcomment{Guillaume}. |
| 268 |
% .3 jeancomedaughter\DTcomment{Mathilde}. |
| 269 |
% .2 usr. |
| 270 |
% .3 bin. |
| 271 |
% } |
| 272 |
% \end{verbatim} |
| 273 |
% give the result |
| 274 |
% \begingroup |
| 275 |
% \renewcommand*\DTstylecomment{\rmfamily\color{green}\textsc} |
| 276 |
% \renewcommand*\DTstyle{\ttfamily\textcolor{red}} |
| 277 |
% \dirtree{%^^A |
| 278 |
% .1 /. |
| 279 |
% .2 bin. |
| 280 |
% .2 home. |
| 281 |
% .3 jeancome. |
| 282 |
% .4 texmf. |
| 283 |
% .5 tex. |
| 284 |
% .3 jeancomeson\DTcomment{Guillaume}. |
| 285 |
% .3 jeancomedaughter\DTcomment{Mathilde}. |
| 286 |
% .2 usr. |
| 287 |
% .3 bin. |
| 288 |
% } |
| 289 |
% \endgroup |
| 290 |
% In this example we have used the \package{xcolor} package. |
| 291 |
% \end{DescribeMacro} |
| 292 |
% \end{DescribeMacro} |
| 293 |
% |
| 294 |
% You can build complex text node. For example, the code |
| 295 |
% \begin{verbatim} |
| 296 |
% \dirtree{% |
| 297 |
% .1 /. |
| 298 |
% .2 bin \ldots{} \begin{minipage}[t]{5cm} |
| 299 |
% This directory holds executable files (binary |
| 300 |
% files or link on binary files){.} |
| 301 |
% \end{minipage}. |
| 302 |
% .2 home \ldots{} \begin{minipage}[t]{5cm} |
| 303 |
% jeancome\\ |
| 304 |
% guillaume\\ |
| 305 |
% mathilde\\ |
| 306 |
% \end{minipage}. |
| 307 |
% .4 texmf. |
| 308 |
% } |
| 309 |
% \end{verbatim} |
| 310 |
% give the result |
| 311 |
% \dirtree{%^^A |
| 312 |
% .1 /. |
| 313 |
% .2 bin \ldots{} \begin{minipage}[t]{5cm} |
| 314 |
% This directory holds executable files (binary |
| 315 |
% files or link on binary files){.} |
| 316 |
% \end{minipage}. |
| 317 |
% .2 home \ldots{} \begin{minipage}[t]{5cm} |
| 318 |
% jeancome\\ |
| 319 |
% guillaume\\ |
| 320 |
% mathilde\\ |
| 321 |
% \end{minipage}. |
| 322 |
% .4 texmf. |
| 323 |
% } |
| 324 |
% We don't encourage to try too complicated code. Package |
| 325 |
% \package{dirtree} is still fragile! Note that we pay attention to |
| 326 |
% use optional parameter |[t]| in order to have a right vertical |
| 327 |
% alignment with horizontal rules. |
| 328 |
% |
| 329 |
% \begin{DescribeMacro}{\DTsetlength} |
| 330 |
% Some dimensions can be changed using the |\DTsetlength| command. The |
| 331 |
% syntax is: |
| 332 |
% \begin{verbatim} |
| 333 |
% \DTsetlength{offset}{width}{sep}{rule-width}{dot-size} |
| 334 |
% \end{verbatim} |
| 335 |
% \begin{center} |
| 336 |
% \begin{pspicture}(0,0)(8,4) |
| 337 |
% \psset{linewidth=3pt} |
| 338 |
% \psline(1,0)(1,4) |
| 339 |
% \psline(1,2)(2.5,2) |
| 340 |
% \psline(3.5,0)(3.5,1.75) |
| 341 |
% \psset{linewidth=0.4pt} |
| 342 |
% \rput[bl](3,2){\framebox{\LARGE Text node}} |
| 343 |
% \psframe*(0.75,1.75)(1.25,2.25) |
| 344 |
% \psset{linewidth=0.2pt} |
| 345 |
% \psline{<->}(0.5,1.75)(0.5,2.25) |
| 346 |
% \uput[l](0.5,2){\scriptsize \ttfamily dot-size} |
| 347 |
% \psline{<->}(1,2.5)(2.5,2.5) |
| 348 |
% \uput[u](1.75,2.5){\scriptsize \ttfamily width} |
| 349 |
% \psline{<->}(2.5,2)(3,2) |
| 350 |
% \uput[u](2.75,2){\scriptsize \ttfamily sep} |
| 351 |
% \psline{<->}(3,1.5)(3.5,1.5) |
| 352 |
% \uput[d](3,1.5){\scriptsize \ttfamily offset} |
| 353 |
% \end{pspicture} |
| 354 |
% \end{center} |
| 355 |
% The default value are: |
| 356 |
% \begin{itemize} |
| 357 |
% \item \texttt{offset = 0.2em} |
| 358 |
% \item \texttt{width = 1em} |
| 359 |
% \item \texttt{sep = 0.2em} |
| 360 |
% \item \texttt{rule-width = 0.4pt} |
| 361 |
% \item \texttt{dot-size = 1.6pt} |
| 362 |
% \end{itemize} |
| 363 |
% |
| 364 |
% \begin{DescribeMacro}{\DTbaselineskip} |
| 365 |
% The last length parameter is |\DTbaselineskip| which indicates the |
| 366 |
% skip between lines of the tree. |
| 367 |
% \end{DescribeMacro} |
| 368 |
% |
| 369 |
% If we typeset the first example with |
| 370 |
% \begin{verbatim} |
| 371 |
% \setlength{\DTbaselineskip}{20pt} |
| 372 |
% \DTsetlength{1em}{3em}{0.1em}{1pt}{4pt} |
| 373 |
% \end{verbatim} |
| 374 |
% we obtain the (strange) result: |
| 375 |
% \begingroup |
| 376 |
% \setlength{\DTbaselineskip}{20pt} |
| 377 |
% \DTsetlength{1em}{3em}{0.1em}{1pt}{4pt} |
| 378 |
% \dirtree{%^^A |
| 379 |
% .1 /. |
| 380 |
% .2 bin. |
| 381 |
% .2 home. |
| 382 |
% .3 jeancome. |
| 383 |
% .4 texmf. |
| 384 |
% .5 tex. |
| 385 |
% .6 latex. |
| 386 |
% .7 dirtree. |
| 387 |
% .3 jeancomeson. |
| 388 |
% .3 jeancomedaughter. |
| 389 |
% .2 usr. |
| 390 |
% .3 bin. |
| 391 |
% .3 games. |
| 392 |
% .4 fortunes. |
| 393 |
% .3 include. |
| 394 |
% .3 local. |
| 395 |
% .4 bin. |
| 396 |
% .4 share. |
| 397 |
% .5 texmf. |
| 398 |
% .6 fonts. |
| 399 |
% .6 metapost. |
| 400 |
% .6 tex. |
| 401 |
% .3 share. |
| 402 |
% } |
| 403 |
% \endgroup |
| 404 |
% \end{DescribeMacro} %^^A of \DTsetlength |
| 405 |
% \end{DescribeMacro} %^^A of \dirtree |
| 406 |
% |
| 407 |
% Note that \package{dirtree} package is not able to split tree on |
| 408 |
% several pages. If this case occurs, the result will be very strange |
| 409 |
% with overfull rules. I suppose that the best is to place such trees |
| 410 |
% inside floats. |
| 411 |
% |
| 412 |
% \section{ToDo} |
| 413 |
% |
| 414 |
% \begin{itemize} |
| 415 |
% \item Parameters with \package{xkeyval} syntax; |
| 416 |
% \item Command |\DTsplittree| to allows a tree to be typeseted on |
| 417 |
% several pages; |
| 418 |
% \item Style parameters to rules (color for example) and gap between |
| 419 |
% text and comment (by now it's |\dotfill|). |
| 420 |
% \item Dimension parameter |abovetreeskip| and |belowtreeskip|. |
| 421 |
% \end{itemize} |
| 422 |
% .................... End of the documentation part .................... |
| 423 |
% |
| 424 |
%<*latex-wrapper> |
| 425 |
% \newpage |
| 426 |
% \section{\package{dirtree} \LaTeX{} Wrapper} |
| 427 |
% Nothing special here but the |\DT@fromsty| definition. This latter |
| 428 |
% is intended to check if \package{dirtree} is called under \LaTeX{} |
| 429 |
% (with |\usepackage|) or under Plain \TeX{}. |
| 430 |
% \begin{macrocode} |
| 431 |
\NeedsTeXFormat{LaTeX2e}[1995/06/01] |
| 432 |
\ProvidesPackage{dirtree}[\filedate\space v\fileversion\space |
| 433 |
package wrapper for dirtree] |
| 434 |
\newcommand*\DT@fromsty{} |
| 435 |
\input{dirtree.tex} |
| 436 |
\ProvidesFile{dirtree.tex} |
| 437 |
[\filedate\space v\fileversion\space `dirtree' (jcc)] |
| 438 |
% \end{macrocode} |
| 439 |
%</latex-wrapper> |
| 440 |
%<*tex> |
| 441 |
% \newpage |
| 442 |
% \section{\package{dirtree} Code} |
| 443 |
% An ``hello'' message. |
| 444 |
% \begin{macrocode} |
| 445 |
\message{`dirtree' v\fileversion, \filedate\space (jcc)} |
| 446 |
% \end{macrocode} |
| 447 |
% Save at current catcode and make @ a letter |
| 448 |
% \begin{macrocode} |
| 449 |
\edef\DTAtCode{\the\catcode`\@} |
| 450 |
\catcode`\@=11 |
| 451 |
% \end{macrocode} |
| 452 |
% \changes{v0.32}{2012/12/11}{LOOP, REPEAT and ITERATE modified to DT@ |
| 453 |
% form in order to prevent some clash with other packages.} |
| 454 |
% Define |\DT@loop|, |\DT@repeat|, and |\DT@iterate| like |\loop|, |
| 455 |
% |\repeat|, and |\iterate|. The |\DT@| form allows to place loop |
| 456 |
% inside loop. |
| 457 |
% \begin{macrocode} |
| 458 |
\long\def\DT@loop#1\DT@repeat{% |
| 459 |
\def\DT@iterate{#1\relax\expandafter\DT@iterate\fi}% |
| 460 |
\DT@iterate |
| 461 |
\let\DT@iterate\relax |
| 462 |
} |
| 463 |
\let\DT@repeat=\fi |
| 464 |
% \end{macrocode} |
| 465 |
% Define some \LaTeX{} macros if we work under Plain \TeX{}. |
| 466 |
% |\@namedef|-like for |\edef|. |
| 467 |
% \begin{macrocode} |
| 468 |
\expandafter\ifx\csname DT@fromsty\endcsname\relax |
| 469 |
\def\@namedef#1{\expandafter\def\csname #1\endcsname} |
| 470 |
\def\@nameuse#1{\csname #1\endcsname} |
| 471 |
\long\def\@gobble#1{} |
| 472 |
\fi |
| 473 |
\def\@nameedef#1{\expandafter\edef\csname #1\endcsname} |
| 474 |
% \end{macrocode} |
| 475 |
% Offset between vertical rule below text and text left boundary. |
| 476 |
% \begin{macrocode} |
| 477 |
\newdimen\DT@offset \DT@offset=0.2em |
| 478 |
% \end{macrocode} |
| 479 |
% Length of horizontal rule. |
| 480 |
% \begin{macrocode} |
| 481 |
\newdimen\DT@width \DT@width=1em |
| 482 |
% \end{macrocode} |
| 483 |
% Gap between horizontal rule and text. |
| 484 |
% \begin{macrocode} |
| 485 |
\newdimen\DT@sep \DT@sep=0.2em |
| 486 |
% \end{macrocode} |
| 487 |
% |\DT@offset|$\null+\null$|\DT@width|$\null+\null$|\DT@sep| |
| 488 |
% \begin{macrocode} |
| 489 |
\newdimen\DT@all |
| 490 |
\DT@all=\DT@offset |
| 491 |
\advance\DT@all \DT@width |
| 492 |
\advance\DT@all \DT@sep |
| 493 |
% \end{macrocode} |
| 494 |
% Rule thickness |
| 495 |
% \begin{macrocode} |
| 496 |
\newdimen\DT@rulewidth \DT@rulewidth=0.4pt |
| 497 |
% \end{macrocode} |
| 498 |
% Size of square junction. |
| 499 |
% \begin{macrocode} |
| 500 |
\newdimen\DT@dotwidth \DT@dotwidth=1.6pt |
| 501 |
% \end{macrocode} |
| 502 |
% baselineskip inside tree. |
| 503 |
% \begin{macrocode} |
| 504 |
\newdimen\DTbaselineskip \DTbaselineskip=\baselineskip |
| 505 |
% \end{macrocode} |
| 506 |
% Max index node. |
| 507 |
% \begin{macrocode} |
| 508 |
\newcount\DT@counti |
| 509 |
% \end{macrocode} |
| 510 |
% Current index node |
| 511 |
% \begin{macrocode} |
| 512 |
\newcount\DT@countii |
| 513 |
% \end{macrocode} |
| 514 |
% |\DT@countiii|$\null=\null$|\DT@countii|$\null-1$. That is, Previous |
| 515 |
% index node. |
| 516 |
% \begin{macrocode} |
| 517 |
\newcount\DT@countiii |
| 518 |
% \end{macrocode} |
| 519 |
% Last node of a level lesser or equal to current one. |
| 520 |
% \begin{macrocode} |
| 521 |
\newcount\DT@countiv |
| 522 |
% \end{macrocode} |
| 523 |
% \begin{macro}{\DTsetlength} |
| 524 |
% |\DTsetlength| allows to define dimensions in use for the directory |
| 525 |
% tree (see above). |
| 526 |
% \begin{macrocode} |
| 527 |
\def\DTsetlength#1#2#3#4#5{% |
| 528 |
\DT@offset=#1\relax |
| 529 |
\DT@width=#2\relax |
| 530 |
\DT@sep=#3\relax |
| 531 |
% \end{macrocode} |
| 532 |
% |\DT@all| is the width of a whole column. |
| 533 |
% \begin{macrocode} |
| 534 |
\DT@all=\DT@offset |
| 535 |
\advance\DT@all by\DT@width |
| 536 |
\advance\DT@all by\DT@sep |
| 537 |
\DT@rulewidth=#4\relax |
| 538 |
\DT@dotwidth=#5\relax |
| 539 |
} |
| 540 |
% \end{macrocode} |
| 541 |
% \end{macro} |
| 542 |
% |\DTstyle| is the style used to typeset nodes. |\DTstylecomment| is |
| 543 |
% the style used to typeset comments. Since \TeX{} and \LaTeX{} are |
| 544 |
% very different, we test the format used before initializations. |
| 545 |
% \begin{macro}{\DTstyle} |
| 546 |
% \begin{macro}{\DTstylecomment} |
| 547 |
% \begin{macrocode} |
| 548 |
\expandafter\ifx\csname DT@fromsty\endcsname\relax |
| 549 |
\def\DTstyle{\tt} |
| 550 |
\def\DTstylecomment{\rm} |
| 551 |
\else |
| 552 |
\def\DTstyle{\ttfamily} |
| 553 |
\def\DTstylecomment{\rmfamily} |
| 554 |
\fi |
| 555 |
% \end{macrocode} |
| 556 |
% \end{macro} |
| 557 |
% \end{macro} |
| 558 |
% \begin{macro}{\DTcomment} |
| 559 |
% |\DTcomment| places comment in a line of the tree. |
| 560 |
% \begin{macrocode} |
| 561 |
\def\DTcomment#1{% |
| 562 |
\kern\parindent\dotfill |
| 563 |
{\DTstylecomment{#1}}% |
| 564 |
} |
| 565 |
% \end{macrocode} |
| 566 |
% \end{macro} |
| 567 |
% \changes{v0.31}{2012/11/02}{save lengths as lengths (not as macro)} |
| 568 |
% In order to save some lengths we create newdimen |
| 569 |
% \begin{macrocode} |
| 570 |
\newdimen\DT@indent |
| 571 |
\newdimen\DT@parskip |
| 572 |
\newdimen\DT@baselineskip |
| 573 |
% \end{macrocode} |
| 574 |
% \begin{macro}{\dirtree} |
| 575 |
% |\dirtree| is the main package macro. |
| 576 |
% \begin{macrocode} |
| 577 |
\def\dirtree#1{% |
| 578 |
% \end{macrocode} |
| 579 |
% Change some parameters (save them before). |
| 580 |
% \begin{macrocode} |
| 581 |
\DT@indent=\parindent |
| 582 |
\parindent=\z@ |
| 583 |
\DT@parskip=\parskip |
| 584 |
\parskip=\z@ |
| 585 |
\DT@baselineskip=\baselineskip |
| 586 |
\baselineskip=\DTbaselineskip |
| 587 |
\let\DT@strut=\strut |
| 588 |
\def\strut{\vrule width\z@ height0.7\baselineskip depth0.3\baselineskip}% |
| 589 |
% \end{macrocode} |
| 590 |
% Read the argument and before that, initialize counters. |\DTcounti| |
| 591 |
% is the current index node. |
| 592 |
% \begin{macrocode} |
| 593 |
\DT@counti=\z@ |
| 594 |
\let\next\DT@readarg |
| 595 |
\next#1\@nil |
| 596 |
% \end{macrocode} |
| 597 |
% When |\DT@readarg| has done its job, the node levels and the node |
| 598 |
% texts are saved in |\DT@level@<index>| and |\DT@body@<index>| |
| 599 |
% respectively. |\DT@counti| holds the greater index. We can now |
| 600 |
% display the tree. |
| 601 |
% |
| 602 |
% Firstly, display the root. For that, the text is boxed. |
| 603 |
% \begin{macrocode} |
| 604 |
\dimen\z@=\hsize |
| 605 |
\advance\dimen\z@ -\DT@offset |
| 606 |
\advance\dimen\z@ -\DT@width |
| 607 |
\setbox\z@=\hbox to\dimen\z@{% |
| 608 |
\hsize=\dimen\z@ |
| 609 |
\vbox{\@nameuse{DT@body@1}}% |
| 610 |
}% |
| 611 |
% \end{macrocode} |
| 612 |
% We change the height and the depth of this box in order to have the |
| 613 |
% same total height and a height of |0.7\baselineskip|, that is, the |
| 614 |
% height of |\strut|. |
| 615 |
% \begin{macrocode} |
| 616 |
\dimen\z@=\ht\z@ |
| 617 |
\advance\dimen0 by\dp\z@ |
| 618 |
\advance\dimen0 by-0.7\baselineskip |
| 619 |
\ht\z@=0.7\baselineskip |
| 620 |
\dp\z@=\dimen\z@ |
| 621 |
% \end{macrocode} |
| 622 |
% Then we display this box with an indentation as if there had a level 0. |
| 623 |
% \begin{macrocode} |
| 624 |
\par\leavevmode |
| 625 |
\kern\DT@offset |
| 626 |
\kern\DT@width |
| 627 |
\box\z@ |
| 628 |
\endgraf |
| 629 |
% \end{macrocode} |
| 630 |
% Initialize index for the loop. |
| 631 |
% \begin{macrocode} |
| 632 |
\DT@countii=\@ne |
| 633 |
\DT@countiii=\z@ |
| 634 |
% \end{macrocode} |
| 635 |
% |\dimen3| holds the height of the node in the tree. In fact, the |
| 636 |
% bottom of the node since this dimension is used to connect vertical |
| 637 |
% rules. |
| 638 |
% \begin{macrocode} |
| 639 |
\dimen3=\dimen\z@ |
| 640 |
% \end{macrocode} |
| 641 |
% |\DT@lastlevel@<level>| holds the baseline of the last node in level |
| 642 |
% |<level>|. |
| 643 |
% \begin{macrocode} |
| 644 |
\@namedef{DT@lastlevel@1}{-0.7\baselineskip}% |
| 645 |
% \end{macrocode} |
| 646 |
% Loop for displaying the remainder of the tree. |
| 647 |
% \begin{macrocode} |
| 648 |
\loop |
| 649 |
% \end{macrocode} |
| 650 |
% Exit loop when the last current index is lesser or equal to max |
| 651 |
% index. |
| 652 |
% \begin{macrocode} |
| 653 |
\ifnum\DT@countii<\DT@counti |
| 654 |
% \end{macrocode} |
| 655 |
% |\DT@counti| holds current index and |\DT@countii| holds previous |
| 656 |
% index (just current index minus one). |
| 657 |
% \begin{macrocode} |
| 658 |
\advance\DT@countii \@ne |
| 659 |
\advance\DT@countiii \@ne |
| 660 |
% \end{macrocode} |
| 661 |
% Horizontal offset for the text: |
| 662 |
% |
| 663 |
% $(\mathtt{current\ level} - 1) \times \mathtt{DT@all} + |
| 664 |
% \mathtt{DT@offset}$. |
| 665 |
% \begin{macrocode} |
| 666 |
\dimen\z@=\@nameuse{DT@level@\the\DT@countii}\DT@all |
| 667 |
\advance\dimen\z@ by\DT@offset |
| 668 |
\advance\dimen\z@ by-\DT@all |
| 669 |
\leavevmode |
| 670 |
\kern\dimen\z@ |
| 671 |
% \end{macrocode} |
| 672 |
% Look for last node in previous level in order to know how connect |
| 673 |
% the current node. |
| 674 |
% \begin{macrocode} |
| 675 |
\DT@countiv=\DT@countii |
| 676 |
\count@=\z@ |
| 677 |
\DT@loop |
| 678 |
% \end{macrocode} |
| 679 |
% Look for previous node |
| 680 |
% \begin{macrocode} |
| 681 |
\advance\DT@countiv \m@ne |
| 682 |
% \end{macrocode} |
| 683 |
% Repeat until this previous node has a level lesser or equal to |
| 684 |
% current level. |
| 685 |
% \begin{macrocode} |
| 686 |
\ifnum\@nameuse{DT@level@\the\DT@countiv} > |
| 687 |
\@nameuse{DT@level@\the\DT@countii}\relax |
| 688 |
\else |
| 689 |
\count@=\@ne |
| 690 |
\fi |
| 691 |
\ifnum\count@=\z@ |
| 692 |
\DT@repeat |
| 693 |
% \end{macrocode} |
| 694 |
% Now |\DT@countiv| holds the index node connected to current node. |
| 695 |
% |
| 696 |
% We box the text node. |
| 697 |
% \begin{macrocode} |
| 698 |
\edef\DT@hsize{\the\hsize}% |
| 699 |
% \end{macrocode} |
| 700 |
% \begin{macrocode} |
| 701 |
\count@=\@nameuse{DT@level@\the\DT@countii}\relax |
| 702 |
% \end{macrocode} |
| 703 |
% Since text node is vboxed, we use a |\hsize| minus horizontal |
| 704 |
% current offset. |
| 705 |
% \begin{macrocode} |
| 706 |
\dimen\z@=\count@\DT@all |
| 707 |
\advance\hsize by-\dimen\z@ |
| 708 |
\setbox\z@=\vbox{\@nameuse{DT@body@\the\DT@countii}}% |
| 709 |
% \end{macrocode} |
| 710 |
% Restore |\hsize|. |
| 711 |
% \begin{macrocode} |
| 712 |
\hsize=\DT@hsize |
| 713 |
% \end{macrocode} |
| 714 |
% Change height and depth in such a way that height is |
| 715 |
% |0.7\DT@baselineskip| (that is, the |\strut| height), and total |
| 716 |
% height is unchanged. |
| 717 |
% \begin{macrocode} |
| 718 |
\dimen\z@=\ht\z@ |
| 719 |
\advance\dimen\z@ by\dp\z@ |
| 720 |
\advance\dimen\z@ by-0.7\baselineskip |
| 721 |
\ht\z@=0.7\baselineskip |
| 722 |
\dp\z@=\dimen\z@ |
| 723 |
% \end{macrocode} |
| 724 |
% Save the height of the box in tree. The last node is the last node |
| 725 |
% in its level! |
| 726 |
% \begin{macrocode} |
| 727 |
\@nameedef{DT@lastlevel@\the\DT@countii}{\the\dimen3}% |
| 728 |
% \end{macrocode} |
| 729 |
% |\dimen3| holds the vertical position of the bottom. |
| 730 |
% \begin{macrocode} |
| 731 |
\advance\dimen3 by\dimen\z@ |
| 732 |
\advance\dimen3 by0.7\baselineskip |
| 733 |
% \end{macrocode} |
| 734 |
% Display vertical rule |
| 735 |
% \begin{macrocode} |
| 736 |
\dimen\z@=\@nameuse{DT@lastlevel@\the\DT@countii}\relax |
| 737 |
\advance\dimen\z@ by-\@nameuse{DT@lastlevel@\the\DT@countiv}\relax |
| 738 |
\advance\dimen\z@ by0.3\baselineskip |
| 739 |
% \end{macrocode} |
| 740 |
% If this vertical rule connect two nodes which have different level, |
| 741 |
% the rule must be reduced by |0.5\baselineskip| (the rule don't rise |
| 742 |
% up to the baselineskip of the connected node). |
| 743 |
% \begin{macrocode} |
| 744 |
\ifnum\@nameuse{DT@level@\the\DT@countiv} < |
| 745 |
\@nameuse{DT@level@\the\DT@countii}\relax |
| 746 |
\advance\dimen\z@ by-0.5\baselineskip |
| 747 |
\fi |
| 748 |
% \end{macrocode} |
| 749 |
% Display vertical rule |
| 750 |
% \begin{macrocode} |
| 751 |
\kern-0.5\DT@rulewidth |
| 752 |
\hbox{\vbox to\z@{\vss\hrule width\DT@rulewidth height\dimen\z@}}% |
| 753 |
\kern-0.5\DT@rulewidth |
| 754 |
% \end{macrocode} |
| 755 |
% Display square junction. |
| 756 |
% \begin{macrocode} |
| 757 |
\kern-0.5\DT@dotwidth |
| 758 |
\vrule width\DT@dotwidth height0.5\DT@dotwidth depth0.5\DT@dotwidth |
| 759 |
\kern-0.5\DT@dotwidth |
| 760 |
% \end{macrocode} |
| 761 |
% Display horizontal rule and gap between horizontal rule and text node. |
| 762 |
% \begin{macrocode} |
| 763 |
\vrule width\DT@width height0.5\DT@rulewidth depth0.5\DT@rulewidth |
| 764 |
\kern\DT@sep |
| 765 |
% \end{macrocode} |
| 766 |
% Display text node. |
| 767 |
% \begin{macrocode} |
| 768 |
\box\z@ |
| 769 |
% \end{macrocode} |
| 770 |
% New paragraph for next node. |
| 771 |
% \begin{macrocode} |
| 772 |
\endgraf |
| 773 |
\repeat |
| 774 |
% \end{macrocode} |
| 775 |
% Restore indentation, paragraph skip, and |\strut|. |
| 776 |
% \begin{macrocode} |
| 777 |
\parindent=\DT@indent |
| 778 |
\parskip=\DT@parskip |
| 779 |
% \end{macrocode} |
| 780 |
% \changes{v0.32}{2012/12/11}{Inverse order of assignation between |
| 781 |
% baselineskip and DT@baselineskip.} |
| 782 |
% \begin{macrocode} |
| 783 |
\baselineskip=\DT@baselineskip |
| 784 |
\let\strut\DT@strut |
| 785 |
} |
| 786 |
% \end{macrocode} |
| 787 |
% \end{macro} |
| 788 |
% \begin{macro}{\DT@readarg} |
| 789 |
% The first processing step is to read the whole tree. It's a |
| 790 |
% recursive macro: each call process one node, that is, a |
| 791 |
% \begin{verbatim} |
| 792 |
% .<index> <text node>.<space> |
| 793 |
% \end{verbatim} |
| 794 |
% in the source file. |
| 795 |
% \begin{macrocode} |
| 796 |
\def\DT@readarg.#1 #2. #3\@nil{% |
| 797 |
% \end{macrocode} |
| 798 |
% |\DT@counti| is the current index. |
| 799 |
% \begin{macrocode} |
| 800 |
\advance\DT@counti \@ne |
| 801 |
% \end{macrocode} |
| 802 |
% save level node in |\DT@level@<index>| and text node in |
| 803 |
% |\DT@body@<index>|. Two \package{dirtree} |\strut| are added to text |
| 804 |
% node in order to ensure a right vertical alignment, according to |
| 805 |
% \package{dirtree} |\baselineskip| |
| 806 |
% \begin{macrocode} |
| 807 |
\@namedef{DT@level@\the\DT@counti}{#1}% |
| 808 |
\@namedef{DT@body@\the\DT@counti}{\strut{\DTstyle{#2}\strut}}% |
| 809 |
% \end{macrocode} |
| 810 |
% If |#3| is not empty, it contains the remainder nodes and macro |
| 811 |
% calls itself. Otherwise, recursive call is stopped. |
| 812 |
% \begin{macrocode} |
| 813 |
\ifx\relax#3\relax |
| 814 |
\let\next\@gobble |
| 815 |
\fi |
| 816 |
\next#3\@nil |
| 817 |
} |
| 818 |
% \end{macrocode} |
| 819 |
% \end{macro} |
| 820 |
% Restore at catcode. |
| 821 |
% \begin{macrocode} |
| 822 |
\catcode`\@=\DTAtCode\relax |
| 823 |
% \end{macrocode} |
| 824 |
%</tex> |
| 825 |
% \endinput |