2

I am trying to draw an arrowhead inside a curved path named uu that is crossed by a vertical line named vert, and two nodes placed at the intersections of these two paths. Here is my minimal example:

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

\tikzset{->-/.style={decoration={
                       markings,
                       mark=at position #1 with {\arrow{>}}},
                     postaction={decorate}}
}

\begin{document}

\begin{tikzpicture}
\path[draw, name path=vert] (0,-1)--(0,1);
\path[draw, ->-=0.8, name path=uu] (-1,-0.7) to[out=0,in=-90] (0.3,0)
   to[out=90,in=0] (-1,0.7);
\draw [name intersections={of=vert and uu}] (intersection-1)  node {o};
\draw [name intersections={of=vert and uu}] (intersection-2)  node {o};
\end{tikzpicture}

\end{document}

Compiling it produces the following error message:

! Package tikz Error: I do not know the path named `uu'. Perhaps you misspelt it.

The ->-=0.8 option in the uu path somehow kills the name uu. How can I solve this problem?

frougon
  • 24,283
  • 1
  • 32
  • 55
user8268
  • 259
  • What document class and what latex distribution do you use? With standalone document class your code throws no errors in overleaf! – Hafid Boukhoulda Jul 22 '19 at 14:19
  • article or standalone, this doesn't matter. One gets the error message Package tikz Error: I do not know the path named \uu'. Perhaps you misspelt it.` – frougon Jul 22 '19 at 14:37
  • Your code works very well as is in overleaf. Which latex distribution do you use? maybe you need an update! – Hafid Boukhoulda Jul 22 '19 at 16:04
  • @HafidBoukhoulda I'm not the OP, but I see the error with TL 2019. – frougon Jul 22 '19 at 16:12
  • @HafidBoukhoulda I use miktex (the latest update) – user8268 Jul 22 '19 at 16:17
  • @frougon It should be a regression in TL2019 (and probably in Miktex 2019) .I have tested the code in TL2018 and in overleaf (TL2017). I get the same picture as you did with no errors. – Hafid Boukhoulda Jul 22 '19 at 16:27
  • @HafidBoukhoulda Thanks for the info, I feel less guilty of not having been able to give an explanation. If no TikZ expert comments further on the issue, I'd say that a bug report should be filed. – frougon Jul 22 '19 at 16:43

2 Answers2

1

I won't hazard an approximate explanation, but using code from Loop Space, you can perform the following steps separately:

  1. define and name your uu path;

  2. draw it, possibly applying decorations as a postaction.

This solves the problem here.

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

% Code from Loop Space: <https://tex.stackexchange.com/a/26386/73317>
\makeatletter
\tikzset{
  use path for main/.code={%
    \tikz@addmode{%
      \expandafter\pgfsyssoftpath@setcurrentpath\csname tikz@intersect@path@name@#1\endcsname
    }%
  },
  use path for actions/.code={%
    \expandafter\def\expandafter\tikz@preactions\expandafter{\tikz@preactions\expandafter\let\expandafter\tikz@actions@path\csname tikz@intersect@path@name@#1\endcsname}%
  },
  use path/.style={%
    use path for main=#1,
    use path for actions=#1,
  }
}
\makeatother

\tikzset{->-/.style={decoration={
                       markings,
                       mark=at position #1 with {\arrow{>}}},
                     postaction={decorate}}
}

\begin{document}

\begin{tikzpicture}

\path[draw, name path=vert] (0,-1)--(0,1);

% First define and name the path
\path[name path=uu]
  (-1,-0.7) to[out=0,in=-90] (0.3,0) to[out=90,in=0] (-1,0.7);
% Then draw it using the 'use path' style from Loop Space
\draw[use path=uu, ->-=0.8];

\draw [name intersections={of=vert and uu}] (intersection-1)  node {o};
\draw [name intersections={of=vert and uu}] (intersection-2)  node {o};

\end{tikzpicture}

\end{document}

Screenshot

frougon
  • 24,283
  • 1
  • 32
  • 55
1

In a similar situation, I just discovered that replacing postaction with preaction does solve this "disappearing path" issue.

However, I am no Tikz expert, so I don't know if this solution is recommended.

And I don't have the same latex distribution as you, so I cannot check that this actually solves your problem.