summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/zero
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex209/contrib/zero
Initial commit
Diffstat (limited to 'macros/latex209/contrib/zero')
-rw-r--r--macros/latex209/contrib/zero/zero-README25
-rw-r--r--macros/latex209/contrib/zero/zero-test.tex64
-rw-r--r--macros/latex209/contrib/zero/zero.sty112
3 files changed, 201 insertions, 0 deletions
diff --git a/macros/latex209/contrib/zero/zero-README b/macros/latex209/contrib/zero/zero-README
new file mode 100644
index 0000000000..f4953db893
--- /dev/null
+++ b/macros/latex209/contrib/zero/zero-README
@@ -0,0 +1,25 @@
+README file accompanying "zero.sty" and "zero-test.tex"
+
+At the Department of Math and CS of Eindhoven Univ of Technology we
+(especially some of the CS people) have developed the habit to start
+numbering at zero. To support this habit, I wrote a LaTeX style file
+"zero.sty" that makes numbering start at zero instead of one, whenever
+appropriate. It is, for instance, not appropriate for things numbered
+with styles other than arabic, such as items in an enumerated
+list at the third level: these are numbered by roman numerals.
+
+The style option "zero" can also be used to make any counter start
+numbering at any other value of your choice. The main implementation
+problem is that some counters are reset by LaTeX whenever some other
+counter steps. For instance, this is the case with subsection
+numbers: the subsection counter gets reset whenever the section
+counter is incremented. The value to which LaTeX resets such a counter
+is "hardwired" into the code in several places. The style option
+"zero" provides a neat solution.
+
+Read the USAGE information included in the LaTeX source code of
+"zero.sty" for more details. Also included is a LaTeX test file
+"zero-test.tex" to show you what the effect is of using option "zero".
+You may want to change some of the options in the test file, for
+instance, removing "a4wide".
+
diff --git a/macros/latex209/contrib/zero/zero-test.tex b/macros/latex209/contrib/zero/zero-test.tex
new file mode 100644
index 0000000000..afc3d58270
--- /dev/null
+++ b/macros/latex209/contrib/zero/zero-test.tex
@@ -0,0 +1,64 @@
+\documentstyle[12pt,a4wide,fleqn,zero]{article}
+
+\title {Test Document for\\ Documentstyle Option {\tt zero}}
+\author {{\em Tom Verhoeff\/}\thanks{Department of Mathematics and
+ Computing Science, Eindhoven University of Technology, NL.}}
+\date {19 June 1991}
+
+\begin{document}
+\maketitle
+
+\part {Verify Initialization and Resetting}
+Text with first footnote\footnote{First footnote in text.}\ldots
+\section {First Section}
+Text with first reference \cite{Dowland}\ldots
+\begin{figure}[h]
+\caption {First figure}
+\end{figure}
+\begin{table}[h]
+\caption {First table}
+\end{table}
+\subsection {First subsection}
+Text\ldots
+\begin{enumerate}
+\item First enumerated item at level i.
+\item
+ \begin{enumerate}
+ \item First enumerated item at level ii.
+ \item
+ \begin{enumerate}
+ \item First enumerated item at level iii.
+ \item
+ \begin{enumerate}
+ \item First enumerated item at level iv.
+ \item Second enumerated item at level iv.
+ \end{enumerate}
+ \end{enumerate}
+ \end{enumerate}
+\end{enumerate}
+\subsubsection {First subsubsection}
+Text\ldots
+\begin{center}
+\fbox{\begin{minipage}{1.5in}
+A minipage with its first footnote\footnote{First footnote in a minipage.}\ldots
+\end{minipage}}
+\end{center}
+\paragraph {First paragraph}
+Text\ldots
+\begin{equation}
+ 1^{st} \mbox{ displayed equation}.
+\end{equation}
+\subparagraph {First subparagraph}
+Text\ldots
+
+\appendix
+\part {First Part in Appendix}
+\section {First Section in Appendix}
+\subsection {First subsection in appendix}
+\subsubsection {First subsubsection in appendix}
+
+\begin{thebibliography}{9}
+\bibitem{Dowland}Iohn Dowland. {\em First Booke of Ayres}. 1597.
+\end{thebibliography}
+
+\end{document}
diff --git a/macros/latex209/contrib/zero/zero.sty b/macros/latex209/contrib/zero/zero.sty
new file mode 100644
index 0000000000..580f9a74bb
--- /dev/null
+++ b/macros/latex209/contrib/zero/zero.sty
@@ -0,0 +1,112 @@
+% LaTeX documentstyle option to start numbering at zero (where appropriate)
+%
+% Tom Verhoeff
+% Department of Mathematics and Computing Science
+% Eindhoven University of Technology
+% The Netherlands
+% E-mail: <wstomv@win.tue.nl>
+%
+\def\filedate{19 June 1991}
+%
+\typeout{Documentstyle option `zero': start numbering at zero. <\filedate>}
+%
+% USAGE
+%
+% Include `zero' in the list of documentstyle options.
+% This initializes all existing counters such that numbering, where appropriate,
+% starts at zero (instead of one). Numbering still starts at one for
+% (i) footnotes on the title page,
+% (ii) parts,
+% (iii) footnotes in minipages,
+% (iv) enumerated lists nested two levels or deeper,
+% since these use a non-arabic numbering format.
+% Furthermore, newly defined counters will be initialized such that numbering
+% starts at zero. When you change the numbering format of a counter to
+% non-arabic, it is advisable to change the initial value to one as well.
+%
+% To change the initial value of counter <cntr> use
+% \initcounter{<cntr>}{<value>}
+% This also resets the counter to its (new) initial value.
+% For example, page numbering can be start at one by \initcounter{page}{1}.
+% N.B. All counters, except page for page numbering, have a value ONE LESS
+% than the next number produced. So to start numbering at one for enumerated
+% lists at the outermost level use \initcounter{enumi}{0}.
+%
+% To reset counter <cntr> to its (current) initial value use
+% \resetcounter{<cntr>}
+%
+% IMPLEMENTATION DETAILS
+%
+% New macros: \initcounter, \resetcounter
+%
+% The macro \initcounter{<cntr>}{<value>} records <value> as the initial
+% value of the numbering counter <cntr>, and resets <cntr>.
+% The initial value of <cntr> is stored in the control sequence \ci@<cntr>.
+% The macro \resetcounter{<cntr>} resets <cntr> to its initial value \ci@<cntr>.
+%
+% The macros \@stpelt, \@definecounter, \usercounter, \pagenumbering,
+% \maketitle, and \@iminipage have been redefined to use \initcounter or
+% \resetcounter.
+%
+% The macro \appendix needs no revision, even though it sets the counters
+% (chapter,) section and subsection to 0. The section counter (cq. chapter
+% counter for report and book) is printed in Alpha and consequently should
+% indeed be reset to 0. The subsection counter (and section counter for
+% report and book) is reset appropriately whenever the section (cq. chapter)
+% counter is stepped. Only if sectioning is done incorrectly,
+% e.g. by starting the appendix with a subsection, then numbering may also
+% be done incorrectly.
+%
+\def\resetcounter#1{\setcounter{#1}{\csname ci@#1\endcsname}}
+\def\initcounter#1#2{% set initial value for counter
+ \global\expandafter\let\csname ci@#1\endcsname#2\relax
+ \resetcounter{#1}}
+\let\@stpelt\resetcounter
+\def\@definecounter#1{%
+ \expandafter\newcount\csname c@#1\endcsname%
+ \initcounter{#1}{\m@ne}%
+ \expandafter\gdef\csname cl@#1\endcsname{}%
+ \@addtoreset{#1}{@ckpt}%
+ \expandafter\gdef\csname p@#1\endcsname{}%
+ \expandafter\gdef\csname the#1\endcsname{\arabic{#1}}}
+\def\usecounter#1{\@nmbrlisttrue\def\@listctr{#1}\resetcounter{#1}}
+\def\pagenumbering#1{\resetcounter{page}%
+ \gdef\thepage{\csname @#1\endcsname\c@page}}
+\let\@ldmaketitle=\maketitle% save old \maketitle macro
+\def\maketitle{%
+ \setcounter{footnote}{0}% because \thanks uses symbolic footnote marks
+ \@ldmaketitle%
+ \resetcounter{footnote}}
+\def\@iminipage[#1]#2{\leavevmode \@pboxswfalse
+ \if #1b\vbox
+ \else \if #1t\vtop
+ \else \ifmmode \vcenter
+ \else \@pboxswtrue $\vcenter
+ \fi
+ \fi
+ \fi\bgroup
+ \hsize #2\textwidth\hsize \columnwidth\hsize
+ \@parboxrestore
+ \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\resetcounter{mpfootnote}
+ \let\@footnotetext\@mpfootnotetext
+ \let\@listdepth\@mplistdepth \@mplistdepth\z@
+ \@minipagerestore\global\@minipagetrue %% \global added 24 May 89
+ \everypar{\global\@minipagefalse\everypar{}}}
+
+%
+% Reinitialize already existing counters to -1 so as to start counting at 0,
+% EXCEPT FOR:
+% * page numbers, because the page count has no lag. Reinitialized at 0.
+% * part numbers, minipage footnote numbers, and enumerated environments
+% nested 2 or deeper, because they do not use the arabic format.
+% Reinitialized at 0.
+%
+{\def\@elt#1{\initcounter{#1}{\m@ne}}\cl@@ckpt}
+\initcounter{page}{\z@}
+\initcounter{part}{\z@}
+\initcounter{mpfootnote}{\z@}
+\initcounter{enumii}{\z@}
+\initcounter{enumiii}{\z@}
+\initcounter{enumiv}{\z@}
+%
+% End of file zero.sty