Mark Wibrow | 1 Oct 18:04

Re: parallel arrows: what about

2009/9/29  <koslowj <at> iti.cs.tu-bs.de>:
> Hi Mark,
>
> Thanks, that looks very promising!   Once I figure out, how to move the labels accordingly, I'll be ready to
replace most of my xypic diagrams ;-)
>
> -- Jürgen
>

Hi,

postactions and the markings decoration are your freinds here. See the
docs for details:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations}
\usetikzlibrary{decorations.markings}

%\usepackage{textcomp}

\begin{document}

\pgfdeclaredecoration{single line}{initial}{
	\state{initial}[width=\pgfdecoratedpathlength-1sp]{\pgfpathmoveto{\pgfpointorigin}}
	\state{final}{\pgfpathlineto{\pgfpointorigin}}
}

\tikzset{
	raise line/.style={
(Continue reading)

GGBBRR | 2 Oct 03:10
Picon

variable for loop


I want to do something really simple namely drawing a, say, 5 by 5 grid with
numbers 1 to 25 in each square. I thought that would be possible with a
nested for loop like this:

\draw (0,0) grid (5,5);
\foreach \i in {0,...,4}
  \foreach \j in {0,...,4}
      \node at (0.5+\j, 4.5-\i ) { 5*\i + \j+1 };

but that does not work since { 5*\i + \j+1 } is not evaluated. I have been
searching around but cannot find out how to do this. Closest I got was this:

\draw (0,0) grid (5,5);
\foreach \i in {0,...,4}
  \foreach \j in {0,...,4}
      \node at (0.5+\j, 4.5-\i ) { \pgfmathparse{ 5*\i +
\j+1}\pgfmathresult}

But then I get numbers ending with a decimal .0 (i.e 1.0, 2.0, etc.) and I
just want integers. Of course I can do this by just having 25 lines printing
the numbers, but is there a way to do this in a nested loop?  Can I  perhaps
somehow define a variable in the loop and increase it each time I run
through the loop?

--

-- 
View this message in context: http://www.nabble.com/variable-for-loop-tp25708820p25708820.html
Sent from the pgf-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
(Continue reading)

Picon

Re: variable for loop

Hi Gerben


What you need is the int function. You should thus use:
\pgfmathparse{int(5*\i +\j+1)}
instead. This will provide with your result.

Regards Nick

2009/10/2 GGBBRR <gerben.rotman <at> gmail.com>

I want to do something really simple namely drawing a, say, 5 by 5 grid with
numbers 1 to 25 in each square. I thought that would be possible with a
nested for loop like this:

\draw (0,0) grid (5,5);
\foreach \i in {0,...,4}
 \foreach \j in {0,...,4}
     \node at (0.5+\j, 4.5-\i ) { 5*\i + \j+1 };

but that does not work since { 5*\i + \j+1 } is not evaluated. I have been
searching around but cannot find out how to do this. Closest I got was this:

\draw (0,0) grid (5,5);
\foreach \i in {0,...,4}
 \foreach \j in {0,...,4}
     \node at (0.5+\j, 4.5-\i ) { \pgfmathparse{ 5*\i +
\j+1}\pgfmathresult}

But then I get numbers ending with a decimal .0 (i.e 1.0, 2.0, etc.) and I
just want integers. Of course I can do this by just having 25 lines printing
the numbers, but is there a way to do this in a nested loop?  Can I  perhaps
somehow define a variable in the loop and increase it each time I run
through the loop?


--
View this message in context: http://www.nabble.com/variable-for-loop-tp25708820p25708820.html
Sent from the pgf-users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
pgf-users mailing list
pgf-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
pgf-users mailing list
pgf-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users
Mark Wibrow | 2 Oct 10:33

Re: variable for loop

Hi,

Slightly more succinct, although perhaps less readable:

\foreach \n in {1,...,25}
	\node [shift={(0.5,4.5)}] at ({mod(\n-1,5)}, {-floor((\n-1)/5)}) {\n};

Regards

Mark

2009/10/2 Nick Papior Andersen <nickpapior <at> gmail.com>:
> Hi Gerben
> What you need is the int function. You should thus use:
> \pgfmathparse{int(5*\i +\j+1)}
> instead. This will provide with your result.
> Regards Nick
>
> 2009/10/2 GGBBRR <gerben.rotman <at> gmail.com>
>>
>> I want to do something really simple namely drawing a, say, 5 by 5 grid
>> with
>> numbers 1 to 25 in each square. I thought that would be possible with a
>> nested for loop like this:
>>
>> \draw (0,0) grid (5,5);
>> \foreach \i in {0,...,4}
>>  \foreach \j in {0,...,4}
>>      \node at (0.5+\j, 4.5-\i ) { 5*\i + \j+1 };
>>
>> but that does not work since { 5*\i + \j+1 } is not evaluated. I have been
>> searching around but cannot find out how to do this. Closest I got was
>> this:
>>
>> \draw (0,0) grid (5,5);
>> \foreach \i in {0,...,4}
>>  \foreach \j in {0,...,4}
>>      \node at (0.5+\j, 4.5-\i ) { \pgfmathparse{ 5*\i +
>> \j+1}\pgfmathresult}
>>
>> But then I get numbers ending with a decimal .0 (i.e 1.0, 2.0, etc.) and I
>> just want integers. Of course I can do this by just having 25 lines
>> printing
>> the numbers, but is there a way to do this in a nested loop?  Can I
>>  perhaps
>> somehow define a variable in the loop and increase it each time I run
>> through the loop?
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/variable-for-loop-tp25708820p25708820.html
>> Sent from the pgf-users mailing list archive at Nabble.com.
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9&#45;12, 2009. Register
>> now&#33;
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> pgf-users mailing list
>> pgf-users <at> lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/pgf-users
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> pgf-users mailing list
> pgf-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pgf-users
>
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
GGBBRR | 2 Oct 16:11
Picon

Re: variable for loop


Hello,

Thanks a lot, guys.

This one works well:

> \foreach \n in {1,...,25}
>         \node [shift={(0.5,4.5)}] at ({mod(\n-1,5)}, {-floor((\n-1)/5)})
> {\n}; 
> 

Unfortunately this one did not work for me:

> \pgfmathparse{int(5*\i +\j+1)}
> 
I get an error message saying "PGF Math Error: Unknown function `int'." This
has probably something to do with the version I am running. I am running
this on an Ubuntu 8.04 system, which has pgf 1.18-1 as the latest supported
version. I have tried installing the Debian package for pgf 2.0
(pgf_2.00-1_all.deb), but that made it only worse. It still could not find
'int' but now it also could not find 'mod'. So, I went back to 1.18-1.
Anyways, now that I know about mod and floor I can probably get everything
done.

A different solution I found later last night, is this:

> \newcount\result
> \begin{tikzpicture}
> \draw (0,0) grid (5,5);
> \foreach \i in {0,...,4}
>   \foreach \j in {0,...,4}
>   {
>       \pgfmathparse{ 5*\i + \j+1}
>       \result = \pgfmathresult
>       \node at (0.5+\j, 4.5-\i ) { $\the\result$};
>   } 
> \end{tikzpicture} 
> 

clearly not as nice as the solutions you have suggested.

Regards,
Gerben
--

-- 
View this message in context: http://www.nabble.com/variable-for-loop-tp25708820p25716487.html
Sent from the pgf-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
GGBBRR | 2 Oct 16:12
Picon

Re: variable for loop


Hello,

Thanks a lot, guys.

This one works well:

> \foreach \n in {1,...,25}
>         \node [shift={(0.5,4.5)}] at ({mod(\n-1,5)}, {-floor((\n-1)/5)})
> {\n}; 
> 

Unfortunately this one did not work for me:

> \pgfmathparse{int(5*\i +\j+1)}
> 
I get an error message saying "PGF Math Error: Unknown function `int'." This
has probably something to do with the version I am running. I am running
this on an Ubuntu 8.04 system, which has pgf 1.18-1 as the latest supported
version. I have tried installing the Debian package for pgf 2.0
(pgf_2.00-1_all.deb), but that made it only worse. It still could not find
'int' but now it also could not find 'mod'. So, I went back to 1.18-1.
Anyways, now that I know about mod and floor I can probably get everything
done.

A different solution I found later last night, is this:

> \newcount\result
> \begin{tikzpicture}
> \draw (0,0) grid (5,5);
> \foreach \i in {0,...,4}
>   \foreach \j in {0,...,4}
>   {
>       \pgfmathparse{ 5*\i + \j+1}
>       \result = \pgfmathresult
>       \node at (0.5+\j, 4.5-\i ) { $\the\result$};
>   } 
> \end{tikzpicture} 
> 

clearly not as nice as the solutions you have suggested.

Regards,
Gerben
--

-- 
View this message in context: http://www.nabble.com/variable-for-loop-tp25708820p25716489.html
Sent from the pgf-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
Alain Matthes | 2 Oct 17:21
Picon
Gravatar

Re: variable for loop


Le 2 oct. 2009 à 16:11, GGBBRR a écrit :
>
>> \pgfmathparse{int(5*\i +\j+1)}
>>
> I get an error message saying "PGF Math Error: Unknown function  
> `int'." This
> has probably something to do with the version I am running. I am  
> running
> this on an Ubuntu 8.04 system, which has pgf 1.18-1 as the latest  
> supported
> version. I have tried installing the Debian package for pgf 2.0
> (pgf_2.00-1_all.deb), but that made it only worse.

Hi,

I think "int" is the  cvs version of pgf 2.00
> It still could not find
> 'int' but now it also could not find 'mod'. So, I went back to 1.18-1.
> Anyways, now that I know about mod and floor I can probably get  
> everything
> done.

but mod is in version 2.00. With  pgf 2.00 cvs you have mod and  Mod  
( and I'm very happy )

Somebody knows when the new version of pgf arrives ?

Best Regards

Alain Matthes
------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
koslowj | 3 Oct 13:09
Picon
Picon
Favicon
Gravatar

question concerning coordinate transformations


Hi,

I'm still in the process of converting old xy-pic diagrams into TikZ/PGF and
ran into the following problem. Some diagrams are based on equilateral
triangles being pasted together.  Either I can compute the relevant
coordinates explicitly:

  \begin{tikzpicture}
    [baseline=(current bounding box.east),scale=1.75]
  \node (00) at (0,0)               {$A$};
  \node (20) at (2*cos{30},-1) {$B$};
  \node (01) at (cos{30},.5)     {$C$};
  \node (21) at (3*cos{30},-.5){$D$};
  \draw[->] 
    (00) -- node[auto]{$f$}
    (01);
  \draw[->] 
    (01) -- node[auto]{$g$}
    (21);
  \draw[->] 
    (00) -- node[auto]{$h$}
    (20);
  \draw[->] 
    (20) -- node[auto,swap]{$k$}
    (21);
  \draw[->,out=-60,in=210] 
    (00) to node[auto,swap,pos=.72]{$l$}
    (20);
  \pgfsetlinewidth{2 pt}\pgfsetinnerlinewidth{1.2 pt}
  \draw[-implies]
    (cos{30}+.15,-.7) -- node[auto,swap]{$\tau$} 
    (cos{30}+.15,-1);
  \end{tikzpicture}

which is somewhat messy, or I could change to an appropriate coordinate
system.  Initially I tried to set the new x- and y-vectors separately, but
found out that theses specifications influenced each other in unexpected
ways.  Actually, after setting the x-vector, the y-vector has to be
specified in the already modified coordinate system.  Then I tried the
cm-method of specifying a matrix, which worked fine for positioning the
vertices, but produced problems with the out= and in= angles for curved
arrows.  In particular, the target of the arrow "l" seems to be the
south-east corner of "B", rather than the center of "B".  Could this be a
bug?  Here are the examples with attempted coordinate transformations, first
the cm-variant:

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows,calc}

\begin{document}
\centering

\[\begin{tikzpicture}
    [baseline=(current bounding box.east),
    cm={cos{30},-.5,cos{30},.5,(0,0)},scale=1.75]
  \node (00) at (0,0) {$A$};
  \node (20) at (2,0) {$B$};
  \node (01) at (0,1) {$C$};
  \node (21) at (2,1) {$D$};
  \draw[->] 
    (00) -- node[auto]{$f$}
    (01);
  \draw[->] 
    (01) -- node[auto]{$g$}
    (21);
  \draw[->] 
    (00) -- node[auto]{$h$}
    (20);
  \draw[->] 
    (20) -- node[auto,swap]{$k$}
    (21);
  \draw[->,out=-30,in=-105] 
    (00) to node[auto,swap,pos=.77]{$l$}
    (20);
  \pgfsetlinewidth{2 pt}\pgfsetinnerlinewidth{1.2 pt}
  \draw[-implies]
    (1.25,-.1) -- node[auto,swap]{$\tau$} 
    (1.55,-.4);
  \end{tikzpicture}
\qquad
  \begin{tikzpicture}
    [baseline=(current bounding box.east),
    x={(-30:1)},y={(45:1.41)},scale=1.75]  % both variants work
%    y={(cos{30},.5)},x={(2*cos{30},-1)},scale=1.75]
  \node (00) at (0,0) {$A$};
  \node (20) at (2,0) {$B$};
  \node (01) at (0,1) {$C$};
  \node (21) at (2,1) {$D$};
  \draw[->] 
    (00) -- node[auto]{$f$}
    (01);
  \draw[->] 
    (01) -- node[auto]{$g$}
    (21);
  \draw[->] 
    (00) -- node[auto]{$h$}
    (20);
  \draw[->] 
    (20) -- node[auto,swap]{$k$}
    (21);
  \draw[->,out=-60,in=-150] 
    (00) to node[auto,swap,pos=.72]{$l$}
    (20);
  \pgfsetlinewidth{2 pt}\pgfsetinnerlinewidth{1.2 pt}
  \draw[-implies]
    (1.25,-.1) -- node[auto,swap]{$\tau$} 
    (1.55,-.4);
  \end{tikzpicture}
\]

\end{document}

If somebody knows a better way of realizing these diagrams, please let me
know.

-- Jürgen
--

-- 
View this message in context: http://www.nabble.com/question-concerning-coordinate-transformations-tp25727779p25727779.html
Sent from the pgf-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
pgf-users mailing list
pgf-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users
Alain Matthes | 3 Oct 20:39
Picon
Gravatar

Re: question concerning coordinate transformations


Le 3 oct. 2009 à 13:09, koslowj a écrit :

>
> If somebody knows a better way of realizing these diagrams, please  
> let me
> know.

Hi,  (Sorry for my bad english)

  I don't know if my way is better ...

Firstly, I think it's better to avoid  the relevant
coordinates explicitly.

For example :

\begin{tikzpicture}[ baseline=(current bounding box.east),scale=1.75]
	 \node (00) at (0,0) {$A$};
	 \node (20) at (2,0) {$B$};
	 \node (01) at (0,1) {$C$};
	 \node (21) at (2,1) {$D$};
	 \draw[->] (00) to node[auto]{$f$} (01);
	 \draw[->] (01) to node[auto]{$g$} (21);
% (m1)
	 \path[] (00) to node(m1){} (20);
	 \draw[->] (00) to node[auto]{$h$} (20);
	 \draw[->,auto] (20) to node[swap]{$k$} (21);

\draw[->,out=-60,in=-120]  (00) to node[label=below:$l$](m2){} (20);
\draw[-implies,double distance=1.2pt]
    (m1) to node[auto,swap]{$\tau$}  (m2);
  \end{tikzpicture}

If I use a transformation, you are right : there is problem
  with the nodes and the cm transformation. Perhaps the transformation
  is applied to the  intersection point  of the curved
arrows and the node. So, I used shorten >=10pt,shorten <=10pt
  and the anchor "center" but there is another problem (see the
  end of the mail)

\begin{tikzpicture}[ baseline=(current bounding box.east),%
scale=1.75,cm={cos{30},-.5,cos{30},.5,(0,0)}]
          \draw[help lines] (0,0) grid (3,2);
	 \node (00) at (0,0) {$A$};
	 \node (20) at (2,0) {$B$};
	 \node (01) at (0,1) {$C$};
	 \node (21) at (2,1) {$D$};
  	 \node (a) at  ($(1,-sqrt(2)$) {$a$};
  	 \draw[lightgray,->](00)--(a);
  	 \draw[lightgray,->](20)--(a);
	 \draw[->] (00) to node[auto]{$f$} (01);
	 \draw[->] (01) to node[auto]{$g$} (21);
	 \path[] (00) to node(m1){} (20);
	 \draw[->] (00) to node[auto]{$h$} (20);
	 \draw[->,auto] (20) to node[swap]{$k$} (21);

\draw[->,out=-60,in=-120,shorten >=10pt,shorten <=10pt]%
   (00.center) to node[label=below:$l$](m2){} (20.center);
\draw[-implies,double distance=1.2pt]
    (m1) to node[auto,swap]{$\tau$}  (m2);
  \end{tikzpicture}

I don't know exactly how work x= ... and y=... with polar coordinates  
and
  options out =... and in = ....

With cm, it's possible to use
        \draw[help lines] (0,0) grid (3,2);

Perhaps you want exactly your first drawing and perhaps
  you want the tau curved arrow vertically. It's possible to
  calculate the intersection of tau with l (pgf 2 cvs)

Another way is to place the first part of the drawing in a scope
  but it's not automatically

\begin{tikzpicture}[ baseline=(current bounding box.east),scale=1.75]
          \begin{scope}[cm={cos{30},-.5,cos{30},.5,(0,0)}]
	         \draw[help lines] (0,0) grid (3,2);
		 \node (00) at (0,0) {$A$};
		 \node (20) at (2,0) {$B$};
		 \node (01) at (0,1) {$C$};
		 \node (21) at (2,1) {$D$};
		 \draw[->] (00) to node[auto]{$f$} (01);
		 \draw[->] (01) to node[auto]{$g$} (21);
		 \path[] (00) to node(m1){} (20);
		 \draw[->] (00) to node[auto]{$h$} (20);
		 \draw[->,auto] (20) to node[swap]{$k$} (21);
   \end{scope}

\draw[reset cm,->,out=-80,in=-150,shorten >=8pt,shorten <=8pt]%
   (00.center) to node[pos=.60](m2){} (20.center);

\draw[-implies,double distance=1.2pt]
    (m1) to node[auto,swap]{$\tau$}  (m2) node[]{$a$};
  \end{tikzpicture}

but now there is another problem

\draw[reset cm,->,out=-80,in=-150,red]%
   (00.center) to node[pos=.60](m2){} (20.center);

instead of

\draw[reset cm,->,out=-80,in=-150,shorten >=8pt,shorten <=8pt]%
   (00.center) to node[pos=.60](m2){} (20.center);

gives a different arrow (perhaps it's normal)

Conclusion: I prefer to avoid coordinates and to draw automatically
the diagram but I seems there are some difficulties to use cm.

Best Regards

Alain Matthes
------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
Michael George | 4 Oct 04:32
Picon
Favicon

bug in callouts?

I am trying to use absolute and relative pointers in my callouts.  I've 
tried a variety of parameters to the "callout absolute pointer" 
variable, but they always seem to point at the most recently defined 
node (!).

Example:

\node[shape=ellipse callout, draw, anchor=west, callout absolute 
pointer={(0,0)}] at (-0.5,16.5) {copy $o_f$ into $o_r \rightarrow a$};

points to some random node in my picture, and not the origin as I expect.

I'm using the ubuntu package for pgf, which is 2.00-1

Any thoughts?

--Mike

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf

Gmane