% \iffalse
%% File: layers.dtx Copyright (C) 1999 Anselm Lingnau
%% Use and distribute this file under the terms of the LPPL.
%
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{layers}
%<package>   [1999/06/20 v1.00 Layers package for TkDVI (AL)]
%
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\documentclass{ltxdoc}
\GetFileInfo{layers.sty}
\RecordChanges
\EnableCrossrefs
%%\DisableCrossrefs% Say \DisableCrossrefs if index is ready
\CodelineIndex   % Index code by line number
\OnlyDescription % comment out for implementation details
%%\OldMakeIndex  % use if your MakeIndex is pre-v2.9
\begin{document}
  \DocInput{layers.dtx}
  \PrintIndex\PrintChanges
   %  Make sure that the index is not printed twice
   %  (ltxdoc.cfg might have a second \PrintIndex command)
   \let\PrintChanges\relax
   \let\PrintIndex\relax
\end{document}
%</driver>
% \fi
%
% \CheckSum{105}
%
%% \CharacterTable
%% {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
%%  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
%%  Digits        \0\1\2\3\4\5\6\7\8\9
%%  Exclamation   \!     Double quote  \"     Hash (number) \#
%%  Dollar        \$     Percent       \%     Ampersand     \&
%%  Acute accent  \'     Left paren    \(     Right paren   \)
%%  Asterisk      \*     Plus          \+     Comma         \,
%%  Minus         \-     Point         \.     Solidus       \/
%%  Colon         \:     Semicolon     \;     Less than     \<
%%  Equals        \=     Greater than  \>     Question mark \?
%%  Commercial at \@     Left bracket  \[     Backslash     \\
%%  Right bracket \]     Circumflex    \^     Underscore    \_
%%  Grave accent  \`     Left brace    \{     Vertical bar  \|
%%  Right brace   \}     Tilde         \~}
%%
%
% \changes{v1.00}{1999-06-20}{New}
%
%  \title{\unskip
%    The \textsf{layers} package^^A
%    \thanks{^^A
%       The version number of this file is \fileversion,
%       last revised \filedate.}^^A
%    }
%  \author{Anselm Lingnau\\[0.5ex]
%          \normalsize Schwanheimer Stra\ss e 66\\
%          \normalsize D-60528 Frankfurt\\
%          \normalsize lingnau@tm.informatik.uni-frankfurt.de}
%  \date{\filedate, \LaTeX{}ed \today}
%  \maketitle
%
% \begin{abstract}
%   This package provides syntactic sugar for the layer mechanism
%   of the TkDVI previewer.
% \end{abstract}
%
% \pagestyle{headings}
%
% \tableofcontents
%
% \section{Introduction}
% ^^A
% This package provides environments and commands that make use of the
% ``layer'' mechanism built into the TkDVI previewer. TkDVI supports
% the \verb|\special| commands \texttt{layer push}, \texttt{layer pop}
% and \texttt{layer reset}. The main body of a DVI file is considered
% to be at layer~0; each \texttt{layer push} increases the current layer
% number by 1, while \texttt{layer pop} decreases it, so in
% \verb|\special{layer push}foo\special{layer pop}bar|, ``foo'' is at
% layer~1 and ``bar'' is at layer~0. Layers can be nested arbitrarily
% deeply. \texttt{layer reset} sets the current layer number to~0,
% regardless of its previous value.
%
% When rendering a DVI page, TkDVI keeps track of the current layer
% number. For each glyph and rule to be typeset, the current layer
% number is compared against the value of the \verb|-layer| option
% of the current DVI image; the glyph or rule is typeset only if
% the current layer number is less than or equal to the value of
% the \verb|-layer| option. This makes it possible to ``uncover''
% the items of an itemized or enumerated list one after the other
% during a presentation, or to write a ``fill in the gaps'' document
% where the reader can mentally figure out what is missing before
% looking at the solution.
%
% \DescribeEnv{layer}
% The contents of the |layer| environment is typeset at the layer
% above the current layer. This environment can be nested.
%
% \DescribeMacro{\uplayer}
% This macro takes one argument, which is typeset at the layer above
% the current layer. The argument may contain further calls to
% |\uplayer|.
%
% \DescribeEnv{litemize}
% This is similar to the |itemize| environment, but the layer number
% increases for each new item. In effect, this will make the items
% appear one after another.
%
% \DescribeEnv{lenumerate}
% This is to |enumerate| what |litemize| is to |itemize|.
%
% Neither |litemize| nor |lenumerate| environments can be nested, not
% even a |litemize| inside a |lenumerate| or vice versa. In any case
% this is intended for presentation slides, which should not have a
% very complicated structure.
%
% \section{The implementation}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
% \begin{macro}{\uplayer}
% \cs{uplayer} takes one argument, which is bracketed in |layer push|
% and |layer pop|.
%    \begin{macrocode}
\newcommand{\uplayer}[1]{\special{layer push}#1\special{layer pop}}
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{layer}
% This is essentially the same thing, but as an environment.
%    \begin{macrocode}
\newenvironment{layer}{%
  \special{layer push}%
}{%
  \special{layer pop}%
}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{lenumerate}
% This is the definition |enumerate| from |latex.ltx|, but with a
% |\special{layer push}| at the beginning of every label and a
% |\special{layer reset}| at the end of the environment.
%    \begin{macrocode}
\def\lenumerate{%
  \ifnum \@enumdepth >\thr@@\@toodeep\else
    \advance\@enumdepth\@ne
    \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
      \expandafter
      \list
        \csname label\@enumctr\endcsname
        {\usecounter\@enumctr
         \def\makelabel##1{\special{layer push}\hss\llap{##1}}}%
  \fi}
\def\endlenumerate{\endlist\special{layer reset}}
%    \end{macrocode}
% \end{environment}
% \begin{environment}{litemize}
% And this is the same thing for |itemize|.
%    \begin{macrocode}
\def\litemize{%
  \ifnum\@itemdepth>\thr@@\@toodeep\else
    \advance\@itemdepth\@ne
    \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
    \expandafter\list\csname\@itemitem\endcsname
    {\def\makelabel##1{\special{layer push}\hss\llap{##1}}}%
    \fi}
\def\endlitemize{\endlist\special{layer reset}}
%    \end{macrocode}
% \end{environment}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% \Finale

