ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* counter values as label names
@ 2011-01-03 14:11 Daniel Schopper
  2011-01-03 16:47 ` Thomas A. Schmitz
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Schopper @ 2011-01-03 14:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Dear list,
this seems a really basic question (and probably not even strictly 
ConTeXt-focused) - so please accept my apologies…

I'm trying to construct a macro which first creates two labels in the 
text (\start/stopline and \pagereference) with the value of a counter as 
the label name and then a footnote which prints the page and line 
numbers of those two. Supposedly because of my limited understanding of 
TeX's expansion mechanism I haven't been able to get things working with 
this code:

\setuplinenumbering[%
	location=inner,
	step=5,
         method=page,
         style=\tfxx,
         align=left,
         distance=1.5cm,
         width=0.3cm]
\setupfootnotes[
	location=text,
	numberconversion=empty,
	paragraph=yes,
	]
\definenumber[entrycounter]
\setnumber[entrycounter]{0}
\def\appentry#1#2{%
	\startline[line:\getnumber[entrycounter]]%
	\pagereference[page:\getnumber[entrycounter]]%
	#1%
	\stopline[line:\getnumber[entrycounter]]%
	\footnote{{\bf \at[page:\getnumber[entrycounter]]}%
	\inline[line:\getnumber[entrycounter]] #1] #2}%
	\incrementnumber[entrycounter]%
}

By now I tried to adapt a LaTeX-only-solution which Uwe Lueck suggested 
on the texhax-mailinglist some years ago (cf. 
http://tug.org/pipermail/texhax/2006-July/006599.html) but failed quite 
miserably.
I also tried the same with plain TeX registers (\newcount\entrycounter 
\entrycounter=0 etc.) instead of ConTeXt counters.
Could it be easier to stuff the \pagereference and \startline-commands 
into before= and after= of setupfootnotes?
Could anyone please give me a hint on this?

The purpose of this: I'm trying to use mkIV's page and linenumbering 
facilities for a critical apparatus (in this case endnotes with page and 
line references). As I didn't succeed with Hans Hagen's recent 
suggestion (cf. 
http://www.mail-archive.com/ntg-context@ntg.nl/msg49695.html) I tried 
this quick and dirty way. Although it's far away from being perfect (in 
an ideal world the endnotes should be grouped into one paragraph per 
page and of course there would be more then one apparatus and so on) 
this seems to be a first approach to me…

Cheers,
Daniel
___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: counter values as label names
  2011-01-03 14:11 counter values as label names Daniel Schopper
@ 2011-01-03 16:47 ` Thomas A. Schmitz
  2011-01-03 18:09   ` Daniel Schopper
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas A. Schmitz @ 2011-01-03 16:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users


On Jan 3, 2011, at 3:11 PM, Daniel Schopper wrote:

> Dear list,
> this seems a really basic question (and probably not even strictly ConTeXt-focused) - so please accept my apologies…
> 
> I'm trying to construct a macro which first creates two labels in the text (\start/stopline and \pagereference) with the value of a counter as the label name and then a footnote which prints the page and line numbers of those two. Supposedly because of my limited understanding of TeX's expansion mechanism I haven't been able to get things working with this code:
> 
> \setuplinenumbering[%
> 	location=inner,
> 	step=5,
>        method=page,
>        style=\tfxx,
>        align=left,
>        distance=1.5cm,
>        width=0.3cm]
> \setupfootnotes[
> 	location=text,
> 	numberconversion=empty,
> 	paragraph=yes,
> 	]
> \definenumber[entrycounter]
> \setnumber[entrycounter]{0}
> \def\appentry#1#2{%
> 	\startline[line:\getnumber[entrycounter]]%
> 	\pagereference[page:\getnumber[entrycounter]]%
> 	#1%
> 	\stopline[line:\getnumber[entrycounter]]%
> 	\footnote{{\bf \at[page:\getnumber[entrycounter]]}%
> 	\inline[line:\getnumber[entrycounter]] #1] #2}%
> 	\incrementnumber[entrycounter]%
> }
> 
> By now I tried to adapt a LaTeX-only-solution which Uwe Lueck suggested on the texhax-mailinglist some years ago (cf. http://tug.org/pipermail/texhax/2006-July/006599.html) but failed quite miserably.
> I also tried the same with plain TeX registers (\newcount\entrycounter \entrycounter=0 etc.) instead of ConTeXt counters.
> Could it be easier to stuff the \pagereference and \startline-commands into before= and after= of setupfootnotes?
> Could anyone please give me a hint on this?
> 
The most important hint: please build test files that will compile. Take out anything which isn't relevant to your problem. Knowledgeable people on this list are quite unlikely to wade through code snippets. This page http://www.minimalbeispiel.de/mini-en.html is somewhat biased towards LaTeX, but you should get the drift.

> The purpose of this: I'm trying to use mkIV's page and linenumbering facilities for a critical apparatus (in this case endnotes with page and line references). As I didn't succeed with Hans Hagen's recent suggestion (cf. http://www.mail-archive.com/ntg-context@ntg.nl/msg49695.html)

Again, please provide relevant information. "Didn't work" is not enough information - maybe the color of your mousepad isn't quite right, maybe you forgot a closing brace, who knows? 

Finally: is the format of your apparatus (endnotes) a requirement? You can try and search the mail archive for "linenotes" and have a look at strc-lnt.mkiv. This will build one (or more) apparatus at the bottom of the page; I'm not sure if those can be selected in endnotes.

Thomas

___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: counter values as label names
  2011-01-03 16:47 ` Thomas A. Schmitz
@ 2011-01-03 18:09   ` Daniel Schopper
  2011-01-03 21:15     ` Thomas A. Schmitz
  2011-01-03 22:23     ` Aditya Mahajan
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Schopper @ 2011-01-03 18:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users

First of all thanks for the advice and sorry for my naïve posting!
Here's a test file for what I try to do. The problem is that the page- 
and linenumbers printed by \placefootnotes all take the values of the 
last reference.

\setupfootnotes[
	location=text,
	numberconversion=empty,
	paragraph=,
	]
\newcount\entrycounter
\entrycounter=0
\def\appentry#1#2{%
	\startline[line:\the\entrycounter]%
	\pagereference[page:\the\entrycounter]%
	#1%
	\stopline[line:\the\entrycounter]%
	\footnote{{\bf \at[page:\the\entrycounter]} 
\inline[line:\the\entrycounter] #1] #2}}%
	\advance\entrycounter by1%
\starttext\startlinenumbering
This is a sample \appentry{paragraph}{om. h1}.\\
An this is another \appentry{one}{sentence}.
\stoplinenumbering
\bigskip
Endnotes
\placefootnotes
\stoptext

> Finally: is the format of your apparatus (endnotes) a requirement?
Yes, unfortunately it is.

Thanks again,
Daniel
___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: counter values as label names
  2011-01-03 18:09   ` Daniel Schopper
@ 2011-01-03 21:15     ` Thomas A. Schmitz
  2011-01-03 22:23     ` Aditya Mahajan
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas A. Schmitz @ 2011-01-03 21:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users


On Jan 3, 2011, at 7:09 PM, Daniel Schopper wrote:

> \setupfootnotes[
> 	location=text,
> 	numberconversion=empty,
> 	paragraph=,
> 	]
> \newcount\entrycounter
> \entrycounter=0
> \def\appentry#1#2{%
> 	\startline[line:\the\entrycounter]%
> 	\pagereference[page:\the\entrycounter]%
> 	#1%
> 	\stopline[line:\the\entrycounter]%
> 	\footnote{{\bf \at[page:\the\entrycounter]} \inline[line:\the\entrycounter] #1] #2}}%
> 	\advance\entrycounter by1%
> \starttext\startlinenumbering
> This is a sample \appentry{paragraph}{om. h1}.\\
> An this is another \appentry{one}{sentence}.
> \stoplinenumbering
> \bigskip
> Endnotes
> \placefootnotes
> \stoptext

Tricky. I can't figure out how to do it. First, the code you write can never work. You define a \newcount and set it to 0. Before your text starts, you increase this count, so now its value is 1. Then, you never touch this value again, so effectively, all your references expand to page:1 and line:1. (And, on top of it all, your file has only one line since \\ doesn't start a new line.) But even if you try to increment your counter within the definition of your macro, it won't work because it will be advanced and frozen by the time your footnotes are typeset. So this approach will not work, I'm afraid. I'm not sure this can be done in ConTeXt.

Thomas
___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: counter values as label names
  2011-01-03 18:09   ` Daniel Schopper
  2011-01-03 21:15     ` Thomas A. Schmitz
@ 2011-01-03 22:23     ` Aditya Mahajan
  2011-01-04  8:38       ` Daniel Schopper
  1 sibling, 1 reply; 6+ messages in thread
From: Aditya Mahajan @ 2011-01-03 22:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

On Mon, 3 Jan 2011, Daniel Schopper wrote:

> First of all thanks for the advice and sorry for my naïve posting!
> Here's a test file for what I try to do. The problem is that the page- and 
> linenumbers printed by \placefootnotes all take the values of the last 
> reference.
>
> \setupfootnotes[
> 	location=text,
> 	numberconversion=empty,
> 	paragraph=,
> 	]
> \newcount\entrycounter
> \entrycounter=0
> \def\appentry#1#2{%
> 	\startline[line:\the\entrycounter]%
> 	\pagereference[page:\the\entrycounter]%
> 	#1%
> 	\stopline[line:\the\entrycounter]%
> 	\footnote{{\bf \at[page:\the\entrycounter]} 
> \inline[line:\the\entrycounter] #1] #2}}%
> 	\advance\entrycounter by1%
> \starttext\startlinenumbering
> This is a sample \appentry{paragraph}{om. h1}.\\
> An this is another \appentry{one}{sentence}.
> \stoplinenumbering
> \bigskip
> Endnotes
> \placefootnotes
> \stoptext
>
>> Finally: is the format of your apparatus (endnotes) a requirement?
> Yes, unfortunately it is.

I am not sure what you want to do, but the following at least increments 
the references (in MKIV)

\setupfootnotes
         [
          location=text,
          numberconversion=empty,
          paragraph=,
         ]

\newcount\entrycounter \entrycounter=0
\def\appentry#1#2%
   {\expanded
     {\startline[line:\the\entrycounter]%
         \noexpand\pagereference[page:\the\entrycounter]%
         #1%
      \noexpand\stopline[line:\the\entrycounter]%
      \noexpand\footnote{{\bf \at[page:\the\entrycounter]}
                          \inline[line:\the\entrycounter]
                          #1 #2}}%
      \advance\entrycounter by 1\relax}

\starttext
\startlinenumbering
This is a sample \appentry{paragraph}{om. h1}. \crlf
An this is another \appentry{one}{sentence}.
\stoplinenumbering
\bigskip
Endnotes
\placefootnotes
\stoptext


Aditya

[-- Attachment #2: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: counter values as label names
  2011-01-03 22:23     ` Aditya Mahajan
@ 2011-01-04  8:38       ` Daniel Schopper
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Schopper @ 2011-01-04  8:38 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Thomas and Aditya, thank you both for your replies! As Thomas already 
suspected it was a mere typo that \advance\entrycounter lied outside of 
the macro definition - sorry for the unnecessary confusion.
I tried to compile Aditya's attempt (MKIV  ver: 2010.12.31) but receive 
the following errors:

references      : unknown reference [][lr:b:line:0]
! Missing control sequence inserted.
<inserted text> \inaccessible

 > I am not sure what you want to do,
My simple idea - being a total newbie to macro programming - was to 
create an automation of the following, in which the unique numbers in 
the label names would be inserted by a counter:

\starttext
\startlinenumbering
This is a sample %
	% wrapper macro would start here
	\startline[line:1]\pagereference[page:1]lemma\stopline[line:1]
	\footnote{\at[page:1] \inline[line:1] some comment}%
	% and end here
. \crlf
And this is another 
\startline[line:2]\pagereference[page:2]one\stopline[line:2]\footnote{\at[page:2] 
\inline[line:2] another comment}. \crlf
\stoplinenumbering
\bigskip
Endnotes
\placefootnotes
\stoptext

But probably my whole approach is completely out of the (Con)TeXt-Way of 
thinking… (May it be possible to collect the "endnotes" into various 
buffers and recurse over them at the end?)
Thanks for the hints,
Daniel



Am 03.01.11 23:23, schrieb Aditya Mahajan:
> On Mon, 3 Jan 2011, Daniel Schopper wrote:
>
>> First of all thanks for the advice and sorry for my naïve posting!
>> Here's a test file for what I try to do. The problem is that the page-
>> and linenumbers printed by \placefootnotes all take the values of the
>> last reference.
>>
>> \setupfootnotes[
>> location=text,
>> numberconversion=empty,
>> paragraph=,
>> ]
>> \newcount\entrycounter
>> \entrycounter=0
>> \def\appentry#1#2{%
>> \startline[line:\the\entrycounter]%
>> \pagereference[page:\the\entrycounter]%
>> #1%
>> \stopline[line:\the\entrycounter]%
>> \footnote{{\bf \at[page:\the\entrycounter]}
>> \inline[line:\the\entrycounter] #1] #2}}%
>> \advance\entrycounter by1%
>> \starttext\startlinenumbering
>> This is a sample \appentry{paragraph}{om. h1}.\\
>> An this is another \appentry{one}{sentence}.
>> \stoplinenumbering
>> \bigskip
>> Endnotes
>> \placefootnotes
>> \stoptext
>>
>>> Finally: is the format of your apparatus (endnotes) a requirement?
>> Yes, unfortunately it is.
>
> I am not sure what you want to do, but the following at least increments
> the references (in MKIV)
>
> \setupfootnotes
> [
> location=text,
> numberconversion=empty,
> paragraph=,
> ]
>
> \newcount\entrycounter \entrycounter=0
> \def\appentry#1#2%
> {\expanded
> {\startline[line:\the\entrycounter]%
> \noexpand\pagereference[page:\the\entrycounter]%
> #1%
> \noexpand\stopline[line:\the\entrycounter]%
> \noexpand\footnote{{\bf \at[page:\the\entrycounter]}
> \inline[line:\the\entrycounter]
> #1 #2}}%
> \advance\entrycounter by 1\relax}
>
> \starttext
> \startlinenumbering
> This is a sample \appentry{paragraph}{om. h1}. \crlf
> An this is another \appentry{one}{sentence}.
> \stoplinenumbering
> \bigskip
> Endnotes
> \placefootnotes
> \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  : http://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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2011-01-04  8:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-03 14:11 counter values as label names Daniel Schopper
2011-01-03 16:47 ` Thomas A. Schmitz
2011-01-03 18:09   ` Daniel Schopper
2011-01-03 21:15     ` Thomas A. Schmitz
2011-01-03 22:23     ` Aditya Mahajan
2011-01-04  8:38       ` Daniel Schopper

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