[NTG-context] figurenumbering

Wolfgang Schuster schuster.wolfgang at googlemail.com
Thu Oct 5 12:35:11 CEST 2006


2006/10/2, Wolfgang Werners-Lucchini <wwl at musensturm.de>:
>
> > This was your example (not exactly the same) you posted as your
> > first example file and works now as expected.
>
> Ahh! I should implement my own testsuit.
>
> Wolfgang


Hi Wolfgang

you should not only make a testsuit.

It is normaly better to work with highlevel macros in your document to
easily
replace the macrodefinition than replacing the macros in your document.

I made a first step for your document.

<example>

\unprotect

% increment the floatnumber

\def\incrementfloatnumber%
 {\dodoubleempty\doincrementfloatnumber}

\def\doincrementfloatnumber[#1][#2]%
 {\ifsecondargument
    \dodoincrementfloatnumber[#1][#2]%
  \else\iffirstargument
    \dodoincrementfloatnumber[#1][1]%
  \fi\fi}

\def\dodoincrementfloatnumber[#1][#2]%
  {\count1=0
   \loop
   \ifnum\count1<#2
     \advance\count1 by 1
     \incrementnumber[#1]
   \repeat}

% set the number

\def\setfloatnumber%
 {\dodoubleempty\dosetfloatnumber}

\def\dosetfloatnumber[#1][#2]%
  {\ifnum#2<\rawnumber[#1]
     \message{:::: Your number need to be higher than the current
counter-value ::::}
   \else
     \count2=#2
     \advance\count2 by -\rawnumber[#1]
     \incrementfloatnumber[#1][\count2]
   \fi}

% Todo:
%
% \definefloatnumber[#1]
%
% example:
% \definefloatnumber[figure]
% o \incrementfigurenumber[#1] --> \incrementfloatnumber[figure][#1]
% o \setfigurenumber[#1]       --> \setfloatnumber[figure][#1]

\protect

\starttext

\placefigure{}{\framed{Blub}}
\placefigure{}{\framed{Bautz}}
\placefigure{}{\framed{Bla}}

This were \rawnumber[figure] figures by now!

\setnumber[figure]{8}
We want to count on with \rawnumber[figure].

\placefigure{}{\framed{Plong}}

Figurenumber is incremented to \rawnumber[figure].

\placefigure{}{\framed{Plong}}

\incrementnumber[figure]

\placefigure{}{\framed{Plong}}

\incrementfloatnumber[figure][2]

\placefigure{}{\framed{Plong}}

\setfloatnumber[figure][25]

\placefigure{}{\framed{Plong}}

\setfloatnumber[figure][12]

\placefigure{}{\framed{Plong}}

\stoptext

</example>



Wolfgang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.ntg.nl/pipermail/ntg-context/attachments/20061005/57adfab9/attachment.html 


More information about the ntg-context mailing list