我有以下 MWE:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{shapes.arrows}
\usetikzlibrary{calc}
\usetikzlibrary{circuits.logic.US,positioning}
\begin{document}
\begin{tikzpicture}[circuit logic US]
\node[rectangle, draw] (R) at (0,0){$R$};
\draw node[xor gate, right of=R](X){};
% How to automatically set this condition such that the end point touches border of R?
\path[black, draw] (X.input 1) -- ($(X.input 1)+(-.3,0)$);
\end{tikzpicture}
\end{document}
输出:
R
我需要帮助来设置连接和的路径X
,以使其接触R
。
答案1
你可以使用
\path[black, draw] (X.input 1) -- (X.input 1-|R.east);
代码:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{circuits.logic.US}
\begin{document}
\begin{tikzpicture}[circuit logic US]
\node[rectangle, draw] (R) at (0,0){$R$};
\draw node[xor gate, right of=R](X){};
\path[black, draw] (X.input 1) -- (X.input 1-|R.east);% <- changed
\end{tikzpicture}
\end{document}