ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Doubled annotation content
@ 2012-12-06 20:24 Marco Patzer
  2012-12-06 20:59 ` Otared Kavian
  2012-12-07  5:38 ` Wolfgang Schuster
  0 siblings, 2 replies; 9+ messages in thread
From: Marco Patzer @ 2012-12-06 20:24 UTC (permalink / raw)
  To: context

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
___________________________________________________________________________________


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

* Re: Doubled annotation content
  2012-12-06 20:24 Doubled annotation content Marco Patzer
@ 2012-12-06 20:59 ` Otared Kavian
  2012-12-06 22:00   ` Marco Patzer
  2012-12-07  5:38 ` Wolfgang Schuster
  1 sibling, 1 reply; 9+ messages in thread
From: Otared Kavian @ 2012-12-06 20:59 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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 <homerow@lavabit.com> wrote:

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

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

* Re: Doubled annotation content
  2012-12-06 20:59 ` Otared Kavian
@ 2012-12-06 22:00   ` Marco Patzer
  2012-12-06 22:27     ` Aditya Mahajan
  2012-12-07  5:51     ` Wolfgang Schuster
  0 siblings, 2 replies; 9+ messages in thread
From: Marco Patzer @ 2012-12-06 22:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

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

* Re: Doubled annotation content
  2012-12-06 22:00   ` Marco Patzer
@ 2012-12-06 22:27     ` Aditya Mahajan
  2012-12-07  5:51     ` Wolfgang Schuster
  1 sibling, 0 replies; 9+ messages in thread
From: Aditya Mahajan @ 2012-12-06 22:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

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

[-- Attachment #2: Type: text/plain, Size: 485 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] 9+ messages in thread

* Re: Doubled annotation content
  2012-12-06 20:24 Doubled annotation content Marco Patzer
  2012-12-06 20:59 ` Otared Kavian
@ 2012-12-07  5:38 ` Wolfgang Schuster
  2012-12-07  9:26   ` Marco Patzer
  1 sibling, 1 reply; 9+ messages in thread
From: Wolfgang Schuster @ 2012-12-07  5:38 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 06.12.2012 um 21:24 schrieb Marco Patzer <homerow@lavabit.com>:

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

* Re: Doubled annotation content
  2012-12-06 22:00   ` Marco Patzer
  2012-12-06 22:27     ` Aditya Mahajan
@ 2012-12-07  5:51     ` Wolfgang Schuster
  1 sibling, 0 replies; 9+ messages in thread
From: Wolfgang Schuster @ 2012-12-07  5:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 06.12.2012 um 23:00 schrieb Marco Patzer <homerow@lavabit.com>:

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

* Re: Doubled annotation content
  2012-12-07  5:38 ` Wolfgang Schuster
@ 2012-12-07  9:26   ` Marco Patzer
  2012-12-07 13:04     ` Wolfgang Schuster
  0 siblings, 1 reply; 9+ messages in thread
From: Marco Patzer @ 2012-12-07  9:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

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

* Re: Doubled annotation content
  2012-12-07  9:26   ` Marco Patzer
@ 2012-12-07 13:04     ` Wolfgang Schuster
  2012-12-07 13:21       ` Marco Patzer
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Schuster @ 2012-12-07 13:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1194 bytes --]


Am 07.12.2012 um 10:26 schrieb Marco Patzer <homerow@lavabit.com>:

> 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

[-- Attachment #1.2: Type: text/html, Size: 2042 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 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] 9+ messages in thread

* Re: Doubled annotation content
  2012-12-07 13:04     ` Wolfgang Schuster
@ 2012-12-07 13:21       ` Marco Patzer
  0 siblings, 0 replies; 9+ messages in thread
From: Marco Patzer @ 2012-12-07 13:21 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

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

end of thread, other threads:[~2012-12-07 13:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-06 20:24 Doubled annotation content Marco Patzer
2012-12-06 20:59 ` Otared Kavian
2012-12-06 22:00   ` Marco Patzer
2012-12-06 22:27     ` Aditya Mahajan
2012-12-07  5:51     ` Wolfgang Schuster
2012-12-07  5:38 ` Wolfgang Schuster
2012-12-07  9:26   ` Marco Patzer
2012-12-07 13:04     ` Wolfgang Schuster
2012-12-07 13:21       ` Marco Patzer

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