summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/shorttoc/shorttoc.dtx
blob: bd2cc78a6afa5fa02125c6c8004e6e776e928e3d (plain)
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
% \iffalse
%% Package `shorttoc' to use with LaTeX 2e
%% Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Jean-Pierre F. Drucbert, all rights reserved
%%
%% You may use and distribute this file freely, provided that
%% you don't pretend that you wrote it.
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.1
% 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.1 or later is part of all distributions of LaTeX 
% version 1999/06/01 or later.
%
%<package>\NeedsTeXFormat{LaTeX2e}[1996/06/01]
%<package>\ProvidesPackage{shorttoc}
%<package>         [2002/08/20 v1.3 Short table of contents (JPFD)]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage[tight]{shorttoc}
\GetFileInfo{shorttoc.sty}
\def\filedate{2002/04/10}
\def\fileversion{v1.3}
\EnableCrossrefs         
%\DisableCrossrefs   % Say \DisableCrossrefs if index is ready
\RecordChanges                  % Gather update information
\CodelineIndex                  % Index code by line number
\title{The \pkg{shorttoc} package}
\author{Jean-Pierre F. Drucbert\\\texttt{drucbert@onecert.fr}}%
\date{\filedate}
\def\bs{\texttt{\char'134}}
\let\pkg\textsf
\begin{document}
\maketitle
\DocInput{shorttoc.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{86}
%
% \changes{v1.0}{21 Jul 98}{First officially released version.}
% \changes{v1.1}{03 Aug 99}{LPPL License.}
% \changes{v1.2}{20 Aug 99}{Added tight/loose options.}
% \changes{v1.3}{10 Apr 2002}{Added macro for external tocs.}
%
% \DoNotIndex{\@Mii,\@Miv,\@cons,\@currlist,\@dblarg,\@dbldeferlist}
% \DoNotIndex{\@dblfloat,\@dottedtocline,\@eha,\@Esphack,\@float}
% \DoNotIndex{\@floatpenalty,\@ifnextchar,\@ifundefined,\@latexerr}
% \DoNotIndex{\@mkboth,\@namedef,\@nameuse,\@parboxrestore,\@spaces}
% \DoNotIndex{\@starttoc,\@tempa,\@tempboxa,\@tempdima,\@warning}
% \DoNotIndex{\addcontentsline,\addtocounter,\advance,\arabic,\bfseries}
% \DoNotIndex{\bgroup,\box,\chapter,\columnwidth,\csname,\def,\dimen,\docdate}
% \DoNotIndex{\edef,\egroup,\else,\endcsname,\endinput,\expandafter,\fi}
% \DoNotIndex{\filedate,\fileversion,\global,\hbadness,\hbox,\hfil,\hrule}
% \DoNotIndex{\hsize,\ht,\if@twocolumn,\ifdim,\iffalse,\ifnum,\iftrue,\ifvbox}
% \DoNotIndex{\ifx,\ignorespaces,\intextsep,\kern,\let,\long,\moveleft,\newbox}
% \DoNotIndex{\newcommand,\newcounter,\newif,\newsavebox,\noexpand,\normalsize}
% \DoNotIndex{\numberline,\PackageError,\PackageWarning,\par,\parindent}
% \DoNotIndex{\penalty,\prevdepth,\protect,\refstepcounter,\relax}
% \DoNotIndex{\renewcommand,\rmfamily,\section,\setbox,\setcounter,\space}
% \DoNotIndex{\textheight,\the,\typeout,\unvbox,\uppercase,\vadjust,\value}
% \DoNotIndex{\vbox,\vrule,\vskip,\vspace,\wd,\z@}
%
% \shorttoc{Short Contents}{1}
% \tableofcontents
% \begin{abstract}
% This package\footnote{%
% \begin{tabular}[t]{l}
% Copyright \copyright\ 1997, 1998, 1999, 2000, 2001, 2002 by\\
% Jean-Pierre F. Drucbert\vphantom{bp}\\
% ONERA/Centre de Toulouse SRI\vphantom{bp}\\
% Office National d'\'Etudes et de Recherches A\'erospatiales\vphantom{bp}\\
% Centre de Toulouse\vphantom{bp}\\
% Service R\'eseaux et Informatique\vphantom{bp}\\
% \\
% Complexe Scientifique de Rangueil\vphantom{bp}\\
% 2, Avenue \'Edouard Belin\vphantom{bp}\\
% BP 4025 F-31055 TOULOUSE CEDEX\vphantom{bp}\\
% FRANCE\vphantom{bp}\\
% \vphantom{bp}\\
% Email: \texttt{drucbert@onecert.fr}\vphantom{bp}\\
% \end{tabular}}
% allows you to create another table of contents, with a different
% depth. This could be useful in large documents where a detailed
% table of contents should be accompanied by a shorter one, giving
% only a general overview of the main topics in the document.
% You can also insert the table of contents of another
% document.
% \end{abstract}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{The \pkg{shorttoc} package}
% \DescribeMacro{\shorttableofcontents}
% This package defines the |\shorttableofcontents| macro, which
% is used as follows:
% \begin{quote}\ttfamily
% \bs shorttableofcontents\marg{title}\marg{depth}
% \end{quote}
% where \meta{title} will be the title of this table of contents and
% \meta{depth} its ``depth'', with the meaning of the \texttt{tocdepth}
% counter.
%
% \DescribeMacro{\shorttoc}
% As this macro has a too long name, |\shorttoc| is a synomym, with
% the same syntax.
%
% \DescribeMacro{\anothertableofcontents}
% This macro allows you to display the table of contents of
% an another document, or its list of figures or list of
% tables. Its use is:
% \begin{quote}\ttfamily
% \bs anothertableofcontents\oarg{suffix}\marg{document}\marg{title}\marg{depth}
% \end{quote}
% where \meta{suffix} is |.toc| by default (table of
% contents), \meta{document} is the base name of the other
% document whose table of contents (or its list of figures or
% list of tables, if you give another \meta{suffix}).
% \meta{title} and \meta{depth} have the same meaning as for
% |\shorttableofcontents|.
%
% \DescribeMacro{\anothertoc}
% As this macro has a too long name, |\anothertoc| is a synomym, with
% the same syntax.
%
% \subsection{Options}
% The available package options are \texttt{loose} (default)
% and \texttt{tight}. \texttt{tight} reduces the amount of
% vertical space between the lines of the short table of contents.
%
% \subsection{Important note}
% This package \emph{does not create} the |.toc| file; this
% file must be created by a classical |\tableofcontents| command, or by
% something similar.  You must place the |\shorttableofcontents|
% (or |\shorttoc|) command \emph{before} the |\tableofcontents|
% (or equivalent) command.  If you do not respect the right sequence,
% the short table of contents will be % empty (just its title).
%
% This restriction does not apply to |\anothertableofcontents|
% and |\anothertoc| macros, but, of course, the files |.toc| (or other)
% for the other document must be available.
%
% \StopEventually{\setcounter{IndexColumns}{2}\PrintIndex\PrintChanges}
%
% \clearpage
% \section{Implementation}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
% \begin{macro}{\@startshorttoc}
% First, we declare the |\@startshorttoc| macro, like |\@starttoc|, 
% but without creating the |.toc| file:
%    \begin{macrocode}
\def\@startshorttoc#1{\bgroup
  \makeatletter
  \@input{\jobname.#1}%
  \global\@nobreakfalse \egroup}
%    \end{macrocode}
% \end{macro}
% The macro |\sht@startshorttoc| is similar, but has a second
% argument to speciffy another document.
%    \begin{macrocode}
\def\sht@startshorttoc#1#2{\bgroup
  \makeatletter
  \@input{#2.#1}%
  \global\@nobreakfalse \egroup}
%    \end{macrocode}
%
% \begin{macro}{\if@tightshtoc}
% Then a flag for the tight/loose options:
%    \begin{macrocode}
\newif\if@tightshtoc \@tightshtocfalse
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\shorttableofcontents}
% Then the user interface macro is copied from
% |\tableofcontents|, but with arguments and
% processing of the depth:
%    \begin{macrocode}
\def\shorttableofcontents#1#2{\bgroup\c@tocdepth=#2\@restonecolfalse
  \if@tightshtoc
     \parsep\z@
  \fi
  \if@twocolumn\@restonecoltrue\onecolumn\fi
  \@ifundefined{chapter}%
  {\section*{{#1}
        \@mkboth{\uppercase{#1}}{\uppercase{#1}}}}%
  {\chapter*{{#1}
        \@mkboth{\uppercase{#1}}{\uppercase{#1}}}}%
  \@startshorttoc{toc}\if@restonecol\twocolumn\fi\egroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\anothertableofcontents}
% This macro is analog, but using another input file and
% with arguments for suffix and name of the other document:
%    \begin{macrocode}
\newcommand{\anothertableofcontents}[4][toc]{\bgroup\c@tocdepth=#4\@restonecolfalse
  \if@tightshtoc
     \parsep\z@
  \fi
  \if@twocolumn\@restonecoltrue\onecolumn\fi
  \@ifundefined{chapter}%
  {\section*{{#3}
        \@mkboth{\uppercase{#3}}{\uppercase{#3}}}}%
  {\chapter*{{#3}
        \@mkboth{\uppercase{#3}}{\uppercase{#3}}}}%
  \sht@startshorttoc{#1}{#2}\if@restonecol\twocolumn\fi\egroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\shorttoc}
% Let us define shorters synonyms:
%    \begin{macrocode}
     \let\shorttoc\shorttableofcontents
     \let\anothertoc\anothertableofcontents
%    \end{macrocode}
% \end{macro}
%
% And declare the options:
%    \begin{macrocode}
     \DeclareOption{tight}{\@tightshtoctrue}
     \DeclareOption{loose}{\@tightshtocfalse}
     \ExecuteOptions{loose}
     \ProcessOptions*
%    \end{macrocode}
%
% \Finale
% \end{document}
\endinput