
절대 좌표를 사용하지 않고 직사각형 노드와 수직선을 연결하는 방법에 대한 문제로 고민하고 있습니다. 두 선의 교차점을 점으로 표시해야 합니다. 나는 이것을 달성하기 위해서는 좀 더 우아한 방법이 있어야 한다는 강한 느낌을 갖고 있습니다.
고마워요 마르셀
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows.meta,positioning,decorations.pathreplacing}
\usetikzlibrary{intersections}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\draw[thick] (-4,10) node (dpdata) [above] {Data} -- (-4,0);
\node[ draw,
align=center,
left=of dpdata,
yshift=-4cm,
minimum width=2cm,
minimum height=3cm,
] (ram) {Transient \\ Memory \\ (RAM)};
\node[ draw,
align=center,
above=of ram,
minimum width=1.5cm,
minimum height=1cm
] (mar) {MAR};
\node[ draw,
align=center,
below=of ram,
minimum width=1.5cm,
minimum height=1cm
] (mdr) {MDR};
\draw[color=blue,thick] (mar.east) -- (-4,9.25);
\fill (-4,9.25) circle [radius=2pt];
\draw[color=blue,thick] (mdr.east) -- (-4,3.25);
\fill (-4,3.25) circle [radius=2pt];
\draw[color=blue,thick] (mdr.north) -- (ram.south);
\draw[color=blue,thick] (mar.south) -- (ram.north);
\end{tikzpicture}
\end{figure}
\end{document}
답변1
모든 점과 연결이 직사각형 그리드에 있는 한 좌표 추출을 위해 이 간단하고 우아한 구문을 사용할 수 있습니다(간단한 예를 제시합니다).
\begin{tikzpicture}
\path
(0,0) node[draw] (joe) {Joe}
(2,2) node[draw] (blow) {Blow};
;
\draw[blue] (joe -| blow) circle (2pt);
\end{tikzpicture}
연산자 -|
는 첫 번째 점(joe)에서 x 좌표를 추출하고 두 번째 점(blow)에서 y 좌표를 추출합니다.
답변2
이와 같이?
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, calc, chains, intersections, positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 3mm and 9mm,
start chain = going below,
box/.style = {rectangle, draw,
text width=22mm, align=center, inner sep=2mm,
on chain}
]
\node (mar) [box] {MAR};
\node (ram) [box] {Transient Memory (RAM)};
\node (mdr) [box] {MDR};
%
\coordinate[above right=of mar] (data);
\draw[thick, name path=A] (data) node[above] {Data} -- + (0,-4);
\path[overlay,name path=B] (mar) -- ++ (3,0);
\path[overlay,name path=C] (mdr) -- ++ (3,0);
%
\draw[color=blue,thick,fill,
name intersections={of=A and B, by={a}}]
(mar) -- (a) circle (2pt);
\draw[color=blue,thick,fill,
name intersections={of=A and C, by={b}}]
(mdr) -- (b) circle (2pt);
\draw[color=blue,thick] (mar) -- (ram) (ram) -- (mdr);
\end{tikzpicture}
\end{document}
부록: 더욱 간단한 솔루션 제공마이클 팔머답변. 위의 MWE에 적용하면 다음과 같이 간단하게 작성할 수 있습니다.
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, calc, chains, intersections, positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 3mm and 9mm,
start chain = going below,
box/.style = {rectangle, draw,
text width=22mm, align=center, inner sep=2mm,
on chain}
]
\node (mar) [box] {MAR};
\node (ram) [box] {Transient Memory (RAM)};
\node (mdr) [box] {MDR};
%
\coordinate[above right=of mar] (data);
\draw[thick] (data) node[above] {Data} -- + (0,-4);% changed
\draw[color=blue,thick,fill]
(mar) -- (mar -| data) circle (2pt)% changed
(mdr) -- (mdr -| data) circle (2pt)% changed
(mar) -- (ram)
(ram) -- (mdr);
\end{tikzpicture}
\end{document}
결과는 이전과 같습니다.