summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ednotes/edcntwd0.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-06-21 00:01:18 +0000
committerKarl Berry <karl@freefriends.org>2006-06-21 00:01:18 +0000
commit63e65439abe4d48cf9eeb759a0ceffae275b1417 (patch)
tree382c94cb0265f27690705634e2220c2c9aecf1ce /Master/texmf-dist/tex/latex/ednotes/edcntwd0.sty
parent6f9c09cec9ce9728f48b2cbcab0ce70b5b142741 (diff)
ednotes update
git-svn-id: svn://tug.org/texlive/trunk@1709 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/ednotes/edcntwd0.sty')
-rw-r--r--Master/texmf-dist/tex/latex/ednotes/edcntwd0.sty123
1 files changed, 89 insertions, 34 deletions
diff --git a/Master/texmf-dist/tex/latex/ednotes/edcntwd0.sty b/Master/texmf-dist/tex/latex/ednotes/edcntwd0.sty
index 913a5416588..64ff79827d8 100644
--- a/Master/texmf-dist/tex/latex/ednotes/edcntwd0.sty
+++ b/Master/texmf-dist/tex/latex/ednotes/edcntwd0.sty
@@ -1,8 +1,8 @@
%% EdCntWd0.sty--count word occurrences with ednotes.sty.
-\def\fileversion{0.32} \def\filedate{2005/05/01} %% TODO
+\def\fileversion{0.32a} \def\filedate{2006/06/16} %% TODO
%% Copyright (C) 2004 Uwe L\"uck & Christian Tapp (direction)
-%% 2005 Uwe L\"uck.
+%% 2005 2006 Uwe L\"uck.
%% Munich, http://www.contact-ednotes.sty.de.vu.
%% Current maintainer is Uwe L\"uck.
@@ -55,7 +55,7 @@
% or \let\CWtextscript\textsuperscript .
% 5.) Pagewise/running line numbering: Switching from pagewise to
% running line numbering needs an extra run or deletion of
-% \jobname.aux. So don't be frightened by error message.
+% \jobname.aux. So don't be frightened by an error message.
%% Please send comments via http://www.contact-ednotes.sty.de.vu.
@@ -71,41 +71,64 @@
%%
%% * Main ideas: *
% \countword occurrences write their order (per paragraph) and line
-% numbers into \jobname.aux. With these informations from
-% \jobname.aux, a table is created which assigns line and place
+% numbers into the .aux-file. With these informations from the
+% latter, a table is created which assigns line and place
% numbers to words. A second table re-orders the first one and
% assigns an index to each place number. An index of 0 means that the
% corresponding word appears only once in a line. A higher index
% tells the order in which an occurrence follows others in the line.
% When processed for the lemma tag, \countword realizes its place
% number and, using this, reads the index from the former table and
-% prints or not prints and index accordingly.
+% prints or does not print an index accordingly.
% \RequirePackage{ednotes}[2004/01/04]
%% Does this work for mere version checking?
%% No--had the problem with edtable. See LaTeX bug latex/3730.
-\newcount\c@CW@repword
-% \newcounter{repword} %% Don't need \the...
+% Auxiliaries:
\def\@CW@stepcnt#1{\advance#1\@ne}
\def\@CW@emptylist{\@eltt} %% Need bound for table rows.
-\newcount\c@CW@par
+% \newif\if@CW@firstinpar \global\@CW@firstinpartrue %% !
+
+% \c@CW@par identifies paragraphs which contain \countword.
+% From v0.32a onwards, it is a LaTeX counter in order to
+% work properly with \includeonly
+\newcounter{CW@par} % \newcount\c@CW@par
+
+% \@CW@wordlist is made a list of \countword-arguments in one
+% paragraph, to be written to the .aux .
+\global\let\@CW@wordlist\@empty
+
+% At the first occurrence of \countword in a paragraph,
+% \@CW@makeplaceindex reads the corresponding \@CW@wordlist
+% and transforms it into \@CW@wordlinelist -- if it has been
+% written in the previous run. Whether the latter is the case
+% is recorded by \if@CW@pardef.
+\global\let\@CW@make@placindexlist\@CW@makeplaceindexlist
\newif\if@CW@pardef \global\@CW@pardeffalse
+\global\let\@CW@wordlinelist\@CW@emptylist
+% When there is evidence that there are more occurrences of
+% \countword than in the previous run:
+\def\@CW@missingdata{\G@refundefinedtrue
+ \@EN@warning{Missing data for \string\countword}%
+ \CWtextscript?}
+%% <- TODO: warning when some \countword has been removed!?
-\def\@CW@cntwi{%
- \global\let\@CW@wordlinelist\@CW@emptylist
+\def\@CW@makeplaceindexlist{%
+ \global\let\@CW@make@placeindexlist\relax
+ \stepcounter{CW@par}% % v0.32a
+% \global\@CW@stepcnt\c@CW@par
+ \@ifundefined{CWp\romannumeral\c@CW@par}%
+% {\G@refundefinedtrue \global\@CW@pardeffalse}%
+ {\global\@CW@pardeffalse}%
+ {%
+ \global\@CW@pardeftrue
+% \global\let\@CW@wordlinelist\@CW@emptylist
%% \@CW@wordlinelist is built as a "table", each row being
%% <WORD>\@elt<LINENO>\@elt<PLACENO>\@eltt
%% --and there is an extra leading \@eltt.
%% Latter needed for determining exact matching.
- \global\let\@CW@placeindexlist\@CW@emptylist
-%% \@CW@placeindexlist has, after starting \@eltt, rows of form
-%% <PLACE>\@elt<INDEX>\@eltt .
- \global\@CW@stepcnt\c@CW@par
- \@ifundefined{CWp\romannumeral\c@CW@par}%
- {\G@refundefinedtrue \global\@CW@pardeffalse}%
- {%
- \global\@CW@pardeftrue
+% \global\let\@CW@placeindexlist\@CW@emptylist
\begingroup
\count@\z@ \let\@elt\relax \let\@eltt\relax
\edef\@tempa{\noexpand\@tfor \noexpand\@tempa :=%
@@ -145,6 +168,7 @@
\@tempb}%
%% TODO: empty referring macros after use -> ednotes as well.
\xdef\@CW@numberofwords{\number\count@}%
+%% \@CW@wordlinelist next is transformed into \@CW@placeindexlist:
\loop
% \typeout{WL=\meaning\@CW@wordlinelist}%% TEST
\ifx\@CW@wordlinelist\@CW@emptylist \else
@@ -159,9 +183,13 @@
\endgroup
}%
% \typeout{PI=\meaning\@CW@placeindexlist}%% TEST
- \global\let\countword\@CW@cntwii
- \@CW@cntwii
+% \global\let\countword\@CW@cntwii
+% \@CW@cntwii
}
+%% \@CW@placeindexlist has, after starting \@eltt, rows of form
+%% <PLACE>\@elt<INDEX>\@eltt .
+\global\let\@CW@placeindexlist\@CW@emptylist
+
\def\@CW@takerow\@eltt#1\@elt#2\@elt#3\@eltt#4\@nil{%
\count@\@ne
\g@addto@macro\@CW@placeindexlist{#3\@elt}%
@@ -210,9 +238,13 @@
\ifx\@nnil#1\@nnil \else
\g@addto@macro\@CW@nextwordlinelist{\@eltt#1}\fi}
-\@ifdefinable\countword{\global\let\countword\@CW@cntwi}
+% \c@CW@repword counts occurrences of \countword in a paragraph:
+\newcount\c@CW@repword
-\newcommand*\@CW@cntwii[2][\@nil]{%
+\newcommand*\countword[2][\@nil]{%
+% \newcommand*\@CW@cntwii[2][\@nil]{%
+% \global\@CW@firstinparfalse
+ \@CW@make@placeindexlist
\global\@CW@stepcnt\c@CW@repword
\def\@tempa{#1}%
\ifx\@tempa\@nnil
@@ -225,15 +257,21 @@
\@tempa
#2}
+% \@ifdefinable\countword{\global\let\countword\@CW@cntwi}
+
+% In the lemma tag of the note, \countword behaves as follows.
+\addlemmaexpands{\let\countword\@CW@cntwl
+ \global\c@CW@nrepword\c@CW@repword}
\newcount\c@CW@nrepword
\newcommand*\@CW@cntwl[2][]{%% First argument just gobbled,
%% using place number instead.
#2%
+ \@CW@make@placeindexlist
\if@CW@pardef
\global\@CW@stepcnt\c@CW@nrepword
\ifnum\c@CW@repword>\@CW@numberofwords\relax
- \G@refundefinedtrue
+ \@CW@missingdata
\else
\edef\@tempc{%
\def\noexpand\@tempb####1\noexpand\@eltt
@@ -242,11 +280,17 @@
\@tempc \@elt##2\@eltt##3\@nil{\def\@tempa{##2}}%
\expandafter\@tempb \@CW@placeindexlist \@nil
\if 0\@tempa \else
- \CWtextscript{\if ?\@tempa ?\else \@tempa \fi}%
+% \CWtextscript{\if ?\@tempa ?\else \@tempa \fi}%
+ \if ?\@tempa \@CW@missingdata
+ \else \CWtextscript\@tempa \fi
\fi
\fi
\else
- \CWtextscript?%
+%% \if@CW@pardef and the question marks could have been given up,
+%% since there is already the `undefined references' warning.
+% \if@CW@firstinpar \CWtextscript 1\else \CWtextscript ?\fi
+% \CWtextscript?%
+ \@CW@missingdata
\fi}
\providecommand*\textsubscript[1]{%
%% Cf. LaTeX \textsuperscript: we will be in a note here!
@@ -256,21 +300,24 @@
%% TODO: empty referring macros after use. -> ednotes as well.
-\addlemmaexpands{\let\countword\@CW@cntwl
- \global\c@CW@nrepword\c@CW@repword}
-
-\global\let\@CW@wordlist\@empty
-
+% \CWClosePar writes \@CW@wordlist to the .aux-file and
+% resets the lists and \if@CWpardef:
\newcommand*\CWClosePar{% %% TODO: -> doc.!? Useful?
\ifx\@CW@wordlist\@empty \else
- \immediate\write\@mainaux{%
+% \immediate\write\@mainaux{%
+ \immediate\write\@auxout{%% for \includeonly
\gdef\expandafter\noexpand
\csname CWp\romannumeral\c@CW@par\endcsname
{\@CW@wordlist}}%
\global\let\@CW@wordlist\@empty
\global\c@CW@repword\z@
\fi
- \global\let\countword\@CW@cntwi
+% \global\let\countword\@CW@cntwi
+ \global\let\@CW@placeindexlist\@CW@emptylist
+ \global\let\@CW@make@placeindexlist\@CW@makeplaceindexlist
+ \global\let\@CW@wordlinelist\@CW@emptylist
+ \global\let\@CW@nextwordlinelist\@empty
+% \global\@CW@firstinpartrue
\global\@CW@pardeffalse}
\expandafter\def\expandafter\linenumberpar\expandafter{%
\expandafter\CWClosePar\linenumberpar}
@@ -303,4 +350,12 @@ v0.3b 2005/01/10 Contact via http.
v0.31 2005/02/20 Added \@EN@first.
2005/03/08 Added Copyright 2005.
v0.32 2005/05/01 Replaced \@EN@first by LaTeX's \@car.
-[not sent, not tested]
+ [sent to CTAN, contrary to final line!]
+ 2006/02/25 Typo fix `USAGE' 5.
+ 2006/05/01 \if@CW@firstinpar to avoid spurious `?'.
+ [given to Lekhtman]
+v0.32a /06/07 \c@CW@par with \includeonly.
+ 2006/06/15 replaced \if@CW@firstinpar by
+ \@CW@make@placeindexlist etc.;
+ extended documentation; rearranged code.
+ 2006/06/16 \@CW@missingdata.