![\draw[->]에서 tikz를 사용하여 둥근 모서리를 더 잘 사용함](https://rvso.com/image/392369/%5Cdraw%5B-%3E%5D%EC%97%90%EC%84%9C%20tikz%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%EB%91%A5%EA%B7%BC%20%EB%AA%A8%EC%84%9C%EB%A6%AC%EB%A5%BC%20%EB%8D%94%20%EC%9E%98%20%EC%82%AC%EC%9A%A9%ED%95%A8.png)
나는 이 코드를 가지고 있습니다 :
% !TeX encoding = UTF-8
\documentclass[utf8]{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{positioning}
\newcommand{\multilinks}[3]{\foreach \noeud in {#1} {\draw[<-, rounded corners] (#2.west) -| ++(-#3em,0em) |- (\noeud.east);}}
\begin{document}
\begin{figure}[htp]
\centering
\tikzset{
basic/.style={draw, rounded corners=2pt, thick, text width=8em, align=flush center, node distance=2em},
}
\begin{tikzpicture}[]
\matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
\node(n1){Text}; & \node(n3){another text}; \\
\node(n2){one thing}; & \node(n4){again text}; \\
};
\multilinks{n1,n2}{n3}{3}
\multilinks{n1}{n4}{1}
\end{tikzpicture}
\end{figure}
\end{document}
그것은 나에게 다음과 같은 결과를 제공합니다:
보시다시피 곡선이 이상합니다. 어떻게 해결할 수 있나요?
내가 원하는 결과는 다음과 같습니다.
답변1
첫 번째 정의 \multilinks
와 목록이 약간 변경되었습니다 .#1
\multilinks
\documentclass[tikz]{standalone}
\usetikzlibrary{matrix,positioning}
\newcommand{\multilinks}[3]{
\foreach \noeud in {#1} {
\draw[<-, rounded corners] (#2.west) -- ++(-#3 em,0em) |- (\noeud.east);
}
}
\begin{document}
\tikzset{
basic/.style={
draw,
rounded corners=2pt,
thick,
text width=8em,
align=flush center,
node distance=2em
}
}
\begin{tikzpicture}[]
\fontsize{8}{9} \selectfont
\matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
\node(n1){Text}; & \node(n3){another text}; \\
\node(n2){one thing}; & \node(n4){again text}; \\
};
\multilinks{n2}{n3}{3}
\multilinks{n1}{n4}{1}
\end{tikzpicture}
\end{document}
편집하다
원래 방식을 유지하려는 경우 정의가 \multilinks
좀 더 복잡해집니다.
\documentclass[tikz]{standalone}
\usetikzlibrary{matrix,positioning}
\newcommand{\multilinks}[3]{
\begin{scope}[x=1em,y=1em]
\newdimen\xend
\newdimen\yend
\path (#2.west);
\pgfgetlastxy{\xend}{\yend}
\foreach \i in {#1} {
\newdimen\xstart
\newdimen\ystart
\path (\i.east);
\pgfgetlastxy{\xstart}{\ystart}
\coordinate (1) at ({\xend-#3 em},\ystart);
\coordinate (2) at ({\xend-#3 em},\yend);
\ifdim\ystart=\yend
\draw[->] (\i.east)--(#2.west);
\else
\draw[->,rounded corners] (\i.east)--(1)--(2)--(#2.west);
\fi
}
\end{scope}
}
\begin{document}
\tikzset{
basic/.style={
draw,
rounded corners=2pt,
thick,
text width=8em,
align=flush center,
node distance=2em
}
}
\begin{tikzpicture}[]
\fontsize{8}{9} \selectfont
\matrix[row sep=2em, column sep=4em, every node/.style={basic}] {
\node(n1){Text}; & \node(n3){another text}; \\
\node(n2){one thing}; & \node(n4){again text}; \\
};
\multilinks{n1,n2}{n3}{3}
\multilinks{n1}{n4}{1}
\end{tikzpicture}
\end{document}
\ifdim
Ti 때문에 추가해야 합니다 .케이rounded corners
Z는 점에서 경로를 그리라는 명령을 받았을 때 매우 혼란스러워합니다.ㅏ가리키다ㅏ(즉, 두 개의 동일한 점):
\documentclass[tikz,margin=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[y=0.2cm]
\draw[rounded corners] (0,0) --(1,0) --(1,0)--(2,0) ; % Some bugs?
\draw[rounded corners] (0,-1)--(1,-1)-- (2,-1);
\draw[rounded corners] (0,-2)-- (2,-2);
\end{tikzpicture}
\end{document}