summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/etaremune/etaremune.sty
blob: f860abc4b775a397d554a6c580cf4879c53e652a (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
%%
%% This is file `etaremune.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% etaremune.dtx  (with options: `etaremune')
%% 
%% ----------------------------------
%% Copyright (C) 2005 Hendri Adriaens
%% ----------------------------------
%%
%% 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 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% This Current Maintainer of this work is Hendri Adriaens.
%%
%% This work consists of the file etaremune.dtx and the
%% derived file etaremune.sty.
%%
%% The following files constitute the etaremune package and must be
%% distributed as a whole: readme, etaremune.dtx, etaremune.pdf and
%% etaremune.sty.
%%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{etaremune}[2005/06/01 v1.2 Reversed enumerate (HA)]
\RequirePackage{xkeyval}
\def\@tempa#1#2{%
  \DeclareOptionX{#1}{\presetkeys[EM]{template}{#1=##1}{}}%
  \define@key[EM]{template}{#1}{\setlength#2{##1}}%
}
\XKV@for@n{topsep,partopsep,itemsep,parsep,leftmargin,rightmargin,%
  listparindent,itemindent,labelwidth,labelsep}\@tempb{%
  \edef\@tempb{%
    {\@tempb}\expandafter\noexpand\csname\@tempb\endcsname
  }%
  \expandafter\@tempa\@tempb
}
\DeclareOptionX*{%
  \PackageWarning{etaremune}{Unknown option `\CurrentOption'}%
}
\ProcessOptionsX
\define@cmdkey[EM]{etaremune}[EM@]{start}{}
\presetkeys[EM]{etaremune}{start=-1}{}
\newcounter{EM@itemctr}
\newcounter{EM@etaremunectr}
\newenvironment{etaremune}[1][]{%
  \ifnum\@enumdepth>\thr@@\@toodeep\else
    \setkeys*[EM]{etaremune}{#1}%
    \advance\@enumdepth\@ne
    \stepcounter{EM@etaremunectr}%
    \edef\EM@currnum{\the\c@EM@itemctr}%
    \edef\EM@currlist{\romannumeral\c@EM@etaremunectr}%
    \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
    \setcounter{EM@itemctr}\z@
    \let\EM@step\m@ne
    \ifnum\EM@start<\z@
      \@ifundefined{etaremune@\EM@currlist}{%
        \let\EM@step\@ne
        \setcounter\@enumctr\m@ne
        \gdef\EM@rerun{%
          \@latex@warning@no@line{Etaremune labels have changed.^^J
          \@spaces\@spaces\@spaces\space\space Rerun to get them right}%
        }%
      }{%
        \setcounter\@enumctr{\csname etaremune@\EM@currlist\endcsname}%
      }%
    \else\setcounter\@enumctr\EM@start\fi
    \stepcounter\@enumctr
    \list{%
      \addtocounter\@enumctr\EM@step
      \ifnum\csname c@\@enumctr\endcsname<\z@\setcounter\@enumctr\z@\fi
      \stepcounter{EM@itemctr}%
      \xdef\@currentlabel{%
        \csname p@\@enumctr\endcsname\csname the\@enumctr\endcsname
      }%
      \csname label\@enumctr\endcsname
    }{\def\makelabel##1{\hss\llap{##1}}\setrmkeys[EM]{template}}%
  \fi
}{%
  \endlist
  \immediate\write\@auxout{\string\gdef\expandafter\string
    \csname etaremune@\EM@currlist\endcsname{\the\c@EM@itemctr}%
  }%
  \setcounter{EM@itemctr}\EM@currnum
}
\AtEndDocument{\EM@rerun}
\let\EM@rerun\relax
\endinput
%%
%% End of file `etaremune.sty'.