3 ms·
Part II \newread\XREFileIn % \message{\string\XREFileIn = \the\XREFileIn} \newwrite\XREFileOut % \newcount\SNChapter \newcou
by graycat 10y ago
Part II
\newread\XREFileIn
% \message{\string\XREFileIn = \the\XREFileIn}
\newwrite\XREFileOut
%
\newcount\SNChapter
\newcount\SNUnit
\newcount\SNTable
\newcount\SNFigure
%
\SNChapter=0
\SNTable=0
\SNFigure=0
%
\def\SNChapterPrefix{}
%
\def\TrimTag#1 {#1} % For trimming trailing blanks.
\def\First#1 #2 #3 {#1} % Parsing first token.
\def\Second#1 #2 #3 {#2} % " second "
\def\Third#1 #2 #3 {#3} % " third "
\def\SNUNone{CH UN PG} % Value for tags before there is an XRF file.
\def\SNTNone{TB JUNK PG} % Value for tags before there is an XRF file.
\def\SNFNone{FG JUNK PG} % Value for tags before there is an XRF file.
\def\SNPNone{PT JUNK PG} % Value for tags before there is an XRF file.
%
\def\SNUAdvanceChapter{\advance\SNChapter by1
\SNUnit=0}
%
% Define a 'chapter' tag:
%
% Need a \global on \advance because might have the \SNC from
% within a group, e.g., {\bf \SNC ...}.
%
\def\SNC#1{{\global\SNUnit=0
\write\XREFileOut{\string#1}%
\def\JUNKA{\SNChapterPrefix\the\SNChapter\space JUNK}%
{\edef\JUNKB{\write\XREFileOut{\JUNKA}}\JUNKB}%
\write\XREFileOut{\the\count0}}}%
%
% Define a 'unit' tag:
%
% To be more sure page number is correct, add text to list
% BEFORE writing page number to XRF file. In principle could
% do the same for \SNT and \SNF but from how these are used in
% practice a page number error would be nearly impossible.
%
\def\SNU#1{{\global\advance\SNUnit by1
\write\XREFileOut{\string#1}%
\SNChapterPrefix\the\SNChapter.\the\SNUnit
\def\JUNKA{\SNChapterPrefix\the\SNChapter\space\the\SNUnit}%
{\edef\JUNKB{\write\XREFileOut{\JUNKA}}\JUNKB}%
\write\XREFileOut{\the\count0}}}%
%
% BEGIN Modified at 04:16:31 on Tuesday, December 29th, 2015.
%
% In this collection, we now have a new
% macro
%
% \SNP -- Sequentially Number Pointer
%
% This macro intended for cross
% referencing to a place in text, that
% is not specifically to a 'unit'
% (definition, theorem), table, or
% figure.
%
% In short, can have
%
% Note\SNP{\SNTagCU}
% that, for $a, b \in R$ and
%
% which will define tag \SNTagCU but
% insert nothing into the document.
%
% Then elsewhere can have
%
% Since as on page
% \SNCGetPage{\SNTagCU}
% an inner product is bilinear,
%
% which will insert into the document
% the page number of the page where the
% macro \SNTagCU was defined. Many
% more details below:
%
% The macro \SNP is part of this
% package of cross referencing and
% sequential numbering but does not
% actually 'number' or 'sequentially
% number' anything. We start the name
% of \SNP with 'SN' just to regard
% macro names of the form SNx as
% 'reserved' in own TeX usage.
%
% Then elsewhere in the document, can
% refer to that place by its page
% number, chapter number (apparently
% with its chapter prefix), etc.
%
% E.g., if give a little discussion of,
% say, bilinear, can type, say,
%
% Note\SNP{\SNTagCU}
% that, for $a, b \in R$ and
%
% and that will just 'define' tag
% SNTagCU. Of course the tag SNTagCU
% was likely from running own KEdit
% macro isntag to find the new tag name
% SNTagCU and insert it in the argument
% of the macro \SPP. That is, in KEdit
% we would have line
%
% Note\SNP{}
%
% current, run KEdit macro isntag, and
% get a new tag found an inserted to
% have something like
%
% Note\SNP{\SNTagCU}
%
% Then elsewhere in the document can
% write, say,
%
% Since as on page
% \SNCGetPage{\SNTagCU}
% an inner product is bilinear,
%
% and get the page number of the page
% in the document with
%
% Note\SNP{\SNTagCU}
%
% that is, where tag \SNTagCU was
% defined.
%
% So, the lines
%
% Note\SNP{\SNTagCU}
% that, for $a, b \in R$ and
%
% write to the XRF file the standard
% three lines that would be written by,
% say, macro \SNU. With those three
% lines, the first has the tag
%
% \SNTagCU
%
% the next line has chapter and unit
% and the third line has the page
% number, all for what was the case for
% that part of that page when the macro
% \SNP was run.
%
% Then, macros
%
% \SNUGetChapter\SNTagCU
% \SNUGetUnit\SNTagCU
% \SNUGetPage\SNTagCU
%
% will all work fine to extract the
% data on, respectively, chapter, unit,
% and page and insert it into the
% document. That is, there is no
% reason to have separate macros to
% extract and for macro \SNP.
%
% Really the macro \SNP is just like
% macro \SNU except does not add 1 to
% SNUnit and does not insert into the
% document the chapter prefix, chapter
% number, and unit number. So, where
% macro \SNP is used, nothing is
% inserted into the document; this is
% in contrast with, say, macro \SNU and
% is why need the new macro \SNT
%