Flavio Costa | 1 Jun 20:42 2008
Picon

dotted decoration

Hello, I'm trying to achieve an effect similar to:

\draw[<->,decorate,decoration={snake,pre length=4em,post length=4em},very thick] (0,3) -- +(18.125em,0);

Instead of "snake", I want the middle part to be "loosely dotted" or maybe "loosely dashed", keeping 4em of
continuous line at each side. However, since dashed or dotted are not decorations but drawing styles, the
above syntax doesn't help.

Is there any decent way of achieving the desired effect in TikZ?

Thanks,

Flavio Costa

      Abra sua conta no Yahoo! Mail, o único sem limite de espaço para armazenamento!
http://br.mail.yahoo.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Till Tantau | 2 Jun 08:33 2008
Picon

Re: problem with pgfpages pacakge

Hi!

I'm sorry about this. This is a bug in the pgfpages code (which only  
became "apparent" with the current CVS version). I fixed it, please  
update to the latest CVS, you will need revision 1.10 of pgfpages.sty.  
Alternatively, find the file pgfpages.sty and the only line reading  
"\hbox{". Replace it by "\vbox{\hbox{" and change the "}}" five lines  
down to "}}}".

Regards,
Till

Am 31.05.2008 um 02:35 schrieb shreyasbabu:

>
> Hi all
> I am having trouble with the pgfpages package.
> The following source gives 2 empty pages.
> I have included the error messages below.
> Any help is highly appreciated.
> Regards
> Shreyas
>
> \documentclass[dvipdfm]{article}
> \usepackage{tikz}
> \usetikzlibrary 
> {arrows,decorations.pathmorphing,backgrounds,positioning,fit}
>
> \special{papersize=297mm,210mm}
>
(Continue reading)

shreyasbabu | 2 Jun 13:19 2008
Picon

Re: pgf keys error with minimum width and minimum height options


Hi again
Yeah it surely looks like a good alternative.
Many thanks for your help.
Regards
Shreyas

Axel E. Retif wrote:
> 
> On  30 May, 2008, at 19:22, shreyasbabu wrote:
> 
>> Hi Axel
>> Thanks for your reply.
>> Well, as I wrote earlier, I have found that the problem was with my  
>> latex
>> (platex) environment.
> 
> This might be out of place, but have you considered Xe(La)TeX?
> 
> http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=xetex
> 
> It works reasonably well with pgf/TikZ, except for patterns, for  
> example, because it uses xdvipdfmx, based on dvipdfmx, which, anyway,  
> you're already using.
> 
> Best,
> 
> Axel
> 
> 
(Continue reading)

张贤义 | 2 Jun 17:58 2008

how to get the integer part from macro '\pgfmathresult'

 Because I need to use the result of \pgfmathparse as the label of node.

 while the \pgfmathresult is a decimal.

 How to get the integer part from "\pgfmathresult"? Any answer will be appreciated.

 The latex code lists as follows:
---------------------------------------------------------
% foo.tex

\documentclass{article}
\usepackage{tikz}
\begin{document}

\path (-4,0)  coordinate (start1);
\path (start1) + (1,1) coordinate (start2);
\path (start2) + (1,1) coordinate (start3);
\path (start3) + (1,1) coordinate (start4);
\path (start4) + (1,1) coordinate (start5);

\foreach \label/\pos in {
  1/start1,
  2/start2,
  3/start3,
  4/start4,
  5/start5}
{
  \foreach \i in {0,1,2,3,4}
  {
    \pgfmathparse{\i*5+\label}
    \let \x\pgfmathresult
    \path ++(\pos)++(\i,-\i) node {\x};
  }
}
\end{tikzpicture}
\end{document}
---------------------------------------------------------























快来用音乐为奥运加油
得奥运会、演唱会门票
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
pgf-users mailing list
pgf-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users
Daniel Alonso i Alemany | 2 Jun 18:15 2008
Picon

Re: how to get the integer part from macro '\pgfmathresult'

El dl 02 de 06 de 2008 a les 23:58 +0800, en/na 张贤义 va escriure:
>  Because I need to use the result of \pgfmathparse as the label of
> node.
> 
>  while the \pgfmathresult is a decimal.
> 
>  How to get the integer part from "\pgfmathresult"? Any answer will be
> appreciated.

Hi. You can use 

\pgfmathtruncatemacro{ macro }{ expression }

(page 411 of the manual).

Your code would be:

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\path (-4,0)  coordinate (start1);
\path (start1) + (1,1) coordinate (start2);
\path (start2) + (1,1) coordinate (start3);
\path (start3) + (1,1) coordinate (start4);
\path (start4) + (1,1) coordinate (start5);

\foreach \label/\pos in {
  1/start1,
  2/start2,
  3/start3,
  4/start4,
  5/start5}
{
  \foreach \i in {0,1,2,3,4}
  {
    \pgfmathtruncatemacro{\x}{\i*5+\label}
    \path ++(\pos)++(\i,-\i) node {\x};
  }
}
\end{tikzpicture}
\end{document}

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
pgf-users mailing list
pgf-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users
张贤义 | 2 Jun 18:47 2008

Re: how to get the integer part from macro

Thank you very much. 

It really works.

 
 
 

在2008-06-03,"Daniel Alonso i Alemany" <dani <at> niunpamde.net> 写道:
El dl 02 de 06 de 2008 a les 23:58 +0800, en/na 张贤义 va escriure: > Because I need to use the result of \pgfmathparse as the label of > node. > > while the \pgfmathresult is a decimal. > > How to get the integer part from "\pgfmathresult"? Any answer will be > appreciated. Hi. You can use \pgfmathtruncatemacro{ macro }{ expression } (page 411 of the manual). Your code would be: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \path (-4,0) coordinate (start1); \path (start1) + (1,1) coordinate (start2); \path (start2) + (1,1) coordinate (start3); \path (start3) + (1,1) coordinate (start4); \path (start4) + (1,1) coordinate (start5); \foreach \label/\pos in { 1/start1, 2/start2, 3/start3, 4/start4, 5/start5} { \foreach \i in {0,1,2,3,4} { \pgfmathtruncatemacro{\x}{\i*5+\label} \path ++(\pos)++(\i,-\i) node {\x}; } } \end{tikzpicture} \end{document}


快来用音乐为奥运加油
得奥运会、演唱会门票
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
pgf-users mailing list
pgf-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users
Mark Wibrow | 3 Jun 12:07 2008

Re: dotted decoration

Hi!

Unfortunately there does not seem (to me) to be a straightforward
general solution to this (i.e., that works in the majority of
situations imaginable).  The problems involve how decorations work,
and how arrows are placed on processed softpaths.

It might be possible to define a (meta-)decoration which would do the
job, but getting it to integrate cleanly with tikz keys like `loosely
dashed' and the way arrowheads are specified would be messy (maybe
even impossible).

However, with some minimal hacking of the basic layer (shown below)
something approaching a `decent' solution can be acheived. The hacking
is necessitated by the fact that considering:

\tikz\draw [<->] (0,0) -- (1,1) (2,2) -- (3,3);

the arrows are drawn on the second subpath. The hacked version allows
the arrows to be drawn at the start and end of the entire path.

\tikz\draw [<->, start arrow on first subpath] (0,0) -- (1,1) (2,2) -- (3,3);

The special curveto is required because the first (very tiny) straight
line drawn by the curveto decoration is too small to make the
arrowhead point correctly, so the decoration curveto* gets around this
with an initial state width equivalent to the line width. All of the
above allows the 4em pre and post decorations to have arrows
positioned correctly.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations}
\begin{document}

% Look away now if you don't like hacking...
%
\makeatletter

\newif\ifpgfextractpointsreseonmoveto

\pgfextractpointsreseonmovetotrue%

% Minor hack of the \pgfprocesspathextractpoints process.
%
\def\pgf <at> extractprocessorsecond#1{%
  \ifx#1\pgfsyssoftpath <at> movetotoken%
    \ifpgfextractpointsreseonmoveto%
      % Reset things...
      \let\pgf <at> next=\pgf <at> extractprocessorfirst%
    \else%
      \let\pgf <at> next=\pgf <at>  <at> extractprocessorsecond%
    \fi%
  \else%
    \let\pgf <at> next=\pgf <at>  <at> extractprocessorsecond%
  \fi%
  \pgf <at> next#1%
}

\def\pgf <at> extractprocessorother#1{%
  \ifx#1\pgfsyssoftpath <at> movetotoken%
    \ifpgfextractpointsreseonmoveto%
      % Reset things...
      \let\pgf <at> next=\pgf <at> extractprocessorfirst%
	  \else%
      \let\pgf <at> next=\pgf <at>  <at> extractprocessorother%
    \fi%
  \else%
    \let\pgf <at> next=\pgf <at>  <at> extractprocessorother%
  \fi%
  \pgf <at> next#1%
}

% Minor hack of the \pgfprocesspathreplacestartandend process.
%
\def\pgf <at> replaceprocessother#1{%
  \ifx#1\pgfsyssoftpath <at> movetotoken%
    \ifpgfextractpointsreseonmoveto%
       \pgf <at> replace <at> handle <at> move%
    \fi%
  \fi%
  \pgf <at>  <at> next#1%
}

\tikzset{
  start arrow on first subpath/.code={% <- Not a very good name.
    \csname if#1\endcsname%
      \pgfextractpointsreseonmovetofalse%
    \else%
      \pgfextractpointsreseonmovetotrue%
    \fi},
  start arrow on first subpath/.default=true,
}

\makeatother% ...and now back to business.

% We must make a special curveto
%
\pgfdeclaredecoration{curveto*}{initial}{
	\state{initial}[width=\pgflinewidth, next state=curveto]
	{
		\pgfpathlineto{\pgfqpoint{\pgflinewidth}{0pt}}
	}
  \state{curveto}[width=\pgfdecoratedinputsegmentlength/100]
  {
    \pgfpathlineto{\pgfpointorigin}
  }
  \state{final}{\pgfpathlineto{\pgfpointdecoratedpathlast}}
}

\tikzset{
  dash middle/.style={%
  	postaction={solid, decorate, start arrow on first subpath, draw,
		  decoration={moveto, pre=curveto*, post=curveto*, pre length=#1,
post length=#1}
	  },
  	postaction={decorate, draw, -,
		  decoration={curveto, pre=moveto, post=moveto, pre length=#1, post length=#1}
		}
	}
}

\tikz\draw[<->, loosely dashed, dash middle=4em, very thick] (0,3) --
+(18.125em,0);

\tikz\path[<->, loosely dotted, dash middle=4em, very thick] (0,0) ..
controls (0,2) and (3,0) .. (3,2);

\end{document}

Hope this helps.

Mark

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Mark Wibrow | 3 Jun 12:11 2008

Re: dotted decoration

Actually I just realised a better name for the key `dash middle' would
be `solid ends'.

Mark

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Flavio Costa | 3 Jun 20:09 2008
Picon

Res: dotted decoration

Hi Mark,

Thank you for your reply and your effort. I supposed that maybe there would be a cleaner way, like creating a
new decoration similar to "ticks", but rotated accordingly. Now I see that the arrow tips do not interact
very well with subpaths and with most decoration types. I replaced snakes for ticks but it didn't work
correctly, it seems only path morphing decorations give the desired result.

Your "dash middle" or "solid ends" are interesting, but I'm going to need this effect only once and it does
not justify using all this code just for it. Therefore, I had to adopt the "poor man's solid ends":

\draw[<-,thick] (0,3.5) -- +(4em,0);
\draw[loosely dotted,thick] (4em,3.5) -- +(10.125em,0);
\draw[->,thick] (14.125em,3.5) -- +(4em,0);

Best regards,

Flavio

----- Mensagem original ----
De: Mark Wibrow <m.wibrow <at> googlemail.com>
Para: Flavio Costa <flaviocosta <at> yahoo.com.br>
Cc: TikZ & PGF Mailing List <pgf-users <at> lists.sourceforge.net>
Enviadas: Terça-feira, 3 de Junho de 2008 7:07:46
Assunto: Re: [Pgf-users] dotted decoration

Hi!

Unfortunately there does not seem (to me) to be a straightforward
general solution to this (i.e., that works in the majority of
situations imaginable).  The problems involve how decorations work,
and how arrows are placed on processed softpaths.

It might be possible to define a (meta-)decoration which would do the
job, but getting it to integrate cleanly with tikz keys like `loosely
dashed' and the way arrowheads are specified would be messy (maybe
even impossible).

However, with some minimal hacking of the basic layer (shown below)
something approaching a `decent' solution can be acheived. The hacking
is necessitated by the fact that considering:

\tikz\draw [<->] (0,0) -- (1,1) (2,2) -- (3,3);

the arrows are drawn on the second subpath. The hacked version allows
the arrows to be drawn at the start and end of the entire path.

\tikz\draw [<->, start arrow on first subpath] (0,0) -- (1,1) (2,2) -- (3,3);

The special curveto is required because the first (very tiny) straight
line drawn by the curveto decoration is too small to make the
arrowhead point correctly, so the decoration curveto* gets around this
with an initial state width equivalent to the line width. All of the
above allows the 4em pre and post decorations to have arrows
positioned correctly.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations}
\begin{document}

% Look away now if you don't like hacking...
%
\makeatletter

\newif\ifpgfextractpointsreseonmoveto

\pgfextractpointsreseonmovetotrue%

% Minor hack of the \pgfprocesspathextractpoints process.
%
\def\pgf <at> extractprocessorsecond#1{%
  \ifx#1\pgfsyssoftpath <at> movetotoken%
    \ifpgfextractpointsreseonmoveto%
      % Reset things...
      \let\pgf <at> next=\pgf <at> extractprocessorfirst%
    \else%
      \let\pgf <at> next=\pgf <at>  <at> extractprocessorsecond%
    \fi%
  \else%
    \let\pgf <at> next=\pgf <at>  <at> extractprocessorsecond%
  \fi%
  \pgf <at> next#1%
}

\def\pgf <at> extractprocessorother#1{%
  \ifx#1\pgfsyssoftpath <at> movetotoken%
    \ifpgfextractpointsreseonmoveto%
      % Reset things...
      \let\pgf <at> next=\pgf <at> extractprocessorfirst%
      \else%
      \let\pgf <at> next=\pgf <at>  <at> extractprocessorother%
    \fi%
  \else%
    \let\pgf <at> next=\pgf <at>  <at> extractprocessorother%
  \fi%
  \pgf <at> next#1%
}

% Minor hack of the \pgfprocesspathreplacestartandend process.
%
\def\pgf <at> replaceprocessother#1{%
  \ifx#1\pgfsyssoftpath <at> movetotoken%
    \ifpgfextractpointsreseonmoveto%
       \pgf <at> replace <at> handle <at> move%
    \fi%
  \fi%
  \pgf <at>  <at> next#1%
}

\tikzset{
  start arrow on first subpath/.code={% <- Not a very good name.
    \csname if#1\endcsname%
      \pgfextractpointsreseonmovetofalse%
    \else%
      \pgfextractpointsreseonmovetotrue%
    \fi},
  start arrow on first subpath/.default=true,
}

\makeatother% ...and now back to business.

% We must make a special curveto
%
\pgfdeclaredecoration{curveto*}{initial}{
    \state{initial}[width=\pgflinewidth, next state=curveto]
    {
        \pgfpathlineto{\pgfqpoint{\pgflinewidth}{0pt}}
    }
  \state{curveto}[width=\pgfdecoratedinputsegmentlength/100]
  {
    \pgfpathlineto{\pgfpointorigin}
  }
  \state{final}{\pgfpathlineto{\pgfpointdecoratedpathlast}}
}

\tikzset{
  dash middle/.style={%
      postaction={solid, decorate, start arrow on first subpath, draw,
          decoration={moveto, pre=curveto*, post=curveto*, pre length=#1,
post length=#1}
      },
      postaction={decorate, draw, -,
          decoration={curveto, pre=moveto, post=moveto, pre length=#1, post length=#1}
        }
    }
}

\tikz\draw[<->, loosely dashed, dash middle=4em, very thick] (0,3) --
+(18.125em,0);

\tikz\path[<->, loosely dotted, dash middle=4em, very thick] (0,0) ..
controls (0,2) and (3,0) .. (3,2);

\end{document}

Hope this helps.

Mark

      Abra sua conta no Yahoo! Mail, o único sem limite de espaço para armazenamento!
http://br.mail.yahoo.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Flavio Costa | 3 Jun 20:09 2008
Picon

Res: dotted decoration

Hi Mark,

Thank you for your reply and your effort. I supposed that maybe there would be a cleaner way, like creating a
new decoration similar to "ticks", but rotated accordingly. Now I see that the arrow tips do not interact
very well with subpaths and with most decoration types. I replaced snakes for ticks but it didn't work
correctly, it seems only path morphing decorations give the desired result.

Your "dash middle" or "solid ends" are interesting, but I'm going to need this effect only once and it does
not justify using all this code just for it. Therefore, I had to adopt the "poor man's solid ends":

\draw[<-,thick] (0,3.5) -- +(4em,0);
\draw[loosely dotted,thick] (4em,3.5) -- +(10.125em,0);
\draw[->,thick] (14.125em,3.5) -- +(4em,0);

Best regards,

Flavio

----- Mensagem original ----
De: Mark Wibrow <m.wibrow <at> googlemail.com>
Para: Flavio Costa <flaviocosta <at> yahoo.com.br>
Cc: TikZ & PGF Mailing List <pgf-users <at> lists.sourceforge.net>
Enviadas: Terça-feira, 3 de Junho de 2008 7:07:46
Assunto: Re: [Pgf-users] dotted decoration

Hi!

Unfortunately there does not seem (to me) to be a straightforward
general solution to this (i.e., that works in the majority of
situations imaginable).  The problems involve how decorations work,
and how arrows are placed on processed softpaths.

It might be possible to define a (meta-)decoration which would do the
job, but getting it to integrate cleanly with tikz keys like `loosely
dashed' and the way arrowheads are specified would be messy (maybe
even impossible).

However, with some minimal hacking of the basic layer (shown below)
something approaching a `decent' solution can be acheived. The hacking
is necessitated by the fact that considering:

\tikz\draw [<->] (0,0) -- (1,1) (2,2) -- (3,3);

the arrows are drawn on the second subpath. The hacked version allows
the arrows to be drawn at the start and end of the entire path.

\tikz\draw [<->, start arrow on first subpath] (0,0) -- (1,1) (2,2) -- (3,3);

The special curveto is required because the first (very tiny) straight
line drawn by the curveto decoration is too small to make the
arrowhead point correctly, so the decoration curveto* gets around this
with an initial state width equivalent to the line width. All of the
above allows the 4em pre and post decorations to have arrows
positioned correctly.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations}
\begin{document}

% Look away now if you don't like hacking...
%
\makeatletter

\newif\ifpgfextractpointsreseonmoveto

\pgfextractpointsreseonmovetotrue%

% Minor hack of the \pgfprocesspathextractpoints process.
%
\def\pgf <at> extractprocessorsecond#1{%
  \ifx#1\pgfsyssoftpath <at> movetotoken%
    \ifpgfextractpointsreseonmoveto%
      % Reset things...
      \let\pgf <at> next=\pgf <at> extractprocessorfirst%
    \else%
      \let\pgf <at> next=\pgf <at>  <at> extractprocessorsecond%
    \fi%
  \else%
    \let\pgf <at> next=\pgf <at>  <at> extractprocessorsecond%
  \fi%
  \pgf <at> next#1%
}

\def\pgf <at> extractprocessorother#1{%
  \ifx#1\pgfsyssoftpath <at> movetotoken%
    \ifpgfextractpointsreseonmoveto%
      % Reset things...
      \let\pgf <at> next=\pgf <at> extractprocessorfirst%
      \else%
      \let\pgf <at> next=\pgf <at>  <at> extractprocessorother%
    \fi%
  \else%
    \let\pgf <at> next=\pgf <at>  <at> extractprocessorother%
  \fi%
  \pgf <at> next#1%
}

% Minor hack of the \pgfprocesspathreplacestartandend process.
%
\def\pgf <at> replaceprocessother#1{%
  \ifx#1\pgfsyssoftpath <at> movetotoken%
    \ifpgfextractpointsreseonmoveto%
       \pgf <at> replace <at> handle <at> move%
    \fi%
  \fi%
  \pgf <at>  <at> next#1%
}

\tikzset{
  start arrow on first subpath/.code={% <- Not a very good name.
    \csname if#1\endcsname%
      \pgfextractpointsreseonmovetofalse%
    \else%
      \pgfextractpointsreseonmovetotrue%
    \fi},
  start arrow on first subpath/.default=true,
}

\makeatother% ...and now back to business.

% We must make a special curveto
%
\pgfdeclaredecoration{curveto*}{initial}{
    \state{initial}[width=\pgflinewidth, next state=curveto]
    {
        \pgfpathlineto{\pgfqpoint{\pgflinewidth}{0pt}}
    }
  \state{curveto}[width=\pgfdecoratedinputsegmentlength/100]
  {
    \pgfpathlineto{\pgfpointorigin}
  }
  \state{final}{\pgfpathlineto{\pgfpointdecoratedpathlast}}
}

\tikzset{
  dash middle/.style={%
      postaction={solid, decorate, start arrow on first subpath, draw,
          decoration={moveto, pre=curveto*, post=curveto*, pre length=#1,
post length=#1}
      },
      postaction={decorate, draw, -,
          decoration={curveto, pre=moveto, post=moveto, pre length=#1, post length=#1}
        }
    }
}

\tikz\draw[<->, loosely dashed, dash middle=4em, very thick] (0,3) --
+(18.125em,0);

\tikz\path[<->, loosely dotted, dash middle=4em, very thick] (0,0) ..
controls (0,2) and (3,0) .. (3,2);

\end{document}

Hope this helps.

Mark

      Abra sua conta no Yahoo! Mail, o único sem limite de espaço para armazenamento!
http://br.mail.yahoo.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Gmane