summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/refman/pagepc.sty
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/latex/contrib/refman/pagepc.sty
Initial commit
Diffstat (limited to 'macros/latex/contrib/refman/pagepc.sty')
-rw-r--r--macros/latex/contrib/refman/pagepc.sty99
1 files changed, 99 insertions, 0 deletions
diff --git a/macros/latex/contrib/refman/pagepc.sty b/macros/latex/contrib/refman/pagepc.sty
new file mode 100644
index 0000000000..e0f2c20895
--- /dev/null
+++ b/macros/latex/contrib/refman/pagepc.sty
@@ -0,0 +1,99 @@
+%%
+%% This is page-per-chapter-package
+%% version 2.0
+%%
+% Copyright 1998 - 99 by Axel Kielhorn
+%
+%% This program can be redistributed and/or modified under the terms
+%% of the LaTeX Project Public License Distributed from CTAN
+%% archives in directory macros/latex/base/lppl.txt; either
+%% version 1 of the License, or any later version.
+%%
+%% Don't use it with repref!
+%% Refrep has these commands already implemented
+%%
+%% This version forces openright!!
+%%
+%% Index-commands should work in chapters and appedices,
+%% they will not work as expected in the preface when the
+%% pagenumbering is not arabic. (MakeIndex can't sort roman-
+%% numbers)
+%%
+%% Bugs:
+%% The index is sortet according to the pagenumber
+%% without looking at the chapternumber.
+%% I don't think MakeIndex could handle that.
+%%
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{pagepc}[1995/05/13]
+
+\@ifundefined{chapter}
+{\PackageError{pagepc}{%
+ You can't number your pages per chapter\MessageBreak when you
+ have no chapters
+ }{%
+ Use ``report'' or ``book'' instead.
+ }
+}%
+{}
+
+%% Reset the pagecounter to 1 at the start of a new chapter
+%%
+\let\ppchapter=\@chapter
+\def\@chapter{\if@pageperchapter\setcounter{page}{1}\fi
+ \ppchapter}
+
+%% Force a pagebreak at the start of the appendix, otherwise
+%% the number of the page right befor the appendix comes
+%% out wrong
+%%
+\let\ppappendix=\appendix
+\def\appendix{\if@pageperchapter\newpage\fi\ppappendix}
+
+\newif\if@pageperchapter \@pageperchapterfalse
+
+%% This command enables Page-per-Chapter, it is not on by
+%% default to allow roman pagenumbers in the preface
+%% (see sample-document)
+%%
+\newcommand{\pageperchapter}
+ {\@pageperchaptertrue
+ \@openrighttrue
+ % Remember old setting for chapter 0 = preface
+ \let\ppthepage=\thepage
+ % The new number needs more space
+ \renewcommand\@pnumwidth{2.55em}
+ % Here it comes :-)
+ \renewcommand\thepage{%
+ \ifnum \c@chapter = \z@
+ \ppthepage
+ \else
+ \thechapter\ -- \arabic{page}
+ \fi
+ }
+ }
+
+%% This is a hack to make MakeIndex happy :-(
+%% You can't use the |-form of an indexentry because
+%% it is used to store the chapternumber.
+%%
+\def\@wrindex#1{%
+ \ifnum \c@chapter = \z@
+ \protected@write\@indexfile{}%
+ {\string\indexentry{#1}{\arabic{page}}}%
+ % The above is wrong if pagenumbering!=arabic,
+ % but I think this is better than nothing.
+ \else
+ \protected@write\@indexfile{}%
+ {\string\indexentry{#1|ppc{\thechapter}}{\arabic{page}}}%
+ \fi
+ \endgroup
+ \@esphack
+}
+
+%% This prints the pagenumber in the index
+%%
+\def\ppc#1#2{#1 -- #2}
+
+\endinput