1

I am using some code found on this site here Add some arrows on the picture and trying to get the following plot: enter image description here

\documentclass{article}
\usepackage[margin=1.5cm]{geometry}
\pagestyle{empty}

\usepackage{tikz} \usetikzlibrary{decorations.markings,arrows.meta}

\newcommand\ALloop[1]% {\ifx\relax#1% \else \ifcsname AL:#1\endcsname \csname AL:#1\endcsname \else \GenericError{(AL)}{AL Error: operator #1 undefined}{}{}% \fi \expandafter\ALloop \fi }

\newcommand\AL[1]% {\begin{tikzpicture}[thick,every node/.style={blob}] \coordinate(X) at (0,0); \ALloop#1\relax \end{tikzpicture} }

\def\ALs{12}% small radius \pgfmathsetmacro\ALm{1.5\ALs}% medium radius \pgfmathsetmacro\ALl{2.25\ALs}% large radius \pgfmathsetmacro\ALh{3\ALs}% huge radius \pgfmathsetmacro\ALt{sqrt(3.7)\ALh}% side of triangle \pgfmathsetmacro\ALa{0.65\ALs}% length of arrow \pgfmathsetmacro\ALn{0.34\ALs}% size of node

\tikzset {midarrow/.style={decoration={markings,mark=at position 0.5 with {\arrow[xshift=0.75*\ALa]{Latex[length=\ALa pt,#1]}}},postaction={decorate}}, full/.style={midarrow}, open/.style={midarrow={open,fill=white}}, blob/.style={circle,draw,fill,minimum size=\ALn pt,inner sep=0pt,outer sep=0pt} }

\newcommand\arrowtype{full} % \ARC{start angle}{delta angle clockwise}{radius} \newcommand\ARC [3]{\draw[\arrowtype] (X) arc(#1:#1-#2:#3) node{} coordinate (X);}

\newcommand\ALdef[1]{\expandafter\def\csname AL:#1\endcsname}

\ALdef{a}{\ARC{270}{180}{\ALl pt}} \ALdef{b}{\ARC{ 189}{100}{\ALh pt}} \ALdef{c}{\ARC{90}{180}{\ALh pt}}

\begin{document} \renewcommand\arraystretch{5}

\newpage

\begin{tabular}{ll}
    \AL{bca}
\end{tabular}

\end{document}

My output is: enter image description here

Jack
  • 169
  • 2
    ... some code found on this site ... -- would you mind posting the URL of the posting from which. you obtained "some code"? – Mico Mar 16 '24 at 01:16
  • 2
    @Mico I edited my question with the link to the code. – Jack Mar 16 '24 at 09:13
  • Unfortunately it’s still unclear what you want. Add more spirals? Stylized or scribbled? The crossing path? Intersections? Please clarify in your question. Thank you – MS-SPO Mar 16 '24 at 09:26
  • I want to plot the crossing path and the arrows before p1 and after p3. – Jack Mar 16 '24 at 09:27
  • Please. Move. Your. Comment. To, The. Question. For the simple reason, everything needed to know will be neatly available in one place, the question, and not littered accross the page (a myrad of comments). Thank you – MS-SPO Mar 16 '24 at 11:44
  • ANALYSIS: If I see it correctly, a coordinate (X) is defined inside the \ARC macro. It can be used by Tikz in macro ÀLfor some reason. However, it's not clear to me if and how these 3 coordinates created inside your tabular are preserved. // So a SOLUTION might be to look fortikzmarkexamples on this site, set such tikzmarks withX` and overlay an other tikzpicture, probably below your tabular. // CONCLUSION: All in all it looks like much effort to me with little effect and alternative ways to obtain easier what you want with cleaner code. – MS-SPO Mar 16 '24 at 12:30

2 Answers2

2

Here's a way to do it more clearly:

result

To include it in other documentclasses, use the graphicx package to include the compiled pdf.

\documentclass[10pt,border=3mm,tikz]{standalone}
\usetikzlibrary{arrows.meta,decorations.markings}

\begin{document} \begin{tikzpicture}[ >={Stealth}, dot/.style={draw,circle,fill=black, inner sep=0pt,minimum size=1mm}, decoration={ markings, mark=at position .1 with {\arrow{Stealth[]}} , mark=at position .45 with {\arrow{Stealth}} , mark=at position .84 with {\arrow{Stealth}} , }, ] % ~~~ arcs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \draw [postaction={decorate}] (0,0) arc [start angle=180,end angle=-90,radius=3cm] node[pos=.4,dot] (P1) {} node[pos=1 ,dot] (P3) {} arc [start angle=270,end angle= 90,radius=22mm] node[pos=.8,dot] (P2) {} ;

% ~~~ intersecting line ~~~~~~~~~~~~~~~~
\draw   (35:7) to[out=225,in=25] 
        (P1)   to[out=205,in=90] 
        (P2)   to[out=280,in=70] 
        (P3)   to[out=290,in=120] 
        +(-30:2)
        ;

% ~~~ labeling the points ~~~~~~~~          
\node[yshift=4mm]       at (P1) {$p_1$};
\node[shift=(135:4mm)]  at (P2) {$p_2$};
\node[shift=(235:4mm)]  at (P3) {$p_3$};

\end{tikzpicture} \end{document}

MS-SPO
  • 11,519
1

I had better luck looking for examples of how to do this, which I found interesting. Within the code you can find the links to the preceding examples.

RESULT:

enter image description here

MWE:

\documentclass[tikz,border=0.5cm]{standalone}
\usetikzlibrary{decorations.pathmorphing,decorations.markings,intersections}

%this code is from Guilherme Zanotelli in a "short" explanation in https://tex.stackexchange.com/a/333824/154390 [start] \newcommand\bonusspiral{} % just for safety % \bonusspiraldraw options(start angle:end angle)(start radius:final radius)[revolutions] \def\bonusspiral#1(#3:#4)(#5:#6)[#7]{ \pgfmathsetmacro{\domain}{#4+#7360} \pgfmathsetmacro{\growth}{180(#6-#5)/(pi(\domain-#3))} \draw [#1, shift={(#2)}, domain=#3pi/180:\domainpi/180, variable=\t, name path=plotA, %smooth, samples=int(\domain/5)] plot ({\t r}: {#5+\growth\t-\growth#3pi/180}); }

%this code is from Frunobulax https://tex.stackexchange.com/a/445690/154390 \makeatletter \pgfset{ /pgf/decoration/randomness/.initial=2, /pgf/decoration/wavelength/.initial=100 } \pgfdeclaredecoration{sketch}{init}{ \state{init}[width=0pt,next state=draw,persistent precomputation={ \pgfmathsetmacro\pgf@lib@dec@sketch@t0 }]{} \state{draw}[width=\pgfdecorationsegmentlength, auto corner on length=\pgfdecorationsegmentlength, persistent precomputation={ \pgfmathsetmacro\pgf@lib@dec@sketch@t{mod(\pgf@lib@dec@sketch@t+pow(\pgfkeysvalueof{/pgf/decoration/randomness},rand),\pgfkeysvalueof{/pgf/decoration/wavelength})} }]{ \pgfmathparse{sin(2\pgf@lib@dec@sketch@tpi/\pgfkeysvalueof{/pgf/decoration/wavelength} r)} \pgfpathlineto{\pgfqpoint{\pgfdecorationsegmentlength}{\pgfmathresult\pgfdecorationsegmentamplitude}} } \state{final}{} } \tikzset{pencildraw/.style={decorate,decoration={sketch,segment length=1pt,amplitude=2pt}}} \makeatother

\begin{document} \begin{tikzpicture}[ Ina/.style={ draw, postaction={ decorate, decoration={ markings, mark=at position #1 with { \fillxscale=-1,xshift=-1pt -- (90+50:4pt) -- (180:2pt) -- (270-50:4pt); } } } } ] %Start drawing the thing. % First spiral that starst from 15 at radious 1 and ends at 120 at radious 3 in two revolutions. \bonusspiralthick,yscale=0.7,pencildraw,Ina=0.97,postaction={Ina=0}(15:120)(1:3)[2]
\drawthick,Ina=0,name path=plotB to [out=100,in=-100] ++ (0,2.5) node[anchor=0]{S}; \fill [name intersections={of=plotA and plotB, name=E, total=\t}][black] \foreach \s in {1,2,...,\t}{(E-\s) circle (2pt) node[inner sep=0,label={[label distance=-0.2em]45:$\rho_\s$}]{}};
\end{tikzpicture} \end{document}

ADDENDUM:

To reverse the enumeration I use an additional counter and change the ordering of the counter. \foreach \s [count=\ss from 1]in {\t,...,2,1} Keep in mind that when adapting the spiral it was drawn from the inside out, for that reason the arrows are inverted with xscale=-1, and the shift is used so that it has a better finish when adapting to the curves. The code allows you to expand the result even with more nodes, all thanks to the \bonusspiral macro

NEW RESULT: enter image description here

NEW MWE:

\documentclass[tikz,border=0.5cm]{standalone}
\usetikzlibrary{decorations.pathmorphing,decorations.markings,intersections}

%this code is from Guilherme Zanotelli in a "short" explanation in https://tex.stackexchange.com/a/333824/154390 [start] \newcommand\bonusspiral{} % just for safety % \bonusspiraldraw options(start angle:end angle)(start radius:final radius)[revolutions] \def\bonusspiral#1(#3:#4)(#5:#6)[#7]{ \pgfmathsetmacro{\domain}{#4+#7360} \pgfmathsetmacro{\growth}{180(#6-#5)/(pi(\domain-#3))} \draw [#1, shift={(#2)}, domain=#3pi/180:\domainpi/180, variable=\t, name path=plotA, %smooth, samples=int(\domain/5)] plot ({\t r}: {#5+\growth\t-\growth#3pi/180}); }

%this code is from Frunobulax https://tex.stackexchange.com/a/445690/154390 \makeatletter \pgfset{ /pgf/decoration/randomness/.initial=2, /pgf/decoration/wavelength/.initial=100 } \pgfdeclaredecoration{sketch}{init}{ \state{init}[width=0pt,next state=draw,persistent precomputation={ \pgfmathsetmacro\pgf@lib@dec@sketch@t0 }]{} \state{draw}[width=\pgfdecorationsegmentlength, auto corner on length=\pgfdecorationsegmentlength, persistent precomputation={ \pgfmathsetmacro\pgf@lib@dec@sketch@t{mod(\pgf@lib@dec@sketch@t+pow(\pgfkeysvalueof{/pgf/decoration/randomness},rand),\pgfkeysvalueof{/pgf/decoration/wavelength})} }]{ \pgfmathparse{sin(2\pgf@lib@dec@sketch@tpi/\pgfkeysvalueof{/pgf/decoration/wavelength} r)} \pgfpathlineto{\pgfqpoint{\pgfdecorationsegmentlength}{\pgfmathresult\pgfdecorationsegmentamplitude}} } \state{final}{} } \tikzset{pencildraw/.style={decorate,decoration={sketch,segment length=1pt,amplitude=2pt}}} \makeatother

\begin{document} \begin{tikzpicture}[ Ina/.style={ draw, postaction={ decorate, decoration={ markings, mark=at position #1 with { \fillxscale=-1,xshift=-1pt -- (90+50:4pt) -- (180:2pt) -- (270-50:4pt); } } } } ] %Start drawing the thing. % First spiral is used as workspace a spiral that starts from 90 at radious 1 and ends at 90 at radious 6. \bonusspiralthick,yscale=0.7,pencildraw,Ina=0.98,postaction={Ina=0}(15:120)(1:5)[4]
\drawthick,Ina=0,name path=plotB to [out=100,in=-100] ++ (0,4) node[anchor=0]{S}; \fill [name intersections={of=plotA and plotB, name=E, total=\t}][black] \foreach \s [count=\ss from 1]in {\t,...,2,1}{(E-\ss) circle (2pt) node[inner sep=0,label={[label distance=-0.2em]45:$\rho_\s$}]{}};
\end{tikzpicture} \end{document}

J Leon V.
  • 11,533
  • 16
  • 47