-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lines intersection in a flowchart (feature request) #23
Comments
I've missed the spath3 documentation, where it shows the example of doing just that. Link: |
I understand that I can do it with spath3, as it is a core (lower level API) to knots tikz library. Add an option to
The last thing is: add the ability to change the direction of the arc, e.g., use one of these paths (over/up arc and under/down/reverse arc): \tikz[overlay] { \path[spath/save global=intersection arc] (0,0) arc[
radius=1cm, start angle=180, delta angle=-180]; }
\tikz[overlay] { \path[spath/save global=intersection reverse arc] (0,0) arc[
radius=1cm, start angle=-180, delta angle=180]; } It will be very useful for everyone who would need to plot any flowchart, specifically if it's just so happen that in the flowchart there is 1 intersection or more. This will obviously save a lot of time as opposed to using spath3 directly and will shrink down the size of a preamble. |
I've modified a bit the example from the documentation (I don't know yet how to reuse the same code with tikz): ...
\tikzset{
bridging path/.initial=intersection arc,
bridging rpath/.initial=intersection reverse arc,
bridging span/.initial=8pt,
bridging gap/.initial=4pt,
bridge/.style 2 args={
spath/split at intersections with={#1}{#2},
spath/insert gaps after
components={#1}{\pgfkeysvalueof{/tikz/bridging span}},
spath/join components upright
with={#1}{\pgfkeysvalueof{/tikz/bridging path}},
spath/split at intersections with={#2}{#1},
spath/insert gaps after
components={#2}{\pgfkeysvalueof{/tikz/bridging gap}},
},
rbridge/.style 2 args={
spath/split at intersections with={#1}{#2},
spath/insert gaps after
components={#1}{\pgfkeysvalueof{/tikz/bridging span}},
spath/join components upright
with={#1}{\pgfkeysvalueof{/tikz/bridging rpath}},
spath/split at intersections with={#2}{#1},
spath/insert gaps after
components={#2}{\pgfkeysvalueof{/tikz/bridging gap}},
},
}
\AtBeginDocument{%
\tikz[overlay] { \path[spath/save global=intersection arc] (0,0) arc[
radius=1cm, start angle=180, delta angle=-180]; }%
\tikz[overlay] { \path[spath/save global=intersection reverse arc] (0,0) arc[
radius=1cm, start angle=-180, delta angle=180]; }%
}
\begin{document}
...
\begin{tikzpicture}
...
\path[spath/save=ab] ...;
\path[spath/save=cd] ...;
\tikzset{
bridging span/.initial=8pt, % any other value
bridging gap/.initial=4pt, % any other value
bridge={ab}{cd},
% or
rbridge={ab}{cd},
}
\draw[spath/use=ab];
\draw[spath/use=cd];
...
\end{tikzpicture}
...
\end{document} That's a lot of code for a small flowchart IMO, I hope that it can be integrated in knots library. Or at the very least, it can be integrated in spath3. |
The So the two are not meant to be used together and trying to make them work together will be tricky. The |
I thought I would share my "temporary" setup, which I will be using until this feature is implemented in any package/library. In case, some would like to have/use the same functionality. Setup\usepackage{tikz}
\usetikzlibrary{spath3, intersections}
\tikzset{
flowchart/arc/.initial=flowchart intersection arc,
flowchart/arc size/.initial=8pt,
flowchart/gap size/.initial=4pt,
flowchart/flip arc/.code={
\ifx#1\relax\relax
\tikzset{flowchart/arc=flowchart intersection arc}
\else
\tikzset{flowchart/arc=intersection reverse arc}
\fi
},
flowchart/insert arcs/.style n args={3}{
flowchart/flip arc={#3},
spath/split at intersections with={#1}{#2},
spath/insert gaps after components={#1}{%
\pgfkeysvalueof{/tikz/flowchart/arc size}},
spath/join components upright with={#1}{%
\pgfkeysvalueof{/tikz/flowchart/arc}},
},
flowchart/insert gaps/.style n args={3}{
spath/split at intersections with={#2}{#1},
spath/insert gaps after components={#2}{%
\pgfkeysvalueof{/tikz/flowchart/gap size}},
},
flowchart intersections/.style={
flowchart/insert arcs/.list={#1},
flowchart/insert gaps/.list={#1},
},
}
\AtBeginDocument{
\tikz[overlay]{
\path[spath/save global=flowchart intersection arc] (0,0) arc[
radius=1pt,
start angle=0,
delta angle=180,
];
}
\tikzset{
spath/clone global={intersection reverse arc}{flowchart intersection arc},
spath/reverse globally=intersection reverse arc
}
}
\DeclareDocumentCommand\spath{O{} m +m}{\path[#1, spath/save=#2] #3}
\DeclareDocumentCommand\sdraw{O{} m}{\draw[#1, spath/use=#2]} And then it can be used like so: \begin{tikzpicture}
\spath {a} (0,0) -- (2,2);
\spath {b} (0,1) -- (1,0);
\spath {c} (0,2) -- (2,0);
\tikzset{
flowchart intersections={
{a}{b}{*},
{c}{a}{}
}
}
\sdraw {a};
\sdraw {b};
\sdraw {c};
\end{tikzpicture} Full code (MWE)\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{spath3, intersections}
\tikzset{
flowchart/arc/.initial=flowchart intersection arc,
flowchart/arc size/.initial=8pt,
flowchart/gap size/.initial=4pt,
flowchart/flip arc/.code={
\ifx#1\relax\relax
\tikzset{flowchart/arc=flowchart intersection arc}
\else
\tikzset{flowchart/arc=intersection reverse arc}
\fi
},
flowchart/insert arcs/.style n args={3}{
flowchart/flip arc={#3},
spath/split at intersections with={#1}{#2},
spath/insert gaps after components={#1}{%
\pgfkeysvalueof{/tikz/flowchart/arc size}},
spath/join components upright with={#1}{%
\pgfkeysvalueof{/tikz/flowchart/arc}},
},
flowchart/insert gaps/.style n args={3}{
spath/split at intersections with={#2}{#1},
spath/insert gaps after components={#2}{%
\pgfkeysvalueof{/tikz/flowchart/gap size}},
},
flowchart intersections/.style={
flowchart/insert arcs/.list={#1},
flowchart/insert gaps/.list={#1},
},
}
\AtBeginDocument{
\tikz[overlay]{
\path[spath/save global=flowchart intersection arc] (0,0) arc[
radius=1pt,
start angle=0,
delta angle=180,
];
}
\tikzset{
spath/clone global={intersection reverse arc}{flowchart intersection arc},
spath/reverse globally=intersection reverse arc
}
}
\DeclareDocumentCommand\spath{O{} m +m}{\path[#1, spath/save=#2] #3}
\DeclareDocumentCommand\sdraw{O{} m}{\draw[#1, spath/use=#2]}
\begin{document}
\begin{tikzpicture}
\spath {a} (0,0) -- (2,2);
\spath {b} (0,1) -- (1,0);
\spath {c} (0,2) -- (2,0);
\tikzset{
flowchart intersections={
{a}{b}{*},
{c}{a}{}
}
}
\sdraw {a};
\sdraw {b};
\sdraw {c};
\end{tikzpicture}
\end{document} Output: For more information, see discussion in #24. Update: Fixed issues, which are noted here: #23 (comment). |
The log for your code contains the line:
which is the result of your Then you also need an empty argument on the line when you don't have a
which is the result of trying to send nothing through on the third argument. There's a difference between no argument and an empty argument. There are ways to make that optional, along the lines of the |
I found 2 "solutions" for what I need:
https://texample.net/tikz/examples/line-junction/ (2014)
https://stackoverflow.com/questions/29963701/latex-flowchart-line-crossing-line (2017)
But then I (don't remember how) discovered spath3 and knots packages. I can see from the documentation that with them, I can cut one line in place of an intersection to prevent the physical intersection itself. But I was hoping that I can change the way the intersection is redrawn to make one line an arc and leave the other one untouched, or apply the same "cutting" effect (but at the arc intersection).
The given examples are manual work, unlike the knots package, and therefore not desirable.
The text was updated successfully, but these errors were encountered: