我正在尝试绘制框图,但遇到了一个问题,因为直角线没有与其他线连接(存在间隙)
代码
\documentclass[borders=5cm,circuitikz]{standalone}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes,arrows}
\begin{document}
% Definition of blocks:
\tikzset{%
block/.style = {draw, thick, rectangle,
anchor=west,
rounded corners,align=center},
sum/.style = {draw, circle, node distance = 2cm}, % Adder
input/.style = {coordinate}, % Input
output/.style = {coordinate} % Output
}
\tikzset{merge/.style={
draw,
isosceles triangle,
isosceles triangle apex angle=60,
shape border rotate=0
},}
\begin{tikzpicture}[auto, thick, node distance=2cm, >=triangle 45]
\draw
% Drawing the blocks of first filter :
node at (0,0)[input, name=input1,right=-1cm]{}
node [block,right of=input1, minimum height = 3.5em,
minimum width = 4.5em, text width=4.5em, node distance=2.5cm](block1) {X}
node [merge,right of=block1 , node distance=4.5cm](tri1) {}
node at (tri1)[right=1.5mm]{\small \textopenbullet}
node [block,below of=tri1, minimum height = 2em,
minimum width = 2em,node distance=1.5cm](block4) {y};
\draw[->](block1) -- node {}(tri1);
\node at (block4)[left=1cm](test33){};
\node at (tri1)[left=1cm](test55){};
\draw[-](test55)-- (test33) -- (block4);
\end{tikzpicture}
\end{document}
答案1
\documentclass[borders=5cm,circuitikz]{standalone}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows, positioning, calc}
\usetikzlibrary{shapes,arrows}
\begin{document}
% Definition of blocks:
\tikzset{%
block/.style = {draw, thick, rectangle, anchor=west, rounded corners,align=center},
sum/.style = {draw, circle, node distance = 2cm}, % Adder
input/.style = {coordinate}, % Input
output/.style = {coordinate} % Output
}
\tikzset{merge/.style={
draw,
isosceles triangle,
isosceles triangle apex angle=60,
shape border rotate=0
},}
\begin{tikzpicture}[auto, thick, node distance=2cm, >=triangle 45]
\draw
% Drawing the blocks of first filter :
node at (0,0) [input,
name=input1,]
{}
node [
block,
right=of input1,
minimum height = 3.5em,
minimum width = 4.5em,
text width=4.5em,
node distance=2.5cm]
(block1) {X}
node [merge,
right=of block1 ,
node distance=4.5cm]
(tri1) {}
node at($(tri1.east)+(1pt,0pt)$)
{\small \textopenbullet}
node [block,
below of=tri1,
minimum height = 2em,
minimum width = 2em,
node distance=1.5cm]
(block4) {y};
\draw[->] (block1) -- (tri1);
\draw[-] ($(block1)!0.5!(tri1)$) |- (block4);
\end{tikzpicture}
\end{document}
答案2
您用来nodes
放置辅助位置。由于绘制时节点具有默认大小(test55)-- (test33) -- (block4)
,因此线条会在其边界处停止。查看绘制这些节点的以下代码:
\documentclass[borders=5cm,circuitikz]{standalone}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes,arrows}
\begin{document}
% Definition of blocks:
\tikzset{%
block/.style = {draw, thick, rectangle,
anchor=west,
rounded corners,align=center},
sum/.style = {draw, circle, node distance = 2cm}, % Adder
input/.style = {coordinate}, % Input
output/.style = {coordinate} % Output
}
\tikzset{merge/.style={
draw,
isosceles triangle,
isosceles triangle apex angle=60,
shape border rotate=0
},}
\begin{tikzpicture}[auto, thick, node distance=2cm, >=triangle 45]
\draw
% Drawing the blocks of first filter :
node at (0,0)[input, name=input1,right=-1cm]{}
node [block,right of=input1, minimum height = 3.5em,
minimum width = 4.5em, text width=4.5em, node distance=2.5cm](block1) {X}
node [merge,right of=block1 , node distance=4.5cm](tri1) {}
node at (tri1)[right=1.5mm]{\small \textopenbullet}
node [block,below of=tri1, minimum height = 2em,
minimum width = 2em,node distance=1.5cm](block4) {y};
\draw[->](block1) -- (tri1);
\node[draw, red] at (block4)[left=1cm](test33){};
\node[draw, red] at (tri1)[left=1cm](test55){};
\draw[-](test55)-- (test33) -- (block4);
\end{tikzpicture}
\end{document}
您有两种选择,使用\draw (test55.center)-- (test33.center) -- (block4);
或将它们定义为coordinates
像点一样的节点,没有任何默认大小:
\coordinate (test33) at ([xshift=-1cm]tri1.west);
\draw[-](test33) |- (block4);