Place an annotation before it is defined
Hi, what is the best solution to place the content of annotations before they are defined in the text? What comes to mind is writing the content into an external file and read it in the next run. But maybe I overcomplicate things (usually I do) and there's a simpler solution. Here's an example: \usemodule [annotation] \defineannotation [myannotation] \setupannotation [myannotation] [alternative=myalternative] \defineannotationalternative [myalternative] [renderingsetup=annotation:myalternative] \startsetups [annotation:myalternative] Content: \placeannotationcontent \stopsetups \starttext %% The annotation content should be placed here. \input ward \blank %% Although it is defined later \startmyannotation \input knuth \stopmyannotation \stoptext Marco
On 1/7/2013 10:20 PM, Marco Patzer wrote:
Hi,
what is the best solution to place the content of annotations before they are defined in the text? What comes to mind is writing the content into an external file and read it in the next run. But maybe I overcomplicate things (usually I do) and there's a simpler solution. Here's an example:
buffers (or blocks) ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 2013–01–07 Hans Hagen wrote:
buffers (or blocks)
Buffers apparently can't be used before the content is defined, but it works for blocks (I never used them). Test: \defineblock [bar] \starttext buf: \getbuffer[foo] BBBBBBBBBBB \startbuffer[foo] buf: AAAAAAAAAAA \stopbuffer \useblocks [bar] DDDDDDDDDDD \beginbar block: CCCCCCCCCCC \endbar \stoptext Is there a reason why the blocks favour begin/end instead of start/stop? Looks weird somehow. Marco
Am 07.01.2013 um 22:49 schrieb Marco Patzer
On 2013–01–07 Hans Hagen wrote:
buffers (or blocks)
Buffers apparently can't be used before the content is defined, but it works for blocks (I never used them). Test:
\defineblock [bar]
\starttext
buf: \getbuffer[foo] BBBBBBBBBBB
\startbuffer[foo] buf: AAAAAAAAAAA \stopbuffer
\useblocks [bar] DDDDDDDDDDD
\beginbar block: CCCCCCCCCCC \endbar
\stoptext
Is there a reason why the blocks favour begin/end instead of start/stop? Looks weird somehow.
Blocks use begin/end to allow the same name for the environment as other commands, e.g. for exams: \defineblock[question] \defineblock[answer] \hideblocks[answer] \defineenumeration[question] \defineenumeration[answer] \starttext \chapter{Questions} % Show only the question blocks \beginquestion \startquestion First question. \stopquestion \endquestion \beginanswer \startasnwer Answer to the first question. \stopanswer \endanswer \chapter{Answers} % Show the question with the corresponding answer \useblocks[question,answer] \stoptext Wolfgang
Hello Wolfgang, Last example is not working! I have installed last version of standalone version... Jaroslav Hajtmar Here is this example ... \defineblock[question] \defineblock[answer] \hideblocks[answer] \defineenumeration[question] \defineenumeration[answer] \starttext \chapter{Questions} % Show only the question blocks \beginquestion \startquestion First question. \stopquestion \endquestion \beginanswer \startasnwer Answer to the first question. \stopanswer \endanswer \chapter{Answers} % Show the question with the corresponding answer \useblocks[question,answer] \stoptext Dne 7.1.2013 22:57, Wolfgang Schuster napsal(a):
Am 07.01.2013 um 22:49 schrieb Marco Patzer
: On 2013–01–07 Hans Hagen wrote:
buffers (or blocks) Buffers apparently can't be used before the content is defined, but it works for blocks (I never used them). Test:
\defineblock [bar]
\starttext
buf: \getbuffer[foo] BBBBBBBBBBB
\startbuffer[foo] buf: AAAAAAAAAAA \stopbuffer
\useblocks [bar] DDDDDDDDDDD
\beginbar block: CCCCCCCCCCC \endbar
\stoptext
Is there a reason why the blocks favour begin/end instead of start/stop? Looks weird somehow. Blocks use begin/end to allow the same name for the environment as other commands, e.g. for exams:
\defineblock[question] \defineblock[answer]
\hideblocks[answer]
\defineenumeration[question] \defineenumeration[answer]
\starttext
\chapter{Questions} % Show only the question blocks
\beginquestion \startquestion First question. \stopquestion \endquestion
\beginanswer \startasnwer Answer to the first question. \stopanswer \endanswer
\chapter{Answers} % Show the question with the corresponding answer
\useblocks[question,answer]
\stoptext
Wolfgang ___________________________________________________________________________________ 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 ___________________________________________________________________________________
Am 07.01.2013 um 23:20 schrieb Jaroslav Hajtmar
Hello Wolfgang, Last example is not working! I have installed last version of standalone version…
The example wasn’t tested and I’m not even sure if everything is correct because I haven’t used the commands since a while. Wolfgang
On 2013–01–07 Jaroslav Hajtmar wrote:
Last example is not working! I have installed last version of
\defineblock[question] \defineblock[answer]
\hideblocks[answer]
\defineenumeration[question] \defineenumeration[answer]
\starttext
\chapter{Questions} % Show only the question blocks
\beginquestion \startquestion First question. \stopquestion \endquestion
\beginanswer \startasnwer
\startanswer
Answer to the first question. \stopanswer \endanswer
\chapter{Answers} % Show the question with the corresponding answer
\useblocks[question,answer]
\stoptext
Marco
On 1/7/2013 10:49 PM, Marco Patzer wrote:
On 2013–01–07 Hans Hagen wrote:
buffers (or blocks)
Buffers apparently can't be used before the content is defined, but it works for blocks (I never used them). Test:
\defineblock [bar]
\starttext
buf: \getbuffer[foo] BBBBBBBBBBB
\startbuffer[foo] buf: AAAAAAAAAAA \stopbuffer
\useblocks [bar] DDDDDDDDDDD
\beginbar block: CCCCCCCCCCC \endbar
\stoptext
Is there a reason why the blocks favour begin/end instead of start/stop? Looks weird somehow.
(1) nicer symmetry checks (matching begin/end start/stop) (2) more visible in complex docs (3) it was first needed for \beginquestion \startquestion ... \stopquestion \endquestion etc Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Am 07.01.2013 um 22:20 schrieb Marco Patzer
Hi,
what is the best solution to place the content of annotations before they are defined in the text? What comes to mind is writing the content into an external file and read it in the next run. But maybe I overcomplicate things (usually I do) and there's a simpler solution. Here's an example:
\usemodule [annotation]
\defineannotation [myannotation]
\setupannotation [myannotation] [alternative=myalternative]
\defineannotationalternative [myalternative] [renderingsetup=annotation:myalternative]
\startsetups [annotation:myalternative] Content: \placeannotationcontent \stopsetups
\starttext
%% The annotation content should be placed here.
\input ward \blank
%% Although it is defined later \startmyannotation \input knuth \stopmyannotation
\stoptext
That’s not possible because the content is stored only in memory and is therefore only available after you put the environment in your document. What you can do is to set the content of the environment at the begin of the document and refer to it at a later position like you can do with buffers. \usemodule[annotation] \defineannotation[test][method=buffer,text=Test] \starttest[one] \input knuth \stoptest \starttest[two] \input ward \stoptest \starttext \gettest[two][title=Ward] \gettest[one][title=Knuth] \stoptext Wolfgang
On 2013–01–07 Wolfgang Schuster wrote:
That’s not possible because the content is stored only in memory and is therefore only available after you put the environment in your document.
What you can do is to set the content of the environment at the begin of the document and refer to it at a later position like you can do with buffers.
\usemodule[annotation]
\defineannotation[test][method=buffer,text=Test]
Nice, I didn't know the “method” key. Blocks, in contrast to buffers, seem to be able to place content before it is defined. I did not check how they work, but since I didn't see any temporary files, the only possibility is to write the data to the tuc file, I assume. It is by any chance possible to provide a “method=block”? Marco
Am 07.01.2013 um 22:56 schrieb Marco Patzer
On 2013–01–07 Wolfgang Schuster wrote:
That’s not possible because the content is stored only in memory and is therefore only available after you put the environment in your document.
What you can do is to set the content of the environment at the begin of the document and refer to it at a later position like you can do with buffers.
\usemodule[annotation]
\defineannotation[test][method=buffer,text=Test]
Nice, I didn't know the “method” key.
Blocks, in contrast to buffers, seem to be able to place content before it is defined. I did not check how they work, but since I didn't see any temporary files, the only possibility is to write the data to the tuc file, I assume. It is by any chance possible to provide a “method=block”?
Yes, blocks are stored in the tux-file while buffers are only stored in memory. I played for a while with \setdataset to store the content but dropped it because it required multiple runs and especially in the first run the output would be always wrong because no content is available but I can consider it as a optional method. Wolfgang
On 2013–01–07 Wolfgang Schuster wrote:
Blocks, in contrast to buffers, seem to be able to place content before it is defined. I did not check how they work, but since I didn't see any temporary files, the only possibility is to write the data to the tuc file, I assume. It is by any chance possible to provide a “method=block”?
Yes, blocks are stored in the tux-file while buffers are only stored in memory.
I played for a while with \setdataset to store the content but dropped it because it required multiple runs and especially in the first run the output would be always wrong
That's no problem IMO. Two-pass data is always wrong the first run. In the worst case, it needs an additional run if text moves around too much. But since it's just another method, which is optional, this only applies if it's activated and then the user knows what he/she is doing and that it might be slower.
I can consider it as a optional method.
I think it would be a nice feature. It enables placement of elements where they logically belong, instead of where they are supposed to be printed. It's nothing mission critical though, but you can keep it in mind for a rainy afternoon. Marco
Am 07.01.2013 um 23:20 schrieb Marco Patzer
On 2013–01–07 Wolfgang Schuster wrote:
Blocks, in contrast to buffers, seem to be able to place content before it is defined. I did not check how they work, but since I didn't see any temporary files, the only possibility is to write the data to the tuc file, I assume. It is by any chance possible to provide a “method=block”?
Yes, blocks are stored in the tux-file while buffers are only stored in memory.
I played for a while with \setdataset to store the content but dropped it because it required multiple runs and especially in the first run the output would be always wrong
That's no problem IMO. Two-pass data is always wrong the first run. In the worst case, it needs an additional run if text moves around too much. But since it's just another method, which is optional, this only applies if it's activated and then the user knows what he/she is doing and that it might be slower.
I can consider it as a optional method.
I think it would be a nice feature. It enables placement of elements where they logically belong, instead of where they are supposed to be printed. It's nothing mission critical though, but you can keep it in mind for a rainy afternoon.
You can try the beta from my bitbucket site [0] which uses a two mechanism for named buffers (\startannotation[<NAME>] … \stopannotation) which can be accessed with \getannotation[<NAME>]. [0] https://bitbucket.org/wolfs/annotation/src Wolfgang
On 2013–01–10 Wolfgang Schuster wrote:
You can try the beta from my bitbucket site [0] which uses a two mechanism for named buffers (\startannotation[<NAME>] … \stopannotation) which can be accessed with \getannotation[<NAME>].
It doesn't work for me: \usemodule [annotation] \defineannotation [myannotation] \starttext aaaaa \getannotation [foo] bbbbb \startmyannotation [foo] ANNOTATION \stopmyannotation \stoptext results in aaaaa bbbbb ANNOTATION Furthermore \usemodule [annotation] \defineannotation [myannotation] \setupannotation [myannotation] [alternative=paragraph] \starttext \startmyannotation \stopmyannotation \stoptext results in <+ t-annotation.lua>) ! Undefined control sequence. […] \540>:way ->\sharedcounterparameter \c!way <argument> ...rparameter {\currentcounter }\c!way Tested on: 2013.01.10 01:04 Marco
Am 11.01.2013 um 09:45 schrieb Marco Patzer
On 2013–01–10 Wolfgang Schuster wrote:
You can try the beta from my bitbucket site [0] which uses a two mechanism for named buffers (\startannotation[<NAME>] … \stopannotation) which can be accessed with \getannotation[<NAME>].
It doesn't work for me:
\usemodule [annotation] \defineannotation [myannotation]
Use \defineannotation[myannotation][method=buffer] to disable the output from \startmyannotation … \stopmyannotation.
\starttext
aaaaa \getannotation [foo]
You need \getmyannotation[foo].
bbbbb
\startmyannotation [foo] ANNOTATION \stopmyannotation
\stoptext
results in
aaaaa bbbbb ANNOTATION
Furthermore
\usemodule [annotation] \defineannotation [myannotation] \setupannotation [myannotation] [alternative=paragraph]
\starttext \startmyannotation \stopmyannotation \stoptext
results in
<+ t-annotation.lua>) ! Undefined control sequence.
[…]
\540>:way ->\sharedcounterparameter \c!way <argument> ...rparameter {\currentcounter }\c!way
Tested on: 2013.01.10 01:04
No idea where this comes from because there is no command with this name in the current version of the module. Do you have the following block at the begin of t-annoation.mkvi? %D \module %D [ file=t-annotation, %D version=2013.01.10, %D title=\CONTEXT\ User Module, %D subtitle=Annotations, %D author=Wolfgang Schuster, %D date=\currentdate, %D copyright=Wolfgang Schuster, %D license=GNU General Public License] Wolfgang
On 2013–01–11 Wolfgang Schuster wrote:
Use
\defineannotation[myannotation][method=buffer]
to disable the output from \startmyannotation … \stopmyannotation.
\starttext
aaaaa \getannotation [foo]
You need \getmyannotation[foo].
It works perfectly, though I don't have much to test it with, except one document. Future will show. Thanks a lot for implementing this.
<+ t-annotation.lua>) ! Undefined control sequence.
[…]
\540>:way ->\sharedcounterparameter \c!way <argument> ...rparameter {\currentcounter }\c!way
Tested on: 2013.01.10 01:04
No idea where this comes from because there is no command with this name in the current version of the module.
Ignore it! For some reason mercurial said “Nothing to update” and let me believe I was using the new version but, in fact kept using the old one.
Do you have the following block at the begin of t-annoation.mkvi? […]
Now I do, yes :) Marco
participants (4)
-
Hans Hagen
-
Jaroslav Hajtmar
-
Marco Patzer
-
Wolfgang Schuster