Re: [dev-context] Fix for Footnote Reference problem

2007-01-25 Thread Mike Bird
On Thursday 25 January 2007 00:35, Taco Hoekwater wrote:
 Hans and I have been looking at your patch, but unfortunately it
 can not be incorporated in the distribution as-is. The problem is
 that some references need to be written inside the output routine,
 that being the only place were the actual page number is known.
 Think about references in floats, for example.

 The bit of code you have modified is unlikely to change soon, so
 you could probably keep using your local patches (or better:
 redefinitions of the macros within cont-loc.tex) without much
 problems.

I wonder whether it would be beneficial to include all of the patches
except the immediate write?  That would appear to solve most problems
except some cases of \somewhere to a reference on the same page.  Most
\somewhere's refer to distant references.  Fixing the off-by-one and
off-by-a-factor-of-two errors would help enormously.

Is there a way to make the immediate write conditional on not floating?

 Hans proposed that a definitive solution would be to always add
 position information to the references, but that will take a fair
 bit of work, so it is on a todo, but not quite now list.

Absolutely.

--Mike Bird
___
dev-context mailing list
dev-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/dev-context


Re: [dev-context] Fix for Footnote Reference problem

2007-01-21 Thread Taco Hoekwater

Hi Mike,


Mike Bird wrote:
 Here are a number of repaired functions (and one repaired variable)
 which together fix the problem of footnote references getting out
 of step between phases resulting in bogus results from \somewhere.

Do you happen to have these changes as a diff file or a patched
core-not.tex, by any chance? I want to compare stuff, and either
of those formats would be a bit easier on me.

Best wishes, Taco
___
dev-context mailing list
dev-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/dev-context


Re: [dev-context] Fix for Footnote Reference problem

2007-01-21 Thread Mike Bird
Hi Taco,

On Saturday 20 January 2007 21:51, Mike Bird wrote:
 The only downside that I have noticed is that two column footnotes
 are now less well balanced.

This was caused by a typo.  I had accidently removed the newline
after '% experiment' which had the effect or disabling the
'\penalty\notepenalty' on the next line.

On Sunday 21 January 2007 01:53, Taco Hoekwater wrote:
 Do you happen to have these changes as a diff file or a patched
 core-not.tex, by any chance? I want to compare stuff, and either
 of those formats would be a bit easier on me.

Attached now is a diff against the original ConTeXt 2007-01-12
and with the afore-mentioned typo corrected.

--Mike Bird
--- /usr/share/texmf/tex/context/base/core-not.tex	2007-01-01 14:50:15.0 -0800
+++ core-not.tex	2007-01-21 10:30:30.0 -0800
@@ -677,7 +677,7 @@
   {\rawreference\s!fnt{\s!fnt:f:\internalfootreference}{}}
 
 \def\footnotereferenceto
-  {\global\advance\crossreferencenumber\minusone\relax % else problem, needs further testing
+  {%\global\advance\crossreferencenumber\minusone\relax % else problem, needs further testing
\rawreference\s!fnt{\s!fnt:t:\internalfootreference}{}}
 
 \def\dostartnote% nog gobble als in pagebody
@@ -715,12 +715,12 @@
 {\gotobox{\noteparameter\c!command % was \c!numbercommand, but compatible
{\preparednumber\domovednote\v!nextpage\v!previouspage}}%
[\s!fnt:f:\internalfootreference]}%
-\fi
-\doifelse{\noteparameter\c!interaction}\v!no
-  {\ifconditional\pagewisenotes
- \footnotereferenceto
-   \fi}%
-  {\footnotereferenceto}}%
+\fi}%
+ \doifelse{\noteparameter\c!interaction}\v!no
+   {\ifconditional\pagewisenotes
+  \footnotereferenceto
+\fi}%
+   {\footnotereferenceto}%
  \bgroup
  \postponenotes
  \aftergroup\dostopnote
--- /usr/share/texmf/tex/context/base/core-ref.tex	2006-11-08 15:11:54.0 -0800
+++ core-ref.tex	2007-01-21 10:24:42.0 -0800
@@ -282,7 +282,7 @@
 %D references, later we will see for what purpose, we maintain
 %D a counter.
 
-\newcount\crossreferencenumber \crossreferencenumber=1
+\newcount\crossreferencenumber \crossreferencenumber=0
 
 \def\writereference#1#2#3#4%
   {\ifreferencing
@@ -317,7 +317,7 @@
 %{\writeutilitycommand
 %   {\mainreference{\referenceprefix}{\lastreference}{#4}{#5}{#6}}}%
 %  \dododowritereference
- \expanded{\writeutilitycommand{\noexpand\mainreference{\referenceprefix}{\lastreference}{#4}{#5}{#6}}}%
+ \expanded{\immediatewriteutilitycommand{\noexpand\mainreference{\referenceprefix}{\lastreference}{#4}{#5}{#6}}}%
\fi
\egroup}
 
@@ -620,10 +620,10 @@
  \fi
  \edef\currentrealreference{#3}%
  \settextreferences#4\end
- \ifnum0#5\crossreferencenumber
-   \forwardreferencetrue
- \else
+ \ifnum0#5\crossreferencenumber
\forwardreferencefalse
+ \else
+   \forwardreferencetrue
  \fi
\else
  \let \currentlocationreference\empty
___
dev-context mailing list
dev-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/dev-context


[dev-context] Fix for Footnote Reference problem

2007-01-20 Thread Mike Bird
Here are a number of repaired functions (and one repaired variable)
which together fix the problem of footnote references getting out
of step between phases resulting in bogus results from \somewhere.

The repairs were made in ConTeXt 2007-01-12.  Each repaired function
is preceded by a comment explaining the reason for the repair.

The repaired functions are followed by a test which generates three
pages of output covering many test cases.

Additionally, I have tested these repairs on a 50 page document with
185 footnotes.  All of the \somewhere's were fixed by these repairs.

The only downside that I have noticed is that two column footnotes
are now less well balanced.  If anyone has any thoughts as to why
this might be happening or how to fix it please let me know.  I'm
just a few days from deadline!

Thanks,

--Mike Bird
\unprotect

% \footnotereferenceto in core-not.tex
% Remove the decrement which hides the problem within a page but breaks
% references in subsequent pages.

\def\footnotereferenceto
  {%\global\advance\crossreferencenumber\minusone\relax % else problem, needs further testing
   \rawreference\s!fnt{\s!fnt:t:\internalfootreference}{}}

% \dostartnote in core-note.tex
% The first thing after \startpushnote is expanded twice, which is not
% good when it generates two calls to \footnotereferenceto.

\def\dostartnote% nog gobble als in pagebody
  {\bgroup
   \settrue\processingnote
  %\restorecatcodes % to be tested first
   \iftypesettinglines % otherwise problems with \type crlf {xxx}
 \ignorelines % makes footnotes work in \startlines ... \stoplines
   \fi
   \ifnotesymbol
 \dolastnotesymbol
   \else
 \unskip\unskip
 \globallet\lastnotesymbol\dolastnotesymbol
   \fi
   \startlocalnoteinsert
 \doif{\noteparameter\c!scope}\v!page{\floatingpenalty\maxdimen}% experiment \penalty\notepenalty
 \forgetall
 \setnotebodyfont
 \redoconvertfont % to undo \undo calls in in headings etc
 \splittopskip\strutht  % not actually needed here
 \splitmaxdepth\strutdp % not actually needed here
 \leftmargindistance\noteparameter\c!margindistance
 \rightmargindistance\leftmargindistance
 \ifnum\noteparameter\c!n=\zerocount % no ifcase new 31-07-99 ; always ?
   \doifnotinset{\noteparameter\c!width}{\v!fit,\v!broad}\setnotehsize
 \fi
 \startpushnote
   {\ifx\lastnotenumber\empty \else
  \preparefullnumber{\??vn\currentnote}\lastnotenumber\preparednumber
  \doifelse{\noteparameter\c!interaction}\v!no
{\noteparameter\c!numbercommand
   {\preparednumber\domovednote\v!nextpage\v!previouspage}}%
{\gotobox{\noteparameter\c!command % was \c!numbercommand, but compatible
   {\preparednumber\domovednote\v!nextpage\v!previouspage}}%
   [\s!fnt:f:\internalfootreference]}%
\fi}%
 \doifelse{\noteparameter\c!interaction}\v!no
   {\ifconditional\pagewisenotes
  \footnotereferenceto
\fi}%
   {\footnotereferenceto}%
 \bgroup
 \postponenotes
 \aftergroup\dostopnote
 \begstrut
 \let\next}

% \dodowritereference in core-ref.tex
% Needs immediate write to prevent refs getting out of order

\def\dodowritereference#1#2#3\end#4#5#6%
  {\bgroup
   \global\advance\crossreferencenumber \plusone\relax
   \if#1-\if#2:%
 \let\referenceprefix\empty
 \xdef\lastreference{#3}%
   \else
 % \xdef\lastreference{#1#2#3}% here we loose the space
   \fi\else
 % \xdef\lastreference{#1#2#3}% here we loose the space
   \fi
   \ifx\lastreference\empty \else
 \doiffirstreferenceoccurance\lastreference
   {\thisisdestination{\referenceprefix\lastreference}}%
 \referenceinfo\lastreference
%  \edef\dododowritereference
%{\writeutilitycommand
%   {\mainreference{\referenceprefix}{\lastreference}{#4}{#5}{#6}}}%
%  \dododowritereference
 \expanded{\immediatewriteutilitycommand{\noexpand\mainreference{\referenceprefix}{\lastreference}{#4}{#5}{#6}}}%
   \fi
   \egroup}

% \crossreferencenumber in core-ref.tex
% Should be initalised to zero, not one.

\newcount\crossreferencenumber \crossreferencenumber=0

% \dogetreferenceelements in core-ref.tex
% Fix the case where we reference the current reference

\def\dogetreferenceelements#1#2#3#4#5%
  {\chardef\currentreferencetype=\ifx#1\relax0\else#1\fi\relax
   \ifnum\currentreferencetype\plustwo
 \edef\currentpagereference{#2}%
 \let \currentdatareference\empty
 \edef\currentlocationreference{#2}%
 \ifx\currentpagereference   \empty
   \let\currentfolioreference\folio
 \else
   \def \currentpagereference {\referencepagenumber[#2]}%
   \edef\currentfolioreference{\dosplitofffoliopart[#2]}%
 \fi
 \edef\currentrealreference{#3}%
 \settextreferences#4\end
 \ifnum0#5\crossreferencenumber
   \forwardreferencefalse
 \else
   \forwardreferencetrue
 \fi
   \else
 \let \currentlocationreference\empty