ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Header number separator
@ 2006-11-07 19:43 Jeff Smith
  2006-11-07 21:42 ` Aditya Mahajan
  0 siblings, 1 reply; 10+ messages in thread
From: Jeff Smith @ 2006-11-07 19:43 UTC (permalink / raw)


Hi,

Some time ago I had a query on the list about roman numbering in
headers. Once I got my answer, I asked something else relatively
unrelated but in the same thread. It's probably bad etiquette, so I
figure that is why it has remained unheeded. I'd like to submit my
second query again.

I have a problem with the separator in header numbers. I want to
use a different separator between chapter and section numbers (-), than between
section and subsection numbers (.).

So, assuming I'm using roman numerals for chapters, I'd like numering
of sections to be I-1, I-2, I-3, etc., of subsections to be I-1.1,
I-1.2, I-2.1, I-2.2, I-2.3, etc.

Now when I use \setuphead for section and subsection blocks with
different [separator=] attributes:

\setuphead[section][separator=-]
\setuphead[subsection][separator=.]

... it defines the separator for the _whole_ header level, not the
number position within any relevant header. So I get this instead:

sections are numbered I-1, I-2, I-3, etc.
subsections are numbered I.1.1, 1.1.2, I.2.1, I.2.2, I.2.3, etc.

Is there a way to achieve what I want to do?

Thanks!
Jeff

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

* Re: Header number separator
  2006-11-07 19:43 Header number separator Jeff Smith
@ 2006-11-07 21:42 ` Aditya Mahajan
  2006-11-07 22:22   ` Aditya Mahajan
  0 siblings, 1 reply; 10+ messages in thread
From: Aditya Mahajan @ 2006-11-07 21:42 UTC (permalink / raw)


On Tue, 7 Nov 2006, Jeff Smith wrote:

> Hi,
>
> Some time ago I had a query on the list about roman numbering in
> headers. Once I got my answer, I asked something else relatively
> unrelated but in the same thread. It's probably bad etiquette, so I
> figure that is why it has remained unheeded. I'd like to submit my
> second query again.
>
> I have a problem with the separator in header numbers. I want to
> use a different separator between chapter and section numbers (-), than between
> section and subsection numbers (.).
>
> So, assuming I'm using roman numerals for chapters, I'd like numering
> of sections to be I-1, I-2, I-3, etc., of subsections to be I-1.1,
> I-1.2, I-2.1, I-2.2, I-2.3, etc.
>
> Is there a way to achieve what I want to do?

Yes, as long as you do not want to refer to your sections :) The 
separator seems to be broken while refering anyways.

\setupsection[section-2][bodypartconversion=Romannumerals]

\setuphead
    [subsection]
    [numbercommand=\mysubsectionnumber]

\setuphead[section][separator=-]

\unprotect

\def\mysubsectionnumber#1%
   {\@@shortsectionnumber{section-2}-%
    \@@shortsectionnumber{section-3}.%
    \@@shortsectionnumber{section-4}}

\protect

\starttext

\chapter{Test}

\section[sec]{section test}

\subsection[sub]{test}

The separator is not honored in \in Section[sec] and in \in 
subsection[sub].

\stoptext

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

* Re: Header number separator
  2006-11-07 21:42 ` Aditya Mahajan
@ 2006-11-07 22:22   ` Aditya Mahajan
  2006-11-09 16:54     ` Jeff Smith
  0 siblings, 1 reply; 10+ messages in thread
From: Aditya Mahajan @ 2006-11-07 22:22 UTC (permalink / raw)


On Tue, 7 Nov 2006, Aditya Mahajan wrote:

> On Tue, 7 Nov 2006, Jeff Smith wrote:
>
>> Hi,
>>
>> Some time ago I had a query on the list about roman numbering in
>> headers. Once I got my answer, I asked something else relatively
>> unrelated but in the same thread. It's probably bad etiquette, so I
>> figure that is why it has remained unheeded. I'd like to submit my
>> second query again.
>>
>> I have a problem with the separator in header numbers. I want to
>> use a different separator between chapter and section numbers (-), than between
>> section and subsection numbers (.).
>>
>> So, assuming I'm using roman numerals for chapters, I'd like numering
>> of sections to be I-1, I-2, I-3, etc., of subsections to be I-1.1,
>> I-1.2, I-2.1, I-2.2, I-2.3, etc.
>>
>> Is there a way to achieve what I want to do?
>
> Yes, as long as you do not want to refer to your sections :) The
> separator seems to be broken while refering anyways.

I need this functionality for a project (IEEE conference style), so 
here is hack to get the feature. The referencing also works.

Use with caution, can break existing macros.

\setupsection[section-1][separator=-]
\setupsection[section-2][separator=-]
\setupsection[section-3][separator=-] %section
\setupsection[section-4][separator=.] %subsection
\setupsection[section-5][separator=-]
\setupsection[section-6][separator=-]

\setupsection[section-2][bodypartconversion=Romannumerals]

\unprotect
\def\@@longsectionnumber#1%
   {\ifreversesectionnumbers
      \@@shortsectionnumber{#1}%
      \ifnum\countervalue{\??se\previoussection{#1}}>\zerocount
       \csname\??se#1\c!separator\endcsname%AM: was .
        \csname\previoussection{#1}\c!number\endcsname
      \fi
    \else
      \ifnum\countervalue{\??se\previoussection{#1}}>\zerocount
      \csname\previoussection{#1}\c!number\endcsname%
      \csname\??se#1\c!separator\endcsname%AM: was .
      \fi
      \@@shortsectionnumber{#1}%
    \fi}

\protect

\starttext

\chapter{Test}

\section[sec]{section test}

\subsection[sub]{test}

The separator is honored in \in Section[sec] and in \in 
subsection[sub].

\stoptext

Basically, section numbers are built according to \??se 
(\setupsection, etc), while separators are specified using \??ko 
(\setuphead, etc), so any interaction is very difficult. I defined 
separators according to \setupsection, and use while generating the 
number.


Aditya

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

* Re: Header number separator
  2006-11-07 22:22   ` Aditya Mahajan
@ 2006-11-09 16:54     ` Jeff Smith
  2006-11-09 18:39       ` Aditya Mahajan
  2006-11-14 11:33       ` Hans Hagen
  0 siblings, 2 replies; 10+ messages in thread
From: Jeff Smith @ 2006-11-09 16:54 UTC (permalink / raw)


On 11/7/06, Aditya Mahajan <adityam@umich.edu> wrote:


> I need this functionality for a project (IEEE conference style), so
> here is hack to get the feature. The referencing also works.
>
> Use with caution, can break existing macros.

Wow, thanks a lot! This works as expected. In what situation can it
break existing macros? I intend to use that extensively but in a
fairly simple document (a thesis... yeah, another one in ConTeXt!). Is
there anything I should _not_ do?

Thanks again for your help! It's always greatly appreciated.
Jeff

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

* Re: Header number separator
  2006-11-09 16:54     ` Jeff Smith
@ 2006-11-09 18:39       ` Aditya Mahajan
  2006-11-14 11:33       ` Hans Hagen
  1 sibling, 0 replies; 10+ messages in thread
From: Aditya Mahajan @ 2006-11-09 18:39 UTC (permalink / raw)


On Thu, 9 Nov 2006, Jeff Smith wrote:

> On 11/7/06, Aditya Mahajan <adityam@umich.edu> wrote:
>
>
>> I need this functionality for a project (IEEE conference style), so
>> here is hack to get the feature. The referencing also works.
>>
>> Use with caution, can break existing macros.
>
> Wow, thanks a lot! This works as expected. In what situation can it
> break existing macros? I intend to use that extensively but in a
> fairly simple document (a thesis... yeah, another one in ConTeXt!). Is
> there anything I should _not_ do?

In principle, it should work fine for european languages. Lot of the 
trickery with numbers and number formats is present because ConTeXt 
also supports other languages like chinese and arabic.

@@longsectionnumber is used a lot by the sectioning macros, and I do 
not completely understand what is happening here. My solution was 
based on trial and error and figuring out what works.

Moreover, it changes a core feature of ConTeXt. I am associating 
separators with sectioning levels rather than with heads. Right now, 
in principle, you can have different separators for different heads at 
the same level. For example

\setuphead[remark][section=section-4,separator=.]
\setuphead[note][section=section-4,separator=-]

With this change, this will no longer work. So, the macro is not 
backward compatible, and thus can break existing code. If you have 
only one head at each sectioning level, and do not plan to use Chinese 
or Arabic, it should work fine. Atleast for my simple, 5 page 
document, it works correctly :-)

Aditya

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

* Re: Header number separator
  2006-11-09 16:54     ` Jeff Smith
  2006-11-09 18:39       ` Aditya Mahajan
@ 2006-11-14 11:33       ` Hans Hagen
  2006-11-14 16:53         ` Aditya Mahajan
  1 sibling, 1 reply; 10+ messages in thread
From: Hans Hagen @ 2006-11-14 11:33 UTC (permalink / raw)


Jeff Smith wrote:
> On 11/7/06, Aditya Mahajan <adityam@umich.edu> wrote:
>
>
>   
>> I need this functionality for a project (IEEE conference style), so
>> here is hack to get the feature. The referencing also works.
>>
>> Use with caution, can break existing macros.
>>     
>
> Wow, thanks a lot! This works as expected. In what situation can it
> break existing macros? I intend to use that extensively but in a
> fairly simple document (a thesis... yeah, another one in ConTeXt!). Is
> there anything I should _not_ do?
>   
hm, can on esummarize what will break macros? (i was away for a week with time for email) 

Hans 

-----------------------------------------------------------------
                                          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] 10+ messages in thread

* Re: Header number separator
  2006-11-14 11:33       ` Hans Hagen
@ 2006-11-14 16:53         ` Aditya Mahajan
  2006-11-14 16:57           ` Hans Hagen
  2006-11-15 15:38           ` Hans Hagen
  0 siblings, 2 replies; 10+ messages in thread
From: Aditya Mahajan @ 2006-11-14 16:53 UTC (permalink / raw)


[-- Attachment #1: Type: TEXT/PLAIN, Size: 963 bytes --]

On Tue, 14 Nov 2006, Hans Hagen wrote:

> Jeff Smith wrote:
>> On 11/7/06, Aditya Mahajan <adityam@umich.edu> wrote:
>>
>>
>>
>>> I need this functionality for a project (IEEE conference style), so
>>> here is hack to get the feature. The referencing also works.
>>>
>>> Use with caution, can break existing macros.
>>>
>>
>> Wow, thanks a lot! This works as expected. In what situation can it
>> break existing macros? I intend to use that extensively but in a
>> fairly simple document (a thesis... yeah, another one in ConTeXt!). Is
>> there anything I should _not_ do?
>>
> hm, can on esummarize what will break macros? (i was away for a week with time for email)

A patch that I sent to Jeff. There is a problem with separators and 
setuphead. I have summarized the problem and a possible patch in the 
attached file. However, I do not know if it will break something in 
multi-lingual documents (esp. Arabic), so I sent the patch with a 
disclaimer.

Aditya

[-- Attachment #2: Type: TEXT/PLAIN, Size: 3846 bytes --]

\starttext

%D Suppose I have a document with three levels of headings|<| chapter,
%D section, and subsection. I want different separators for different levels,
%D say 1,2, etc. for chapter; 1-1, 1-2, etc., for sections and 1-1.1, 1-1.2
%D etc., for subsections. The present context approach of using
%D \starttyping
%D \setuphead[section][separator=-]
%D \setuphead[subsection][separator=.]
%D \stoptyping
%D does not work properly. See the output of the following

\setuphead[section][separator=-]
\setuphead[subsection][separator=.]


\chapter[chap]{First Chapter}
\section[sec]{First Section}
\subsection[subsec]{First Subsection}
As you may have noticed, \in[subsec] is the first subsubsection of
\in[sec], which in turn is the first section of \in[chap].

Notice that the all the separators in the subsection have changed, and the
separator is not honored in the references.

The reason that this happens is \tex{@@longsectionnumber} can not 
keep track of sectioning levels. One way to overcome this is to associate
the separator with \mono{section-x} rather than with \mono{head}. The
following patch does this, but I am not sure if it will break anything or
not.

\page

% Begin Patch

\setupsection[section-1][separator=.]
\setupsection[section-2][separator=.]
\setupsection[section-3][separator=.]
\setupsection[section-4][separator=.]
\setupsection[section-5][separator=.]
\setupsection[section-6][separator=.]
   
\unprotect
\def\@@longsectionnumber#1%
  {\ifreversesectionnumbers
     \@@shortsectionnumber{#1}%
     \ifnum\countervalue{\??se\previoussection{#1}}>\zerocount
      \csname\??se#1\c!separator\endcsname
       \csname\previoussection{#1}\c!number\endcsname
     \fi
   \else
     \ifnum\countervalue{\??se\previoussection{#1}}>\zerocount
     \csname\previoussection{#1}\c!number\endcsname%
     \csname\??se#1\c!separator\endcsname%
     \fi
     \@@shortsectionnumber{#1}%
   \fi}
\protect

% End Patch

%D Now let us see how we can get the desired output.
%D \startbuffer
%D \setupsection[section-3][separator=-]
%D \stopbuffer
%D \typebuffer
%D which gives the output o the next page
%D \getbuffer
%D \chapter[chap new]{First Chapter}
%D \section[sec new]{First Section}
%D \subsection[subsec new]{First Subsection}
%D As you may have noticed, \in[subsec new] is the first subsubsection of
%D \in[sec new], which in turn is the first section of \in[chap new].
%D \page

% Begin Patch

\setupsection[section-1][separator=.]
\setupsection[section-2][separator=.]
\setupsection[section-3][separator=.]
\setupsection[section-4][separator=.]
\setupsection[section-5][separator=.]
\setupsection[section-6][separator=.]
   
\unprotect
\def\@@longsectionnumber#1%
  {\ifreversesectionnumbers
     \@@shortsectionnumber{#1}%
     \ifnum\countervalue{\??se\previoussection{#1}}>\zerocount
      \csname\??se#1\c!separator\endcsname%AM: was .
       \csname\previoussection{#1}\c!number\endcsname
     \fi
   \else
     \ifnum\countervalue{\??se\previoussection{#1}}>\zerocount
     \csname\previoussection{#1}\c!number\endcsname%
     \csname\??se#1\c!separator\endcsname%AM: was .
     \fi
     \@@shortsectionnumber{#1}%
   \fi}
\protect

% End Patch

%D Now let us see how we can get the desired output.
%D \starttyping
%D \setupsection[section-3][separator=-]
%D \stoptyping
%D which gives the output on the next page

\setupsection[section-3][separator=-]

\chapter[chap new]{First Chapter}
\section[sec new]{First Section}
\subsection[subsec new]{First Subsection}
As you may have noticed, \in[subsec new] is the first subsubsection of
\in[sec new], which in turn is the first section of \in[chap new].

Notice that the section numbering as well as the reference numbering is
correct.

\stoptext

[-- Attachment #3: Type: text/plain, Size: 139 bytes --]

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

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

* Re: Header number separator
  2006-11-14 16:53         ` Aditya Mahajan
@ 2006-11-14 16:57           ` Hans Hagen
  2006-11-15 15:38           ` Hans Hagen
  1 sibling, 0 replies; 10+ messages in thread
From: Hans Hagen @ 2006-11-14 16:57 UTC (permalink / raw)


Aditya Mahajan wrote:
> On Tue, 14 Nov 2006, Hans Hagen wrote:
>
>> Jeff Smith wrote:
>>> On 11/7/06, Aditya Mahajan <adityam@umich.edu> wrote:
>>>
>>>
>>>
>>>> I need this functionality for a project (IEEE conference style), so
>>>> here is hack to get the feature. The referencing also works.
>>>>
>>>> Use with caution, can break existing macros.
>>>>
>>>
>>> Wow, thanks a lot! This works as expected. In what situation can it
>>> break existing macros? I intend to use that extensively but in a
>>> fairly simple document (a thesis... yeah, another one in ConTeXt!). Is
>>> there anything I should _not_ do?
>>>
>> hm, can on esummarize what will break macros? (i was away for a week 
>> with time for email)
>
> A patch that I sent to Jeff. There is a problem with separators and 
> setuphead. I have summarized the problem and a possible patch in the 
> attached file. However, I do not know if it will break something in 
> multi-lingual documents (esp. Arabic), so I sent the patch with a 
> disclaimer.
hm, then let's not patch before tex live code freeze then; after all it 
would be bad to break anything arab related the first week after a tug 
conference with a focus on high quality arab (including arab math)

Hans

-- 

-----------------------------------------------------------------
                                          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] 10+ messages in thread

* Re: Header number separator
  2006-11-14 16:53         ` Aditya Mahajan
  2006-11-14 16:57           ` Hans Hagen
@ 2006-11-15 15:38           ` Hans Hagen
  2006-11-16  1:14             ` Aditya Mahajan
  1 sibling, 1 reply; 10+ messages in thread
From: Hans Hagen @ 2006-11-15 15:38 UTC (permalink / raw)


Aditya Mahajan wrote:
> On Tue, 14 Nov 2006, Hans Hagen wrote:
>
>> Jeff Smith wrote:
>>> On 11/7/06, Aditya Mahajan <adityam@umich.edu> wrote:
>>>
>>>
>>>
>>>> I need this functionality for a project (IEEE conference style), so
>>>> here is hack to get the feature. The referencing also works.
>>>>
>>>> Use with caution, can break existing macros.
>>>>
>>>
>>> Wow, thanks a lot! This works as expected. In what situation can it
>>> break existing macros? I intend to use that extensively but in a
>>> fairly simple document (a thesis... yeah, another one in ConTeXt!). Is
>>> there anything I should _not_ do?
>>>
>> hm, can on esummarize what will break macros? (i was away for a week 
>> with time for email)
>
> A patch that I sent to Jeff. There is a problem with separators and 
> setuphead. I have summarized the problem and a possible patch in the 
> attached file. However, I do not know if it will break something in 
> multi-lingual documents (esp. Arabic), so I sent the patch with a 
> disclaimer.
i took a quick look at it; the problem is that it will mess up other things; the period in fullsectionnumber is a placeholder that will be replaced later on; the actual code where things happen in \doseparatednumber and it's not that easy to hook level dependent separators in there 

(i will reimplement sectionnumbering some day soon due to some other pending issues) 

anyhow, here's another approach: 

\starttext

\unexpanded\def\seplist#1%
  {\ifx\sepnumber\undefined\def\sepnumber{0}\fi
   \increment\sepnumber
   \getfromcommacommand[#1][\sepnumber]%
   \ifx\commalistelement\empty
     \getcommalistsize[#1]%
     \def\sepnumber{\number\commalistsize}%
     \getfromcommacommand[#1][\sepnumber]%
   \fi
   \commalistelement}

% \setuphead[section]   [separator=\seplist{?,!,*}]
% \setuphead[subsection][separator=\seplist{??,!!,**}]

\let\spr\seplist % quick hack 

% \setuphead[section]   [separator={?,!,*}]
% \setuphead[subsection][separator={??,!!,**}]

\setupheads[separator={A,B,C,D,E,F}]

\chapter{test}
\section{test}
\subsection{test}
\subsection{test}
\section{test}
\subsection{test}
\subsection{test}

\stoptext


Hans 


-----------------------------------------------------------------
                                          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] 10+ messages in thread

* Re: Header number separator
  2006-11-15 15:38           ` Hans Hagen
@ 2006-11-16  1:14             ` Aditya Mahajan
  0 siblings, 0 replies; 10+ messages in thread
From: Aditya Mahajan @ 2006-11-16  1:14 UTC (permalink / raw)


On Wed, 15 Nov 2006, Hans Hagen wrote:

> Aditya Mahajan wrote:
>> On Tue, 14 Nov 2006, Hans Hagen wrote:
>>
>>> Jeff Smith wrote:
>>>> On 11/7/06, Aditya Mahajan <adityam@umich.edu> wrote:
>>>>
>>>>
>>>>
>>>>> I need this functionality for a project (IEEE conference style), so
>>>>> here is hack to get the feature. The referencing also works.
>>>>>
>>>>> Use with caution, can break existing macros.
>>>>>
>>>>
>>>> Wow, thanks a lot! This works as expected. In what situation can it
>>>> break existing macros? I intend to use that extensively but in a
>>>> fairly simple document (a thesis... yeah, another one in ConTeXt!). Is
>>>> there anything I should _not_ do?
>>>>
>>> hm, can on esummarize what will break macros? (i was away for a week
>>> with time for email)
>>
>> A patch that I sent to Jeff. There is a problem with separators and
>> setuphead. I have summarized the problem and a possible patch in the
>> attached file. However, I do not know if it will break something in
>> multi-lingual documents (esp. Arabic), so I sent the patch with a
>> disclaimer.
> i took a quick look at it; the problem is that it will mess up other things; the period in fullsectionnumber is a placeholder that will be replaced later on; the actual code where things happen in \doseparatednumber and it's not that easy to hook level dependent separators in there
>
> (i will reimplement sectionnumbering some day soon due to some other pending issues)
>
> anyhow, here's another approach:
> [snip]

This does not work with references, \in[ref] still gives . as the 
separator. Consider IEEE's journal and conference requirements

In the head only show the current number

Section        I.
Subsection     B.
Subsubsection  3)
paragraph      a)

While refereing to a section, use

Section       I
Subsection    I-A
subsubsection I-A.1
paragraph     I-A.1.a


The first part is easy

\setupsection[section-3][bodypartconversion=Romannumerals]
\setupsection[section-4][bodypartconversion=Character,
                          previousnumber=no]
\setupsection[section-5][bodypartconversion=numbers,
                          previousnumber=no]
\setupsection[section-6][bodypartconversion=character,
                          previousnumber=no]

\setuphead[section]
           [numbercommand={\groupedcommand{}{.}}]

\setuphead[subsection]
           [numbercommand={\groupedcommand{}{)}}]


I could never get the second part working and had to go back to Latex 
:-( Hoping that your reimplementation is before my next deadline.


Aditya

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

end of thread, other threads:[~2006-11-16  1:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-07 19:43 Header number separator Jeff Smith
2006-11-07 21:42 ` Aditya Mahajan
2006-11-07 22:22   ` Aditya Mahajan
2006-11-09 16:54     ` Jeff Smith
2006-11-09 18:39       ` Aditya Mahajan
2006-11-14 11:33       ` Hans Hagen
2006-11-14 16:53         ` Aditya Mahajan
2006-11-14 16:57           ` Hans Hagen
2006-11-15 15:38           ` Hans Hagen
2006-11-16  1:14             ` Aditya Mahajan

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).