From d3cf783af3eef0576a9acb15fb345ac082f53d66 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 19 Nov 2009 18:33:38 +0000 Subject: new latex package pagerange (29oct09) git-svn-id: svn://tug.org/texlive/trunk@16079 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/pagerange/README | 48 +++++++ .../doc/latex/pagerange/pagerange-guide.pdf | Bin 0 -> 52617 bytes .../doc/latex/pagerange/pagerange-guide.tex | 109 +++++++++++++++ .../texmf-dist/tex/latex/pagerange/pagerange.sty | 147 +++++++++++++++++++++ Master/tlpkg/bin/tlpkg-ctan-check | 2 +- Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc | 1 + Master/tlpkg/tlpsrc/pagerange.tlpsrc | 0 7 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 Master/texmf-dist/doc/latex/pagerange/README create mode 100644 Master/texmf-dist/doc/latex/pagerange/pagerange-guide.pdf create mode 100644 Master/texmf-dist/doc/latex/pagerange/pagerange-guide.tex create mode 100644 Master/texmf-dist/tex/latex/pagerange/pagerange.sty create mode 100644 Master/tlpkg/tlpsrc/pagerange.tlpsrc diff --git a/Master/texmf-dist/doc/latex/pagerange/README b/Master/texmf-dist/doc/latex/pagerange/README new file mode 100644 index 00000000000..a13f231a81b --- /dev/null +++ b/Master/texmf-dist/doc/latex/pagerange/README @@ -0,0 +1,48 @@ +% This is file 'pagerange.sty'. % +% % +% When a given page range xx-yy (simple/plain characters) or % +% \pages (command token, eg, \def\pages{xx-yy}) is submitted to the macro % +% \pagerange (eg, \pagerange{xx-yy} or \pagerange\pages), this package % +% splits the range as xx in the macro \pagestart and yy in \pageend. % +% The counter equivalents of these are \prg@cnta and \prg@cntb. % +% The command token (eg, \pages) is fully expanded before the page % +% range is split. % +% % +% If you specify a range consisting of a hyphen (or any tie) but with % +% one or two empty page numbers, the following will happen: % +% 1. a range of the form -34 is taken to mean pages 1 to 34; % +% 2. a range of the form 12- is taken to mean page 12 to last page; % +% 3. a range of the form - (only hyphen) is taken to mean page 1 to % +% last page; % +% % +% An empty or blank page range (ie, containing no argument and no % +% hyphen/tie) is taken to mean range 1-1 or it may prompt a fatal error, % +% depending on whether the boolean 'acceptempty' is true or false % +% (respectively). % +% % +% Page ranges containing more than one hyphen/tie cause fatal error. % +% % +% If the upper limit of the page range is smaller than the lower % +% limit, a fatal error is flagged. % +% % +% The tie between the pages in the pagerange can be any single % +% non-active character; its default is the hyphen '-'. It can be % +% changed in the call to the package (eg, \usepackage[tie=+]{pagerange}) % +% or at any moment through \pagerangeoptions{tie=+}. Of course, active % +% characters can't be used as ties. % +% % +% Because of the need for the last page of the document, at leat 2 % +% runs/passes are needed to obtain the correct last page. % +% % +% This package has been tested with the 'hyperref' package, which % +% redefines the label used by the 'lastpage' package. % +% % +% Copyright (c) 2009 Ahmed Musa (a.musa@rocketmail.com). % +% % +% The LPPL maintenance status of this software is 'author-maintained'. % +% % +% This software is provided 'as it is', without warranty of any kind, % +% either expressed or implied, including, but not limited to, the % +% implied warranties of merchantability and fitness for a particular % +% purpose. % +%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% diff --git a/Master/texmf-dist/doc/latex/pagerange/pagerange-guide.pdf b/Master/texmf-dist/doc/latex/pagerange/pagerange-guide.pdf new file mode 100644 index 00000000000..05d68998c73 Binary files /dev/null and b/Master/texmf-dist/doc/latex/pagerange/pagerange-guide.pdf differ diff --git a/Master/texmf-dist/doc/latex/pagerange/pagerange-guide.tex b/Master/texmf-dist/doc/latex/pagerange/pagerange-guide.tex new file mode 100644 index 00000000000..866709ca404 --- /dev/null +++ b/Master/texmf-dist/doc/latex/pagerange/pagerange-guide.tex @@ -0,0 +1,109 @@ +\documentclass[10pt,a4paper]{article} +\usepackage{lipsum} +\usepackage{shortvrb} +\usepackage{fancyvrb} +\usepackage{parskip} +\usepackage{paralist} +\usepackage[acceptempty,hyperlink]{pagerange} +\usepackage{hyperref} +\hypersetup{colorlinks=true,linkcolor=red,pdfpagemode=UseThumbs, + implicit=true,breaklinks=true,citecolor=purple,pdfview=FitH, + pdfstartview=FitH} +\begin{document} +\MakeShortVerb{\+} +\title{The {\tt pagerange} Package} +\author{Ahmed Musa\\[.5ex]University of Central Lancashire\\ + Preston, United Kingdom\\[1ex]\url{a.musa@rocketmail.com} +} +\maketitle + +\section{Introduction} +This package emerged from my desire to resolve page ranges in the +draftmark+ package, but it may be useful to other \LaTeX{} enthusiasts. + +There is additional user guide in the comments within the package. + +\section{Examples} + +\pagerange{123-456} +\par\medskip\noindent +Pages~\pagestart\space to\space\pageend + +\pagerange{12345-67890} +\par\medskip\noindent +Pages~\pagestart\space to\space\pageend + +\pagerange{123-4567} +\par\medskip\noindent +Pages~\pagestart\space to\space\pageend + +\pagerange{600-601} +\par\medskip\noindent +Pages~\pagestart\space to\space\pageend + +\pagerange{-34} +\par\medskip\noindent +Pages~\pagestart\space to\space\pageend + +\bigskip\noindent +Hyperlinking of last page: +\pagerange{1-} +\par\medskip\noindent +Pages~\pagestart\space to\space\pageend + +\pagerange{-} +\par\medskip\noindent +Pages~\pagestart\space to\space\pageend + +\bigskip\noindent +No hyperlinking of last page: +\pagerangeoptions{hyperlink=false} +\pagerange{1-} +\par\medskip\noindent +Pages~\pagestart\space to\space\pageend + +\pagerange{-} +\par\medskip\noindent +Pages~\pagestart\space to\space\pageend + +\pagerange{123-234} +\par\medskip\noindent +Pages~\pagestart\space to\space\pageend + +\pagerange{} % This logs a warning message or issues fatal error. +\par\medskip\noindent +Page~\pagestart\space to\space\pageend + +%\pagerange{123-456-789} % Uncomment this line to get fatal error. + +%\pagerange{34-12} % Uncomment this line to get fatal error. + +\par\medskip + +\pagerangeoptions{tie=*} +\pagerange{123*234} +\par\noindent +Pages~\pagestart\space to\space\pageend + +\pagerangeoptions{tie=T} +\pagerange{1234T1235} +\par\medskip\noindent +Pages~\pagestart\space to\space\pageend + +\pagerangeoptions{tie=X} +\pagerange{2034X2135} +\par\medskip\noindent +Pages~\pagestart\space to\space\pageend + +\section{To-do} + +\begin{compactenum}[a)] +\item To provide for calls such as in {\tt\string\pagerange\{\string\pageref\{page:label\}-200\}}. +\item Documentation. +\end{compactenum} + +\par\bigskip +\centerline{\rule{.5\hsize}{.4pt}} +\bigskip +\lipsum[1-4] + +\end{document} \ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/pagerange/pagerange.sty b/Master/texmf-dist/tex/latex/pagerange/pagerange.sty new file mode 100644 index 00000000000..a002d738707 --- /dev/null +++ b/Master/texmf-dist/tex/latex/pagerange/pagerange.sty @@ -0,0 +1,147 @@ +%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% This is file 'pagerange.sty'. % +% % +% When a given page range xx-yy (simple/plain characters) or % +% \pages (command token, eg, \def\pages{xx-yy}) is submitted to the macro % +% \pagerange (eg, \pagerange{xx-yy} or \pagerange\pages), this package % +% splits the range as xx in the macro \pagestart and yy in \pageend. % +% The counter equivalents of these are \prg@cnta and \prg@cntb. % +% The command token (eg, \pages) is fully expanded before the page % +% range is split. % +% % +% If you specify a range consisting of a hyphen (or any tie) but with % +% one or two empty page numbers, the following will happen: % +% 1. a range of the form -34 is taken to mean pages 1 to 34; % +% 2. a range of the form 12- is taken to mean page 12 to last page; % +% 3. a range of the form - (only hyphen) is taken to mean page 1 to % +% last page; % +% % +% An empty or blank page range (ie, containing no argument and no % +% hyphen/tie) is taken to mean range 1-1 or it may prompt a fatal error, % +% depending on whether the boolean 'acceptempty' is true or false % +% (respectively). % +% % +% Page ranges containing more than one hyphen/tie cause fatal error. % +% % +% If the upper limit of the page range is smaller than the lower % +% limit, a fatal error is flagged. % +% % +% The tie between the pages in the pagerange can be any single % +% non-active character; its default is the hyphen '-'. It can be % +% changed in the call to the package (eg, \usepackage[tie=+]{pagerange}) % +% or at any moment through \pagerangeoptions{tie=+}. Of course, active % +% characters can't be used as ties. % +% % +% Because of the need for the last page of the document, at leat 2 % +% runs/passes are needed to obtain the correct last page. % +% % +% This package has been tested with the 'hyperref' package, which % +% redefines the label used by the 'lastpage' package. % +% % +% The LPPL maintenance status of this software is 'author-maintained'. % +% % +% This software is provided 'as it is', without warranty of any kind, % +% either expressed or implied, including, but not limited to, the % +% implied warranties of merchantability and fitness for a particular % +% purpose. % +% % +% Copyright (c) 2009 Ahmed Musa (a.musa@rocketmail.com). % +%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + +\ProvidesPackage{pagerange}[2009/05/10 v0.1 Split page ranges intelligently] +\NeedsTeXFormat{LaTeX2e}[1996/12/01] +\def\prg@warn#1{\PackageWarningNoLine{pagerange}{#1}} +\def\prg@err#1{\PackageError{pagerange}{#1}{\@ehc}} +\RequirePackage{lastpage}[1994/06/25] +\RequirePackage{xkeyval}[2008/08/13] +\newcount\orighyphencode\orighyphencode=\the\catcode045\relax +\AtEndOfPackage{\catcode045=\orighyphencode} +\catcode045=12\relax +\define@boolkeys[KV]{pagerange}[prg@]{acceptempty,hyperlink}[true] +\define@cmdkey[KV]{pagerange}[prg@]{tie}[-]{} +\DeclareOptionX*{\prg@warn{Unknown option '\CurrentOption' ignored}} +\ExecuteOptionsX{tie} +\ProcessOptionsX*\relax +\gdef\pagerangeoptions#1{\setkeys[KV]{pagerange}{#1}} +\long\def\prg@forall#1#2\do#3{% + #3{#1}% + \begingroup\expandafter\expandafter\expandafter\endgroup + \ifx\relax#2\relax% + \relax + \else + \prg@forall#2\do{#3} + \fi +} +\begingroup +\catcode`\&=3\relax +\long\gdef\prg@ifblank#1{% adapted from ifmtarg.sty + \i@prg@ifblank#1&&\@secondoftwo\@firstoftwo:} +\long\gdef\i@prg@ifblank#1#2#4#5:{#4} +\endgroup +\long\def\prg@x@ifblank#1{\begingroup + \protected@edef\@tempa{\endgroup\noexpand\prg@ifblank{#1}} + \@tempa +} +\let\pagestart\@empty +\let\pageend\@empty +\newcount\prg@cntx\prg@cntx=\z@\relax +\long\def\prg@split@pagerange#1{% + \def\reserved@a{#1}% + \ifx\reserved@a\prg@tie + \advance\prg@cntx\@ne + \fi + \ifnum\prg@cntx=\z@ + \g@addto@macro\pagestart{#1}% + \else\ifnum\prg@cntx=\@ne + \ifx\reserved@a\prg@tie\else + \g@addto@macro\pageend{#1}% + \fi + \else\ifnum\prg@cntx>\@ne + \prg@err{Multiple ties in page range} + \fi\fi\fi +} +\newcount\prg@cnta\prg@cnta=\z@\relax +\newcount\prg@cntb\prg@cntb=\z@\relax +\def\pagerange#1{% + \let\pagestart\@empty + \let\pageend\@empty + \prg@cntx=\z@\relax + \prg@x@ifblank{#1}{% + \ifprg@acceptempty + \prg@warn{Blank page range supplied:\MessageBreak + I've therefore set the range as 1-1 and continued} + \def\pagestart{1}% + \def\pageend{1}% + \else + \prg@err{Blank page range} + \fi + }{% + \begingroup + \edef\@tempa{\endgroup% + \noexpand\prg@forall#1\noexpand\do{\noexpand\prg@split@pagerange}} + \@tempa + } + \ifx\@empty\pagestart + \ifnum\prg@cntx=\@ne + \def\pagestart{1}% + \fi + \fi + \prg@cnta=\pagestart\relax + \ifx\@empty\pageend + \prg@cntb=100000\relax + \ifnum\prg@cntx=\@ne + \ifprg@hyperlink + \def\pageend{\pageref{LastPage}} + \else + \def\pageend{\pageref*{LastPage}} + \fi + \fi + \else + \prg@cntb=\number\pageend\relax + \fi + \ifnum\prg@cnta>\prg@cntb + \prg@err{Inconsistent page range} + \fi +} + +\endinput \ No newline at end of file diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index f28504e827c..4d110cee3cb 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -183,7 +183,7 @@ my @WorkingTLP = qw( ntgclass ntheorem-vn numname numprint oberdiek ocr-latex octavo ofs ogham oldstyle onlyamsmath opcit ordinalpt orkhun othello outline - pagecont pagenote paper papercdcase papertex + pagecont pagenote pagerange paper papercdcase papertex parallel paresse parrun passivetex patch pauldoc pax pbox pb-diagram pdf-forms-tutorial-de pdf-forms-tutorial-en diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc index d079e90fe2d..ebca2c7407e 100644 --- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc @@ -384,6 +384,7 @@ depend outliner depend overpic depend pagecont depend pagenote +depend pagerange depend paper depend papercdcase depend papertex diff --git a/Master/tlpkg/tlpsrc/pagerange.tlpsrc b/Master/tlpkg/tlpsrc/pagerange.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d -- cgit v1.2.3