%%
%% This is file `tableof.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tableof.dtx  (with options: `package')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from tableof.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file tableof.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%%
\ProvidesPackage{tableof}
 [2021/07/05 v1.4c Tables of tagged contents (JFB)]
%%
%% Package: tableof
%% Version: 1.4c (2021/07/05)
%% License: LPPL 1.3c
%% Copyright (C) 2012, 2013, 2015, 2018, 2021 Jean-Francois Burnol <jfbu at free dot fr>
%%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{atveryend}
\DeclareOption*{\PackageWarning{tableof}{Option `\CurrentOption' is unknown.}}
\ProcessOptions\relax
\newtoks\tof@toctoks
\def\tof@readtoc {%
  \ifeof\tof@tf
  \else
     \read\tof@tf to \tof@buffer
     \tof@toctoks\expandafter\expandafter\expandafter
       {\expandafter\the\expandafter\tof@toctoks\tof@buffer}%
     \expandafter\tof@readtoc
  \fi }
\AtBeginDocument{\IfFileExists{\jobname.toc}
    {{\endlinechar\m@ne
        \makeatletter
        \newread\tof@tf
        \openin\tof@tf\@filef@und
        \tof@toctoks{\tof@begingroup}%
        \tof@readtoc
        \global\tof@toctoks=\expandafter{\the\tof@toctoks\tof@endgroup}%
        \closein\tof@tf}}{}}
\AtBeginDocument{
    \addtocontents{toc}{\string\@ifundefined{tof@begin}%
       {\global\let\string\tof@begin\relax
        \global\let\string\tof@finish\string\@empty
        \global\let\string\tof@starttags\string\@gobble
        \global\let\string\tof@stoptags\string\@gobble
        \global\let\string\tof@tagthis\string\@gobble
        \global\let\string\tof@untagthis\string\@gobble}\relax}
    \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{}}}
\AfterLastShipout
    {\immediate\write\@auxout{\string\@writefile{toc}{\string\tof@finish}}}
\let\tof@global     \@empty
\let\tof@begingroup \begingroup
\let\tof@endgroup   \endgroup
\def\tof@@finish   {\tof@global\let\contentsline\tof@savedcontentsline
                    \global\let\tof@begin\relax
                    \global\let\tof@tags\@empty }
\def\tof@@tagthis   #1{\def\tof@tags@tmp{#1}}
\def\tof@@untagthis #1{\def\tof@untags@tmp{#1}}
\def\tof@init#1{%
    \def\tof@begin{%
        \tof@global\let\tof@tagthis  \tof@@tagthis
        \tof@global\let\tof@untagthis\tof@@untagthis
        \tof@global\let\tof@starttags\tof@@starttags
        \tof@global\let\tof@stoptags \tof@@stoptags
        \tof@global\let\tof@finish   \tof@@finish
        \tof@global\let\tof@savedcontentsline\contentsline
        \tof@global\def\contentsline {#1}}}
\newcommand\tofOpenTocFileForWrite{%
  \if@filesw
   \newwrite \tf@toc
   \immediate \openout \tf@toc \jobname.toc\relax
  \fi}
\let\tof@tags      \@empty
\let\tof@tags@tmp  \@empty
\let\tof@untags@tmp\@empty
\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 tofsw@#1\endcsname\else\let\tof@next\@secondoftwo\fi}
\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@filter#1#2{\ifx#1#2\else
    \ifx\tof@tmptags\@empty
         \expandafter\def\expandafter\tof@tmptags\expandafter{#2}%
    \else
         \expandafter\expandafter\expandafter\def
         \expandafter\expandafter\expandafter\tof@tmptags
         \expandafter\expandafter\expandafter{\expandafter
         \tof@tmptags\expandafter,#2}%
    \fi\fi}
\def\tof@@starttags#1{%
    \ifx\tof@tags\@empty
      \tof@global\def\tof@tags{#1}%
    \else
      \tof@global
      \expandafter\def\expandafter\tof@tags\expandafter{\tof@tags,#1}%
    \fi }
\def\tof@@stoptags#1{%
    \@for\@tempa:=#1\do{%
          \def\tof@tmptags{}%
          \@for\@tempb:=\tof@tags\do{\tof@filter\@tempa\@tempb}%
          \tof@global
          \expandafter\def\expandafter\tof@tags\expandafter{\tof@tmptags}%
         }%
    }
\def\tof@zapspaces #1 #2{#1#2\tof@zapspaces }%
\def\tof@cleanspaces #1#2{\edef\tof@tmp {{\tof@zapspaces #2 \@gobble}}%
    \expandafter #1\tof@tmp }
\def\tof@and  #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 }
\def\tof@or   #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 }
\def\tof@nor  #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 }
\def\tof@nand #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 }
\newcommand*\tableof{\@ifstar{\tof@cleanspaces\tof@or}
                             {\tof@cleanspaces\tof@and}}
\newcommand*\tablenotof{\@ifstar{\tof@cleanspaces\tof@nand}
                                {\tof@cleanspaces\tof@nor}}
\def\tof@nextof@or #1{\toks@{\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@cleanspaces\tof@nextof@nand}
                {\tof@cleanspaces\tof@nextof@nor}}
\def\tof@nextof@and #1{\toks@{\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@cleanspaces\tof@nextof@nand}
                {\tof@cleanspaces\tof@nextof@nor}}
\def\tof@nextof@nor #1{%
       \toks@\expandafter{\the\toks@
             {\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@}%
       \tof@printtoc }
\def\tof@nextof@nand #1{%
       \toks@\expandafter{\the\toks@
             {\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@}%
       \tof@printtoc }
\newcommand*{\nexttocwithtags}{\let\tof@printtoc\relax
             \@ifstar{\tof@cleanspaces\tof@nextof@or}
                     {\tof@cleanspaces\tof@nextof@and}}
\newcommand*{\tableoftaggedcontents}{\def\tof@printtoc{\the\tof@toctoks}%
             \@ifstar{\tof@cleanspaces\tof@nextof@or}
                     {\tof@cleanspaces\tof@nextof@and}}
\newcommand*\toftagthis[1]
  {\addtocontents{toc}{\string\tof@tagthis  {\tof@zapspaces #1 \@gobble }}}
\newcommand*\tofuntagthis[1]
  {\addtocontents{toc}{\string\tof@untagthis{\tof@zapspaces #1 \@gobble }}}
\newcommand*\toftagstart[1]
  {\addtocontents{toc}{\string\tof@starttags{\tof@zapspaces #1 \@gobble }}}
\newcommand*\toftagstop[1]
  {\addtocontents{toc}{\string\tof@stoptags {\tof@zapspaces #1 \@gobble }}}
\endinput
%%
%% End of file `tableof.sty'.
