[NTG-context] Bug or feature? Strange counter behaviour in macro

2008-01-12 Thread Carsten Fechtmann

Hello everyone,

first off: I am new to ConTeXt (even if not so new to LaTeX)
and would like to transfer some of my old macros to ConTeXt...

I am well aware, that this means re-programming (most) of them.
So be it.

Furthermore, I am not sure if this is really the right way (read  
ConTeXt Way) to do it.
It just looked like a good idea at the time ...

However, I just hit a snuff with the following:

If one places \NewIssue[Some Time] somewhere in the text, it should  
result in a new (issue / timestamp) to be generated, which can then  
placed in a list of issues / changes.

I also want to be able to make use of the last value Issue to be  
placed in the header, same goes for the last timestamp

Now this is how I went out to do this in ConTeXt (maybe wrongly so?)
following the manual and some examples on contextwiki

%---  code below  ---
\definesynonyms[Issue][issues][\IssueText][\IssueDate]
\setupsynonyms[Issue][criterium=all]

\newcounter\IssueCounter

\definenumber[IssueNumber]

\def\TempIssueText{%
%% This was the (seemingly) only way to get any value beside 0
%%  from \getnumber within doAddIssue
%% Original place for
\incrementnumber[IssueNumber]
Issue~\getnumber[IssueNumber]:
}
\def\NewIssue{\dosingleargument\doNewIssue}
\def\doNewIssue[#1]{%
\increment\IssueCounter  % This one works correctly.
%% Alternative place for
%\incrementnumber[IssueNumber]

%% if placed here instead of in \TempIssueText
%% a DIFFERENT, but still wrong result comes out
%% that is: Debug shows the right progression,
%% but ALL Issue x Numbers are set to the last one
Debug: \IssueCounter / \getnumber[IssueNumber]%
%% but alas I can't seem to make this work with the following lines :-(
\doifempty{#1}{\Issue[\IssueCounter]{\TempIssueText}{\currentdate}}
\doifnotempty{#1}{\Issue[\IssueCounter]{\TempIssueText}{#1}}
%% Note: Using \dofiemptyelse gives the same result,
%% I just wanted to make sure here that I am /really/ not calling it  
twice,
%% somehow, by being able to disable each case, separately and  
definitely.
-- \IssueCounter / \getnumber[IssueNumber]
\crlf
}
% -- -- -- -- -- --
\starttext
\NewIssue[January 9, 2008]
\NewIssue[January 10, 2008]
\NewIssue   % January 11, 2008

List of issue \# and dates:

\placelistofissues \blank

\IssueDate{\IssueCounter} % produces correct result in either case

\stoptext
%---  code above  ---

  Result as printed out by original version
--
  Debug: 1/ 0 – 1/ 0
  Debug: 2/ 0 – 2/ 0
  Debug: 3/ 0 – 3/ 0

  List of issue # and dates:
  Issue 2: January 9, 2008
  Issue 4: January 10, 2008
  Issue 6: January 11, 2008

  January 11, 2008
--
So while \IssueCounter is updated correctly and used with the right  
values,
\getnumber[IssueNumber] always sees / reports the original value
However, the value in \placelistofissues are twice what they should be?!

This is changed if one places \incrementnumber[IssueNumber] INSIDE of  
\doAddIssue
Here, \getnumber[IssueNumber] does report the right value (same as  
IssueCounter)
However, in that case the result looks like this:

  Result as printed out by alternative version
--
Debug: 1/ 1 – 1/ 1
Debug: 2/ 2 – 2/ 2
Debug: 3/ 3 – 3/ 3

List of issue # and dates:

Issue 3: January 9, 2008
Issue 3: January 10, 2008
Issue 3: January 11, 2008

January 11, 2008

In short, while now the value of \getnumber[IssueNumber] is correct  
before and after,
its value in \placelistofissues is always the last value, i.e. equal  
to the total number of issues.

And this does NOT even change, when one replaces
Issue~\getnumber[IssueNumber]:
Issue~\IssueCounter:
in \TempIssueText

So for some reason, \TempIssueText is called twice ? How? Where?

Unfortunately, my ConTeXt.foo is not yet good enough to make it over  
the TeX.bar here
as I haven't found a way to make this work (preferably with  
\IssueCounter
as all this \XXXnumber stuff does not seem to work the way I think it  
should, anyway...)

And yes, ANY help with this is very welcome by now

Sincerely
Carsten

P.S: Context version is 2007.01.12 15:56 / TeXlive / OS X

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] many columns and then one column on the same page

2008-01-12 Thread Yvon Henel
hello all

I've failed to find how I could put first some text in two columns and then 
other text in one column on the same page.
After \stopcolumnsep my text goes on a new page.

Any hint would be greatly appreciated

Many thanks
-- 
Yvon Henel


signature.asc
Description: This is a digitally signed message part.
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] typesetting underscore

2008-01-12 Thread Gour
Hi!

Yesterday I played a bit with emacs' muse mode which has option to
'publish' to ConTeXt, but its output was wailing when texeexec-ing due
to use of \textunderscore (option in muse).

Today I discussed the issue on muse mailing list, got help and the
following remark: '...Context gurus don't seem to imagine you can use
_ elsewhere than in math mode btw'.


I looked at ConTeXt docs (excursion and manual), as well as wiki on
contextgarden, but was not able to find more about what is the status
of underscore '_' char in ConTeXt and is the above remark true?

My usage of '_' in muse document was for preparing tables of some
library functions and, as it is often the case in software, there is
usually some prefix for all library functions as eg. gtk_x for GTK+
toolkit.


Sincerely,
Gour


signature.asc
Description: PGP signature
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] many columns and then one column on the same page

2008-01-12 Thread Yvon Henel
Le samedi 12 janvier 2008, Yvon Henel wrote too quickly! 

 I've failed to find how I could put first some text in two columns and then
 other text in one column on the same page.
 After \stopcolumnsep my text goes on a new page.

And, after having wrote, began to think and look at the manuals with renewed 
attention!
The answer is: use \startcolumns \stopcolumns.

And I say to myself: RTFM, RTFM,...

sorry for the noise :-(
-- 
Yvon Henel


signature.asc
Description: This is a digitally signed message part.
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Bug or feature? Strange counter behaviour in macro

2008-01-12 Thread Aditya Mahajan

Hi Carsten,

On Fri, 11 Jan 2008, Carsten Fechtmann wrote:


first off: I am new to ConTeXt (even if not so new to LaTeX)
and would like to transfer some of my old macros to ConTeXt...

I am well aware, that this means re-programming (most) of them.
So be it.


Have you looked at enumerations? They provide a way to something very 
similar to what you want.



If one places \NewIssue[Some Time] somewhere in the text, it should
result in a new (issue / timestamp) to be generated, which can then
placed in a list of issues / changes.


\defineenuemration[Issue][title=yes]

\Issue[one]{January 9, 2008} blah blah blah

\Issue[two]{January 10, 2008} more blah blah blah

In issue \in[one] we wrote what we did on \about[one]


I also want to be able to make use of the last value Issue to be
placed in the header, same goes for the last timestamp


Another option may to think of issue as a section (or subsection)

\definehead[Issue][section]

\Issue {Jan 9, 2008} What we did at that time.

\Issue {Jan 10, 2008} something else

\stoptext

Then you can use \setupheadertexts[issue] to get the current issue in the 
header.



Now this is how I went out to do this in ConTeXt (maybe wrongly so?)
following the manual and some examples on contextwiki


I haven't looked at your code below. First check if one the in-built 
stuctural environments of ConTeXt do what you want.


Aditya


%---  code below  ---
\definesynonyms[Issue][issues][\IssueText][\IssueDate]
\setupsynonyms[Issue][criterium=all]

\newcounter\IssueCounter

\definenumber[IssueNumber]

\def\TempIssueText{%
%% This was the (seemingly) only way to get any value beside 0
%%  from \getnumber within doAddIssue
%% Original place for
\incrementnumber[IssueNumber]
Issue~\getnumber[IssueNumber]:
}
\def\NewIssue{\dosingleargument\doNewIssue}
\def\doNewIssue[#1]{%
\increment\IssueCounter  % This one works correctly.
%% Alternative place for
%\incrementnumber[IssueNumber]

%% if placed here instead of in \TempIssueText
%% a DIFFERENT, but still wrong result comes out
%% that is: Debug shows the right progression,
%% but ALL Issue x Numbers are set to the last one
Debug: \IssueCounter / \getnumber[IssueNumber]%
%% but alas I can't seem to make this work with the following lines :-(
\doifempty{#1}{\Issue[\IssueCounter]{\TempIssueText}{\currentdate}}
\doifnotempty{#1}{\Issue[\IssueCounter]{\TempIssueText}{#1}}
%% Note: Using \dofiemptyelse gives the same result,
%% I just wanted to make sure here that I am /really/ not calling it
twice,
%% somehow, by being able to disable each case, separately and
definitely.
-- \IssueCounter / \getnumber[IssueNumber]
\crlf
}
% -- -- -- -- -- --
\starttext
\NewIssue[January 9, 2008]
\NewIssue[January 10, 2008]
\NewIssue   % January 11, 2008

List of issue \# and dates:

\placelistofissues \blank

\IssueDate{\IssueCounter} % produces correct result in either case

\stoptext
%---  code above  ---

 Result as printed out by original version
--
 Debug: 1/ 0 – 1/ 0
 Debug: 2/ 0 – 2/ 0
 Debug: 3/ 0 – 3/ 0

 List of issue # and dates:
 Issue 2: January 9, 2008
 Issue 4: January 10, 2008
 Issue 6: January 11, 2008

 January 11, 2008
--
So while \IssueCounter is updated correctly and used with the right
values,
\getnumber[IssueNumber] always sees / reports the original value
However, the value in \placelistofissues are twice what they should be?!

This is changed if one places \incrementnumber[IssueNumber] INSIDE of
\doAddIssue
Here, \getnumber[IssueNumber] does report the right value (same as
IssueCounter)
However, in that case the result looks like this:

 Result as printed out by alternative version
--
Debug: 1/ 1 – 1/ 1
Debug: 2/ 2 – 2/ 2
Debug: 3/ 3 – 3/ 3

List of issue # and dates:

Issue 3: January 9, 2008
Issue 3: January 10, 2008
Issue 3: January 11, 2008

January 11, 2008

In short, while now the value of \getnumber[IssueNumber] is correct
before and after,
its value in \placelistofissues is always the last value, i.e. equal
to the total number of issues.

And this does NOT even change, when one replaces
Issue~\getnumber[IssueNumber]:
Issue~\IssueCounter:
in \TempIssueText

So for some reason, \TempIssueText is called twice ? How? Where?

Unfortunately, my ConTeXt.foo is not yet good enough to make it over
the TeX.bar here
as I haven't found a way to make this work (preferably with
\IssueCounter
as all this \XXXnumber stuff does not seem to work the way I think it
should, anyway...)

And yes, ANY help with this is very welcome by now

Sincerely
Carsten


P.S: Context version is 2007.01.12 15:56 / TeXlive / OS X


___
If your question is of interest to others as 

Re: [NTG-context] typesetting underscore

2008-01-12 Thread Aditya Mahajan
On Sat, 12 Jan 2008, Gour wrote:

 Yesterday I played a bit with emacs' muse mode which has option to
 'publish' to ConTeXt, but its output was wailing when texeexec-ing due
 to use of \textunderscore (option in muse).

Why does \textunderscore wail? \textunderscore should work fine.

 Today I discussed the issue on muse mailing list, got help and the
 following remark: '...Context gurus don't seem to imagine you can use
 _ elsewhere than in math mode btw'.

:) This is how it is done in plain TeX, and both LaTeX and ConTeXt follow 
this. If you do not use maths at all, you can say

\catcode`\_ = 11

on the top of your file and then _ will be a letter in both text and math 
mode (which basically means that you will have to use \sb to get subscript 
in math mode.

It is possible to define something along the lines of underscore.sty in 
latex, so that _ is treated as a letter in text mode, and as a subscript 
indicator in math mode, but, read below.

 I looked at ConTeXt docs (excursion and manual), as well as wiki on
 contextgarden, but was not able to find more about what is the status
 of underscore '_' char in ConTeXt and is the above remark true?

 My usage of '_' in muse document was for preparing tables of some
 library functions and, as it is often the case in software, there is
 usually some prefix for all library functions as eg. gtk_x for GTK+
 toolkit.

Shouldn't such function names be written as \type{gtk_} when muse 
converts the document to ConTeXt? In that case the _ will be preserved.

Aditya
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] showframe - showgrid = 2pt ??

2008-01-12 Thread Steffen Wolfrum
Hans,

I know I've asked you this before ... I just can't find the answer  
anymore ;o(
Look at line 43:


\newdimen\XVertikal
\XVertikal=12pt

\setupbodyfont[postscript,10pt] \setupinterlinespace[line=\XVertikal]

\setuplayout
[width=113mm,height=\the\dimexpr48\XVertikal-2pt\relax,
backspace=20mm,topspace=15mm,
header=\XVertikal,headerdistance=0.5\XVertikal,
footer=3.5\XVertikal,footerdistance=0pt,
location=middle,marking=on,grid=yes]

\showframe
\showgrid
\starttext
bla
\stoptext


... when height is made 2pt smaller then it fits:


\newdimen\XVertikal
\XVertikal=12pt

\setupbodyfont[postscript,10pt] \setupinterlinespace[line=\XVertikal]

\setuplayout
[width=113mm,height=\the\dimexpr48\XVertikal-2pt\relax,
backspace=20mm,topspace=15mm,
header=\XVertikal,headerdistance=0.5\XVertikal,
footer=3.5\XVertikal,footerdistance=0pt,
location=middle,marking=on,grid=yes]

\showframe
\showgrid
\starttext
bla
\stoptext


Does this difference has a specific purpose?
Would you recommend *not* to use the second?


Steffen
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] typesetting underscore

2008-01-12 Thread Gour
On Sat, 12 Jan 2008 12:59:39 -0500 (EST)
Aditya Mahajan [EMAIL PROTECTED] wrote:


 Why does \textunderscore wail? \textunderscore should work fine.

See https://mail.gna.org/public/muse-el-discuss/2008-01/msg1.html
thread.

 :) This is how it is done in plain TeX, and both LaTeX and ConTeXt
 follow this. If you do not use maths at all, you can say
 
 \catcode`\_ = 11
 
 on the top of your file and then _ will be a letter in both text and
 math mode (which basically means that you will have to use \sb to get
 subscript in math mode.

Hmm, not ideal...

 It is possible to define something along the lines of underscore.sty
 in latex, so that _ is treated as a letter in text mode, and as a
 subscript indicator in math mode, but, read below.

I do not remember having ever problem with underscore in LaTeX.

 Shouldn't such function names be written as \type{gtk_} when muse 
 converts the document to ConTeXt? In that case the _ will be
 preserved.

Right. They will fix default in muse and use \type{_} as value for
underscore.

Thank you for your input.

Sincerely,
Gour
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Bug or feature? Strange counter behaviour in macro

2008-01-12 Thread Carsten Fechtmann
Hi Aditya,

thanks for taking the time to answer this. And yes, I looked at what  
ConTeXt has already built in.

On 12.01.2008 at 18:44 wrote Aditya Mahajan:

 I haven't looked at your code below. First check if one the in-built  
 stuctural environments of ConTeXt do what you want.

As a matter of fact, I am using the following for all the heavy stuff  
(implementing that in LaTeX is/was a REAL pain)

\definesynonyms[Issue][issues][\IssueText][\IssueDate]
\setupsynonyms[Issue][criterium=all]

\Issue[1]{Issue 1:}{Some Date}
\Issue[2]{Issue 2:}{\currentdate}

and if I just put the values in by hand, it works like a champ. Sorted  
list and all.   ;-D

Took me less than 5 minutes to implement (read: find in the manual).  
Just gonna _love_ ConTeXt for that!

Now, with such a nice success (and because I have much more counter  
stuff on the way)
I was feeling lucky ...
and spent the next 5 hours figuring out / searching on the web / going  
over the source
how to have the number for each issue placed automatically, every  
time a new issue date is set.

Yes, sure, I could just _write_ that in, but then I would have to  
check myself,
which number is exactly the one I need, and not have the computer do  
it for me.
But, hey where is the fun in that? ;-)

What this all burns down is, that I /really/ would like to understand,  
how I can pass a value from a counter as (constant) argument to a self- 
defined function. As that seems to be the core of the matter/problem  
here.

Any suggestions?

Cheers
Carsten



___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] typesetting underscore

2008-01-12 Thread Aditya Mahajan
On Sat, 12 Jan 2008, Gour wrote:

 On Sat, 12 Jan 2008 12:59:39 -0500 (EST)
 Aditya Mahajan [EMAIL PROTECTED] wrote:


 Why does \textunderscore wail? \textunderscore should work fine.

 See https://mail.gna.org/public/muse-el-discuss/2008-01/msg1.html
 thread.

This is just a mistake of the parser. Either _ should be translated to 
\textunderscore (\textunderscore followed by a space) or more precisely 
by \textunderscore{} or \_ .

 I do not remember having ever problem with underscore in LaTeX.

Read the documentation of underscore.sty and you will know the trouble of 
using underscore in LaTeX (some of those are true for ConTeXt also).

 Shouldn't such function names be written as \type{gtk_} when muse
 converts the document to ConTeXt? In that case the _ will be
 preserved.

 Right. They will fix default in muse and use \type{_} as value for
 underscore.

No, the default should either be \_ or \letterunderscore{} (with the 
brackets). \type{_} will be influenced by \setuptype (or \setuptyping) and 
can give colored output also.

Aditya
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Bug or feature? Strange counter behaviour in macro

2008-01-12 Thread Aditya Mahajan
Hi Carsten,

On Sat, 12 Jan 2008, Carsten Fechtmann wrote:

 What this all burns down is, that I /really/ would like to understand,
 how I can pass a value from a counter as (constant) argument to a self-
 defined function. As that seems to be the core of the matter/problem
 here.

You need to understand how synonyms work. It writes enteries to the tuo 
file, and then uses that in the second pass to sort things. One way to 
make sure that you have the correct entry in the tuo file is to use 
expanded:

\definesynonyms[Issue][issues][\IssueText][\IssueDate]
\setupsynonyms[Issue][criterium=all]

\newcounter\IssueCounter

\def\NewIssue{\dosingleargument\doNewIssue}

\def\doNewIssue[#1]%
   {\increment\IssueCounter
 %Debug: \IssueCounter / \getnumber[IssueNumber]%
 \doifelsenothing{#1}
   {\expanded{\Issue[\IssueCounter]{\IssueCounter}{\currentdate}}}
   {\expanded{\Issue[\IssueCounter]{\IssueCounter}{#1

% Compare the tuo file with and without expanded and you will know what is 
% happening.

\starttext
\NewIssue[January 9, 2008]
\NewIssue[January 10, 2008]
\NewIssue   % January 11, 2008

List of issue \# and dates:

\placelistofissues \blank

\IssueDate{\IssueCounter} % produces correct result in either case

\stoptext

Aditya
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Bug or feature? Strange counter behaviour in macro

2008-01-12 Thread Carsten Fechtmann
Hi Aditya,

yes, looking at the .tuo did the trick. :-D

I had tried things with expanded already, but at that time I still had
 {\expanded{\Issue[\IssueCounter]{Issue~\IssueCounter:}{\currentdate}}}
as command. Which does NOT work (due to the tilde ~ resulting in an  
error message then)
The rest was actually fine. Now, without it (i.e. ~) it works!
...
{\expanded{\Issue[\IssueCounter]{Issue: \IssueCounter:}{\currentdate}}}
...

Thanks a lot, that had me seriously baffled ;-)
Carsten

On 12.01.2008 at 23:29 wrote Aditya Mahajan:

 Hi Carsten,

 On Sat, 12 Jan 2008, Carsten Fechtmann wrote:

 What this all burns down is, that I /really/ would like to  
 understand,
 how I can pass a value from a counter as (constant) argument to a  
 self-
 defined function. As that seems to be the core of the matter/problem
 here.

 You need to understand how synonyms work. It writes enteries to the  
 tuo
 file, and then uses that in the second pass to sort things. One way to
 make sure that you have the correct entry in the tuo file is to use
 expanded:

 \definesynonyms[Issue][issues][\IssueText][\IssueDate]
 \setupsynonyms[Issue][criterium=all]

 \newcounter\IssueCounter

 \def\NewIssue{\dosingleargument\doNewIssue}

 \def\doNewIssue[#1]%
   {\increment\IssueCounter
 %Debug: \IssueCounter / \getnumber[IssueNumber]%
 \doifelsenothing{#1}
   {\expanded{\Issue[\IssueCounter]{\IssueCounter}{\currentdate}}}
   {\expanded{\Issue[\IssueCounter]{\IssueCounter}{#1

 % Compare the tuo file with and without expanded and you will know  
 what is
 % happening.

 \starttext
 \NewIssue[January 9, 2008]
 \NewIssue[January 10, 2008]
 \NewIssue   % January 11, 2008

 List of issue \# and dates:

 \placelistofissues \blank

 \IssueDate{\IssueCounter} % produces correct result in either case

 \stoptext

 Aditya
 ___
 If your question is of interest to others as well, please add an  
 entry to the Wiki!

 maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
 webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
 archive  : https://foundry.supelec.fr/projects/contextrev/
 wiki : http://contextgarden.net
 ___

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Bug or feature? Strange counter behaviour in macro

2008-01-12 Thread Aditya Mahajan
On Sun, 13 Jan 2008, Carsten Fechtmann wrote:

 Hi Aditya,

 yes, looking at the .tuo did the trick. :-D

 I had tried things with expanded already, but at that time I still had
 {\expanded{\Issue[\IssueCounter]{Issue~\IssueCounter:}{\currentdate}}}
 as command. Which does NOT work (due to the tilde ~ resulting in an
 error message then)

\nonbreakablespace works instead of ~.

Aditya
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] active strings in luatex?

2008-01-12 Thread Arthur Reutenauer
Hello Idris,

  I didn't see any reply to this e-mail you sent two weeks ago, so I
wanted to give it a try:

  In luatex can I make a definition such that such that the string
 
 U004C U0303 (l ̃)
 
 is always treated as l with tilde above, taking into account italics and  
 without using \~l (which does not work in, eg, footnote)?

  What you want here is to support the Unicode combining characters,
which isn't straightforward in TeX because according to the Standard,
they come after the base letter they modify, while TeX's accent commands
are, of course, typed before.  So you can't simply make the combining
characters active and equivalent to the appropriate accent macros.

  In traditional TeX, it would have been tempting to make the base letter
active instead, but this has a lot of drawbacks, and LuaTeX offers many
other possibilities.  Here I've used a set of macros that Taco had
written a couple of months ago in response to a question by Thomas
Schmitz (see http://www.ntg.nl/pipermail/ntg-context/2007/027095.html).
The attached file implements the transformation of the sequence LATIN
SMALL LETTER L, COMBINING TILDE in \buildtextaccent\texttilde l,
which I hope gives the expected result in every circumstance.  I've done
it only for the small letter, but of course it's easy to adapt to add
the capital letter as well.

  Finally, I wish to clarify a small misunderstanding: you quoted the
two lines below:

LATIN CAPITAL LETTER L WITH TILDE;004C 0303
LATIN SMALL LETTER L WITH TILDE;006C 0303

with the comment The proposal is still under consideration for
Lithuanian and not yet in Unicode.  Actually it is already encoded in
Unicode; that is, all the characters you need are present with the
appropriate semantics, and you can accurately represent a small l with
tilde in Unicode; only, you have to use two characters (U+006C followed
by U+0303).  The only thing that will be added to Unicode in that
respect is the *name* of those strings (I guess you took those two lines
from the data files for Unicode version 5.1.0, in beta stage).  The
corresponding characters, though, will not be added to Unicode,
according to a decision which has been made several years ago (I could
trace it back to a discussion at the Unicode Technical Committee in
October 1999, but I don't know the details).  The idea is that it can
already be represented as a sequence of characters, and the Unicode
Consortium does not wish to make the set of alphabetic characters
explode with diacritics.

  In spite of this, Unicode still wishes to acknowledge that some
unencoded accented letters are important in some languages, and provides
names for the character sequences representing them, like it does for
all the encoded characters.  The relevant document that explains this is
Unicode Standard Annex #34 (http://www.unicode.org/reports/tr34/).

Arthur
% engine=luatex

% Macros to handle a particular combining sequence of Unicode characters
% in ConTeXt Mark IV by modifying the token list.
% © A. Reutenauer, January 2008.
% This file is distributed under the terms of the WTF Public License
% (http://sam.zoy.org/wftpl/)

\usetypescript[iwona]
\setupbodyfont[iwona, 14pt]

% Convert the sequence U+006C LATIN SMALL LETTER L, U+0303 COMBINING TILDE
% to an appropriate ConTeXt representation (\buildtextaccent\texttilde l).
% Strongly influenced by macros by Taco.
% See http://www.ntg.nl/pipermail/ntg-context/2007/027095.html
\def\handletokens[#1][#2]{\ctxlua{collectors.handle(#1, #2)}}

\def\startcombining{\ctxlua{collectors.install(combining, stopcombining)}}

\startluacode
  -- The actual conversion function: we loop over the characters in 'str'.
  function convert_combining(str)
-- l is true if we have just read an 'l'.
-- t is the list of tokens read thus far.
local l, t = false, { }
-- The following should check if we read ‘l’ and ‘combining tilde’
-- consecutively.  A lot of overhead; it would be much prettier to
-- implement a finite automaton :-)
for _, v in ipairs(str) do
  if not l then
if v[2] == 0x6c -- v is LATIN SMALL LETTER L: set l to true, and hold
then l = true
else t[#t+1] = v -- Otherwise, append v to the token list
end
  else -- l is true
if v[2] == 0x0303 then -- v is COMBINING TILDE
  -- Found!  Append the ConTeXt sequence for “l with tilde” to t!
  t[#t+1] = token.create('buildtextaccent')
  t[#t+1] = token.create('texttilde')
  t[#t+1] =  token.create(0x6c, 11)
  l = false -- Don't forget to set l back to false
else -- This is annoying: we need to check if v is ‘l’ again.
  t[#t+1] = token.create(0x6c, 11) -- First append the previous ‘l’
  if v[2] == 0x6c -- v is LATIN SMALL LETTER L: start all over again
  then l = true
  else
t[#t+1] = v
l = false
  end
end -- of if l
  end -- of if not l