summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/outlines/outlines.sty
blob: 1d67e5c7b8852d1552146c092616f433debed7f2 (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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% outlines.sty - Provides an "outline" environment for mixed-level
% outline lists
%
% Charles Pecheur, UCL, 2005 -- 2012
% charles.pecheur@uclouvain.be
%
% Note: this package has no connection with outline.sty or outliner.sty, 
% that are available on CTAN
%
% This work 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 2005/12/01 or later.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Usage: 
%
% \usepackage{outlines}
%
% \begin{outline}[<list-style>] 
%   \1 <level 1 text>
%   \1[<label>] <level 1 text>
%      \2 <level 2 text>
%         \3 <level 3 text>
%            \4 <level 4 text>
% \0 <normal paragraph>
%   ...
% \end{outline}
%
% where:
% + <list-style> is an optional list environment name 
%   (e.g. itemize, enumerate, ...).  The default is itemize.
%   The same style is used for all levels that have not been overridden.
% + <label> is an optional label, as in \item[<label>].
% + Levels may be mixed freely, except that a \1 must come before
%   the first \2, a \2 before the first \3, etc. 
%   (this restriction is inherited from list environments).
% + \0 gives a normal, non-list paragraph.
% + List styles for each level can be overridden by re-defining
%   \outlinei, ..., \outlineiiii, either globally or inside an outline block.
%
% Do not nest outlines inside outlines or other lists.  Lists inside outlines
% should work fine.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ProvidesPackage{outlines}[2012/1/23 1.1 Ch. Pecheur]
\RequirePackage{ifthen}

\makeatletter
% \ol@type stores the default list style
\newcommand{\ol@type}{itemize}
% \ol@typei ... store the (list) environment names used in outlines
\newcommand{\outlinei}{\ol@type}
\newcommand{\outlineii}{\ol@type}
\newcommand{\outlineiii}{\ol@type}
\newcommand{\outlineiiii}{\ol@type}
% \ol@inci ..., \ol@deci ... increase/decrease the indentation level
\newcommand{\ol@inci}{\begin{\outlinei}}
\newcommand{\ol@deci}{\end{\outlinei}}
\newcommand{\ol@incii}{\begin{\outlineii}}
\newcommand{\ol@decii}{\end{\outlineii}}
\newcommand{\ol@inciii}{\begin{\outlineiii}}
\newcommand{\ol@deciii}{\end{\outlineiii}}
\newcommand{\ol@inciiii}{\begin{\outlineiiii}}
\newcommand{\ol@deciiii}{\end{\outlineiiii}}

% \ol@toz, \ol@toi ... "transition" to indentation level 0..4 by opening or
% closing nested list levels as needed.
% They are dynamically modified according to the current level.
\newcommand{\ol@toz}{}
\newcommand{\ol@toi}{}
\newcommand{\ol@toii}{}
\newcommand{\ol@toiii}{}
\newcommand{\ol@toiiii}{}

% \ol@commands{C0}{C1}{C2}{C3}{C4} set the level transition commands 
% above to C0..C4
\newcommand{\ol@commands}[5]{%
  \renewcommand{\ol@toz}{#1}%
  \renewcommand{\ol@toi}{#2}%
  \renewcommand{\ol@toii}{#3}%
  \renewcommand{\ol@toiii}{#4}%
  \renewcommand{\ol@toiiii}{#5}%
}

% \ol@exit resets transition commands.  This is not mandatory, just cleaner.
\newcommand{\ol@exit}{%
  \ol@commands{}{}{}{}{}}
% \ol@z, \ol@i ... update all transitions for level 0..4
\newcommand{\ol@z}{%
  \ol@commands%
    {}%
  	{\ol@inci}%
	{\ol@inci\ol@incii}%
    {\ol@inci\ol@incii\ol@inciii}%
    {\ol@inci\ol@incii\ol@inciii\ol@inciiii}}
\newcommand{\ol@i}{%
  \ol@commands%
    {\ol@deci}%
    {}%
    {\ol@incii}%
    {\ol@incii\ol@inciii}%
    {\ol@incii\ol@inciii\ol@inciiii}}
\newcommand{\ol@ii}{%
  \ol@commands%
    {\ol@decii\ol@deci}%
    {\ol@decii}%
    {}%
    {\ol@inciii}%
    {\ol@inciii\ol@inciiii}}
\newcommand{\ol@iii}{%
  \ol@commands%
    {\ol@deciii\ol@decii\ol@deci}%
    {\ol@deciii\ol@decii}%
    {\ol@deciii}%
    {}%
    {\ol@inciiii}}
\newcommand{\ol@iiii}{%
  \ol@commands%
    {\ol@deciiii\ol@deciii\ol@decii\ol@deci}%
    {\ol@deciiii\ol@deciii\ol@decii}%
	{\ol@deciiii\ol@deciii}%
	{\ol@deciiii}%
	{}}


% the outline environment provides commands \1..\4 for 
% introducing items at level 1..4, and \0 for normal paragraphs 
% within the outline section.
\newenvironment{outline}[1][]{%
  \ifthenelse{\equal{#1}{}}{}{\renewcommand{\ol@type}{#1}}%
  \ol@z%
  \newcommand{\0}{\ol@toz\ol@z}%
  \newcommand{\1}{\ol@toi\ol@i\item}%
  \newcommand{\2}{\ol@toii\ol@ii\item}%
  \newcommand{\3}{\ol@toiii\ol@iii\item}%  
  \newcommand{\4}{\ol@toiiii\ol@iiii\item}%  
}{%
  \ol@toz\ol@exit%
}

\makeatother