Doubled annotation content
![](https://secure.gravatar.com/avatar/d39338246f50cca667c8256c313d7cfd.jpg?s=120&d=mm&r=g)
In the following example the content of the annotation is printed twice. Bug? \usemodule [annotation] \defineannotation [myannotation] [alternative=command, command=\cmd] \def\cmd {\placeannotationcontent} \starttext \startmyannotation foo \stopmyannotation \stoptext Marco
![](https://secure.gravatar.com/avatar/5faea8b4fa0adb143383811dc94f0d22.jpg?s=120&d=mm&r=g)
Hi Marco,
It seems that your command \cmd places again the content… Why do you want that command?
This works fine:
\usemodule [annotation]
\defineannotation
[myannotation]
\starttext
\startmyannotation
foo
\input knuth.tex
\stopmyannotation
\stoptext
Best regards: OK
On 6 déc. 2012, at 21:24, Marco Patzer
In the following example the content of the annotation is printed twice. Bug?
\usemodule [annotation]
\defineannotation [myannotation] [alternative=command, command=\cmd]
\def\cmd {\placeannotationcontent}
\starttext \startmyannotation foo \stopmyannotation \stoptext
Marco
___________________________________________________________________________________ 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 ___________________________________________________________________________________
![](https://secure.gravatar.com/avatar/d39338246f50cca667c8256c313d7cfd.jpg?s=120&d=mm&r=g)
On 2012–12–06 Otared Kavian wrote:
It seems that your command \cmd places again the content…
That's not the case. Check this example: \usemodule [annotation] \defineannotation [first] [alternative=command, command=\cmdFirst] \defineannotation [second] [alternative=command, command=\cmdSecond] \def\cmdFirst{} \def\cmdSecond {\placeannotationcontent} \starttext \startfirst first %% not printed \stopfirst \startsecond second %% printed twice \stopsecond \stoptext
Why do you want that command?
??? It allows for flexible placement of the content.
This works fine:
\usemodule [annotation] \defineannotation [myannotation]
\starttext \startmyannotation foo
\input knuth.tex \stopmyannotation \stoptext
Try to use a custom command. Marco
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Thu, 6 Dec 2012, Marco Patzer wrote:
On 2012–12–06 Otared Kavian wrote:
It seems that your command \cmd places again the content…
That's not the case. Check this example:
\usemodule [annotation]
\defineannotation [first] [alternative=command, command=\cmdFirst]
\defineannotation [second] [alternative=command, command=\cmdSecond]
\def\cmdFirst{} \def\cmdSecond {\placeannotationcontent}
Untested: Does \unexpanded\def\cmdSecond ... help?
\starttext \startfirst first %% not printed \stopfirst
\startsecond second %% printed twice \stopsecond \stoptext
Aditya
![](https://secure.gravatar.com/avatar/27c34cb91f1e92bd850fe60b3d9ef336.jpg?s=120&d=mm&r=g)
Am 06.12.2012 um 23:00 schrieb Marco Patzer
Why do you want that command?
??? It allows for flexible placement of the content.
You can also use \defineannotationalternative to create your own styles, see - http://www.ntg.nl/pipermail/ntg-context/2012/070019.html and - http://www.ntg.nl/pipermail/ntg-context/2012/070327.html Wolfgang
![](https://secure.gravatar.com/avatar/27c34cb91f1e92bd850fe60b3d9ef336.jpg?s=120&d=mm&r=g)
Am 06.12.2012 um 21:24 schrieb Marco Patzer
In the following example the content of the annotation is printed twice. Bug?
\usemodule [annotation]
\defineannotation [myannotation] [alternative=command, command=\cmd]
\def\cmd {\placeannotationcontent}
The argument for the command keys has to be a macro with two parameters, the first parameters contains the formatted header and the second argument the formatted content of the environment. You have to change your definition of \cmd to \define[2]\cmd{#2} or \define[2]\cmd{\placeannotationcontent} Wolfgang
![](https://secure.gravatar.com/avatar/d39338246f50cca667c8256c313d7cfd.jpg?s=120&d=mm&r=g)
On 2012–12–07 Wolfgang Schuster wrote:
The argument for the command keys has to be a macro with two parameters, the first parameters contains the formatted header and the second argument the formatted content of the environment.
That's how I used it in the past, but after an update I got an error which vanished after I removed the two arguments. I thought the interface might have changed. I used it as follows. What's wrong with that? %% macros=mkvi \usemodule [annotation] \defineannotation [myannotation] [alternative=command, command=\cmd] \starttexdefinition cmd #first #second \placeannotationcontent \stoptexdefinition \starttext \startmyannotation foo \stopmyannotation \stoptext Thanks for the annotationalternative tip, I didn't know that one. Marco
![](https://secure.gravatar.com/avatar/27c34cb91f1e92bd850fe60b3d9ef336.jpg?s=120&d=mm&r=g)
Am 07.12.2012 um 10:26 schrieb Marco Patzer
On 2012–12–07 Wolfgang Schuster wrote:
The argument for the command keys has to be a macro with two parameters, the first parameters contains the formatted header and the second argument the formatted content of the environment.
That's how I used it in the past, but after an update I got an error which vanished after I removed the two arguments. I thought the interface might have changed.
I used it as follows. What's wrong with that?
%% macros=mkvi \usemodule [annotation]
\defineannotation [myannotation] [alternative=command, command=\cmd]
\starttexdefinition cmd #first #second \placeannotationcontent \stoptexdefinition
Commands need to be unexpandable because when you use the “command”. This is necessary because I check for a command and this needs \unexpanded\def to work. You can create a unexpandable command with \starttexdefintion by adding the unexpanded keyword as first argument to the environment. \starttexdefinition unexpanded cmd #first #second \placeannotationcontent \stoptexdefinition Wolfgang
![](https://secure.gravatar.com/avatar/d39338246f50cca667c8256c313d7cfd.jpg?s=120&d=mm&r=g)
On 2012–12–07 Wolfgang Schuster wrote:
Commands need to be unexpandable because when you use the “command”.
This is necessary because I check for a command and this needs \unexpanded\def to work.
You can create a unexpandable command with \starttexdefintion by adding the unexpanded keyword as first argument to the environment.
\starttexdefinition unexpanded cmd #first #second \placeannotationcontent \stoptexdefinition
That does the trick. Thanks Wolfgang! Marco
participants (4)
-
Aditya Mahajan
-
Marco Patzer
-
Otared Kavian
-
Wolfgang Schuster