8

What is the equivalent of the pstricks command \psecurve in tikz?

The yellow line is the \psecurve. It's basically the same as the \pscurve: the curve is defined by all the named points, but is not drawn to the end points.

\documentclass{article}
\usepackage{pstricks}
\pagestyle{empty}
\begin{document}

\begin{pspicture}(0,-3)(5,5)
   \pscurve[linewidth=5pt,arrows=<->](0,0)(2,3)(4,-3)(2,5)(1,0)
  \psecurve[linewidth=1.5pt,linecolor=yellow](0,0)(2,3)(4,-3)(2,5)(1,0)
\end{pspicture}

\end{document}

enter image description here

0

1 Answer 1

5

You can use my style between style (from TikZ: Thick curve segment in a curve):

enter image description here

\documentclass[margin=2mm]{standalone}
\usepackage{tikz}
\usepackage{ifthen}
\usetikzlibrary{decorations.pathreplacing,decorations.markings}
\newcounter{pos}
\tikzset{
  initcounter/.code={\setcounter{pos}{0}},
  style between/.style n args={3}{
    postaction={initcounter, decorate,
      decoration={show path construction, curveto code={
          \addtocounter{pos}{1}
          \pgfmathtruncatemacro{\min}{#1 - 1}
          \ifthenelse{\thepos < #2 \AND \thepos > \min}{
            \draw[#3]
            (\tikzinputsegmentfirst) .. controls
               (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
            .. (\tikzinputsegmentlast);
          }{}
        }
      }
    },
  },
}
\begin{document}
\begin{tikzpicture}[line join=round]
  \draw[line width=5pt,<->]
  (0,0) to[out=70,in=180] (2,3) to[out=0,in=180] (4,-3)
  to [out=0,in=0] (2,5) to[out=180,in=100] (1,0);

  \path [style between={2}{4}{line width=1.5pt,yellow}]
  (0,0) to[out=70,in=180] (2,3) to[out=0,in=180] (4,-3)
  to [out=0,in=0] (2,5) to[out=180,in=100] (1,0);
\end{tikzpicture}
\end{document}
5
  • Could you explain how this works at all?
    – A.Ellett
    Commented Feb 19, 2013 at 0:33
  • @A.Ellett Look at the show path construction decoration into the pgf manual. Commented Feb 19, 2013 at 0:38
  • That's what I've been doing. It still looks like magic to me.
    – A.Ellett
    Commented Feb 19, 2013 at 0:43
  • The default arrow head of TikZ is not as sharp as that of PSTricks. (But it is not the point here) Commented Feb 19, 2013 at 2:09
  • 1
    @GarbageCollector TikZ \neq PSTricks. You may use >=stealth... Commented Feb 19, 2013 at 7:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .