ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* feature request: \everytrypass
@ 2006-04-20 10:49 Vit Zyka
  2006-04-20 11:01 ` Peter Rolf
  2006-04-20 21:55 ` Hans Hagen
  0 siblings, 2 replies; 5+ messages in thread
From: Vit Zyka @ 2006-04-20 10:49 UTC (permalink / raw)


Dear ConTeXters,

I am counting occurence of some macro in the text. Problem is when this 
macro is inside \bTABLE (and may be somewhere else). Due to try passes 
the increment is counter is incremented more then once and the result is 
multiplied.

It is possible to implement some \everytrypass in which user can (e.g.) 
null incrementing? Or there is some another solution?

Thanks
Vit

Minimal example:
-----------------------------------------------
\newcount\C
\def\doIncrement{\global\advance\C by1\relax}

% \def\nullIncrement{\let\doIncrement\relax}
% \appendtoks \nullIncrement to \everytrypass

\starttext
   \bTABLE
     \bTR\bTD Counter\doIncrement\eTD\eTR
   \eTABLE
   \message{ <<Counter=\the\C>> }%
\stoptext
------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: feature request: \everytrypass
  2006-04-20 10:49 feature request: \everytrypass Vit Zyka
@ 2006-04-20 11:01 ` Peter Rolf
  2006-04-21 12:57   ` Vit Zyka
  2006-04-20 21:55 ` Hans Hagen
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Rolf @ 2006-04-20 11:01 UTC (permalink / raw)


Vit Zyka wrote:
> Dear ConTeXters,
> 
> I am counting occurence of some macro in the text. Problem is when this 
> macro is inside \bTABLE (and may be somewhere else). Due to try passes 
> the increment is counter is incremented more then once and the result is 
> multiplied.
> 
> It is possible to implement some \everytrypass in which user can (e.g.) 
> null incrementing? Or there is some another solution?
> 
> Thanks
> Vit
> 
> Minimal example:
> -----------------------------------------------
> \newcount\C
> \def\doIncrement{\global\advance\C by1\relax}

\def\doIncrement{\iftrialtypesetting
  \else\global\advance\C by1\relax\fi}%

donno if this works correctly inside a TABLE...


Greets, Peter

> 
> % \def\nullIncrement{\let\doIncrement\relax}
> % \appendtoks \nullIncrement to \everytrypass
> 
> \starttext
>    \bTABLE
>      \bTR\bTD Counter\doIncrement\eTD\eTR
>    \eTABLE
>    \message{ <<Counter=\the\C>> }%
> \stoptext
> ------------------------------------------------
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: feature request: \everytrypass
  2006-04-20 10:49 feature request: \everytrypass Vit Zyka
  2006-04-20 11:01 ` Peter Rolf
@ 2006-04-20 21:55 ` Hans Hagen
  1 sibling, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2006-04-20 21:55 UTC (permalink / raw)


Vit Zyka wrote:
> Dear ConTeXters,
>
> I am counting occurence of some macro in the text. Problem is when this 
> macro is inside \bTABLE (and may be somewhere else). Due to try passes 
> the increment is counter is incremented more then once and the result is 
> multiplied.
>   
\iftrialtypesetting ... \else ... \fi

> It is possible to implement some \everytrypass in which user can (e.g.) 
> null incrementing? Or there is some another solution?
>
> Thanks
> Vit
>
> Minimal example:
> -----------------------------------------------
> \newcount\C
> \def\doIncrement{\global\advance\C by1\relax}
>
> % \def\nullIncrement{\let\doIncrement\relax}
> % \appendtoks \nullIncrement to \everytrypass
>
> \starttext
>    \bTABLE
>      \bTR\bTD Counter\doIncrement\eTD\eTR
>    \eTABLE
>    \message{ <<Counter=\the\C>> }%
> \stoptext
> ------------------------------------------------
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>   


-- 

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: feature request: \everytrypass
  2006-04-20 11:01 ` Peter Rolf
@ 2006-04-21 12:57   ` Vit Zyka
  2006-04-21 20:06     ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Vit Zyka @ 2006-04-21 12:57 UTC (permalink / raw)


Peter Rolf wrote:
> Vit Zyka wrote:
>> Dear ConTeXters,
>>
>> I am counting occurence of some macro in the text. Problem is when this 
>> macro is inside \bTABLE (and may be somewhere else). Due to try passes 
>> the increment is counter is incremented more then once and the result is 
>> multiplied.
>>
>> It is possible to implement some \everytrypass in which user can (e.g.) 
>> null incrementing? Or there is some another solution?
>>
>> Thanks
>> Vit
>>
>> Minimal example:
>> -----------------------------------------------
>> \newcount\C
>> \def\doIncrement{\global\advance\C by1\relax}
> 
> \def\doIncrement{\iftrialtypesetting
>   \else\global\advance\C by1\relax\fi}%
> 
> donno if this works correctly inside a TABLE...

Oh, it is already done! ... How I was able to think in opposite...
Seems it works correctly in TABLE.

... but there is (at least) two \trialtypesettingtrue missing in caption 
composition. Bellow is the patch (see VZ comment marks).

Thanks Peter
Vit

--------------------------------------------------
\def\dopreparestackcaptionaut#1#2#3#4%
   {\doifsomething\@@kjkjalign
      {\ExpandBothAfter\doifnotinset\v!middle\@@kjkjalign
         {\let\captionovershoot\!!zeropoint}}%
    \edef\captionhsize{\the\wd\tempfloatbox}%
    \ifdim\captionhsize>\hsize
      % float is wider than \hsize
      \dosetraggedvbox\@@kjkjalign
      \setbox\scratchbox\raggedbox % trial run
        {\hsize\captionhsize
         \trialtypesettingtrue % VZ
         \notesenabledfalse
         \putcompletecaption{#4}{#2}{#3}{0}}%
      \ifdim\ht\scratchbox>\lineheight % more lines
        \dosetraggedvbox\@@kjkjalign
        \setbox\tempcaptionbox\raggedbox
          {\hsize\captionhsize
           \advance\hsize -\captionovershoot\relax
           \ifdim\hsize<\captionminwidth\relax
             \hsize\captionhsize
           \fi
           \putcompletecaption{#4}{#2}{#3}{0}}%
      \else
        \setbox\tempcaptionbox\raggedbox
          {\hsize\captionhsize
           \putcompletecaption{#4}{#2}{#3}{0}}%
      \fi
    \else
      % float is smaller of equal to \hsize
      \ifdim\captionhsize<\captionminwidth\relax
        \scratchdimen\captionminwidth % float smaller than min width
        \edef\captionhsize{\the\scratchdimen}%
      \fi
      \setbox\scratchbox\vbox     % test with overshoot
        {\scratchdimen\captionhsize
         \trialtypesettingtrue % VZ
         \advance\scratchdimen \captionovershoot
         \advance\scratchdimen 3em % an average word length
         \ifdim\scratchdimen<\hsize \hsize\scratchdimen \fi
         \notesenabledfalse
         \putcompletecaption{#4}{#2}{#3}{0}}%
      \ifdim\ht\scratchbox>\lineheight
        % at least an average word longer than a line
        \dosetraggedvbox\@@kjkjalign
        \setbox\tempcaptionbox\raggedbox
          {\scratchdimen\captionhsize
           \advance\scratchdimen \captionovershoot
           \ifdim\scratchdimen<\hsize \hsize\scratchdimen \fi
           \putcompletecaption{#4}{#2}{#3}{0}}%
      \else
        % just over a line, don't use an overshoot
 
\expanded{\doifcommonelse{\@@kjkjalign}}{\v!left,\v!right,\v!flushleft,\v!flushright}
          {\dosetraggedvbox\@@kjkjalign
           \setbox\tempcaptionbox\raggedbox
             {\hsize\captionhsize
              % strange : \raggedcenter
              \putcompletecaption{#4}{#2}{#3}{0}}}
          {% nicer
           \setbox\tempcaptionbox\cbox
             {\hsize\captionhsize
              \putcompletecaption{#4}{#2}{#3}{0}}}%
      \fi
    \fi}
------------------------------------------------------------
> 
> Greets, Peter
> 
>> % \def\nullIncrement{\let\doIncrement\relax}
>> % \appendtoks \nullIncrement to \everytrypass
>>
>> \starttext
>>    \bTABLE
>>      \bTR\bTD Counter\doIncrement\eTD\eTR
>>    \eTABLE
>>    \message{ <<Counter=\the\C>> }%
>> \stoptext
>> ------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: feature request: \everytrypass
  2006-04-21 12:57   ` Vit Zyka
@ 2006-04-21 20:06     ` Hans Hagen
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2006-04-21 20:06 UTC (permalink / raw)


Vit Zyka wrote:
>
> Oh, it is already done! ... How I was able to think in opposite...
> Seems it works correctly in TABLE.
>
> ... but there is (at least) two \trialtypesettingtrue missing in caption 
> composition. Bellow is the patch (see VZ comment marks).
>   
ok, patched 

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-04-21 20:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-20 10:49 feature request: \everytrypass Vit Zyka
2006-04-20 11:01 ` Peter Rolf
2006-04-21 12:57   ` Vit Zyka
2006-04-21 20:06     ` Hans Hagen
2006-04-20 21:55 ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).