ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Problem with MkIV and TikZ picture remembering
@ 2015-03-03  7:23 Jörg Weger
  2015-03-03  7:25 ` Jörg Weger
  2015-03-03 17:12 ` Aditya Mahajan
  0 siblings, 2 replies; 25+ messages in thread
From: Jörg Weger @ 2015-03-03  7:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users

In the minimal working example below inside of a text two words should 
be printed inside of rounded TikZ rectangles and should be connected by 
an TikZ arrow pointing from the first word to the other.

TikZ offers the remember picture/overlay option for that.

The MWE works in MkII (command “texexec”) which I am not using, but not 
in the latest MkIV (command “context”).

The problem might be that according to the PGF/TikZ manual “You need to 
use a driver that supports picture remembering and you need to run TEX 
twice” (16.13.1 Referencing a Node in a Different Picture).

So my questions are:

1.) Does LuaTeX support TikZ picture remembering?

2.) If so, how can I get ConTeXt MkIV to “run TeX twice”?

3.) If all of the above worked, would that work also if the inline TikZ 
pictures to be remembered are on another file referenced via \input?

I have seen a solution similar to what I want to achieve in the METAFUN 
manual but I don’t have a clue how to get that METAPOST alternative working.


Greetings Jörg


%%%%%%%%%%%%%%%% START MWE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usemodule[tikz]

\usetikzlibrary[shapes.misc,arrows]

\starttext

\tikz[baseline,remember picture] \node[rounded 
rectangle,draw,anchor=text] (n1) {this};
belongs to
\tikz[baseline,remember picture] \node[rounded 
rectangle,draw,anchor=text] (n2) {that};

\starttikzpicture
	[remember picture,overlay]
		\draw[->] (n1.north) to [bend left] (n2.north);
\stoptikzpicture

\stoptext

%%%%%%%%%%%%%%%% STOP MWE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
___________________________________________________________________________________
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] 25+ messages in thread

* Problem with MkIV and TikZ picture remembering
  2015-03-03  7:23 Problem with MkIV and TikZ picture remembering Jörg Weger
@ 2015-03-03  7:25 ` Jörg Weger
  2015-03-03  7:54   ` Wolfgang Schuster
  2015-03-03 17:12 ` Aditya Mahajan
  1 sibling, 1 reply; 25+ messages in thread
From: Jörg Weger @ 2015-03-03  7:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users

In the minimal working example below inside of a text two words should
be printed inside of rounded TikZ rectangles and should be connected by
an TikZ arrow pointing from the first word to the other.

TikZ offers the remember picture/overlay option for that.

The MWE works in MkII (command “texexec”) which I am not using, but not
in the latest MkIV (command “context”).

The problem might be that according to the PGF/TikZ manual “You need to
use a driver that supports picture remembering and you need to run TEX
twice” (16.13.1 Referencing a Node in a Different Picture).

So my questions are:

1.) Does LuaTeX support TikZ picture remembering?

2.) If so, how can I get ConTeXt MkIV to “run TeX twice”?

3.) If all of the above worked, would that work also if the inline TikZ
pictures to be remembered are on another file referenced via \input?

I have seen a solution similar to what I want to achieve in the METAFUN
manual but I don’t have a clue how to get that METAPOST alternative working.


Greetings Jörg


%%%%%%%%%%%%%%%% START MWE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usemodule[tikz]

\usetikzlibrary[shapes.misc,arrows]

\starttext

\tikz[baseline,remember picture] \node[rounded
rectangle,draw,anchor=text] (n1) {this};
belongs to
\tikz[baseline,remember picture] \node[rounded
rectangle,draw,anchor=text] (n2) {that};

\starttikzpicture
	[remember picture,overlay]
		\draw[->] (n1.north) to [bend left] (n2.north);
\stoptikzpicture

\stoptext

%%%%%%%%%%%%%%%% STOP MWE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-03  7:25 ` Jörg Weger
@ 2015-03-03  7:54   ` Wolfgang Schuster
  2015-03-03 12:38     ` Ulrike Fischer
  0 siblings, 1 reply; 25+ messages in thread
From: Wolfgang Schuster @ 2015-03-03  7:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users


> Am 03.03.2015 um 08:25 schrieb Jörg Weger <joerg73.muc@googlemail.com>:
> 
> In the minimal working example below inside of a text two words should
> be printed inside of rounded TikZ rectangles and should be connected by
> an TikZ arrow pointing from the first word to the other.
> 
> TikZ offers the remember picture/overlay option for that.
> 
> The MWE works in MkII (command “texexec”) which I am not using, but not
> in the latest MkIV (command “context”).
> 
> The problem might be that according to the PGF/TikZ manual “You need to
> use a driver that supports picture remembering and you need to run TEX
> twice” (16.13.1 Referencing a Node in a Different Picture).
> 
> So my questions are:
> 
> 1.) Does LuaTeX support TikZ picture remembering?
> 
> 2.) If so, how can I get ConTeXt MkIV to “run TeX twice”?

It depends, when you have a command which writes something into
contexts own auxiliary file context will make another run but when
you have a module like tikz which uses its own auxiliary file just
make another run with „context <filename>”.

> 3.) If all of the above worked, would that work also if the inline TikZ
> pictures to be remembered are on another file referenced via \input?

The problem here is the content of tikz auxiliary file, when I process
your document with MkII it contains

\pgfsyspdfmark {pgfid1}{5006382}{46179011}
\pgfsyspdfmark {pgfid2}{10902017}{46179011}
\pgfsyspdfmark {pgfid3}{4661756}{45230922}

but with MkIV i get the following result:

\gdef \pgf@sys@pdf@mark@pos@pgfid1 {\pgf@x =0sp\pgf@y =0sp}
\gdef \pgf@sys@pdf@mark@pos@pgfid2 {\pgf@x =0sp\pgf@y =0sp}
\gdef \pgf@sys@pdf@mark@pos@pgfid3 {\pgf@x =0sp\pgf@y =0sp}

There is something wrong with the way tikz saves the coordinates
of the nodes in MkIV. 

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-03  7:54   ` Wolfgang Schuster
@ 2015-03-03 12:38     ` Ulrike Fischer
  2015-03-03 13:11       ` Mojca Miklavec
  0 siblings, 1 reply; 25+ messages in thread
From: Ulrike Fischer @ 2015-03-03 12:38 UTC (permalink / raw)
  To: ntg-context

Am Tue, 3 Mar 2015 08:54:00 +0100 schrieb Wolfgang Schuster:

I wanted to try the example in my context standalone installation
and got an "undefined command error" on the \usetikzlibrary.
After a bit digging I could repair this with "first-install.bat
--modules="t-tikz" which seems to get me the newest tikz.

But during this digging I saw

-- that tikz is not mentioned on the module list:
http://modules.contextgarden.net/

-- Following the link to the module
(http://modules.contextgarden.net/TikZ) from
http://wiki.contextgarden.net/TikZ gives an "internal error message"

-- the installation advices on contextgarden doesn't explain what to
do if you want to update modules too. I'm always using (on windows)
first-setup.bat --keep as explained here
http://wiki.contextgarden.net/ConTeXt_Standalone#Updating_2. But
this doesn't seem to update the modules. Is first-setup.bat --all
better if one simply wants the newest complete standalone?


-- 
Ulrike Fischer 
http://www.troubleshooting-tex.de/

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-03 12:38     ` Ulrike Fischer
@ 2015-03-03 13:11       ` Mojca Miklavec
  2015-03-03 13:27         ` Ulrike Fischer
  2015-03-03 13:51         ` Ulrike Fischer
  0 siblings, 2 replies; 25+ messages in thread
From: Mojca Miklavec @ 2015-03-03 13:11 UTC (permalink / raw)
  To: Ulrike Fischer, mailing list for ConTeXt users

On Tue, Mar 3, 2015 at 1:38 PM, Ulrike Fischer wrote:
>
> I wanted to try the example in my context standalone installation
> and got an "undefined command error" on the \usetikzlibrary.
> After a bit digging I could repair this with "first-install.bat
> --modules="t-tikz" which seems to get me the newest tikz.
>
> But during this digging I saw
>
> -- that tikz is not mentioned on the module list:
> http://modules.contextgarden.net/

That site is used for uploading modules by authors. I never thought
about users trying to learn about existence of modules via that site.

> -- Following the link to the module
> (http://modules.contextgarden.net/TikZ) from
> http://wiki.contextgarden.net/TikZ gives an "internal error message"

I removed the link.

> -- the installation advices on contextgarden doesn't explain what to
> do if you want to update modules too.

Do you want to say that the module gets removed next time when you run
first-setup.bat? If that is the case, it should be fixed. Updating
works for me and also keeps the modules up to date.

> I'm always using (on windows)
> first-setup.bat --keep

I would advise you against using the --keep option unless there are
some other/strong reasons to do so. But you shouldn't need keep just
for the sake of a potential bug.

I would need to check again what exactly --all does. But --modules=all
should install all modules and --modules=t-tikz should be sufficient
to keep that module. However I don't know what happens if you use
--modules=t-somethingelse next time. Maybe that removes the modules
that you installed previously as it expects the complete list of
modules. I need to check.

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-03 13:11       ` Mojca Miklavec
@ 2015-03-03 13:27         ` Ulrike Fischer
  2015-03-03 15:29           ` Mojca Miklavec
  2015-03-03 13:51         ` Ulrike Fischer
  1 sibling, 1 reply; 25+ messages in thread
From: Ulrike Fischer @ 2015-03-03 13:27 UTC (permalink / raw)
  To: ntg-context

Am Tue, 3 Mar 2015 14:11:56 +0100 schrieb Mojca Miklavec:

>> -- the installation advices on contextgarden doesn't explain what to
>> do if you want to update modules too.

> Do you want to say that the module gets removed next time when you run
> first-setup.bat? If that is the case, it should be fixed. Updating
> works for me and also keeps the modules up to date.

I have no idea ;-). 

 
>> I'm always using (on windows)
>> first-setup.bat --keep
> 
> I would advise you against using the --keep option unless there are
> some other/strong reasons to do so. 

Then the instructions here are quite misleading:
http://wiki.contextgarden.net/ConTeXt_Standalone#Updating_2

I'm not a regularly context user, I maintain the installation mostly
for tests and want "an up-to-date, complete (with all modules)"
installation and was looking for a command that compares to "tlmgr
update --all" from texlive.  

Did I got it right now that I should do "first-setup.bat" and that
"first-setup.bat --keep" doesn't update the modules?

-- 
Ulrike Fischer 
http://www.troubleshooting-tex.de/

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-03 13:11       ` Mojca Miklavec
  2015-03-03 13:27         ` Ulrike Fischer
@ 2015-03-03 13:51         ` Ulrike Fischer
  1 sibling, 0 replies; 25+ messages in thread
From: Ulrike Fischer @ 2015-03-03 13:51 UTC (permalink / raw)
  To: ntg-context

Am Tue, 3 Mar 2015 14:11:56 +0100 schrieb Mojca Miklavec:

>> -- that tikz is not mentioned on the module list:
>> http://modules.contextgarden.net/
> 
> That site is used for uploading modules by authors. I never thought
> about users trying to learn about existence of modules via that site.

tikz isn't mentioned here too:

http://wiki.contextgarden.net/Modules


-- 
Ulrike Fischer 
http://www.troubleshooting-tex.de/

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-03 13:27         ` Ulrike Fischer
@ 2015-03-03 15:29           ` Mojca Miklavec
  0 siblings, 0 replies; 25+ messages in thread
From: Mojca Miklavec @ 2015-03-03 15:29 UTC (permalink / raw)
  To: Ulrike Fischer, mailing list for ConTeXt users

On Tue, Mar 3, 2015 at 2:27 PM, Ulrike Fischer  wrote:
>
>>> I'm always using (on windows)
>>> first-setup.bat --keep
>>
>> I would advise you against using the --keep option unless there are
>> some other/strong reasons to do so.
>
> Then the instructions here are quite misleading:
> http://wiki.contextgarden.net/ConTeXt_Standalone#Updating_2

Thank you. Removed. I need to review the page. There are some weird
statements there.

If you are familiar with rsync: all that --keep does is omit the
"--delete" flag in rsync modules. It's not exactly the same, but it is
roughly "equally evil" as setting the TeX Live's option to keep the
removed modules installed. Except that here it would accumulate all
the files that ever existed in ConTeXt since the first day when the
user first installed the distribution. When, say, fonts in TeX Live
move around, users would end up with duplicate files at two locations.

> I'm not a regularly context user, I maintain the installation mostly
> for tests and want "an up-to-date, complete (with all modules)"
> installation and was looking for a command that compares to "tlmgr
> update --all" from texlive.
>
> Did I got it right now that I should do "first-setup.bat" and that
> "first-setup.bat --keep" doesn't update the modules?

No, --keep isn't related to updating modules at all. The flag would
help you keep things that you install in your tree from your own
sources (something that doesn't come from the distribution). But it
would also keep all other outdated files. It's waaaaaay better to keep
your own files elsewhere. (Even if simply under "texmf-local" that's
created for you. But not in "texmf-modules" to "texmf-context" or
alike.)

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-03  7:23 Problem with MkIV and TikZ picture remembering Jörg Weger
  2015-03-03  7:25 ` Jörg Weger
@ 2015-03-03 17:12 ` Aditya Mahajan
  2015-03-03 19:04   ` Hans Hagen
  1 sibling, 1 reply; 25+ messages in thread
From: Aditya Mahajan @ 2015-03-03 17:12 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

On Tue, 3 Mar 2015, Jörg Weger wrote:

> In the minimal working example below inside of a text two words should 
> be printed inside of rounded TikZ rectangles and should be connected by 
> an TikZ arrow pointing from the first word to the other.
>
> TikZ offers the remember picture/overlay option for that.
>
> I have seen a solution similar to what I want to achieve in the METAFUN 
> manual but I don’t have a clue how to get that METAPOST alternative working.

Here is how to get the metafun alternative working.

1. I don't understand why I need to manually input the mp-abck file; that 
should be input automatically.

2. The metafun alternative is a bit inconvenient. Suppose you want to draw 
a bunch of such graphics (words connected by arrows). Then, you will need 
to ensure that node names are unique. (Is there a way to get around that?)

3. I did not bother to set the style of the boxes and arrows. So it looks 
a bit dry.

\startMPdefinitions
   % I don't know why this does not get loaded automatically.
   input mp-abck.mpiv;
\stopMPdefinitions

\defineoverlay[highlight] [\positionoverlay{highlightoverlay}]

\startpositionoverlay{highlightoverlay}
   \setMPpositiongraphic{n1}{highlightgraphic}{from=n1,to=n2}
\stoppositionoverlay

\startMPpositiongraphic{highlightgraphic}
   save n; path n[];

   initialize_box(\MPpos{\MPvar{from}}); n[1] := pxy;
   initialize_box(\MPpos{\MPvar{to}});   n[2] := pxy;

   draw n[1];
   draw n[2];

   drawarrow (center n[1]){dir 45} .. {dir -45}(center n[2])
        cutbefore n[1]
        cutafter  n[2];

   anchor_box(\MPanchor{\MPvar{from}});
\stopMPpositiongraphic

\setuppapersize[A6]

\setupbackgrounds[page][background=highlight]

\starttext
\hpos{n1}{this} belongs to \hpos{n2}{that}
\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] 25+ messages in thread

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-03 17:12 ` Aditya Mahajan
@ 2015-03-03 19:04   ` Hans Hagen
  2015-03-03 19:28     ` Aditya Mahajan
  0 siblings, 1 reply; 25+ messages in thread
From: Hans Hagen @ 2015-03-03 19:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 3/3/2015 6:12 PM, Aditya Mahajan wrote:
> On Tue, 3 Mar 2015, Jörg Weger wrote:
>
>> In the minimal working example below inside of a text two words should
>> be printed inside of rounded TikZ rectangles and should be connected
>> by an TikZ arrow pointing from the first word to the other.
>>
>> TikZ offers the remember picture/overlay option for that.
>>
>> I have seen a solution similar to what I want to achieve in the
>> METAFUN manual but I don’t have a clue how to get that METAPOST
>> alternative working.
>
> Here is how to get the metafun alternative working.
>
> 1. I don't understand why I need to manually input the mp-abck file;
> that should be input automatically.
>
> 2. The metafun alternative is a bit inconvenient. Suppose you want to
> draw a bunch of such graphics (words connected by arrows). Then, you
> will need to ensure that node names are unique. (Is there a way to get
> around that?)
>
> 3. I did not bother to set the style of the boxes and arrows. So it
> looks a bit dry.
>
> \startMPdefinitions
>    % I don't know why this does not get loaded automatically.
>    input mp-abck.mpiv;
> \stopMPdefinitions
>
> \defineoverlay[highlight] [\positionoverlay{highlightoverlay}]
>
> \startpositionoverlay{highlightoverlay}
>    \setMPpositiongraphic{n1}{highlightgraphic}{from=n1,to=n2}
> \stoppositionoverlay
>
> \startMPpositiongraphic{highlightgraphic}
>    save n; path n[];
>
>    initialize_box(\MPpos{\MPvar{from}}); n[1] := pxy;
>    initialize_box(\MPpos{\MPvar{to}});   n[2] := pxy;
>
>    draw n[1];
>    draw n[2];
>
>    drawarrow (center n[1]){dir 45} .. {dir -45}(center n[2])
>         cutbefore n[1]
>         cutafter  n[2];
>
>    anchor_box(\MPanchor{\MPvar{from}});
> \stopMPpositiongraphic
>
> \setuppapersize[A6]
>
> \setupbackgrounds[page][background=highlight]
>
> \starttext
> \hpos{n1}{this} belongs to \hpos{n2}{that}
> \stoptext

\startMPdefinitions
     % I don't know why this does not get loaded automatically. Answer: 
seldom needed.
     input mp-abck.mpiv;
\stopMPdefinitions

\defineoverlay[highlight] [\positionoverlay{highlightoverlay}]

\startMPpositiongraphic{highlightgraphic}
     save n; path n[];

     initialize_box(\MPpos{\MPvar{from}}); n[1] := pxy;
     initialize_box(\MPpos{\MPvar{to}});   n[2] := pxy;

     draw n[1];
     draw n[2];

     if ypart center n[1] > ypart center n[2] :
         drawarrow (center n[1]){dir 225} ... {dir -225}(center n[2])
             cutbefore n[1]
             cutafter  n[2] ;
     else :
         drawarrow (center n[1]){dir 45} ... {dir -45}(center n[2])
             cutbefore n[1]
             cutafter  n[2] ;
     fi ;

     anchor_box(\MPanchor{\MPvar{from}});
\stopMPpositiongraphic

\newcounter\connectedwordcounter

\starttexdefinition unexpanded fromword [#1]#2
     \expandafter\pushmacro\csname cwc>#1\endcsname % nesting hack
     \doglobal\increment\connectedwordcounter
     \setxvalue{cwc>#1}{\connectedwordcounter}%
     \startpositionoverlay{highlightoverlay}
         \setMPpositiongraphic
           {\getvalue{cwc>#1}>f}
           {highlightgraphic}
           {from=\getvalue{cwc>#1}>f,to=\getvalue{cwc>#1}>t}
     \stoppositionoverlay
     \hpos{\getvalue{cwc>#1}>f}{#2}%
\stoptexdefinition

\starttexdefinition unexpanded toword [#1]#2
     \hpos{\getvalue{cwc>#1}>t}{#2}
     \expandafter\popmacro\csname cwc>#1\endcsname % nesting hack
\stoptexdefinition

\setuppapersize[A6]

\setupbackgrounds[page][background=highlight]

\starttext
     \fromword[foo]{this} belongs to \toword[foo]{that}
     \fromword[bar]{this} belongs to \toword[bar]{that}
     \fromword[foo]{this} belongs to \toword[foo]{that}
     \fromword[bar]{this} belongs \fromword[bar]{this} belongs to 
\toword[bar]{that} to \toword[bar]{that}
\stoptext

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-03 19:04   ` Hans Hagen
@ 2015-03-03 19:28     ` Aditya Mahajan
  2015-03-07 12:08       ` Jörg Weger
  0 siblings, 1 reply; 25+ messages in thread
From: Aditya Mahajan @ 2015-03-03 19:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Tue, 3 Mar 2015, Hans Hagen wrote:

> On 3/3/2015 6:12 PM, Aditya Mahajan wrote:
>> 2. The metafun alternative is a bit inconvenient. Suppose you want to
>> draw a bunch of such graphics (words connected by arrows). Then, you
>> will need to ensure that node names are unique. (Is there a way to get
>> around that?)
>>
> \newcounter\connectedwordcounter
>
> \starttexdefinition unexpanded fromword [#1]#2
>     \expandafter\pushmacro\csname cwc>#1\endcsname % nesting hack
>     \doglobal\increment\connectedwordcounter
>     \setxvalue{cwc>#1}{\connectedwordcounter}%
>     \startpositionoverlay{highlightoverlay}
>         \setMPpositiongraphic
>           {\getvalue{cwc>#1}>f}
>           {highlightgraphic}
>           {from=\getvalue{cwc>#1}>f,to=\getvalue{cwc>#1}>t}
>     \stoppositionoverlay
>     \hpos{\getvalue{cwc>#1}>f}{#2}%
> \stoptexdefinition
>
> \starttexdefinition unexpanded toword [#1]#2
>     \hpos{\getvalue{cwc>#1}>t}{#2}
>     \expandafter\popmacro\csname cwc>#1\endcsname % nesting hack
> \stoptexdefinition

Thanks.

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
___________________________________________________________________________________

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-03 19:28     ` Aditya Mahajan
@ 2015-03-07 12:08       ` Jörg Weger
  2015-03-07 14:52         ` Hans Hagen
  0 siblings, 1 reply; 25+ messages in thread
From: Jörg Weger @ 2015-03-07 12:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Thank you very much Hans and Aditya for your efforts and sorry for only 
replying now — momentarily I am writing a paper (of course typeset with 
ConTeXt :-) ) that has to get finished.

For now I have dropped the idea of using that certain type of 
illustration in the paper as your METAPOST examples are working, but I 
had forgotten to say that I need effectively two arrows from one part of 
a sentence two two others (I am trying to illustrate a linguistic 
ambiguity problem) and I did not manage to get that working starting 
from your examples. Then I need a shape other than a tight frame to 
surround the words, TikZ’ rounded rectangles were too nice for that. In 
the moment I don’t have the time to dive deeper into METAPOST which 
seems to be a mighty beast from what I see in the Metafun manual, but in 
future I shurely will.

The nice thing about TikZ are that you can use the self explaining 
commands rather intuitively (at least having some experience in Lilypond 
and now ConTeXt), that there are many different building blocks 
predefined that you can use and that there are hundreds of examples in 
the internet that you can use as starting point. So I managed to get 
some things working after a self-tought one day crash course – 
Metapost’s learnig curve seems to be a lot steeper to me. It is really a 
pity that ConTeXt mkiv does not save the node coordinates correctly as 
Wolfgang found out.

Greetings Jörg

On 03.03.2015 20:28, Aditya Mahajan wrote:
> On Tue, 3 Mar 2015, Hans Hagen wrote:
>
>> On 3/3/2015 6:12 PM, Aditya Mahajan wrote:
>>> 2. The metafun alternative is a bit inconvenient. Suppose you want to
>>> draw a bunch of such graphics (words connected by arrows). Then, you
>>> will need to ensure that node names are unique. (Is there a way to get
>>> around that?)
>>>
>> \newcounter\connectedwordcounter
>>
>> \starttexdefinition unexpanded fromword [#1]#2
>>     \expandafter\pushmacro\csname cwc>#1\endcsname % nesting hack
>>     \doglobal\increment\connectedwordcounter
>>     \setxvalue{cwc>#1}{\connectedwordcounter}%
>>     \startpositionoverlay{highlightoverlay}
>>         \setMPpositiongraphic
>>           {\getvalue{cwc>#1}>f}
>>           {highlightgraphic}
>>           {from=\getvalue{cwc>#1}>f,to=\getvalue{cwc>#1}>t}
>>     \stoppositionoverlay
>>     \hpos{\getvalue{cwc>#1}>f}{#2}%
>> \stoptexdefinition
>>
>> \starttexdefinition unexpanded toword [#1]#2
>>     \hpos{\getvalue{cwc>#1}>t}{#2}
>>     \expandafter\popmacro\csname cwc>#1\endcsname % nesting hack
>> \stoptexdefinition
>
> Thanks.
>
> 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] 25+ messages in thread

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-07 12:08       ` Jörg Weger
@ 2015-03-07 14:52         ` Hans Hagen
  2015-03-07 17:30           ` Jörg Weger
  0 siblings, 1 reply; 25+ messages in thread
From: Hans Hagen @ 2015-03-07 14:52 UTC (permalink / raw)
  To: ntg-context

On 3/7/2015 1:08 PM, Jörg Weger wrote:

> Metapost’s learnig curve seems to be a lot steeper to me. It is really a
> pity that ConTeXt mkiv does not save the node coordinates correctly as
> Wolfgang found out.

Is that really an mkiv issue? If I understood well tikz has its own way 
of keeping track of positions independent of context.

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-07 14:52         ` Hans Hagen
@ 2015-03-07 17:30           ` Jörg Weger
  2015-03-07 18:22             ` Wolfgang Schuster
  0 siblings, 1 reply; 25+ messages in thread
From: Jörg Weger @ 2015-03-07 17:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users

 > Is that really an mkiv issue? If I understood well tikz has its own way
 > of keeping track of positions independent of context.

Normally yes.

But there is TikZ’ “remember picture” mode. You can produce several 
independent TikZ pictures on a ConTeXt/LaTeX/plain text page. TikZ tells 
ConTeXt (or LaTeX or plain TeX) to give back the coordinates of those 
pictures on the page after the page has been typeset. TikZ can then draw 
interconnections between those images which are rendered in an extra run.

In my example the rounded rectangles with the words inside are TikZ 
images which are put inline into the ConteXt text by the command

\tikz[baseline] \node[<form of node>, draw, anchor=text] {<text content>}

When I use

\tikz[baseline, remember picture] …

instead I activate the mode explained above and the arrows can be drawn 
according to the “remembered” coordinates after ConTeXt’s first 
typesetting run.

According to Wolfgang Schuster in the first reply in this thread when 
using ConTeXt mkiv – other than mkii – file the coordinates given back 
after the first typesetting run look strange in TikZ’ auxiliary so there 
seems to be a mistake somnewhere between ConTeXt and TikZ in this regard.


Greetings Jörg


On 07.03.2015 15:52, Hans Hagen wrote:
> On 3/7/2015 1:08 PM, Jörg Weger wrote:
>
>> Metapost’s learnig curve seems to be a lot steeper to me. It is really a
>> pity that ConTeXt mkiv does not save the node coordinates correctly as
>> Wolfgang found out.
>
> Is that really an mkiv issue? If I understood well tikz has its own way
> of keeping track of positions independent of context.
>
> 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
> -----------------------------------------------------------------
> ___________________________________________________________________________________
>
> 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] 25+ messages in thread

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-07 17:30           ` Jörg Weger
@ 2015-03-07 18:22             ` Wolfgang Schuster
  2015-03-08 10:11               ` Hans Hagen
  0 siblings, 1 reply; 25+ messages in thread
From: Wolfgang Schuster @ 2015-03-07 18:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users


> Am 07.03.2015 um 18:30 schrieb Jörg Weger <joerg73.muc@googlemail.com>:
> 
> > Is that really an mkiv issue? If I understood well tikz has its own way
> > of keeping track of positions independent of context.
> 
> Normally yes.
> 
> But there is TikZ’ “remember picture” mode. You can produce several independent TikZ pictures on a ConTeXt/LaTeX/plain text page. TikZ tells ConTeXt (or LaTeX or plain TeX) to give back the coordinates of those pictures on the page after the page has been typeset. TikZ can then draw interconnections between those images which are rendered in an extra run.

Tikz uses the pdftex commands \pdfsavepos, \pdflastxpos and \pdflastypos to save the position
of the graphics on the page. ConTeXt isn’t involved in this process which provides its own
interface for this mechanism but Tikz doesn’t use it.

> In my example the rounded rectangles with the words inside are TikZ images which are put inline into the ConteXt text by the command
> 
> \tikz[baseline] \node[<form of node>, draw, anchor=text] {<text content>}
> 
> When I use
> 
> \tikz[baseline, remember picture] …
> 
> instead I activate the mode explained above and the arrows can be drawn according to the “remembered” coordinates after ConTeXt’s first typesetting run.
> 
> According to Wolfgang Schuster in the first reply in this thread when using ConTeXt mkiv – other than mkii – file the coordinates given back after the first typesetting run look strange in TikZ’ auxiliary so there seems to be a mistake somnewhere between ConTeXt and TikZ in this regard.

The problem is the \write command which differs in MkII and MkIV and Tikz
way to prevent the expansion of a command which is written to the auxiliary file.


The following example demonstrates the difference between MkII and MkIV.

In MkII the \noexpand prevents the expansion of \dummytext when writes
content is written to the external file but in MkIV \write is redefined and this
doesn’t work anymore.

%%%% begin example
\newwrite\testwrite

\starttext

\immediate\openout\testwrite=\jobname-dummytext.tmp

\def\dummytext{First sample text.}

\immediate\write\testwrite{\noexpand\dummytext}

\def\dummytext{Second sample text.}

\immediate\write\testwrite{\noexpand\dummytext}

\immediate\closeout\testwrite

\stoptext
%%%% end example

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-07 18:22             ` Wolfgang Schuster
@ 2015-03-08 10:11               ` Hans Hagen
  2015-03-08 11:26                 ` Wolfgang Schuster
  0 siblings, 1 reply; 25+ messages in thread
From: Hans Hagen @ 2015-03-08 10:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 3/7/2015 7:22 PM, Wolfgang Schuster wrote:
>
>> Am 07.03.2015 um 18:30 schrieb Jörg Weger <joerg73.muc@googlemail.com>:
>>
>>> Is that really an mkiv issue? If I understood well tikz has its own way
>>> of keeping track of positions independent of context.
>>
>> Normally yes.
>>
>> But there is TikZ’ “remember picture” mode. You can produce several independent TikZ pictures on a ConTeXt/LaTeX/plain text page. TikZ tells ConTeXt (or LaTeX or plain TeX) to give back the coordinates of those pictures on the page after the page has been typeset. TikZ can then draw interconnections between those images which are rendered in an extra run.
>
> Tikz uses the pdftex commands \pdfsavepos, \pdflastxpos and \pdflastypos to save the position
> of the graphics on the page. ConTeXt isn’t involved in this process which provides its own
> interface for this mechanism but Tikz doesn’t use it.
>
>> In my example the rounded rectangles with the words inside are TikZ images which are put inline into the ConteXt text by the command
>>
>> \tikz[baseline] \node[<form of node>, draw, anchor=text] {<text content>}
>>
>> When I use
>>
>> \tikz[baseline, remember picture] …
>>
>> instead I activate the mode explained above and the arrows can be drawn according to the “remembered” coordinates after ConTeXt’s first typesetting run.
>>
>> According to Wolfgang Schuster in the first reply in this thread when using ConTeXt mkiv – other than mkii – file the coordinates given back after the first typesetting run look strange in TikZ’ auxiliary so there seems to be a mistake somnewhere between ConTeXt and TikZ in this regard.
>
> The problem is the \write command which differs in MkII and MkIV and Tikz
> way to prevent the expansion of a command which is written to the auxiliary file.
>
>
> The following example demonstrates the difference between MkII and MkIV.
>
> In MkII the \noexpand prevents the expansion of \dummytext when writes
> content is written to the external file but in MkIV \write is redefined and this
> doesn’t work anymore.
>
> %%%% begin example
> \newwrite\testwrite
>
> \starttext
>
> \immediate\openout\testwrite=\jobname-dummytext.tmp
>
> \def\dummytext{First sample text.}
>
> \immediate\write\testwrite{\noexpand\dummytext}
>
> \def\dummytext{Second sample text.}
>
> \immediate\write\testwrite{\noexpand\dummytext}
>
> \immediate\closeout\testwrite
>
> \stoptext
> %%%% end example

this should help:

\unexpanded\def\writeviatex#1#2%
   {\ifx\normalwrite\relax\else
     % the \detokenize makes sure we don't expand \noexpanded macros
      \normalwrite#1{\detokenize{#2}}%
    \fi}

(in future version i might replace write completely)

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-08 10:11               ` Hans Hagen
@ 2015-03-08 11:26                 ` Wolfgang Schuster
  2015-03-08 11:55                   ` Hans Hagen
  0 siblings, 1 reply; 25+ messages in thread
From: Wolfgang Schuster @ 2015-03-08 11:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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


> Am 08.03.2015 um 11:11 schrieb Hans Hagen <pragma@wxs.nl>:
> 
> this should help:
> 
> \unexpanded\def\writeviatex#1#2%
>  {\ifx\normalwrite\relax\else
>    % the \detokenize makes sure we don't expand \noexpanded macros
>     \normalwrite#1{\detokenize{#2}}%
>   \fi}
> 
> (in future version i might replace write completely)

Only partially because the saved positions from \pdfsavepos are wrong.

%%%% begin example
\newwrite\testwrite

\immediate\openout\testwrite=\jobname-testwrite.tmp

\parindent=1cm

\starttext

  \indent\pdfsavepos\write\testwrite{1:\number\pdflastxpos:\number\pdflastypos}

\noindent\pdfsavepos\write\testwrite{2:\number\pdflastxpos:\number\pdflastypos}

\page

  \indent\pdfsavepos\write\testwrite{3:\number\pdflastxpos:\number\pdflastypos}

\noindent\pdfsavepos\write\testwrite{4:\number\pdflastxpos:\number\pdflastypos}

\page

  \indent\pdfsavepos\write\testwrite{5:\number\pdflastxpos:\number\pdflastypos}

\noindent\pdfsavepos\write\testwrite{6:\number\pdflastxpos:\number\pdflastypos}

\stoptext
%%%% end example

Wolfgang

[-- Attachment #1.2: Type: text/html, Size: 7936 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] 25+ messages in thread

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-08 11:26                 ` Wolfgang Schuster
@ 2015-03-08 11:55                   ` Hans Hagen
  2015-03-08 12:04                     ` Wolfgang Schuster
  0 siblings, 1 reply; 25+ messages in thread
From: Hans Hagen @ 2015-03-08 11:55 UTC (permalink / raw)
  To: ntg-context

On 3/8/2015 12:26 PM, Wolfgang Schuster wrote:
>
>> Am 08.03.2015 um 11:11 schrieb Hans Hagen <pragma@wxs.nl
>> <mailto:pragma@wxs.nl>>:
>>
>> this should help:
>>
>> \unexpanded\def\writeviatex#1#2%
>>  {\ifx\normalwrite\relax\else
>>    % the \detokenize makes sure we don't expand \noexpanded macros
>>     \normalwrite#1{\detokenize{#2}}%
>>   \fi}
>>
>> (in future version i might replace write completely)
>
> Only partially because the saved positions from \pdfsavepos are wrong.

in what sense wrong?


> %%%% begin example
> \newwrite\testwrite
>
> \immediate\openout\testwrite=\jobname-testwrite.tmp
>
> \parindent=1cm
>
> \starttext
>
>
> \indent\pdfsavepos\write\testwrite{1:\number\pdflastxpos:\number\pdflastypos}
>
> \noindent\pdfsavepos\write\testwrite{2:\number\pdflastxpos:\number\pdflastypos}
>
> \page
>
>
> \indent\pdfsavepos\write\testwrite{3:\number\pdflastxpos:\number\pdflastypos}
>
> \noindent\pdfsavepos\write\testwrite{4:\number\pdflastxpos:\number\pdflastypos}
>
> \page
>
>
> \indent\pdfsavepos\write\testwrite{5:\number\pdflastxpos:\number\pdflastypos}
>
> \noindent\pdfsavepos\write\testwrite{6:\number\pdflastxpos:\number\pdflastypos}
>
> \stoptext
> %%%% end example
>
> 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
> ___________________________________________________________________________________
>


-- 

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-08 11:55                   ` Hans Hagen
@ 2015-03-08 12:04                     ` Wolfgang Schuster
  2015-03-08 17:39                       ` Hans Hagen
  0 siblings, 1 reply; 25+ messages in thread
From: Wolfgang Schuster @ 2015-03-08 12:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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


> Am 08.03.2015 um 12:55 schrieb Hans Hagen <pragma@wxs.nl>:
> 
> On 3/8/2015 12:26 PM, Wolfgang Schuster wrote:
>> 
>>> Am 08.03.2015 um 11:11 schrieb Hans Hagen <pragma@wxs.nl <mailto:pragma@wxs.nl>
>>> <mailto:pragma@wxs.nl <mailto:pragma@wxs.nl>>>:
>>> 
>>> this should help:
>>> 
>>> \unexpanded\def\writeviatex#1#2%
>>> {\ifx\normalwrite\relax\else
>>>   % the \detokenize makes sure we don't expand \noexpanded macros
>>>    \normalwrite#1{\detokenize{#2}}%
>>>  \fi}
>>> 
>>> (in future version i might replace write completely)
>> 
>> Only partially because the saved positions from \pdfsavepos are wrong.
> 
> in what sense wrong?

Content of the external file from MkIV (the entries on the first page show 0
and the values on page 2 and 3 are always the same):

1:0:0
2:0:0
3:4661756:45255023
4:4661756:45255023
5:4661756:45255023
6:4661756:45255023

Content of the external file from MkII (different values for the first
and second position on each page):

1:6526435:46204089
2:4661756:45256000
3:6526435:46204089
4:4661756:45256000
5:6526435:46204089
6:4661756:45256000

Wolfgang

[-- Attachment #1.2: Type: text/html, Size: 4358 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] 25+ messages in thread

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-08 12:04                     ` Wolfgang Schuster
@ 2015-03-08 17:39                       ` Hans Hagen
  2015-03-08 18:07                         ` Wolfgang Schuster
  0 siblings, 1 reply; 25+ messages in thread
From: Hans Hagen @ 2015-03-08 17:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 3/8/2015 1:04 PM, Wolfgang Schuster wrote:
>
>> Am 08.03.2015 um 12:55 schrieb Hans Hagen <pragma@wxs.nl
>> <mailto:pragma@wxs.nl>>:
>>
>> On 3/8/2015 12:26 PM, Wolfgang Schuster wrote:
>>>
>>>> Am 08.03.2015 um 11:11 schrieb Hans Hagen <pragma@wxs.nl
>>>> <mailto:pragma@wxs.nl>
>>>> <mailto:pragma@wxs.nl>>:
>>>>
>>>> this should help:
>>>>
>>>> \unexpanded\def\writeviatex#1#2%
>>>> {\ifx\normalwrite\relax\else
>>>>   % the \detokenize makes sure we don't expand \noexpanded macros
>>>>    \normalwrite#1{\detokenize{#2}}%
>>>>  \fi}
>>>>
>>>> (in future version i might replace write completely)
>>>
>>> Only partially because the saved positions from \pdfsavepos are wrong.
>>
>> in what sense wrong?
>
> Content of the external file from MkIV (the entries on the first page show 0
> and the values on page 2 and 3 are always the same):
>
> 1:0:0
> 2:0:0
> 3:4661756:45255023
> 4:4661756:45255023
> 5:4661756:45255023
> 6:4661756:45255023
>
> Content of the external file from MkII (different values for the first
> and second position on each page):
>
> 1:6526435:46204089
> 2:4661756:45256000
> 3:6526435:46204089
> 4:4661756:45256000
> 5:6526435:46204089
> 6:4661756:45256000

ypositions can differ a bit because we use different fonts and so does 
the interlinespace

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-08 17:39                       ` Hans Hagen
@ 2015-03-08 18:07                         ` Wolfgang Schuster
  2015-03-08 19:04                           ` Hans Hagen
  2015-03-08 22:17                           ` Hans Hagen
  0 siblings, 2 replies; 25+ messages in thread
From: Wolfgang Schuster @ 2015-03-08 18:07 UTC (permalink / raw)
  To: mailing list for ConTeXt users


> Am 08.03.2015 um 18:39 schrieb Hans Hagen <pragma@wxs.nl>:
> 
> On 3/8/2015 1:04 PM, Wolfgang Schuster wrote:
>> 
>>> Am 08.03.2015 um 12:55 schrieb Hans Hagen <pragma@wxs.nl
>>> <mailto:pragma@wxs.nl>>:
>>> 
>>> On 3/8/2015 12:26 PM, Wolfgang Schuster wrote:
>>>> 
>>>>> Am 08.03.2015 um 11:11 schrieb Hans Hagen <pragma@wxs.nl
>>>>> <mailto:pragma@wxs.nl>
>>>>> <mailto:pragma@wxs.nl>>:
>>>>> 
>>>>> this should help:
>>>>> 
>>>>> \unexpanded\def\writeviatex#1#2%
>>>>> {\ifx\normalwrite\relax\else
>>>>>  % the \detokenize makes sure we don't expand \noexpanded macros
>>>>>   \normalwrite#1{\detokenize{#2}}%
>>>>> \fi}
>>>>> 
>>>>> (in future version i might replace write completely)
>>>> 
>>>> Only partially because the saved positions from \pdfsavepos are wrong.
>>> 
>>> in what sense wrong?
>> 
>> Content of the external file from MkIV (the entries on the first page show 0
>> and the values on page 2 and 3 are always the same):
>> 
>> 1:0:0
>> 2:0:0
>> 3:4661756:45255023
>> 4:4661756:45255023
>> 5:4661756:45255023
>> 6:4661756:45255023
>> 
>> Content of the external file from MkII (different values for the first
>> and second position on each page):
>> 
>> 1:6526435:46204089
>> 2:4661756:45256000
>> 3:6526435:46204089
>> 4:4661756:45256000
>> 5:6526435:46204089
>> 6:4661756:45256000
> 
> ypositions can differ a bit because we use different fonts and so does the interlinespace

But the values for both positions should be different which isn’t the case for MkIV
and the first page saves 0 for the x and y positions.

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-08 18:07                         ` Wolfgang Schuster
@ 2015-03-08 19:04                           ` Hans Hagen
  2015-03-08 22:17                           ` Hans Hagen
  1 sibling, 0 replies; 25+ messages in thread
From: Hans Hagen @ 2015-03-08 19:04 UTC (permalink / raw)
  To: ntg-context

On 3/8/2015 7:07 PM, Wolfgang Schuster wrote:
>
>> Am 08.03.2015 um 18:39 schrieb Hans Hagen <pragma@wxs.nl>:
>>
>> On 3/8/2015 1:04 PM, Wolfgang Schuster wrote:
>>>
>>>> Am 08.03.2015 um 12:55 schrieb Hans Hagen <pragma@wxs.nl
>>>> <mailto:pragma@wxs.nl>>:
>>>>
>>>> On 3/8/2015 12:26 PM, Wolfgang Schuster wrote:
>>>>>
>>>>>> Am 08.03.2015 um 11:11 schrieb Hans Hagen <pragma@wxs.nl
>>>>>> <mailto:pragma@wxs.nl>
>>>>>> <mailto:pragma@wxs.nl>>:
>>>>>>
>>>>>> this should help:
>>>>>>
>>>>>> \unexpanded\def\writeviatex#1#2%
>>>>>> {\ifx\normalwrite\relax\else
>>>>>>   % the \detokenize makes sure we don't expand \noexpanded macros
>>>>>>    \normalwrite#1{\detokenize{#2}}%
>>>>>> \fi}
>>>>>>
>>>>>> (in future version i might replace write completely)
>>>>>
>>>>> Only partially because the saved positions from \pdfsavepos are wrong.
>>>>
>>>> in what sense wrong?
>>>
>>> Content of the external file from MkIV (the entries on the first page show 0
>>> and the values on page 2 and 3 are always the same):
>>>
>>> 1:0:0
>>> 2:0:0
>>> 3:4661756:45255023
>>> 4:4661756:45255023
>>> 5:4661756:45255023
>>> 6:4661756:45255023
>>>
>>> Content of the external file from MkII (different values for the first
>>> and second position on each page):
>>>
>>> 1:6526435:46204089
>>> 2:4661756:45256000
>>> 3:6526435:46204089
>>> 4:4661756:45256000
>>> 5:6526435:46204089
>>> 6:4661756:45256000
>>
>> ypositions can differ a bit because we use different fonts and so does the interlinespace
>
> But the values for both positions should be different which isn’t the case for MkIV
> and the first page saves 0 for the x and y positions.

hm, after some playing with it i think that is a luatex bug (it expands 
the positions in a tex.write which is wrong

so we need to revert to this:

\def\syst_write_execute#1%
   {\ctxcommand{execute(\!!bs#1\!!es)}}

\unexpanded\def\write#1#%
   {\ifnum#1=18
      \expandafter\syst_write_execute
    \else
      \normalwrite#1%
    \fi}

(context itself doesn't suffer from this as it does things differently; 
maybe i should make an api and then nil \pdf*pos)

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-08 18:07                         ` Wolfgang Schuster
  2015-03-08 19:04                           ` Hans Hagen
@ 2015-03-08 22:17                           ` Hans Hagen
  2015-03-13 13:17                             ` Jörg Weger
  1 sibling, 1 reply; 25+ messages in thread
From: Hans Hagen @ 2015-03-08 22:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 3/8/2015 7:07 PM, Wolfgang Schuster wrote:
>
>> Am 08.03.2015 um 18:39 schrieb Hans Hagen <pragma@wxs.nl>:
>>
>> On 3/8/2015 1:04 PM, Wolfgang Schuster wrote:
>>>
>>>> Am 08.03.2015 um 12:55 schrieb Hans Hagen <pragma@wxs.nl
>>>> <mailto:pragma@wxs.nl>>:
>>>>
>>>> On 3/8/2015 12:26 PM, Wolfgang Schuster wrote:
>>>>>
>>>>>> Am 08.03.2015 um 11:11 schrieb Hans Hagen <pragma@wxs.nl
>>>>>> <mailto:pragma@wxs.nl>
>>>>>> <mailto:pragma@wxs.nl>>:
>>>>>>
>>>>>> this should help:
>>>>>>
>>>>>> \unexpanded\def\writeviatex#1#2%
>>>>>> {\ifx\normalwrite\relax\else
>>>>>>   % the \detokenize makes sure we don't expand \noexpanded macros
>>>>>>    \normalwrite#1{\detokenize{#2}}%
>>>>>> \fi}
>>>>>>
>>>>>> (in future version i might replace write completely)
>>>>>
>>>>> Only partially because the saved positions from \pdfsavepos are wrong.
>>>>
>>>> in what sense wrong?
>>>
>>> Content of the external file from MkIV (the entries on the first page show 0
>>> and the values on page 2 and 3 are always the same):
>>>
>>> 1:0:0
>>> 2:0:0
>>> 3:4661756:45255023
>>> 4:4661756:45255023
>>> 5:4661756:45255023
>>> 6:4661756:45255023
>>>
>>> Content of the external file from MkII (different values for the first
>>> and second position on each page):
>>>
>>> 1:6526435:46204089
>>> 2:4661756:45256000
>>> 3:6526435:46204089
>>> 4:4661756:45256000
>>> 5:6526435:46204089
>>> 6:4661756:45256000
>>
>> ypositions can differ a bit because we use different fonts and so does the interlinespace
>
> But the values for both positions should be different which isn’t the case for MkIV
> and the first page saves 0 for the x and y positions.

It's a side effect of expansion at the wrong time (where such primitives 
can return wrong values but at least they return something) but 
something like this works:

\def\syst_write#1#2%
   {\ctxcommand{write(\number#1,\!!bs\normalunexpanded{#2}\!!es)}}

\unexpanded\def\writeviatex#1#2%
   {\ifx\normalwrite\relax\else
      \normalwrite#1{#2}%
    \fi}




-- 

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

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-08 22:17                           ` Hans Hagen
@ 2015-03-13 13:17                             ` Jörg Weger
  2015-03-13 13:32                               ` Wolfgang Schuster
  0 siblings, 1 reply; 25+ messages in thread
From: Jörg Weger @ 2015-03-13 13:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Hans Hagen

After putting the definition you proposed last in front of my minimal 
example in mkiv beta 2015.02.03 it worked once and then not any more. I 
also tried to remove all auxiliary files after a new pass.

But today I installed beta 2015.03.10 (complete fresh install as I keep 
the older version in a renamed folder) and now the MWE with your extra 
code renders repeatedly correct.

So this seems to be a workaround until you rewrite “write” as you said.

I will experiment further with tikz’ ‘remember’ picture mode.


Greetings Jörg

%%%%%%%%%%%%%%%% START MWE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%D %%%%%%% Hans’ redefinition of write function: %%%%%%%%%%%

\def\syst_write#1#2%
   {\ctxcommand{write(\number#1,\!!bs\normalunexpanded{#2}\!!es)}}

\unexpanded\def\writeviatex#1#2%
   {\ifx\normalwrite\relax\else
      \normalwrite#1{#2}%
    \fi}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usemodule[tikz]

\usetikzlibrary[shapes.misc,arrows]

\starttext

\tikz[baseline,remember picture] \node[rounded 
rectangle,draw,anchor=text] (n1) {this};
belongs to
\tikz[baseline,remember picture] \node[rounded 
rectangle,draw,anchor=text] (n2) {that};

\starttikzpicture
     [remember picture,overlay]
         \draw[->] (n1.north) to [bend left] (n2.north);
\stoptikzpicture

\stoptext

%%%%%%%%%%%%%%%% STOP MWE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



On 08.03.2015 23:17, Hans Hagen wrote:
> On 3/8/2015 7:07 PM, Wolfgang Schuster wrote:
>>
>>> Am 08.03.2015 um 18:39 schrieb Hans Hagen <pragma@wxs.nl>:
>>>
>>> On 3/8/2015 1:04 PM, Wolfgang Schuster wrote:
>>>>
>>>>> Am 08.03.2015 um 12:55 schrieb Hans Hagen <pragma@wxs.nl
>>>>> <mailto:pragma@wxs.nl>>:
>>>>>
>>>>> On 3/8/2015 12:26 PM, Wolfgang Schuster wrote:
>>>>>>
>>>>>>> Am 08.03.2015 um 11:11 schrieb Hans Hagen <pragma@wxs.nl
>>>>>>> <mailto:pragma@wxs.nl>
>>>>>>> <mailto:pragma@wxs.nl>>:
>>>>>>>
>>>>>>> this should help:
>>>>>>>
>>>>>>> \unexpanded\def\writeviatex#1#2%
>>>>>>> {\ifx\normalwrite\relax\else
>>>>>>>   % the \detokenize makes sure we don't expand \noexpanded macros
>>>>>>>    \normalwrite#1{\detokenize{#2}}%
>>>>>>> \fi}
>>>>>>>
>>>>>>> (in future version i might replace write completely)
>>>>>>
>>>>>> Only partially because the saved positions from \pdfsavepos are
>>>>>> wrong.
>>>>>
>>>>> in what sense wrong?
>>>>
>>>> Content of the external file from MkIV (the entries on the first
>>>> page show 0
>>>> and the values on page 2 and 3 are always the same):
>>>>
>>>> 1:0:0
>>>> 2:0:0
>>>> 3:4661756:45255023
>>>> 4:4661756:45255023
>>>> 5:4661756:45255023
>>>> 6:4661756:45255023
>>>>
>>>> Content of the external file from MkII (different values for the first
>>>> and second position on each page):
>>>>
>>>> 1:6526435:46204089
>>>> 2:4661756:45256000
>>>> 3:6526435:46204089
>>>> 4:4661756:45256000
>>>> 5:6526435:46204089
>>>> 6:4661756:45256000
>>>
>>> ypositions can differ a bit because we use different fonts and so
>>> does the interlinespace
>>
>> But the values for both positions should be different which isn’t the
>> case for MkIV
>> and the first page saves 0 for the x and y positions.
>
> It's a side effect of expansion at the wrong time (where such primitives
> can return wrong values but at least they return something) but
> something like this works:
>
> \def\syst_write#1#2%
>    {\ctxcommand{write(\number#1,\!!bs\normalunexpanded{#2}\!!es)}}
>
> \unexpanded\def\writeviatex#1#2%
>    {\ifx\normalwrite\relax\else
>       \normalwrite#1{#2}%
>     \fi}
>
>
>
>
___________________________________________________________________________________
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] 25+ messages in thread

* Re: Problem with MkIV and TikZ picture remembering
  2015-03-13 13:17                             ` Jörg Weger
@ 2015-03-13 13:32                               ` Wolfgang Schuster
  0 siblings, 0 replies; 25+ messages in thread
From: Wolfgang Schuster @ 2015-03-13 13:32 UTC (permalink / raw)
  To: mailing list for ConTeXt users


> Am 13.03.2015 um 14:17 schrieb Jörg Weger <joerg73.muc@googlemail.com>:
> 
> After putting the definition you proposed last in front of my minimal example in mkiv beta 2015.02.03 it worked once and then not any more. I also tried to remove all auxiliary files after a new pass.
> 
> But today I installed beta 2015.03.10 (complete fresh install as I keep the older version in a renamed folder) and now the MWE with your extra code renders repeatedly correct.
> 
> So this seems to be a workaround until you rewrite “write” as you said.
> 
> I will experiment further with tikz’ ‘remember’ picture mode.

1. The current beta has a fix for the \write command and you don’t need Hans patch.

2. Commands with a _ in the name, e.g. \syst_write can only be used when you place them
   in a group which starts with \unprotect and ends with \protect.

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

end of thread, other threads:[~2015-03-13 13:32 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-03  7:23 Problem with MkIV and TikZ picture remembering Jörg Weger
2015-03-03  7:25 ` Jörg Weger
2015-03-03  7:54   ` Wolfgang Schuster
2015-03-03 12:38     ` Ulrike Fischer
2015-03-03 13:11       ` Mojca Miklavec
2015-03-03 13:27         ` Ulrike Fischer
2015-03-03 15:29           ` Mojca Miklavec
2015-03-03 13:51         ` Ulrike Fischer
2015-03-03 17:12 ` Aditya Mahajan
2015-03-03 19:04   ` Hans Hagen
2015-03-03 19:28     ` Aditya Mahajan
2015-03-07 12:08       ` Jörg Weger
2015-03-07 14:52         ` Hans Hagen
2015-03-07 17:30           ` Jörg Weger
2015-03-07 18:22             ` Wolfgang Schuster
2015-03-08 10:11               ` Hans Hagen
2015-03-08 11:26                 ` Wolfgang Schuster
2015-03-08 11:55                   ` Hans Hagen
2015-03-08 12:04                     ` Wolfgang Schuster
2015-03-08 17:39                       ` Hans Hagen
2015-03-08 18:07                         ` Wolfgang Schuster
2015-03-08 19:04                           ` Hans Hagen
2015-03-08 22:17                           ` Hans Hagen
2015-03-13 13:17                             ` Jörg Weger
2015-03-13 13:32                               ` Wolfgang Schuster

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