ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
Subject: Re: Header number separator
Date: Tue, 14 Nov 2006 11:53:34 -0500 (EST)	[thread overview]
Message-ID: <Pine.WNT.4.63.0611141147290.1620@nqvgln> (raw)
In-Reply-To: <4559A99A.2090308@wxs.nl>

[-- 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

  reply	other threads:[~2006-11-14 16:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-07 19:43 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 [this message]
2006-11-14 16:57           ` Hans Hagen
2006-11-15 15:38           ` Hans Hagen
2006-11-16  1:14             ` Aditya Mahajan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.WNT.4.63.0611141147290.1620@nqvgln \
    --to=adityam@umich.edu \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).