diff options
author | Karl Berry <karl@freefriends.org> | 2012-12-15 00:26:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-12-15 00:26:47 +0000 |
commit | 6c2053928d978eb2ece483b2b88ae89d5a5353be (patch) | |
tree | d9077f696001a83dfba0fd69301e372a17b05597 /Master/texmf-dist/source/latex | |
parent | f578adf9b821e3531047240f907fb16c2af2d923 (diff) |
tableof (14dec12)
git-svn-id: svn://tug.org/texlive/trunk@28534 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r-- | Master/texmf-dist/source/latex/tableof/tableof.dtx | 313 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/tableof/tableof.ins | 6 |
2 files changed, 206 insertions, 113 deletions
diff --git a/Master/texmf-dist/source/latex/tableof/tableof.dtx b/Master/texmf-dist/source/latex/tableof/tableof.dtx index aceb5e6123b..2859a225dc5 100644 --- a/Master/texmf-dist/source/latex/tableof/tableof.dtx +++ b/Master/texmf-dist/source/latex/tableof/tableof.dtx @@ -1,9 +1,9 @@ % -*- coding: iso-latin-1; -*- %<*ins> -\def\lasttimestamp{Time-stamp: <06-12-2012 22:11:56 CET jfb>} +\def\lasttimestamp{Time-stamp: <13-12-2012 23:22:46 CET jfb>} \def\pkgname{tableof} -\def\pkgdate{2012/12/06} -\def\pkgversion{v1.0} +\def\pkgdate{2012/12/13} +\def\pkgversion{v1.1} \def\pkgdescription{tables of tagged contents (jfB)} %</ins> %% @@ -11,7 +11,7 @@ %% Copyright (C) 2012 by Jean-Francois Burnol %% %<*none> -\def\docdate{2012/12/06} +\def\docdate{2012/12/13} \def\striptimestamp#1 <#2 #3 #4 #5>{#2 at #3 #4} \edef\dtxtimestamp{\expandafter\striptimestamp\lasttimestamp} \ProvidesFile{\pkgname.dtx} @@ -102,18 +102,32 @@ \documentclass{article} \usepackage[colorlinks,linkcolor=blue]{hyperref} \usepackage{tableof} +%%\usepackage{etoc} \begin{document} -\tofOpenTocFileForWrite +%% \etoctoclines % (from package etoc) +%% +%% we don't need here \tofOpenTocFileForWrite +%% as the document has \tableofcontents a few lines down. \section*{with (and)} \tableof{} -\section*{with (or)} -\tableof*{} +\section*{with (A or B or C or D or E or F)} +\tableof*{A,B,C,D,E,F} \section*{with A (and)} \tableof{A} \section*{with A (or)} \tableof*{A} \section*{with A and with C} \tableof{A,C} +\renewcommand\contentsname{with (A or D) and (without B or without F)} +\nexttocwithtags*{A,D}*{B,F}\tableofcontents +%% requires package etoc +%% (or at least a class or package allowing multiple \tableofcontents): +%% \etoctocstyle{1}{with A and D and without B and without F} +%% \nexttocwithtags{A,D}{B,F}\tableofcontents +%% \etoctocstyle{1}{with (A or D) and without B and without F} +%% \nexttocwithtags*{A,D}{B,F}\tableofcontents +%% \etoctocstyle{1}{with A and D and (without B or without F)} +%% \nexttocwithtags{A,D}*{B,F}\tableofcontents \section*{with B or with C} \tableof*{B,C} \section*{with A and with B and with C} @@ -146,43 +160,45 @@ \section{no tag} nothing \begin{verbatim} -\toftagstart{D,E} +\toftagstart{D,E,F} \toftagthis{A} \end{verbatim} -\toftagstart{D,E} +\toftagstart{D,E,F} \toftagthis{A} -\section{A,D,E} -A,D,E +\section{A,D,E,F} +A,D,E,F \begin{verbatim} \toftagthis{B} \end{verbatim} \toftagthis{B} -\section{B,D,E} -B,D,E +\section{B,D,E,F} +B,D,E,F \begin{verbatim} \toftagthis{C} \end{verbatim} \toftagthis{C} -\section{C,D,E} -C,D,E +\section{C,D,E,F} +C,D,E,F \begin{verbatim} -\toftagstop{E,F} +\toftagstop{F} \toftagthis{A,B} \end{verbatim} -\toftagstop{E,F} +\toftagstop{F} \toftagthis{A,B} -\section{A,B,D} -A,B,D +\section{A,B,D,E} +A,B,D,E \begin{verbatim} \toftagthis{B,C} \end{verbatim} \toftagthis{B,C} -\section{B,C,D} +\section{B,C,D,E} B,C,D \begin{verbatim} \toftagthis{A,C} +\toftagstop{E} \end{verbatim} \toftagthis{A,C} +\toftagstop{E} \section{A,C,D} A,C,D \begin{verbatim} @@ -194,10 +210,10 @@ A,C,D \section{A,B,C} A,B,C \begin{verbatim} -\toftagstop{A,B,C,D,E} +\toftagstop{A,B,C,D,E,F} \toftagstart{kitchenware,rabbits} \end{verbatim} -\toftagstop{A,B,C,D,E} +\toftagstop{A,B,C,D,E,F} \toftagstart{kitchenware,rabbits} \section{Knives and rabbits} \begin{verbatim} @@ -241,6 +257,7 @@ A,B,C \usepackage{txfonts} \usepackage{xspace} \usepackage{color} + \definecolor{joli}{RGB}{225,95,0} \definecolor{JOLI}{RGB}{225,95,0} \definecolor{BLUE}{RGB}{0,0,255} @@ -301,12 +318,17 @@ pdfpagemode=UseOutlines} \end{center} \begin{abstract} - The \tableof package allows to tag the table of contents entries. + The \tableof package allows to tag table of contents entries. - The \csb{tableof}\{{\color{blue}\emph{comma,separated,list,of,tags}}\} command + The command \csb{tableof}\{{\color{blue}\emph{comma,separated,list,of,tags}}\} displays a table of contents containing only the entries having all the listed tags. There is a complementary command \csb{tablenotof}. They may be used multiple times. + + The command + \csb{nexttocwithtags}\{{\color{blue}\emph{required\_tags}}\}\{{\color{blue}\emph{excluded\_tags}}\} + specifies which tags are to be obeyed by the next standard + \cs{tableofcontents} or equivalent command. \end{abstract} @@ -348,12 +370,40 @@ command untags the next entry. \subsection{Impact of the rabbit on global climate} \end{verbatim} +\subsection{\csbhyp{nexttocwithtags}} + +This command is new with version |1.1|. It has two \emph{mandatory} arguments +(possibly empty): the first one is a comma separated list of required tags, the +second one is a comma separated list of excluded tags. The command has no +immediate effect but influences the next \cs{tableofcontents} (or equivalent +command) in the document:\footnote{in documents with a class or package allowing + multiple uses of the command \cs{tableofcontents}, the command + \cs{nexttocwithtags} influences only the next use of \cs{tableofcontents}.} +the TOC will contain only the entries having been tagged with all the required +tags and none of the excluded tags. For example: +\begin{verbatim} +\nexttocwithtags{A,B}{C,D,E} +\tableofcontents +\end{verbatim} +will print only the division units having both tags |A| and |B| and none of |C|, +|D|, or |E|. + +There are starred variants: +\begin{verbatim} +\nexttocwithtags{A,B}{C,D,E} % A and B and neither C nor D nor E +\nexttocwithtags*{A,B}{C,D,E} % (A or B) and neither C nor D nor E +\nexttocwithtags{A,B}*{C,D,E} % A and B and (not C or not D or not E) +\nexttocwithtags*{A,B}*{C,D,E} % (A or B) and (not C or not D or not E) +\end{verbatim} + + \subsection{\csbhyp{tableof}} -This command has a mandatory argument which is a comma separated list of tags. -It displays, exactly as would appear in the table of contents, the corresponding -tagged entries from the |.toc| file. Its title needs to be explicitely set up by -additional code. +\tableof also provides commands to typeset on its own the tagged entries of +the |.toc| file: \cs{tableof} has a mandatory argument which is a comma +separated list of tags. It displays, exactly as would appear in the actual table +of contents, the corresponding tagged entries from the |.toc| file. Its title +needs to be explicitely set up by additional code. \begin{verbatim} \section*{Table of entries tagged with weaponry AND with hunting} \tableof{weaponry,hunting} @@ -378,30 +428,39 @@ There is a starred variant: \section*{Table of entries NOT tagged with weaponry OR NOT tagged with hunting} \tablenotof*{weaponry,hunting} \end{verbatim} +Both \cs{tableof} and \cs{tablenotof} may be used arbitrarily many times +(whether or not the document has somewhere a \cs{tableofcontents}). \subsection{\csbhyp{tofOpenTocFileForWrite}} -The |.toc| file is read into memory (if it exists) by \tableof at the -\cs{usepackage}. But the creation of the |.toc| file is not dealt with by -\tableof itself: either this will be done by a standard \cs{tableofcontents} -command somewhere in the document, or, one may use the package provided command -\cs{tofOpenTocFileForWrite} which does not display anything and just does what -its name indicates. This command can be used also in the preamble.\footnote{Note - to people or packages wanting also to access the |.toc| file: as - happens with the standard \cs{tableofcontents}, the |.toc| file - becomes temporarily empty immediately after \cs{tofOpenTocFileForWrite}.} +The |.toc| file is read (if it exists) into memory by \tableof at the +\cs{usepackage}, for use by \cs{tableof} and \cs{tablenotof}. But the creation +of the |.toc| file is not dealt with by \tableof itself: either this will be +done by a standard \cs{tableofcontents} command somewhere in the document, or, +one may use the package provided command \cs{tofOpenTocFileForWrite} which does +not display anything and just does what its name indicates. This command can be +used also in the preamble.\footnote{Note to people or packages wanting also to + access the |.toc| file: as happens with the standard \cs{tableofcontents}, the + |.toc| file becomes temporarily empty immediately after + \cs{tofOpenTocFileForWrite}.} + +Again: this command should \emph{not} be used when the document has its own +\cs{tableofcontents} or equivalent. \subsection{Compatibility with other packages} -\tableof checks if the package |hyperref| is loaded as it modifies the format -of the |.toc| file lines. This check is done at the \cs{begin}|{document}| so -the order of loading is not important. +\tableof checks if |hyperref| is loaded as |hyperref| modifies the format of the +|.toc| file. This check is done at the \cs{begin}|{document}| so the order +of loading is not important. -\tableof adds the tag data to the |.toc| file, but this data is defined to do -nothing except when it is used by \tableof itself. +\tableof adds the tag data to the |.toc| file, but this data is defined (within +the |.toc| file) to do +nothing. Hence the generated |.toc| file may be imported for use +by other \TeX{} documents.\footnote{this import must do \cs{makeatletter} and + also the new document must use |hyperref| if the original did so.} \subsection{TODO} @@ -410,14 +469,23 @@ this kind of thing must have been done a zillion times already, as it belongs to the basics in computer science! . . . and it surely is no easy task in \TeX{}! so I cautiously retreated from such an endeavor. +\subsection{version history} + +|2012/12/13 v1.1: i.| new command \cs{nexttocwithtags},\\ +| ii.| |.toc| remains usable from other \LaTeX{} source files.\\ +|2012/12/06 v1.0:| initial version. + \section{Generating the package file and the test file} -Running |latex| (or |pdflatex|) on |tableof.dtx| generates:\\ -(1) the package file |tableof.sty| (which should be moved to a suitable -location within the \TeX{} installation), (2) |tableof.ins| for \TeX{} -distributions expecting such a file, (3) |tableoftest.tex| which +Running |latex| (or |pdflatex|) on |tableof.dtx| generates: +{1})~the package file |tableof.sty| (which should be moved to a suitable +location within the \TeX{} installation), +{2})~|tableof.ins| for \TeX{} +distributions expecting such a file, +{3})~|tableoftest.tex| which demonstrates the package features (one should run |latex| twice on it), -and (4) the documentation itself (run |pdflatex| twice to get the +and +{4})~the documentation itself (run |pdflatex| twice to get the bookmarks.) @@ -489,7 +557,8 @@ release. % \end{macrocode} % \begin{macrocode} \IfFileExists{\jobname .toc} - {{\endlinechar=-1 \makeatletter + {{% \endlinechar-1 + \makeatletter \newread\tof@tf \openin\tof@tf\@filef@und \tof@readtoc\tof@tf @@ -497,90 +566,117 @@ release. % \end{macrocode} % \begin{macrocode} \AtBeginDocument{ -\@ifpackageloaded{hyperref} - {\def\tof@gobblethree@orfour#1#2#3#4{}% - \ifx\hyper@last\@undefined\tof@toctoks{}\fi} - {\def\tof@gobblethree@orfour#1#2#3{}}} + \addtocontents{toc}{\string\@ifundefined\string{tof@begin\string}} + \addtocontents{toc}{\string{\let\string\tof@begin\string\relax% + \string\let\string\tof@finish\string\relax% + \string\let\string\tof@starttags\string\@gobble% + \string\let\string\tof@stoptags\string\@gobble% + \string\let\string\tof@tagthis\string\@gobble% + \string\let\string\tof@untagthis\string\@gobble\string}\string{\string}} + \addtocontents{toc}{\string\tof@begin} + \@ifpackageloaded{hyperref} + {\def\tof@gobblethree@orfour#1#2#3#4{}% + \ifx\hyper@last\@undefined\tof@toctoks{}\fi} + {\def\tof@gobblethree@orfour#1#2#3{}}} +\AtEndDocument{\addtocontents{toc}{\string\tof@finish}} +\newcommand\tofOpenTocFileForWrite{% +\expandafter\newwrite \csname tf@toc\endcsname +\immediate \openout \csname tf@toc\endcsname \jobname .toc\relax} % \end{macrocode} % \begin{macrocode} \def\tof@tags{} \def\tof@tags@tmp{} \def\tof@untags@tmp{} -\def\tof@true#1{\expandafter\let\csname if@tof#1.\endcsname\iftrue} -\def\tof@false#1{\expandafter\let\csname if@tof#1.\endcsname\iffalse} -\def\tof@secondiftrue#1{\csname if@tof#1.\endcsname +\def\tof@true#1{\expandafter\let\csname tofsw@#1\endcsname\iftrue} +\def\tof@false#1{\expandafter\let\csname tofsw@#1\endcsname\iffalse} +\def\tof@secondiftrue#1{\csname tofsw@#1\endcsname \let\tof@next\@secondoftwo\fi} -\def\tof@secondiffalse#1{\csname if@tof#1.\endcsname\else +\def\tof@secondiffalse#1{\csname tofsw@#1\endcsname\else \let\tof@next\@secondoftwo\fi} -\def\tof@setflags#1{% - \let\tof@next\@firstoftwo +\def\tof@setflags#1{\let\tof@next\@firstoftwo \@for\@tempa:=#1\do{\tof@true{\@tempa}}% \@for\@tempa:=\tof@tags\do{\tof@false{\@tempa}}% \@for\@tempa:=\tof@tags@tmp\do{\tof@false{\@tempa}}% - \@for\@tempa:=\tof@untags@tmp\do{\tof@true{\@tempa}}% - \def\tof@tags@tmp{}\def\tof@untags@tmp{}} + \@for\@tempa:=\tof@untags@tmp\do{\tof@true{\@tempa}}} +% \end{macrocode} +% \begin{macrocode} +\def\tof@filter#1#2{\ifx#1#2\else + \ifx\tof@tmptags\@empty\edef\tof@tmptags{#2}\else + \edef\tof@tmptags{\tof@tmptags,#2}\fi\fi} +\def\tof@@starttags#1{% + \ifx\tof@tags\@empty\edef\tof@tags{#1}\else + \edef\tof@tags{\tof@tags,#1}\fi} +\def\tof@@stoptags#1{% + \@for\@tempa:=#1\do{\def\tof@tmptags{}% + \@for\@tempb:=\tof@tags\do{\tof@filter\@tempa\@tempb}% + \edef\tof@tags{\tof@tmptags}}} +% \end{macrocode} +% \begin{macrocode} +\def\tof@init#1{% + \def\tof@begin{% + \begingroup + \let\tof@finish\endgroup + \let\tof@savedcontentsline\contentsline + \let\tof@starttags\tof@@starttags + \let\tof@stoptags\tof@@stoptags + \def\tof@tagthis####1{\def\tof@tags@tmp{####1}}% + \def\tof@untagthis####1{\def\tof@untags@tmp{####1}}% + \def\contentsline{#1}}} % \end{macrocode} % \begin{macrocode} \def\tof@and#1{% - \def\contentsline{% - \tof@setflags{#1}% + \tof@init{\tof@setflags{#1}\def\tof@tags@tmp{}\def\tof@untags@tmp{}% \@for\@tempa:=#1\do{\tof@secondiftrue{\@tempa}}% - \tof@next\tof@savedcontentsline\tof@gobblethree@orfour} - \the\tof@toctoks - \endgroup} + \tof@next\tof@savedcontentsline\tof@gobblethree@orfour}% + \the\tof@toctoks} % \end{macrocode} % \begin{macrocode} \def\tof@or#1{% - \def\contentsline{% - \tof@setflags{#1}% + \tof@init{\tof@setflags{#1}\def\tof@tags@tmp{}\def\tof@untags@tmp{}% \@for\@tempa:=#1\do{\tof@secondiffalse{\@tempa}}% - \tof@next\tof@gobblethree@orfour\tof@savedcontentsline} - \the\tof@toctoks - \endgroup} + \tof@next\tof@gobblethree@orfour\tof@savedcontentsline}% + \the\tof@toctoks} % \end{macrocode} % \begin{macrocode} \def\tof@nor#1{% - \def\contentsline{% - \tof@setflags{#1}% + \tof@init{\tof@setflags{#1}\def\tof@tags@tmp{}\def\tof@untags@tmp{}% \@for\@tempa:=#1\do{\tof@secondiffalse{\@tempa}}% - \tof@next\tof@savedcontentsline\tof@gobblethree@orfour} - \the\tof@toctoks - \endgroup} + \tof@next\tof@savedcontentsline\tof@gobblethree@orfour}% + \the\tof@toctoks} % \end{macrocode} % \begin{macrocode} \def\tof@nand#1{% - \def\contentsline{% - \tof@setflags{#1}% + \tof@init{\tof@setflags{#1}\def\tof@tags@tmp{}\def\tof@untags@tmp{}% \@for\@tempa:=#1\do{\tof@secondiftrue{\@tempa}}% - \tof@next\tof@gobblethree@orfour\tof@savedcontentsline} - \the\tof@toctoks - \endgroup} -% \end{macrocode} -% \begin{macrocode} -\def\tof@filter#1#2{\ifx#1#2\else - \ifx\tof@tmptags\@empty\edef\tof@tmptags{#2}\else - \edef\tof@tmptags{\tof@tmptags,#2}\fi\fi} -\def\tof@@start#1{% - \ifx\tof@tags\@empty\edef\tof@tags{#1}\else - \edef\tof@tags{\tof@tags,#1}\fi} -\def\tof@@stop#1{% - \@for\@tempa:=#1\do{\def\tof@tmptags{}% - \@for\@tempb:=\tof@tags\do{\tof@filter\@tempa\@tempb}% - \edef\tof@tags{\tof@tmptags}}} + \tof@next\tof@gobblethree@orfour\tof@savedcontentsline}% + \the\tof@toctoks} % \end{macrocode} % \begin{macrocode} -\let\tof@start\@gobble -\let\tof@stop\@gobble -\let\tof@tagthis\@gobble -\let\tof@untagthis\@gobble -\def\tof@init{\begingroup - \let\tof@savedcontentsline\contentsline - \let\tof@start\tof@@start - \let\tof@stop\tof@@stop - \def\tof@tagthis##1{\def\tof@tags@tmp{##1}}% - \def\tof@untagthis##1{\def\tof@untags@tmp{##1}}} -\newcommand\tableof{\tof@init\@ifstar{\tof@or}{\tof@and}} -\newcommand\tablenotof{\tof@init\@ifstar{\tof@nand}{\tof@nor}} +\newcommand\nexttocwithtags{\@ifstar{\tof@nextof@or}{\tof@nextof@and}} +\def\tof@nextof@or#1{\toks\z@{\tof@setflags{#1}% + \@for\@tempa:=#1\do{\tof@secondiffalse{\@tempa}}% + \tof@next + {\def\tof@tags@tmp{}\def\tof@untags@tmp{}\tof@gobblethree@orfour}}% + \@ifstar{\tof@nextof@nand}{\tof@nextof@nor}} +\def\tof@nextof@and#1{\toks\z@{\tof@setflags{#1}% + \@for\@tempa:=#1\do{\tof@secondiftrue{\@tempa}}% + \tof@next\@secondoftwo\@firstoftwo + {\def\tof@tags@tmp{}\def\tof@untags@tmp{}\tof@gobblethree@orfour}}% + \@ifstar{\tof@nextof@nand}{\tof@nextof@nor}} +\def\tof@nextof@nor#1{% + \toks\z@\expandafter{\the\toks\z@ + {\tof@setflags{#1}\def\tof@tags@tmp{}\def\tof@untags@tmp{}% + \@for\@tempa:=#1\do{\tof@secondiffalse{\@tempa}}% + \tof@next\tof@savedcontentsline\tof@gobblethree@orfour}}% + \expandafter\tof@init\expandafter{\the\toks\z@}} +\def\tof@nextof@nand#1{% + \toks\z@\expandafter{\the\toks\z@ + {\tof@setflags{#1}\def\tof@tags@tmp{}\def\tof@untags@tmp{}% + \@for\@tempa:=#1\do{\tof@secondiftrue{\@tempa}}% + \tof@next\tof@gobblethree@orfour\tof@savedcontentsline}}% + \expandafter\tof@init\expandafter{\the\toks\z@}} +\newcommand\tableof{\@ifstar{\tof@or}{\tof@and}} +\newcommand\tablenotof{\@ifstar{\tof@nand}{\tof@nor}} % \end{macrocode} % \begin{macrocode} \newcommand*\toftagthis[1]{\addtocontents{toc} @@ -588,12 +684,9 @@ release. \newcommand*\tofuntagthis[1]{\addtocontents{toc} {\string\tof@untagthis\string{#1\string}}} \newcommand*\toftagstart[1]{\addtocontents{toc} - {\string\tof@start\string{#1\string}}} + {\string\tof@starttags\string{#1\string}}} \newcommand*\toftagstop[1]{\addtocontents{toc} - {\string\tof@stop\string{#1\string}}} -\newcommand\tofOpenTocFileForWrite{% -\expandafter\newwrite \csname tf@toc\endcsname -\immediate \openout \csname tf@toc\endcsname \jobname .toc\relax} + {\string\tof@stoptags\string{#1\string}}} \endinput % \end{macrocode} % \MakePercentComment @@ -613,7 +706,7 @@ release. Grave accent \` Left brace \{ Vertical bar \| Right brace \} Tilde \~} -\CheckSum{322} +\CheckSum{470} \Finale %% diff --git a/Master/texmf-dist/source/latex/tableof/tableof.ins b/Master/texmf-dist/source/latex/tableof/tableof.ins index c27a0dd83ba..e90980bc7e1 100644 --- a/Master/texmf-dist/source/latex/tableof/tableof.ins +++ b/Master/texmf-dist/source/latex/tableof/tableof.ins @@ -1,7 +1,7 @@ -\def\lasttimestamp{Time-stamp: <06-12-2012 22:11:56 CET jfb>} +\def\lasttimestamp{Time-stamp: <13-12-2012 23:22:46 CET jfb>} \def\pkgname{tableof} -\def\pkgdate{2012/12/06} -\def\pkgversion{v1.0} +\def\pkgdate{2012/12/13} +\def\pkgversion{v1.1} \def\pkgdescription{tables of tagged contents (jfB)} %% %% Package `tableof' by Jean-Francois Burnol |