Re: [NTG-context] enumerated lists

2005-08-04 Thread Brooks Moses

At 12:31 AM 7/7/2005, Frank Grieshaber wrote:

Hello all (esp. the ConTeXt-Developers),

some time ago I sent the following email to this list and got no reply so 
I'm resending it.

Dear all,
I have a manuscript with long nested numbered enumerations and I want the 
numbers of all levels to be printed automatically like:

1. one
1.1 one-one
1.2 one-two
2. two
2.1 two-one
2.2.1 two-two-one
...
Using the following prints only the current level's number, not all levels:
\startitemize[n,packed]
\item
\item
  \startitemize[m,packed]
  \item
  \item
  \stopitemize
\item
\item
\stopitemize

For Latex there is the package paralist.sty for doing the desired 
numbering, how can this be done with ConTeXt?


(I wrote this before I noticed that Hans had already replied, but I'm 
sending this anyway in case someone finds it useful.)


I just accidentally solved this problem, in some of the LaTeX-compatibility 
stuff that I've been working on.  Have a look at t-ltenum.tex for the 
kernel code that does it, and latextest.tex for an example of how to use it 
for something akin to that effect.  It's fairly self-contained; you should 
be able to use t-ltenum.tex, t-ltcnts (which does counters) and 
t-ltbase.tex to get the "LaTeX-style enumerations" working, without needing 
any of the other bits.  All my current files are in this repository:

  http://dpdx.net/context/latex-compat/

That's sort of the long way around to doing what you're looking for, 
though, and you can get the same effect without the LaTeX-compatibility 
overhead.  Here's the trick


First, you create a set of "conversions" for each level of the list -- see 
the Wiki page linked off "Enumerations" for how to do that.  The conversion 
for level one will look something like this:


  \def\listconversioni{%
 \edef\listheadi{\numbers{#1}.}%
 \numbers{#1}}

  \defineconversion[listconvi][\listconversioni]

That returns the list-counter in number form, but it also stores it (with a 
"." after it) in a "header".  (I don't know whether that should be \edef or 
just \def, but I _think_ \edef is right.)


Then, the conversion for level two looks something like this:

  \def\listconversionii{%
 \edef\listheadii{\listheadi\numbers{#1}.}%
 \listheadi\numbers{#1}}

  \defineconversion[listconvii][\listconversionii]

That does the same thing, but now it's prefixing it with \listheadi.  This 
then continues down the list as deep as you want to go.  You then do a 
\defineitemgroup and some \setupitemgroup commands (again, see the Wiki's 
"Enumerations" page) to set it so that each one of those is associated with 
the appropriate level, and off you go; it's all automatic from there.



Depending on whether \startitemize / \stopitemize includes grouping or not 
(and on exactly where that grouping is placed), it may be possible to do 
this in a more general form -- have \startitemize execute some code to set 
\parentlisthead to the current \listhead (which comes from the next level 
up), and then have one conversion for all levels which uses \parentlisthead 
and defines a new \listhead to be used on any child itemizations.  The 
trick here is that \stopitemize will (hopefully) contain a \endgroup or 
\egroup, so that after it the \listhead value will revert to what it was 
before the corresponding \startitemize.  This has the advantage of being 
able to go arbitrarily deep, but you can't do things like "1.a" where the 
levels are enumerated differently.



There are, of course, variations on all of these, but that general idea 
should be enough to get you going.


And I'll second the recommendation that something like this ought go in the 
kernel; I'm actually rather surprised that it's not already in there!


Actually, what I would specifically suggest is that the \item code should 
place the converted item counter -- the result of calling \doconversion -- 
into something like \currentitemlabel, and then \startitemize should move 
that to \parentitemlabel, all automatically, so one can simply define 
conversions with \parentitemlabel in them without having to implement the 
machinery oneself.


Or ... ah, wait; I see that Hans already replied to this shortly after you 
posted, and I missed it.  Oh, well; I'll send this anyway.  :)


- Brooks

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


Re: [NTG-context] enumerated lists

2005-07-08 Thread Radhelorn

Frank Grieshaber wrote:

Hello all (esp. the ConTeXt-Developers),

some time ago I sent the following email to this list and got no reply 
so I'm resending it.


Is there any possibility that this feature will be part of the next/one 
of the next ConTeXt-versions?


Frank



Dear all,
I have a manuscript with long nested numbered enumerations and I want 
the numbers of all levels to be printed automatically like:


1. one
1.1 one-one
1.2 one-two
2. two
2.1 two-one
2.2.1 two-two-one
...


Well, I've solved this problem with enumerations, but example isn't 
necessary because more elegant solution will be in next release ;-).


--
Radhelorn <[EMAIL PROTECTED]>
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] enumerated lists

2005-07-08 Thread Hans Hagen

Mojca Miklavec wrote:

Frank Grieshaber wrote:


Hello all (esp. the ConTeXt-Developers),

some time ago I sent the following email to this list and got no reply 
so I'm resending it.


Is there any possibility that this feature will be part of the 
next/one of the next ConTeXt-versions?


Frank



I'm affraid that despite the huge amount of features that "itemize" 
offers, it should be rewritten one day. Sometimes it doesn't really work 
as expected (some comments can be found in my post 
"\setupitemize[packed,paragraph]") and the features you are mentioning 
here are missing, although they would be sensible.



Dear all,
I have a manuscript with long nested numbered enumerations and I want 
the numbers of all levels to be printed automatically like:


1. one
1.1 one-one
1.2 one-two
2. two
2.1 two-one
2.2.1 two-two-one
...

Using the following prints only the current level's number, not all 
levels:


\startitemize[n,packed]
\item
\item
  \startitemize[m,packed]
  \item
  \item
  \stopitemize
\item
\item
\stopitemize



PS: But once again - If anyone will be reading this post in the mail 
archive: please, don't use this trick!!! Please check first if this 
feature has been added in the meantime.


sorry for being mean again ...

% copy this into cont-new.tex

\unprotect

\def\dododosetupitemgroupconstant[#1][#2#3#4]% * permits [2]
  {\processaction
 [#2#3#4]
 [   \v!packed*=>\packitems,
  \v!intro*=>\itemintrotrue,
  \v!autointro*=>\autoitemintrotrue,
  \v!broad*=>\setitemparameter{#1}\c!factor{1},
 #2#3*\v!broad*=>\setitemparameter{#1}\c!factor{#2#3},
   #2*\v!broad*=>\setitemparameter{#1}\c!factor{#2},
   \v!text*=>\textitemstrue
 \settrue\inlinelistitem
 \dosetuppackeditemgroup{#1}%
 \packitems,
\v!columns*=>\packitems,
 \v!margin*=>\setitemparameter{#1}\c!width{-2em}, % signal
   \v!inmargin*=>\setitemparameter{#1}\c!width{-2em}, % signal
   \v!atmargin*=>\doifnot{#1}{1}{\setitemparameter{#1}\c!width{0em}}, % 
signal
 \v!intext*=>\settrue\inlinelistitem, % new
  \v!loose*=>\optimizeitemsfalse,
  \v!paragraph*=>\paragraphitemstrue
 \packitems,
   \v!joinedup*=>\dosetuppackeditemgroup{#1}%
 \packitems,
\v!serried*=>\setitemparameter{#1}\c!factor{-1},
   #2#3*\v!serried*=>\setitemparameter{#1}\c!factor{-#2#3},
 #2*\v!serried*=>\setitemparameter{#1}\c!factor{-#2},
\v!stopper*=>\setitemparameter{#1}\c!placestopper\v!yes,
   \v!unpacked*=>\packeditemsfalse,
 \v!repeat*=>\settrue\repeatlistitem, % new
   \v!standard*=>\dosetupstandarditemgroup{#1}]}

\def\dolistitem % evt aantal items opslaan per niveau, scheelt zoeken
  {\iftextitems
 % begin of item
   \else
 \par
   \fi
   \ignorespaces
   \increment\noflistelements
   \ifnum\itemcolumndepth=\zerocount \ifoptimizeitems
 \ifnum\noflistelements=\plusone% tgv bv kolommen/nesting
   \findtwopassdata\s!list{\noflists:}% % wordt soms de volgorde
 \fi% verstoord, vandaar \find
 \iftwopassdatafound
   \ifcase0\twopassdata\relax \twopassdatafoundfalse \fi
 \fi
 \iftwopassdatafound
   \ifnum\twopassdata=3
 \ifnum\noflistelements>1
   \doitembreak\itemnobreak
 \fi
   \else\ifnum\twopassdata>3
 \ifnum\noflistelements=2
   \ifitemintro
 \doitembreak\nobreak
   \else
 \doitembreak\itemnobreak
   \fi
 \else\ifnum\twopassdata=\noflistelements\relax
   \doitembreak\itemnobreak
 \else\ifnum\noflistelements>2
   \doitembreak\itembreak
 \else
   \ifitemintro\else\doitembreak\itembreak\fi
 \fi\fi\fi
   \fi\fi
 \fi
   \fi\fi
   \noindent
   \setbox8\hbox
 {\ifheaditem
\doitemattributes\itemlevel\c!headstyle\c!headcolor{\listitem}%
  \else\ifsymbolitem
\symsymbol
  \else
\doitemattributes\itemlevel\c!style\c!color{\listitem}%
  \fi\fi}%
   \doifsomething\somdestination
 {\setbox8\hbox{\goto{\box8}[\somdestination]}}%
   \globallet\somdestination\empty
   \dimen2=\getitemparameter\itemlevel\c!width\relax
   % new, prevents loops when symbol is (not yet found) graphic
   \ht8=\strutheight
   \dp8=\strutdepth
   % so that content differs per run (esp mp graphics afterwards)
\checkforrepeatedlistitem
   \ifdim\dimen2<\zeropoint\relax
 \llap{\ifsubitem\llap{+}\fi\box8\hskip\leftmargindistance}%
   \else
 \ifdim\dimen2=\zeropoint\relax
   \calculatelistwidth1{\dimen0}%
 \else
   \calculatelistwidth\itemlevel{\dimen0}%
 \fi
 \iftextitems
   \hbox{\ifsubitem+\fi\box8\hskip\fontdimen2\font}\nobreak
 \else
   \ifconditional\inlinelistitem
 \hbox to \dimen0{\ifsubitem\llap{+}\fi\box8\hfill}%
   \else
 % todo: align+marge binnen de hbo

Re: [NTG-context] enumerated lists

2005-07-07 Thread Mojca Miklavec

Frank Grieshaber wrote:

Hello all (esp. the ConTeXt-Developers),

some time ago I sent the following email to this list and got no reply 
so I'm resending it.


Is there any possibility that this feature will be part of the next/one 
of the next ConTeXt-versions?


Frank


I'm affraid that despite the huge amount of features that "itemize" 
offers, it should be rewritten one day. Sometimes it doesn't really work 
as expected (some comments can be found in my post 
"\setupitemize[packed,paragraph]") and the features you are mentioning 
here are missing, although they would be sensible.



Dear all,
I have a manuscript with long nested numbered enumerations and I want 
the numbers of all levels to be printed automatically like:


1. one
1.1 one-one
1.2 one-two
2. two
2.1 two-one
2.2.1 two-two-one
...

Using the following prints only the current level's number, not all 
levels:


\startitemize[n,packed]
\item
\item
  \startitemize[m,packed]
  \item
  \item
  \stopitemize
\item
\item
\stopitemize


For Latex there is the package paralist.sty for doing the desired 
numbering, how can this be done with ConTeXt?


Frank


Here's a solution that:
- doesn't work (well, it's actually not far away from working)
- may not be taken as an example of nice programming habits:
  so use it at your own risk!!! (You have been warned!)
- if someone can help me to define this command, it will work:

% the command to be defined:
\def\deleteeverythingbehindthelastdot#1{#1}
\def\MyCommand{\deleteeverythingbehindthelastdot{\itemreference}}

\starttext

\setupitemize[1][n][indentnext=no]

% what should indentnext do?
%
% I thought it would not try to indent further
% Is there a way to itemize like
% 1. one
% 1.1. one-one
% 1.2. one-two
% 2. two
%
% instead of
% 1. one
%1.1. one-one
%1.2. one-two
% 2. two

\setupitemize[2][n,3*broad][left={\MyCommand}]
\setupitemize[3][n,4*broad][left={\MyCommand}]
\startitemize
  \item bla
  \item blabla
  \startitemize
\item bla
\item blabla
\startitemize
  \item bla
  \item blabla
\stopitemize
\item bla
\item bla
\item bla
\startitemize
  \item bla
  \item blabla
\stopitemize
\item bla
\item bla
\item bla
  \stopitemize
  \item bla
  \startitemize
\item bla
\item blabla
\startitemize
  \item bla
  \item blabla
\stopitemize
\item bla
  \stopitemize
  \item bla
  \item bla
\stopitemize

\stoptext


Mojca


PS: But once again - If anyone will be reading this post in the mail 
archive: please, don't use this trick!!! Please check first if this 
feature has been added in the meantime.

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


Re: [NTG-context] enumerated lists

2005-07-07 Thread Taco Hoekwater



Frank Grieshaber wrote:

Hello all (esp. the ConTeXt-Developers),

some time ago I sent the following email to this list and got no reply 
so I'm resending it.


Just to let you know i've received your message. Unfortunately,
I don't have a clue about how to achieve this effect.

Taco

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


[NTG-context] enumerated lists

2005-07-07 Thread Frank Grieshaber

Hello all (esp. the ConTeXt-Developers),

some time ago I sent the following email to this list and got no reply 
so I'm resending it.


Is there any possibility that this feature will be part of the next/one 
of the next ConTeXt-versions?


Frank



Dear all,
I have a manuscript with long nested numbered enumerations and I want 
the numbers of all levels to be printed automatically like:


1. one
1.1 one-one
1.2 one-two
2. two
2.1 two-one
2.2.1 two-two-one
...

Using the following prints only the current level's number, not all levels:

\startitemize[n,packed]
\item
\item
  \startitemize[m,packed]
  \item
  \item
  \stopitemize
\item
\item
\stopitemize


For Latex there is the package paralist.sty for doing the desired 
numbering, how can this be done with ConTeXt?


Frank



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


[NTG-context] enumerated lists

2005-05-01 Thread Frank Grieshaber
Dear all,
I have a manuscript with long nested numbered enumerations and I want 
the numbers of all levels to be printed like:

1. one
1.1 one-one
1.2 one-two
2. two
2.1 two-one
2.2.1 two-two-one
...
Using the following prints only the current level's number, not all levels:
\startitemize[n,packed]
\item
\item
  \startitemize[m,packed]
  \item
  \item
  \stopitemize
\item
\item
\stopitemize
For Latex there is the package paralist.sty for doing the desired 
numbering, how can this be done with ConTeXt?

Frank
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context